(p5, fn)
| 72 | export const RGBA = 'rgba'; |
| 73 | |
| 74 | function creatingReading(p5, fn){ |
| 75 | fn.RGB = RGB; |
| 76 | fn.RGBHDR = RGBHDR; |
| 77 | fn.HSB = HSB; |
| 78 | fn.HSL = HSL; |
| 79 | fn.HWB = HWB; |
| 80 | |
| 81 | fn.LAB = LAB; |
| 82 | fn.LCH = LCH; |
| 83 | |
| 84 | fn.OKLAB = OKLAB; |
| 85 | fn.OKLCH = OKLCH; |
| 86 | |
| 87 | fn.RGBA = RGBA; |
| 88 | |
| 89 | // Add color states to renderer state machine |
| 90 | p5.Renderer.states.colorMode = RGB; |
| 91 | p5.Renderer.states.colorMaxes = { |
| 92 | [RGB]: [255, 255, 255, 255], |
| 93 | [RGBHDR]: [255, 255, 255, 255], |
| 94 | [HSB]: [360, 100, 100, 1], |
| 95 | [HSL]: [360, 100, 100, 1], |
| 96 | [HWB]: [360, 100, 100, 1], |
| 97 | |
| 98 | [LAB]: [100, [-125, 125], [-125, 125], 1], |
| 99 | [LCH]: [100, 150, 360, 1], |
| 100 | |
| 101 | [OKLAB]: [100, [-125, 125], [-125, 125], 1], |
| 102 | [OKLCH]: [100, 150, 360, 1], |
| 103 | clone: function(){ |
| 104 | const cloned = { ...this }; |
| 105 | for (const key in cloned) { |
| 106 | if (cloned[key] instanceof Array) { |
| 107 | cloned[key] = [...cloned[key]]; |
| 108 | } |
| 109 | } |
| 110 | return cloned; |
| 111 | } |
| 112 | }; |
| 113 | |
| 114 | /** |
| 115 | * Creates a <a href="#/p5/p5.Color">p5.Color</a> object. |
| 116 | * |
| 117 | * By default, the parameters are interpreted as RGB values. Calling |
| 118 | * `color(255, 204, 0)` will return a bright yellow color. The way these |
| 119 | * parameters are interpreted may be changed with the |
| 120 | * <a href="#/p5/colorMode">colorMode()</a> function. |
| 121 | * |
| 122 | * The version of `color()` with one parameter interprets the value one of two |
| 123 | * ways. If the parameter is a number, it's interpreted as a grayscale value. |
| 124 | * If the parameter is a string, it's interpreted as a CSS color string. |
| 125 | * |
| 126 | * The version of `color()` with two parameters interprets the first one as a |
| 127 | * grayscale value. The second parameter sets the alpha (transparency) value. |
| 128 | * |
| 129 | * The version of `color()` with three parameters interprets them as RGB, HSB, |
| 130 | * or HSL colors, depending on the current `colorMode()`. |
| 131 | * |
no test coverage detected