map(v: number, l1: number, h1: number, l2: number, h2: number): number
Map a value from one range to another range. If the value overshoots, the source range, the result values will also do. For clamping check mapc
param
vThe value the function will depend on.
param
l1The minimum value of the source range.
param
h1The minimum result value.
param
l2The maximum value of the source range.
param
h2The maximum result value.
onUpdate(() => { // Redness will be 0 when the mouse is at the left edge and 255 when the mouse is at the right edge const redness = map(mousePos().x, 0, width(), 0, 255) setBackground(rgb(redness, 0, 0)) })
returns
The result value based on the source value.
since
v2000.0