Loading

Pmap

processing

Re-maps a number from one range to another.

In the first example, the number 25 is converted from a value in the range of 0 to 100 into a value that ranges from the left edge of the window (0) to the right edge (width).

As shown in the second example, numbers outside of the range are not clamped to the minimum and maximum parameters values, because out-of-range values are often intentional and useful.

Link to original Processing doc

Pmap is available since version 1.0.0.

See also

Signatures

Examples

//draw two ellipses // @preview image 200 'size' STORE //change size here $size $size '2D3' PGraphics 255 Pbackground 50.0 0.0 100.0 0 $size Pmap 'y' STORE 25.0 'value' STORE //first ellipse at 25% of width $value 0.0 100.0 0 $size Pmap 'm' STORE $m $y 10 10 Pellipse 75.0 'value' STORE //first ellipse at 75% of width $value 0.0 100.0 0 $size Pmap 'm' STORE $m $y 10 10 Pellipse Pencode
//output of interpolation is not clamped: 10 10 '2D3' PGraphics 110 'value' STORE $value 0 100 -20 -10 Pmap //returns -9.0