| 69 | // Used to add additional color modes to p5.js |
| 70 | // Uses underlying library's definition |
| 71 | static addColorMode(mode, definition){ |
| 72 | ColorSpace.register(definition); |
| 73 | Color.colorMap[mode] = definition.id; |
| 74 | |
| 75 | // Get colorjs maxes |
| 76 | Color.#colorjsMaxes[mode] = Object.values(definition.coords) |
| 77 | .reduce((acc, v) => { |
| 78 | acc.push(v.refRange || v.range); |
| 79 | return acc; |
| 80 | }, []); |
| 81 | Color.#colorjsMaxes[mode].push([0, 1]); |
| 82 | |
| 83 | // Get grayscale mapping |
| 84 | Color.#grayscaleMap[mode] = definition.fromGray; |
| 85 | } |
| 86 | |
| 87 | constructor(vals, colorMode, colorMaxes, { clamp = false } = {}) { |
| 88 | // This changes with the color object |