mapc(v: number, l1: number, h1: number, l2: number, h2: number): number

Map a value from one range to another range, and clamp to the dest range.

paramvThe value the function will depend on.

paraml1The minimum value of the source range.

paramh1The minimum result value.

paraml2The maximum value of the source range.

paramh2The maximum result value.

onUpdate(() => {
     // This variable will be 0 when the mouse is at the left edge and 255 when the mouse is at the right edge
     const redness = mapc(mousePos().x, 0, width(), 0, 255)
     setBackground(rgb(redness, 0, 0))
})

returnsThe clamped result value based on the source value.

sincev2000.0

kaplay logo

Misc

Layer