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

Method addColorMode

src/color/p5.Color.js:71–85  ·  view source on GitHub ↗
(mode, definition)

Source from the content-addressed store, hash-verified

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

Callers 1

colorFunction · 0.45

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected