| 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){ |