MCPcopy Index your code
hub / github.com/processing/p5.js / mapColorRange

Method mapColorRange

src/color/p5.Color.js:248–267  ·  view source on GitHub ↗
(origin, mode, maxes, clamp)

Source from the content-addressed store, hash-verified

246
247 // Convert from p5 color range to color.js color range
248 static mapColorRange(origin, mode, maxes, clamp){
249 const p5Maxes = maxes.map(max => {
250 if(!Array.isArray(max)){
251 return [0, max];
252 }else{
253 return max;
254 }
255 });
256 const colorjsMaxes = Color.#colorjsMaxes[mode];
257
258 return origin.map((channel, i) => {
259 const newval = map(
260 channel,
261 p5Maxes[i][0], p5Maxes[i][1],
262 colorjsMaxes[i][0], colorjsMaxes[i][1],
263 clamp
264 );
265 return newval;
266 });
267 }
268
269 // Convert from color.js color range to p5 color range
270 static unmapColorRange(origin, mode, maxes){

Callers 1

constructorMethod · 0.80

Calls 1

mapFunction · 0.85

Tested by

no test coverage detected