It may have triggered the protection mechanism of Aha, and my submission was mistakenly deleted as spam.
construct3-21h2.ideas.aha.io/ideas/C321H2-I-485
---
Before waiting for the administrator to review, I would like to resubmit my ideas here.
Processing has a great function:
processing.org/reference/map_.html
p5js.org/reference
map(value, start1, stop1, start2, stop2)
Re-maps a number from one range to another.
It is used to calculate a number reach another number get 0-1 progress and re-mapping into another range according to this progress,. I think we could have a similar expressions. That would be cool.
remapping(value, x1, y1, x2, y2)
map(mouse.x, sprite.bboxleft, sprite.bboxright, 0, 200)
Map the mouse's X-axis position to the left and right position progress within the Sprite range, and map it to a value of 0-200.
- If mouse over bboxleft, then the mapping value is 0.
- If mouse over bboxright, then the mapping value is 200.
map(30, 30, 60, 0, 200) // 0 map(60, 30, 60, 0, 200) // 200 map(90, 30, 60, 0, 200) // 400 map(6, 30, 60, 0, 200) // -160
Notice that even if the position of the Mouse exceeds bboxright, it continues to grow at the current scale.
What comes to mind is that it can be used to make some virtual joysticks, The progress bar. UI controls. Or a mapping of relative positions.
For example, I want to simulate dragging an object with a mouse, and then calculate a power to the stretch within the range of the UI indicator image.
map(mouse.x, 0, Width, MinPower, MaxPower) map(mouse.y, 0, Width, MinPower, MaxPower)
stackoverflow.com/questions/3451553/value-remapping
stackoverflow.com/questions/20910091/recreating-the-processing-map-function-in-javascript
Develop games in your browser. Powerful, performant & highly capable.
If I'm not mistaken, this can be done with this expression in C3:
lerp(0, 200, unlerp(sprite.bboxleft, sprite.bboxright, mouse.x))
If I'm not mistaken, this can be done with this expression in C3: lerp(0, 200, unlerp(sprite.bboxleft, sprite.bboxright, mouse.x))
Wow, I didn't know it could be used like that! Thank you, I got it!