MCPcopy
hub / github.com/processing/p5.js / map

Function map

src/color/p5.Color.js:33–40  ·  view source on GitHub ↗
(n, start1, stop1, start2, stop2, clamp)

Source from the content-addressed store, hash-verified

31import HSBSpace from './color_spaces/hsb.js';
32
33const map = (n, start1, stop1, start2, stop2, clamp) => {
34 let result = ((n - start1) / (stop1 - start1) * (stop2 - start2) + start2);
35 if (clamp) {
36 result = Math.max(result, Math.min(start2, stop2));
37 result = Math.min(result, Math.max(start2, stop2));
38 }
39 return result;
40}
41
42const toHexComponent = (v) => {
43 const vInt = ~~(v * 255);

Callers 15

drawFunction · 0.85
regenerateFunction · 0.85
drawFunction · 0.85
updateMethod · 0.85
drawBlobMethod · 0.85
drawFunction · 0.85
drawFunction · 0.85
drawFunction · 0.85
drawGradientRowFunction · 0.85
drawFunction · 0.85
drawFunction · 0.85
drawFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected