p5 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src → dist}/accessibility/color_namer.js +48 -3
- package/{src → dist}/accessibility/describe.js +12 -2
- package/{src → dist}/accessibility/gridOutput.js +2 -2
- package/dist/accessibility/index.js +60 -0
- package/{src → dist}/accessibility/outputs.js +23 -2
- package/{src → dist}/accessibility/textOutput.js +2 -2
- package/dist/app.js +120 -0
- package/{src → dist}/color/color_conversion.js +48 -10
- package/{src → dist}/color/color_spaces/hsb.js +3 -1
- package/dist/color/creating_reading.js +3 -0
- package/dist/color/index.js +13 -0
- package/dist/color/p5.Color.culori.js +1 -0
- package/dist/color/p5.Color.js +3 -0
- package/{src → dist}/color/setting.js +9 -6
- package/{src/core/constants.js → dist/constants-tYr0tCl8.js} +284 -132
- package/{src → dist}/core/States.js +3 -1
- package/dist/core/constants.js +1 -0
- package/{src → dist}/core/environment.js +12 -10
- package/{src → dist}/core/friendly_errors/browser_errors.js +1 -1
- package/{src → dist}/core/friendly_errors/fes_core.js +14 -44
- package/{src → dist}/core/friendly_errors/file_errors.js +6 -3
- package/dist/core/friendly_errors/index.js +23 -0
- package/dist/core/friendly_errors/param_validator.js +5421 -0
- package/{src → dist}/core/friendly_errors/sketch_reader.js +50 -4
- package/{src → dist}/core/friendly_errors/sketch_verifier.js +6 -6
- package/{src → dist}/core/friendly_errors/stacktrace.js +3 -5
- package/{src → dist}/core/friendly_errors/validate_params.js +50 -41
- package/{src → dist}/core/helpers.js +9 -6
- package/dist/core/init.js +105 -0
- package/dist/core/internationalization.js +302 -0
- package/dist/core/legacy.js +73 -0
- package/dist/core/main.js +44 -0
- package/dist/core/noop.js +3 -0
- package/dist/core/p5.Graphics.js +40 -0
- package/dist/core/p5.Renderer.js +11 -0
- package/dist/core/p5.Renderer2D.js +44 -0
- package/dist/core/reference.js +1 -0
- package/dist/core/rendering.js +40 -0
- package/{src → dist}/core/structure.js +3 -3
- package/{src → dist}/core/transform.js +2 -2
- package/{src/color/creating_reading.js → dist/creating_reading-Cr8L2Jnm.js} +841 -13
- package/{src → dist}/data/index.js +3 -1
- package/{src → dist}/data/local_storage.js +2 -8
- package/{src → dist}/dom/dom.js +19 -13
- package/dist/dom/index.js +18 -0
- package/{src → dist}/dom/p5.Element.js +14 -12
- package/{src → dist}/dom/p5.File.js +4 -4
- package/{src → dist}/dom/p5.MediaElement.js +10 -4
- package/{src → dist}/events/acceleration.js +26 -26
- package/{src → dist}/events/index.js +3 -1
- package/{src → dist}/events/keyboard.js +14 -12
- package/{src → dist}/events/pointer.js +16 -17
- package/dist/image/const.js +9 -0
- package/{src → dist}/image/filterRenderer2D.js +57 -37
- package/{src → dist}/image/filters.js +1 -3
- package/dist/image/image.js +40 -0
- package/dist/image/index.js +51 -0
- package/dist/image/loading_displaying.js +40 -0
- package/dist/image/p5.Image.js +11 -0
- package/{src → dist}/image/pixels.js +5 -3
- package/{src → dist}/io/csv.js +72 -70
- package/dist/io/files.js +40 -0
- package/dist/io/index.js +51 -0
- package/{src → dist}/io/p5.Table.js +6 -6
- package/{src → dist}/io/p5.TableRow.js +5 -6
- package/{src → dist}/io/p5.XML.js +2 -5
- package/{src → dist}/io/utilities.js +1 -1
- package/{src/core/p5.Renderer2D.js → dist/main-CAxvgiOV.js} +738 -57
- package/{src → dist}/math/Matrices/Matrix.js +10 -8
- package/{src → dist}/math/Matrices/MatrixInterface.js +5 -3
- package/{src → dist}/math/Matrices/MatrixNumjs.js +12 -26
- package/{src → dist}/math/calculation.js +2 -2
- package/{src → dist}/math/index.js +6 -3
- package/{src → dist}/math/math.js +3 -3
- package/{src → dist}/math/noise.js +2 -2
- package/{src → dist}/math/p5.Matrix.js +7 -4
- package/{src → dist}/math/p5.Vector.js +6 -6
- package/{src → dist}/math/random.js +2 -2
- package/{src → dist}/math/trigonometry.js +16 -15
- package/{src/image/p5.Image.js → dist/p5.Renderer-Swjl9HQO.js} +393 -22
- package/dist/rendering-B5TRR7aY.js +24960 -0
- package/{src → dist}/shape/2d_primitives.js +18 -17
- package/{src → dist}/shape/attributes.js +18 -17
- package/{src → dist}/shape/curves.js +2 -2
- package/{src → dist}/shape/custom_shapes.js +44 -64
- package/{src → dist}/shape/index.js +10 -2
- package/{src → dist}/shape/vertex.js +2 -3
- package/dist/type/index.js +25 -0
- package/{src → dist}/type/lib/Typr.js +76 -94
- package/{src → dist}/type/p5.Font.js +37 -63
- package/{src → dist}/type/textCore.js +35 -58
- package/{src → dist}/type/unicodeRanges.js +3 -1
- package/{src → dist}/utilities/conversion.js +2 -2
- package/{src → dist}/utilities/index.js +3 -1
- package/{src → dist}/utilities/time_date.js +6 -7
- package/{src → dist}/utilities/utility_functions.js +2 -2
- package/dist/webgl/3d_primitives.js +40 -0
- package/{src → dist}/webgl/GeometryBufferCache.js +3 -1
- package/{src → dist}/webgl/GeometryBuilder.js +12 -8
- package/{src → dist}/webgl/ShaderGenerator.js +79 -82
- package/{src → dist}/webgl/ShapeBuilder.js +26 -23
- package/dist/webgl/index.js +76 -0
- package/{src → dist}/webgl/interaction.js +7 -6
- package/dist/webgl/light.js +40 -0
- package/{src → dist}/webgl/loading.js +45 -12
- package/dist/webgl/material.js +40 -0
- package/dist/webgl/p5.Camera.js +40 -0
- package/{src → dist}/webgl/p5.DataArray.js +3 -5
- package/dist/webgl/p5.Framebuffer.js +40 -0
- package/{src → dist}/webgl/p5.Geometry.js +12 -15
- package/{src → dist}/webgl/p5.Quat.js +5 -4
- package/{src → dist}/webgl/p5.RenderBuffer.js +2 -3
- package/dist/webgl/p5.RendererGL.js +40 -0
- package/dist/webgl/p5.Shader.js +40 -0
- package/dist/webgl/p5.Texture.js +40 -0
- package/{src → dist}/webgl/text.js +78 -38
- package/lib/p5.esm.js +296 -194
- package/lib/p5.js +296 -194
- package/lib/p5.min.js +1 -1
- package/package.json +17 -17
- package/translations/dev.js +6 -6
- package/translations/index.js +1 -1
- package/types/accessibility/color_namer.d.ts +8 -0
- package/types/accessibility/describe.d.ts +184 -0
- package/types/accessibility/gridOutput.d.ts +8 -0
- package/types/accessibility/outputs.d.ts +235 -0
- package/types/accessibility/textOutput.d.ts +8 -0
- package/types/color/color_conversion.d.ts +47 -0
- package/types/color/creating_reading.d.ts +1348 -0
- package/types/color/p5.Color.d.ts +1070 -0
- package/types/color/setting.d.ts +2085 -0
- package/types/core/constants.d.ts +341 -0
- package/types/core/environment.d.ts +668 -0
- package/types/core/friendly_errors/fes_core.d.ts +8 -0
- package/types/core/friendly_errors/file_errors.d.ts +8 -0
- package/types/core/friendly_errors/param_validator.d.ts +30 -0
- package/types/core/friendly_errors/sketch_reader.d.ts +8 -0
- package/types/core/friendly_errors/stacktrace.d.ts +11 -0
- package/types/core/friendly_errors/validate_params.d.ts +8 -0
- package/types/core/helpers.d.ts +8 -0
- package/types/core/legacy.d.ts +8 -0
- package/types/core/main.d.ts +5996 -0
- package/types/core/p5.Graphics.d.ts +484 -0
- package/types/core/p5.Renderer.d.ts +14 -0
- package/types/core/reference.d.ts +8 -0
- package/types/core/rendering.d.ts +481 -0
- package/types/core/structure.d.ts +492 -0
- package/types/core/transform.d.ts +1638 -0
- package/types/data/local_storage.d.ts +323 -0
- package/types/dom/dom.d.ts +1295 -0
- package/types/dom/p5.Element.d.ts +2011 -0
- package/types/dom/p5.File.d.ts +13 -0
- package/types/dom/p5.MediaElement.d.ts +1249 -0
- package/types/events/acceleration.d.ts +193 -0
- package/types/events/keyboard.d.ts +499 -0
- package/types/events/pointer.d.ts +782 -0
- package/types/global.d.ts +5542 -0
- package/types/image/filterRenderer2D.d.ts +54 -0
- package/types/image/image.d.ts +326 -0
- package/types/image/loading_displaying.d.ts +580 -0
- package/types/image/p5.Image.d.ts +5882 -0
- package/types/image/pixels.d.ts +832 -0
- package/types/io/files.d.ts +1447 -0
- package/types/io/p5.Table.d.ts +1247 -0
- package/types/io/p5.TableRow.d.ts +343 -0
- package/types/io/p5.XML.d.ts +1188 -0
- package/types/math/Matrices/Matrix.d.ts +1029 -0
- package/types/math/Matrices/MatrixNumjs.d.ts +8 -0
- package/types/math/calculation.d.ts +923 -0
- package/types/math/math.d.ts +90 -0
- package/types/math/noise.d.ts +311 -0
- package/types/math/p5.Matrix.d.ts +8 -0
- package/types/math/p5.Vector.d.ts +3416 -0
- package/types/math/random.d.ts +267 -0
- package/types/math/trigonometry.d.ts +663 -0
- package/types/p5.d.ts +6663 -0
- package/types/shape/2d_primitives.d.ts +1033 -0
- package/types/shape/attributes.d.ts +466 -0
- package/types/shape/curves.d.ts +740 -0
- package/types/shape/custom_shapes.d.ts +888 -0
- package/types/shape/vertex.d.ts +1141 -0
- package/types/type/p5.Font.d.ts +575 -0
- package/types/type/textCore.d.ts +1198 -0
- package/types/utilities/conversion.d.ts +894 -0
- package/types/utilities/time_date.d.ts +295 -0
- package/types/utilities/utility_functions.d.ts +587 -0
- package/types/webgl/3d_primitives.d.ts +1432 -0
- package/types/webgl/ShaderGenerator.d.ts +8 -0
- package/types/webgl/interaction.d.ts +371 -0
- package/types/webgl/light.d.ts +1184 -0
- package/types/webgl/loading.d.ts +481 -0
- package/types/webgl/material.d.ts +2656 -0
- package/types/webgl/p5.Camera.d.ts +3023 -0
- package/types/webgl/p5.DataArray.d.ts +61 -0
- package/types/webgl/p5.Framebuffer.d.ts +760 -0
- package/types/webgl/p5.Geometry.d.ts +1191 -0
- package/types/webgl/p5.Quat.d.ts +45 -0
- package/types/webgl/p5.RendererGL.d.ts +234 -0
- package/types/webgl/p5.Shader.d.ts +660 -0
- package/types/webgl/p5.Texture.d.ts +61 -0
- package/types/webgl/text.d.ts +74 -0
- package/src/README.md +0 -27
- package/src/accessibility/index.js +0 -13
- package/src/app.js +0 -61
- package/src/color/index.js +0 -9
- package/src/color/p5.Color.culori.js +0 -66
- package/src/color/p5.Color.js +0 -851
- package/src/core/README.md +0 -91
- package/src/core/friendly_errors/index.js +0 -13
- package/src/core/friendly_errors/param_validator.js +0 -561
- package/src/core/init.js +0 -58
- package/src/core/internationalization.js +0 -195
- package/src/core/legacy.js +0 -29
- package/src/core/main.js +0 -689
- package/src/core/noop.js +0 -1
- package/src/core/p5.Graphics.js +0 -696
- package/src/core/p5.Renderer.js +0 -408
- package/src/core/reference.js +0 -2060
- package/src/core/rendering.js +0 -697
- package/src/dom/index.js +0 -11
- package/src/image/const.js +0 -6
- package/src/image/image.js +0 -731
- package/src/image/index.js +0 -15
- package/src/image/loading_displaying.js +0 -1431
- package/src/io/files.js +0 -2210
- package/src/io/index.js +0 -11
- package/src/math/README.md +0 -40
- package/src/type/index.js +0 -9
- package/src/webgl/3d_primitives.js +0 -2741
- package/src/webgl/index.js +0 -37
- package/src/webgl/light.js +0 -1851
- package/src/webgl/material.js +0 -3854
- package/src/webgl/p5.Camera.js +0 -4010
- package/src/webgl/p5.Framebuffer.js +0 -1865
- package/src/webgl/p5.RendererGL.js +0 -2867
- package/src/webgl/p5.Shader.js +0 -1505
- package/src/webgl/p5.Texture.js +0 -541
- package/src/webgl/shaders/basic.frag +0 -6
- package/src/webgl/shaders/filters/base.frag +0 -22
- package/src/webgl/shaders/filters/base.vert +0 -19
- package/src/webgl/shaders/filters/blur.frag +0 -60
- package/src/webgl/shaders/filters/default.vert +0 -18
- package/src/webgl/shaders/filters/dilate.frag +0 -39
- package/src/webgl/shaders/filters/erode.frag +0 -39
- package/src/webgl/shaders/filters/gray.frag +0 -16
- package/src/webgl/shaders/filters/invert.frag +0 -15
- package/src/webgl/shaders/filters/opaque.frag +0 -12
- package/src/webgl/shaders/filters/posterize.frag +0 -29
- package/src/webgl/shaders/filters/threshold.frag +0 -23
- package/src/webgl/shaders/font.frag +0 -216
- package/src/webgl/shaders/font.vert +0 -44
- package/src/webgl/shaders/imageLight.vert +0 -33
- package/src/webgl/shaders/imageLightDiffused.frag +0 -82
- package/src/webgl/shaders/imageLightSpecular.frag +0 -134
- package/src/webgl/shaders/light.vert +0 -37
- package/src/webgl/shaders/light_texture.frag +0 -26
- package/src/webgl/shaders/lighting.glsl +0 -227
- package/src/webgl/shaders/line.frag +0 -74
- package/src/webgl/shaders/line.vert +0 -294
- package/src/webgl/shaders/normal.frag +0 -6
- package/src/webgl/shaders/normal.vert +0 -72
- package/src/webgl/shaders/phong.frag +0 -84
- package/src/webgl/shaders/phong.vert +0 -87
- package/src/webgl/shaders/point.frag +0 -29
- package/src/webgl/shaders/point.vert +0 -19
- package/src/webgl/shaders/sphereMapping.frag +0 -26
- package/src/webgl/shaders/webgl2Compatibility.glsl +0 -34
|
@@ -0,0 +1,1070 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
import { Color } from '../color/p5.Color';
|
|
5
|
+
|
|
6
|
+
declare module 'p5' {
|
|
7
|
+
class Color {
|
|
8
|
+
constructor(pInst?: p5, vals: number[] | string);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns the color formatted as a `String`.Calling `myColor.toString()` can be useful for debugging, as in
|
|
12
|
+
* `print(myColor.toString())`. It's also helpful for using p5.js with other
|
|
13
|
+
* libraries.The parameter, `format`, is optional. If a format string is passed, as in
|
|
14
|
+
* `myColor.toString('#rrggbb')`, it will determine how the color string is
|
|
15
|
+
* formatted. By default, color strings are formatted as `'rgba(r, g, b, a)'`.
|
|
16
|
+
*
|
|
17
|
+
* @param
|
|
18
|
+
*/
|
|
19
|
+
toString(format: string): string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Sets the red component of a color.The range depends on the colorMode(). In the
|
|
23
|
+
* default RGB mode it's between 0 and 255.
|
|
24
|
+
*
|
|
25
|
+
* @param
|
|
26
|
+
* @param
|
|
27
|
+
* @param
|
|
28
|
+
*/
|
|
29
|
+
setRed(new_red: any, max: any, red: number): void;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sets the green component of a color.The range depends on the colorMode(). In the
|
|
33
|
+
* default RGB mode it's between 0 and 255.
|
|
34
|
+
*
|
|
35
|
+
* @param
|
|
36
|
+
* @param
|
|
37
|
+
* @param
|
|
38
|
+
*/
|
|
39
|
+
setGreen(new_green: any, max: any, green: number): void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Sets the blue component of a color.The range depends on the colorMode(). In the
|
|
43
|
+
* default RGB mode it's between 0 and 255.
|
|
44
|
+
*
|
|
45
|
+
* @param
|
|
46
|
+
* @param
|
|
47
|
+
* @param
|
|
48
|
+
*/
|
|
49
|
+
setBlue(new_blue: any, max: any, blue: number): void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sets the alpha (transparency) value of a color.The range depends on the
|
|
53
|
+
* colorMode(). In the default RGB mode it's
|
|
54
|
+
* between 0 and 255.
|
|
55
|
+
*
|
|
56
|
+
* @param
|
|
57
|
+
* @param
|
|
58
|
+
* @param
|
|
59
|
+
*/
|
|
60
|
+
setAlpha(new_alpha: any, max: any, alpha: number): void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Hue is the same in HSB and HSL, but the maximum value may be different.
|
|
64
|
+
* This function will return the HSB-normalized saturation when supplied with
|
|
65
|
+
* an HSB color object, but will default to the HSL-normalized saturation
|
|
66
|
+
* otherwise.
|
|
67
|
+
*
|
|
68
|
+
* @param
|
|
69
|
+
*/
|
|
70
|
+
_getHue(max: any): void;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Saturation is scaled differently in HSB and HSL. This function will return
|
|
74
|
+
* the HSB saturation when supplied with an HSB color object, but will default
|
|
75
|
+
* to the HSL saturation otherwise.
|
|
76
|
+
*
|
|
77
|
+
* @param
|
|
78
|
+
*/
|
|
79
|
+
_getSaturation(max: any): void;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns the color formatted as a `String`.Calling `myColor.toString()` can be useful for debugging, as in
|
|
83
|
+
* `print(myColor.toString())`. It's also helpful for using p5.js with other
|
|
84
|
+
* libraries.The parameter, `format`, is optional. If a format string is passed, as in
|
|
85
|
+
* `myColor.toString('#rrggbb')`, it will determine how the color string is
|
|
86
|
+
* formatted. By default, color strings are formatted as `'rgba(r, g, b, a)'`.
|
|
87
|
+
*
|
|
88
|
+
* @param
|
|
89
|
+
*/
|
|
90
|
+
toString(format: string): string;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Sets the red component of a color.The range depends on the colorMode(). In the
|
|
94
|
+
* default RGB mode it's between 0 and 255.
|
|
95
|
+
*
|
|
96
|
+
* @param
|
|
97
|
+
* @param
|
|
98
|
+
* @param
|
|
99
|
+
*/
|
|
100
|
+
setRed(new_red: any, max: any, red: number): void;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Sets the green component of a color.The range depends on the colorMode(). In the
|
|
104
|
+
* default RGB mode it's between 0 and 255.
|
|
105
|
+
*
|
|
106
|
+
* @param
|
|
107
|
+
* @param
|
|
108
|
+
* @param
|
|
109
|
+
*/
|
|
110
|
+
setGreen(new_green: any, max: any, green: number): void;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Sets the blue component of a color.The range depends on the colorMode(). In the
|
|
114
|
+
* default RGB mode it's between 0 and 255.
|
|
115
|
+
*
|
|
116
|
+
* @param
|
|
117
|
+
* @param
|
|
118
|
+
* @param
|
|
119
|
+
*/
|
|
120
|
+
setBlue(new_blue: any, max: any, blue: number): void;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Sets the alpha (transparency) value of a color.The range depends on the
|
|
124
|
+
* colorMode(). In the default RGB mode it's
|
|
125
|
+
* between 0 and 255.
|
|
126
|
+
*
|
|
127
|
+
* @param
|
|
128
|
+
* @param
|
|
129
|
+
* @param
|
|
130
|
+
*/
|
|
131
|
+
setAlpha(new_alpha: any, max: any, alpha: number): void;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Hue is the same in HSB and HSL, but the maximum value may be different.
|
|
135
|
+
* This function will return the HSB-normalized saturation when supplied with
|
|
136
|
+
* an HSB color object, but will default to the HSL-normalized saturation
|
|
137
|
+
* otherwise.
|
|
138
|
+
*
|
|
139
|
+
* @param
|
|
140
|
+
*/
|
|
141
|
+
_getHue(max: any): void;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Saturation is scaled differently in HSB and HSL. This function will return
|
|
145
|
+
* the HSB saturation when supplied with an HSB color object, but will default
|
|
146
|
+
* to the HSL saturation otherwise.
|
|
147
|
+
*
|
|
148
|
+
* @param
|
|
149
|
+
*/
|
|
150
|
+
_getSaturation(max: any): void;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Returns the color formatted as a `String`.Calling `myColor.toString()` can be useful for debugging, as in
|
|
154
|
+
* `print(myColor.toString())`. It's also helpful for using p5.js with other
|
|
155
|
+
* libraries.The parameter, `format`, is optional. If a format string is passed, as in
|
|
156
|
+
* `myColor.toString('#rrggbb')`, it will determine how the color string is
|
|
157
|
+
* formatted. By default, color strings are formatted as `'rgba(r, g, b, a)'`.
|
|
158
|
+
*
|
|
159
|
+
* @param
|
|
160
|
+
*/
|
|
161
|
+
toString(format: string): string;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Sets the red component of a color.The range depends on the colorMode(). In the
|
|
165
|
+
* default RGB mode it's between 0 and 255.
|
|
166
|
+
*
|
|
167
|
+
* @param
|
|
168
|
+
* @param
|
|
169
|
+
* @param
|
|
170
|
+
*/
|
|
171
|
+
setRed(new_red: any, max: any, red: number): void;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sets the green component of a color.The range depends on the colorMode(). In the
|
|
175
|
+
* default RGB mode it's between 0 and 255.
|
|
176
|
+
*
|
|
177
|
+
* @param
|
|
178
|
+
* @param
|
|
179
|
+
* @param
|
|
180
|
+
*/
|
|
181
|
+
setGreen(new_green: any, max: any, green: number): void;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Sets the blue component of a color.The range depends on the colorMode(). In the
|
|
185
|
+
* default RGB mode it's between 0 and 255.
|
|
186
|
+
*
|
|
187
|
+
* @param
|
|
188
|
+
* @param
|
|
189
|
+
* @param
|
|
190
|
+
*/
|
|
191
|
+
setBlue(new_blue: any, max: any, blue: number): void;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Sets the alpha (transparency) value of a color.The range depends on the
|
|
195
|
+
* colorMode(). In the default RGB mode it's
|
|
196
|
+
* between 0 and 255.
|
|
197
|
+
*
|
|
198
|
+
* @param
|
|
199
|
+
* @param
|
|
200
|
+
* @param
|
|
201
|
+
*/
|
|
202
|
+
setAlpha(new_alpha: any, max: any, alpha: number): void;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Hue is the same in HSB and HSL, but the maximum value may be different.
|
|
206
|
+
* This function will return the HSB-normalized saturation when supplied with
|
|
207
|
+
* an HSB color object, but will default to the HSL-normalized saturation
|
|
208
|
+
* otherwise.
|
|
209
|
+
*
|
|
210
|
+
* @param
|
|
211
|
+
*/
|
|
212
|
+
_getHue(max: any): void;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Saturation is scaled differently in HSB and HSL. This function will return
|
|
216
|
+
* the HSB saturation when supplied with an HSB color object, but will default
|
|
217
|
+
* to the HSL saturation otherwise.
|
|
218
|
+
*
|
|
219
|
+
* @param
|
|
220
|
+
*/
|
|
221
|
+
_getSaturation(max: any): void;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Returns the color formatted as a `String`.Calling `myColor.toString()` can be useful for debugging, as in
|
|
225
|
+
* `print(myColor.toString())`. It's also helpful for using p5.js with other
|
|
226
|
+
* libraries.The parameter, `format`, is optional. If a format string is passed, as in
|
|
227
|
+
* `myColor.toString('#rrggbb')`, it will determine how the color string is
|
|
228
|
+
* formatted. By default, color strings are formatted as `'rgba(r, g, b, a)'`.
|
|
229
|
+
*
|
|
230
|
+
* @param
|
|
231
|
+
*/
|
|
232
|
+
toString(format: string): string;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Sets the red component of a color.The range depends on the colorMode(). In the
|
|
236
|
+
* default RGB mode it's between 0 and 255.
|
|
237
|
+
*
|
|
238
|
+
* @param
|
|
239
|
+
* @param
|
|
240
|
+
* @param
|
|
241
|
+
*/
|
|
242
|
+
setRed(new_red: any, max: any, red: number): void;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Sets the green component of a color.The range depends on the colorMode(). In the
|
|
246
|
+
* default RGB mode it's between 0 and 255.
|
|
247
|
+
*
|
|
248
|
+
* @param
|
|
249
|
+
* @param
|
|
250
|
+
* @param
|
|
251
|
+
*/
|
|
252
|
+
setGreen(new_green: any, max: any, green: number): void;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Sets the blue component of a color.The range depends on the colorMode(). In the
|
|
256
|
+
* default RGB mode it's between 0 and 255.
|
|
257
|
+
*
|
|
258
|
+
* @param
|
|
259
|
+
* @param
|
|
260
|
+
* @param
|
|
261
|
+
*/
|
|
262
|
+
setBlue(new_blue: any, max: any, blue: number): void;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Sets the alpha (transparency) value of a color.The range depends on the
|
|
266
|
+
* colorMode(). In the default RGB mode it's
|
|
267
|
+
* between 0 and 255.
|
|
268
|
+
*
|
|
269
|
+
* @param
|
|
270
|
+
* @param
|
|
271
|
+
* @param
|
|
272
|
+
*/
|
|
273
|
+
setAlpha(new_alpha: any, max: any, alpha: number): void;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Hue is the same in HSB and HSL, but the maximum value may be different.
|
|
277
|
+
* This function will return the HSB-normalized saturation when supplied with
|
|
278
|
+
* an HSB color object, but will default to the HSL-normalized saturation
|
|
279
|
+
* otherwise.
|
|
280
|
+
*
|
|
281
|
+
* @param
|
|
282
|
+
*/
|
|
283
|
+
_getHue(max: any): void;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Saturation is scaled differently in HSB and HSL. This function will return
|
|
287
|
+
* the HSB saturation when supplied with an HSB color object, but will default
|
|
288
|
+
* to the HSL saturation otherwise.
|
|
289
|
+
*
|
|
290
|
+
* @param
|
|
291
|
+
*/
|
|
292
|
+
_getSaturation(max: any): void;
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Returns the color formatted as a `String`.Calling `myColor.toString()` can be useful for debugging, as in
|
|
298
|
+
* `print(myColor.toString())`. It's also helpful for using p5.js with other
|
|
299
|
+
* libraries.The parameter, `format`, is optional. If a format string is passed, as in
|
|
300
|
+
* `myColor.toString('#rrggbb')`, it will determine how the color string is
|
|
301
|
+
* formatted. By default, color strings are formatted as `'rgba(r, g, b, a)'`.
|
|
302
|
+
*
|
|
303
|
+
* @param how the color string will be formatted.
|
|
304
|
+
* Leaving this empty formats the string as rgba(r, g, b, a).
|
|
305
|
+
* '#rgb' '#rgba' '#rrggbb' and '#rrggbbaa' format as hexadecimal color codes.
|
|
306
|
+
* 'rgb' 'hsb' and 'hsl' return the color formatted in the specified color mode.
|
|
307
|
+
* 'rgba' 'hsba' and 'hsla' are the same as above but with alpha channels.
|
|
308
|
+
* 'rgb%' 'hsb%' 'hsl%' 'rgba%' 'hsba%' and 'hsla%' format as percentages.
|
|
309
|
+
* @return the formatted string.
|
|
310
|
+
* @example <div>
|
|
311
|
+
* <code>
|
|
312
|
+
* function setup() {
|
|
313
|
+
* createCanvas(100, 100);
|
|
314
|
+
*
|
|
315
|
+
* background(200);
|
|
316
|
+
*
|
|
317
|
+
* // Create a p5.Color object.
|
|
318
|
+
* let myColor = color('darkorchid');
|
|
319
|
+
*
|
|
320
|
+
* // Style the text.
|
|
321
|
+
* textAlign(CENTER);
|
|
322
|
+
* textSize(16);
|
|
323
|
+
*
|
|
324
|
+
* // Display the text.
|
|
325
|
+
* text(myColor.toString('#rrggbb'), 50, 50);
|
|
326
|
+
*
|
|
327
|
+
* describe('The text "#9932cc" written in purple on a gray background.');
|
|
328
|
+
* }
|
|
329
|
+
* </code>
|
|
330
|
+
* </div>
|
|
331
|
+
*/
|
|
332
|
+
function toString(format?: string): string;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Sets the red component of a color.The range depends on the colorMode(). In the
|
|
336
|
+
* default RGB mode it's between 0 and 255.
|
|
337
|
+
*
|
|
338
|
+
* @param the new red value.
|
|
339
|
+
* @example <div>
|
|
340
|
+
* <code>
|
|
341
|
+
* function setup() {
|
|
342
|
+
* createCanvas(100, 100);
|
|
343
|
+
*
|
|
344
|
+
* background(200);
|
|
345
|
+
*
|
|
346
|
+
* // Create a p5.Color object.
|
|
347
|
+
* let c = color(255, 128, 128);
|
|
348
|
+
*
|
|
349
|
+
* // Draw the left rectangle.
|
|
350
|
+
* noStroke();
|
|
351
|
+
* fill(c);
|
|
352
|
+
* rect(15, 20, 35, 60);
|
|
353
|
+
*
|
|
354
|
+
* // Change the red value.
|
|
355
|
+
* c.setRed(64);
|
|
356
|
+
*
|
|
357
|
+
* // Draw the right rectangle.
|
|
358
|
+
* fill(c);
|
|
359
|
+
* rect(50, 20, 35, 60);
|
|
360
|
+
*
|
|
361
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is teal.');
|
|
362
|
+
* }
|
|
363
|
+
* </code>
|
|
364
|
+
* </div>
|
|
365
|
+
*/
|
|
366
|
+
function setRed(new_red: any, max: any, red: number): void;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Sets the green component of a color.The range depends on the colorMode(). In the
|
|
370
|
+
* default RGB mode it's between 0 and 255.
|
|
371
|
+
*
|
|
372
|
+
* @param the new green value.
|
|
373
|
+
* @example <div>
|
|
374
|
+
* <code>
|
|
375
|
+
* function setup() {
|
|
376
|
+
* createCanvas(100, 100);
|
|
377
|
+
*
|
|
378
|
+
* background(200);
|
|
379
|
+
*
|
|
380
|
+
* // Create a p5.Color object.
|
|
381
|
+
* let c = color(255, 128, 128);
|
|
382
|
+
*
|
|
383
|
+
* // Draw the left rectangle.
|
|
384
|
+
* noStroke();
|
|
385
|
+
* fill(c);
|
|
386
|
+
* rect(15, 20, 35, 60);
|
|
387
|
+
*
|
|
388
|
+
* // Change the green value.
|
|
389
|
+
* c.setGreen(255);
|
|
390
|
+
*
|
|
391
|
+
* // Draw the right rectangle.
|
|
392
|
+
* fill(c);
|
|
393
|
+
* rect(50, 20, 35, 60);
|
|
394
|
+
*
|
|
395
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is yellow.');
|
|
396
|
+
* }
|
|
397
|
+
* </code>
|
|
398
|
+
* </div>
|
|
399
|
+
*/
|
|
400
|
+
function setGreen(new_green: any, max: any, green: number): void;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Sets the blue component of a color.The range depends on the colorMode(). In the
|
|
404
|
+
* default RGB mode it's between 0 and 255.
|
|
405
|
+
*
|
|
406
|
+
* @param the new blue value.
|
|
407
|
+
* @example <div>
|
|
408
|
+
* <code>
|
|
409
|
+
* function setup() {
|
|
410
|
+
* createCanvas(100, 100);
|
|
411
|
+
*
|
|
412
|
+
* background(200);
|
|
413
|
+
*
|
|
414
|
+
* // Create a p5.Color object.
|
|
415
|
+
* let c = color(255, 128, 128);
|
|
416
|
+
*
|
|
417
|
+
* // Draw the left rectangle.
|
|
418
|
+
* noStroke();
|
|
419
|
+
* fill(c);
|
|
420
|
+
* rect(15, 20, 35, 60);
|
|
421
|
+
*
|
|
422
|
+
* // Change the blue value.
|
|
423
|
+
* c.setBlue(255);
|
|
424
|
+
*
|
|
425
|
+
* // Draw the right rectangle.
|
|
426
|
+
* fill(c);
|
|
427
|
+
* rect(50, 20, 35, 60);
|
|
428
|
+
*
|
|
429
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is pale fuchsia.');
|
|
430
|
+
* }
|
|
431
|
+
* </code>
|
|
432
|
+
* </div>
|
|
433
|
+
* *
|
|
434
|
+
*/
|
|
435
|
+
function setBlue(new_blue: any, max: any, blue: number): void;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Sets the alpha (transparency) value of a color.The range depends on the
|
|
439
|
+
* colorMode(). In the default RGB mode it's
|
|
440
|
+
* between 0 and 255.
|
|
441
|
+
*
|
|
442
|
+
* @param the new alpha value.
|
|
443
|
+
* @example <div>
|
|
444
|
+
* <code>
|
|
445
|
+
* function setup() {
|
|
446
|
+
* createCanvas(100, 100);
|
|
447
|
+
*
|
|
448
|
+
* background(200);
|
|
449
|
+
*
|
|
450
|
+
* // Create a p5.Color object.
|
|
451
|
+
* let c = color(255, 128, 128);
|
|
452
|
+
*
|
|
453
|
+
* // Draw the left rectangle.
|
|
454
|
+
* noStroke();
|
|
455
|
+
* fill(c);
|
|
456
|
+
* rect(15, 20, 35, 60);
|
|
457
|
+
*
|
|
458
|
+
* // Change the alpha value.
|
|
459
|
+
* c.setAlpha(128);
|
|
460
|
+
*
|
|
461
|
+
* // Draw the right rectangle.
|
|
462
|
+
* fill(c);
|
|
463
|
+
* rect(50, 20, 35, 60);
|
|
464
|
+
*
|
|
465
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is faded pink.');
|
|
466
|
+
* }
|
|
467
|
+
* </code>
|
|
468
|
+
* </div>
|
|
469
|
+
*/
|
|
470
|
+
function setAlpha(new_alpha: any, max: any, alpha: number): void;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Hue is the same in HSB and HSL, but the maximum value may be different.
|
|
474
|
+
* This function will return the HSB-normalized saturation when supplied with
|
|
475
|
+
* an HSB color object, but will default to the HSL-normalized saturation
|
|
476
|
+
* otherwise.
|
|
477
|
+
*
|
|
478
|
+
*/
|
|
479
|
+
function _getHue(max: any): void;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Saturation is scaled differently in HSB and HSL. This function will return
|
|
483
|
+
* the HSB saturation when supplied with an HSB color object, but will default
|
|
484
|
+
* to the HSL saturation otherwise.
|
|
485
|
+
*
|
|
486
|
+
*/
|
|
487
|
+
function _getSaturation(max: any): void;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Returns the color formatted as a `String`.Calling `myColor.toString()` can be useful for debugging, as in
|
|
491
|
+
* `print(myColor.toString())`. It's also helpful for using p5.js with other
|
|
492
|
+
* libraries.The parameter, `format`, is optional. If a format string is passed, as in
|
|
493
|
+
* `myColor.toString('#rrggbb')`, it will determine how the color string is
|
|
494
|
+
* formatted. By default, color strings are formatted as `'rgba(r, g, b, a)'`.
|
|
495
|
+
*
|
|
496
|
+
* @param how the color string will be formatted.
|
|
497
|
+
* Leaving this empty formats the string as rgba(r, g, b, a).
|
|
498
|
+
* '#rgb' '#rgba' '#rrggbb' and '#rrggbbaa' format as hexadecimal color codes.
|
|
499
|
+
* 'rgb' 'hsb' and 'hsl' return the color formatted in the specified color mode.
|
|
500
|
+
* 'rgba' 'hsba' and 'hsla' are the same as above but with alpha channels.
|
|
501
|
+
* 'rgb%' 'hsb%' 'hsl%' 'rgba%' 'hsba%' and 'hsla%' format as percentages.
|
|
502
|
+
* @return the formatted string.
|
|
503
|
+
* @example <div>
|
|
504
|
+
* <code>
|
|
505
|
+
* function setup() {
|
|
506
|
+
* createCanvas(100, 100);
|
|
507
|
+
*
|
|
508
|
+
* background(200);
|
|
509
|
+
*
|
|
510
|
+
* // Create a p5.Color object.
|
|
511
|
+
* let myColor = color('darkorchid');
|
|
512
|
+
*
|
|
513
|
+
* // Style the text.
|
|
514
|
+
* textAlign(CENTER);
|
|
515
|
+
* textSize(16);
|
|
516
|
+
*
|
|
517
|
+
* // Display the text.
|
|
518
|
+
* text(myColor.toString('#rrggbb'), 50, 50);
|
|
519
|
+
*
|
|
520
|
+
* describe('The text "#9932cc" written in purple on a gray background.');
|
|
521
|
+
* }
|
|
522
|
+
* </code>
|
|
523
|
+
* </div>
|
|
524
|
+
*/
|
|
525
|
+
function toString(format?: string): string;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Sets the red component of a color.The range depends on the colorMode(). In the
|
|
529
|
+
* default RGB mode it's between 0 and 255.
|
|
530
|
+
*
|
|
531
|
+
* @param the new red value.
|
|
532
|
+
* @example <div>
|
|
533
|
+
* <code>
|
|
534
|
+
* function setup() {
|
|
535
|
+
* createCanvas(100, 100);
|
|
536
|
+
*
|
|
537
|
+
* background(200);
|
|
538
|
+
*
|
|
539
|
+
* // Create a p5.Color object.
|
|
540
|
+
* let c = color(255, 128, 128);
|
|
541
|
+
*
|
|
542
|
+
* // Draw the left rectangle.
|
|
543
|
+
* noStroke();
|
|
544
|
+
* fill(c);
|
|
545
|
+
* rect(15, 20, 35, 60);
|
|
546
|
+
*
|
|
547
|
+
* // Change the red value.
|
|
548
|
+
* c.setRed(64);
|
|
549
|
+
*
|
|
550
|
+
* // Draw the right rectangle.
|
|
551
|
+
* fill(c);
|
|
552
|
+
* rect(50, 20, 35, 60);
|
|
553
|
+
*
|
|
554
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is teal.');
|
|
555
|
+
* }
|
|
556
|
+
* </code>
|
|
557
|
+
* </div>
|
|
558
|
+
*/
|
|
559
|
+
function setRed(new_red: any, max: any, red: number): void;
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Sets the green component of a color.The range depends on the colorMode(). In the
|
|
563
|
+
* default RGB mode it's between 0 and 255.
|
|
564
|
+
*
|
|
565
|
+
* @param the new green value.
|
|
566
|
+
* @example <div>
|
|
567
|
+
* <code>
|
|
568
|
+
* function setup() {
|
|
569
|
+
* createCanvas(100, 100);
|
|
570
|
+
*
|
|
571
|
+
* background(200);
|
|
572
|
+
*
|
|
573
|
+
* // Create a p5.Color object.
|
|
574
|
+
* let c = color(255, 128, 128);
|
|
575
|
+
*
|
|
576
|
+
* // Draw the left rectangle.
|
|
577
|
+
* noStroke();
|
|
578
|
+
* fill(c);
|
|
579
|
+
* rect(15, 20, 35, 60);
|
|
580
|
+
*
|
|
581
|
+
* // Change the green value.
|
|
582
|
+
* c.setGreen(255);
|
|
583
|
+
*
|
|
584
|
+
* // Draw the right rectangle.
|
|
585
|
+
* fill(c);
|
|
586
|
+
* rect(50, 20, 35, 60);
|
|
587
|
+
*
|
|
588
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is yellow.');
|
|
589
|
+
* }
|
|
590
|
+
* </code>
|
|
591
|
+
* </div>
|
|
592
|
+
*/
|
|
593
|
+
function setGreen(new_green: any, max: any, green: number): void;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Sets the blue component of a color.The range depends on the colorMode(). In the
|
|
597
|
+
* default RGB mode it's between 0 and 255.
|
|
598
|
+
*
|
|
599
|
+
* @param the new blue value.
|
|
600
|
+
* @example <div>
|
|
601
|
+
* <code>
|
|
602
|
+
* function setup() {
|
|
603
|
+
* createCanvas(100, 100);
|
|
604
|
+
*
|
|
605
|
+
* background(200);
|
|
606
|
+
*
|
|
607
|
+
* // Create a p5.Color object.
|
|
608
|
+
* let c = color(255, 128, 128);
|
|
609
|
+
*
|
|
610
|
+
* // Draw the left rectangle.
|
|
611
|
+
* noStroke();
|
|
612
|
+
* fill(c);
|
|
613
|
+
* rect(15, 20, 35, 60);
|
|
614
|
+
*
|
|
615
|
+
* // Change the blue value.
|
|
616
|
+
* c.setBlue(255);
|
|
617
|
+
*
|
|
618
|
+
* // Draw the right rectangle.
|
|
619
|
+
* fill(c);
|
|
620
|
+
* rect(50, 20, 35, 60);
|
|
621
|
+
*
|
|
622
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is pale fuchsia.');
|
|
623
|
+
* }
|
|
624
|
+
* </code>
|
|
625
|
+
* </div>
|
|
626
|
+
* *
|
|
627
|
+
*/
|
|
628
|
+
function setBlue(new_blue: any, max: any, blue: number): void;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Sets the alpha (transparency) value of a color.The range depends on the
|
|
632
|
+
* colorMode(). In the default RGB mode it's
|
|
633
|
+
* between 0 and 255.
|
|
634
|
+
*
|
|
635
|
+
* @param the new alpha value.
|
|
636
|
+
* @example <div>
|
|
637
|
+
* <code>
|
|
638
|
+
* function setup() {
|
|
639
|
+
* createCanvas(100, 100);
|
|
640
|
+
*
|
|
641
|
+
* background(200);
|
|
642
|
+
*
|
|
643
|
+
* // Create a p5.Color object.
|
|
644
|
+
* let c = color(255, 128, 128);
|
|
645
|
+
*
|
|
646
|
+
* // Draw the left rectangle.
|
|
647
|
+
* noStroke();
|
|
648
|
+
* fill(c);
|
|
649
|
+
* rect(15, 20, 35, 60);
|
|
650
|
+
*
|
|
651
|
+
* // Change the alpha value.
|
|
652
|
+
* c.setAlpha(128);
|
|
653
|
+
*
|
|
654
|
+
* // Draw the right rectangle.
|
|
655
|
+
* fill(c);
|
|
656
|
+
* rect(50, 20, 35, 60);
|
|
657
|
+
*
|
|
658
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is faded pink.');
|
|
659
|
+
* }
|
|
660
|
+
* </code>
|
|
661
|
+
* </div>
|
|
662
|
+
*/
|
|
663
|
+
function setAlpha(new_alpha: any, max: any, alpha: number): void;
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Hue is the same in HSB and HSL, but the maximum value may be different.
|
|
667
|
+
* This function will return the HSB-normalized saturation when supplied with
|
|
668
|
+
* an HSB color object, but will default to the HSL-normalized saturation
|
|
669
|
+
* otherwise.
|
|
670
|
+
*
|
|
671
|
+
*/
|
|
672
|
+
function _getHue(max: any): void;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Saturation is scaled differently in HSB and HSL. This function will return
|
|
676
|
+
* the HSB saturation when supplied with an HSB color object, but will default
|
|
677
|
+
* to the HSL saturation otherwise.
|
|
678
|
+
*
|
|
679
|
+
*/
|
|
680
|
+
function _getSaturation(max: any): void;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Returns the color formatted as a `String`.Calling `myColor.toString()` can be useful for debugging, as in
|
|
684
|
+
* `print(myColor.toString())`. It's also helpful for using p5.js with other
|
|
685
|
+
* libraries.The parameter, `format`, is optional. If a format string is passed, as in
|
|
686
|
+
* `myColor.toString('#rrggbb')`, it will determine how the color string is
|
|
687
|
+
* formatted. By default, color strings are formatted as `'rgba(r, g, b, a)'`.
|
|
688
|
+
*
|
|
689
|
+
* @param how the color string will be formatted.
|
|
690
|
+
* Leaving this empty formats the string as rgba(r, g, b, a).
|
|
691
|
+
* '#rgb' '#rgba' '#rrggbb' and '#rrggbbaa' format as hexadecimal color codes.
|
|
692
|
+
* 'rgb' 'hsb' and 'hsl' return the color formatted in the specified color mode.
|
|
693
|
+
* 'rgba' 'hsba' and 'hsla' are the same as above but with alpha channels.
|
|
694
|
+
* 'rgb%' 'hsb%' 'hsl%' 'rgba%' 'hsba%' and 'hsla%' format as percentages.
|
|
695
|
+
* @return the formatted string.
|
|
696
|
+
* @example <div>
|
|
697
|
+
* <code>
|
|
698
|
+
* function setup() {
|
|
699
|
+
* createCanvas(100, 100);
|
|
700
|
+
*
|
|
701
|
+
* background(200);
|
|
702
|
+
*
|
|
703
|
+
* // Create a p5.Color object.
|
|
704
|
+
* let myColor = color('darkorchid');
|
|
705
|
+
*
|
|
706
|
+
* // Style the text.
|
|
707
|
+
* textAlign(CENTER);
|
|
708
|
+
* textSize(16);
|
|
709
|
+
*
|
|
710
|
+
* // Display the text.
|
|
711
|
+
* text(myColor.toString('#rrggbb'), 50, 50);
|
|
712
|
+
*
|
|
713
|
+
* describe('The text "#9932cc" written in purple on a gray background.');
|
|
714
|
+
* }
|
|
715
|
+
* </code>
|
|
716
|
+
* </div>
|
|
717
|
+
*/
|
|
718
|
+
function toString(format?: string): string;
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Sets the red component of a color.The range depends on the colorMode(). In the
|
|
722
|
+
* default RGB mode it's between 0 and 255.
|
|
723
|
+
*
|
|
724
|
+
* @param the new red value.
|
|
725
|
+
* @example <div>
|
|
726
|
+
* <code>
|
|
727
|
+
* function setup() {
|
|
728
|
+
* createCanvas(100, 100);
|
|
729
|
+
*
|
|
730
|
+
* background(200);
|
|
731
|
+
*
|
|
732
|
+
* // Create a p5.Color object.
|
|
733
|
+
* let c = color(255, 128, 128);
|
|
734
|
+
*
|
|
735
|
+
* // Draw the left rectangle.
|
|
736
|
+
* noStroke();
|
|
737
|
+
* fill(c);
|
|
738
|
+
* rect(15, 20, 35, 60);
|
|
739
|
+
*
|
|
740
|
+
* // Change the red value.
|
|
741
|
+
* c.setRed(64);
|
|
742
|
+
*
|
|
743
|
+
* // Draw the right rectangle.
|
|
744
|
+
* fill(c);
|
|
745
|
+
* rect(50, 20, 35, 60);
|
|
746
|
+
*
|
|
747
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is teal.');
|
|
748
|
+
* }
|
|
749
|
+
* </code>
|
|
750
|
+
* </div>
|
|
751
|
+
*/
|
|
752
|
+
function setRed(new_red: any, max: any, red: number): void;
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Sets the green component of a color.The range depends on the colorMode(). In the
|
|
756
|
+
* default RGB mode it's between 0 and 255.
|
|
757
|
+
*
|
|
758
|
+
* @param the new green value.
|
|
759
|
+
* @example <div>
|
|
760
|
+
* <code>
|
|
761
|
+
* function setup() {
|
|
762
|
+
* createCanvas(100, 100);
|
|
763
|
+
*
|
|
764
|
+
* background(200);
|
|
765
|
+
*
|
|
766
|
+
* // Create a p5.Color object.
|
|
767
|
+
* let c = color(255, 128, 128);
|
|
768
|
+
*
|
|
769
|
+
* // Draw the left rectangle.
|
|
770
|
+
* noStroke();
|
|
771
|
+
* fill(c);
|
|
772
|
+
* rect(15, 20, 35, 60);
|
|
773
|
+
*
|
|
774
|
+
* // Change the green value.
|
|
775
|
+
* c.setGreen(255);
|
|
776
|
+
*
|
|
777
|
+
* // Draw the right rectangle.
|
|
778
|
+
* fill(c);
|
|
779
|
+
* rect(50, 20, 35, 60);
|
|
780
|
+
*
|
|
781
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is yellow.');
|
|
782
|
+
* }
|
|
783
|
+
* </code>
|
|
784
|
+
* </div>
|
|
785
|
+
*/
|
|
786
|
+
function setGreen(new_green: any, max: any, green: number): void;
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Sets the blue component of a color.The range depends on the colorMode(). In the
|
|
790
|
+
* default RGB mode it's between 0 and 255.
|
|
791
|
+
*
|
|
792
|
+
* @param the new blue value.
|
|
793
|
+
* @example <div>
|
|
794
|
+
* <code>
|
|
795
|
+
* function setup() {
|
|
796
|
+
* createCanvas(100, 100);
|
|
797
|
+
*
|
|
798
|
+
* background(200);
|
|
799
|
+
*
|
|
800
|
+
* // Create a p5.Color object.
|
|
801
|
+
* let c = color(255, 128, 128);
|
|
802
|
+
*
|
|
803
|
+
* // Draw the left rectangle.
|
|
804
|
+
* noStroke();
|
|
805
|
+
* fill(c);
|
|
806
|
+
* rect(15, 20, 35, 60);
|
|
807
|
+
*
|
|
808
|
+
* // Change the blue value.
|
|
809
|
+
* c.setBlue(255);
|
|
810
|
+
*
|
|
811
|
+
* // Draw the right rectangle.
|
|
812
|
+
* fill(c);
|
|
813
|
+
* rect(50, 20, 35, 60);
|
|
814
|
+
*
|
|
815
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is pale fuchsia.');
|
|
816
|
+
* }
|
|
817
|
+
* </code>
|
|
818
|
+
* </div>
|
|
819
|
+
* *
|
|
820
|
+
*/
|
|
821
|
+
function setBlue(new_blue: any, max: any, blue: number): void;
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Sets the alpha (transparency) value of a color.The range depends on the
|
|
825
|
+
* colorMode(). In the default RGB mode it's
|
|
826
|
+
* between 0 and 255.
|
|
827
|
+
*
|
|
828
|
+
* @param the new alpha value.
|
|
829
|
+
* @example <div>
|
|
830
|
+
* <code>
|
|
831
|
+
* function setup() {
|
|
832
|
+
* createCanvas(100, 100);
|
|
833
|
+
*
|
|
834
|
+
* background(200);
|
|
835
|
+
*
|
|
836
|
+
* // Create a p5.Color object.
|
|
837
|
+
* let c = color(255, 128, 128);
|
|
838
|
+
*
|
|
839
|
+
* // Draw the left rectangle.
|
|
840
|
+
* noStroke();
|
|
841
|
+
* fill(c);
|
|
842
|
+
* rect(15, 20, 35, 60);
|
|
843
|
+
*
|
|
844
|
+
* // Change the alpha value.
|
|
845
|
+
* c.setAlpha(128);
|
|
846
|
+
*
|
|
847
|
+
* // Draw the right rectangle.
|
|
848
|
+
* fill(c);
|
|
849
|
+
* rect(50, 20, 35, 60);
|
|
850
|
+
*
|
|
851
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is faded pink.');
|
|
852
|
+
* }
|
|
853
|
+
* </code>
|
|
854
|
+
* </div>
|
|
855
|
+
*/
|
|
856
|
+
function setAlpha(new_alpha: any, max: any, alpha: number): void;
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Hue is the same in HSB and HSL, but the maximum value may be different.
|
|
860
|
+
* This function will return the HSB-normalized saturation when supplied with
|
|
861
|
+
* an HSB color object, but will default to the HSL-normalized saturation
|
|
862
|
+
* otherwise.
|
|
863
|
+
*
|
|
864
|
+
*/
|
|
865
|
+
function _getHue(max: any): void;
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Saturation is scaled differently in HSB and HSL. This function will return
|
|
869
|
+
* the HSB saturation when supplied with an HSB color object, but will default
|
|
870
|
+
* to the HSL saturation otherwise.
|
|
871
|
+
*
|
|
872
|
+
*/
|
|
873
|
+
function _getSaturation(max: any): void;
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Returns the color formatted as a `String`.Calling `myColor.toString()` can be useful for debugging, as in
|
|
877
|
+
* `print(myColor.toString())`. It's also helpful for using p5.js with other
|
|
878
|
+
* libraries.The parameter, `format`, is optional. If a format string is passed, as in
|
|
879
|
+
* `myColor.toString('#rrggbb')`, it will determine how the color string is
|
|
880
|
+
* formatted. By default, color strings are formatted as `'rgba(r, g, b, a)'`.
|
|
881
|
+
*
|
|
882
|
+
* @param how the color string will be formatted.
|
|
883
|
+
* Leaving this empty formats the string as rgba(r, g, b, a).
|
|
884
|
+
* '#rgb' '#rgba' '#rrggbb' and '#rrggbbaa' format as hexadecimal color codes.
|
|
885
|
+
* 'rgb' 'hsb' and 'hsl' return the color formatted in the specified color mode.
|
|
886
|
+
* 'rgba' 'hsba' and 'hsla' are the same as above but with alpha channels.
|
|
887
|
+
* 'rgb%' 'hsb%' 'hsl%' 'rgba%' 'hsba%' and 'hsla%' format as percentages.
|
|
888
|
+
* @return the formatted string.
|
|
889
|
+
* @example <div>
|
|
890
|
+
* <code>
|
|
891
|
+
* function setup() {
|
|
892
|
+
* createCanvas(100, 100);
|
|
893
|
+
*
|
|
894
|
+
* background(200);
|
|
895
|
+
*
|
|
896
|
+
* // Create a p5.Color object.
|
|
897
|
+
* let myColor = color('darkorchid');
|
|
898
|
+
*
|
|
899
|
+
* // Style the text.
|
|
900
|
+
* textAlign(CENTER);
|
|
901
|
+
* textSize(16);
|
|
902
|
+
*
|
|
903
|
+
* // Display the text.
|
|
904
|
+
* text(myColor.toString('#rrggbb'), 50, 50);
|
|
905
|
+
*
|
|
906
|
+
* describe('The text "#9932cc" written in purple on a gray background.');
|
|
907
|
+
* }
|
|
908
|
+
* </code>
|
|
909
|
+
* </div>
|
|
910
|
+
*/
|
|
911
|
+
function toString(format?: string): string;
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Sets the red component of a color.The range depends on the colorMode(). In the
|
|
915
|
+
* default RGB mode it's between 0 and 255.
|
|
916
|
+
*
|
|
917
|
+
* @param the new red value.
|
|
918
|
+
* @example <div>
|
|
919
|
+
* <code>
|
|
920
|
+
* function setup() {
|
|
921
|
+
* createCanvas(100, 100);
|
|
922
|
+
*
|
|
923
|
+
* background(200);
|
|
924
|
+
*
|
|
925
|
+
* // Create a p5.Color object.
|
|
926
|
+
* let c = color(255, 128, 128);
|
|
927
|
+
*
|
|
928
|
+
* // Draw the left rectangle.
|
|
929
|
+
* noStroke();
|
|
930
|
+
* fill(c);
|
|
931
|
+
* rect(15, 20, 35, 60);
|
|
932
|
+
*
|
|
933
|
+
* // Change the red value.
|
|
934
|
+
* c.setRed(64);
|
|
935
|
+
*
|
|
936
|
+
* // Draw the right rectangle.
|
|
937
|
+
* fill(c);
|
|
938
|
+
* rect(50, 20, 35, 60);
|
|
939
|
+
*
|
|
940
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is teal.');
|
|
941
|
+
* }
|
|
942
|
+
* </code>
|
|
943
|
+
* </div>
|
|
944
|
+
*/
|
|
945
|
+
function setRed(new_red: any, max: any, red: number): void;
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* Sets the green component of a color.The range depends on the colorMode(). In the
|
|
949
|
+
* default RGB mode it's between 0 and 255.
|
|
950
|
+
*
|
|
951
|
+
* @param the new green value.
|
|
952
|
+
* @example <div>
|
|
953
|
+
* <code>
|
|
954
|
+
* function setup() {
|
|
955
|
+
* createCanvas(100, 100);
|
|
956
|
+
*
|
|
957
|
+
* background(200);
|
|
958
|
+
*
|
|
959
|
+
* // Create a p5.Color object.
|
|
960
|
+
* let c = color(255, 128, 128);
|
|
961
|
+
*
|
|
962
|
+
* // Draw the left rectangle.
|
|
963
|
+
* noStroke();
|
|
964
|
+
* fill(c);
|
|
965
|
+
* rect(15, 20, 35, 60);
|
|
966
|
+
*
|
|
967
|
+
* // Change the green value.
|
|
968
|
+
* c.setGreen(255);
|
|
969
|
+
*
|
|
970
|
+
* // Draw the right rectangle.
|
|
971
|
+
* fill(c);
|
|
972
|
+
* rect(50, 20, 35, 60);
|
|
973
|
+
*
|
|
974
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is yellow.');
|
|
975
|
+
* }
|
|
976
|
+
* </code>
|
|
977
|
+
* </div>
|
|
978
|
+
*/
|
|
979
|
+
function setGreen(new_green: any, max: any, green: number): void;
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Sets the blue component of a color.The range depends on the colorMode(). In the
|
|
983
|
+
* default RGB mode it's between 0 and 255.
|
|
984
|
+
*
|
|
985
|
+
* @param the new blue value.
|
|
986
|
+
* @example <div>
|
|
987
|
+
* <code>
|
|
988
|
+
* function setup() {
|
|
989
|
+
* createCanvas(100, 100);
|
|
990
|
+
*
|
|
991
|
+
* background(200);
|
|
992
|
+
*
|
|
993
|
+
* // Create a p5.Color object.
|
|
994
|
+
* let c = color(255, 128, 128);
|
|
995
|
+
*
|
|
996
|
+
* // Draw the left rectangle.
|
|
997
|
+
* noStroke();
|
|
998
|
+
* fill(c);
|
|
999
|
+
* rect(15, 20, 35, 60);
|
|
1000
|
+
*
|
|
1001
|
+
* // Change the blue value.
|
|
1002
|
+
* c.setBlue(255);
|
|
1003
|
+
*
|
|
1004
|
+
* // Draw the right rectangle.
|
|
1005
|
+
* fill(c);
|
|
1006
|
+
* rect(50, 20, 35, 60);
|
|
1007
|
+
*
|
|
1008
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is pale fuchsia.');
|
|
1009
|
+
* }
|
|
1010
|
+
* </code>
|
|
1011
|
+
* </div>
|
|
1012
|
+
* *
|
|
1013
|
+
*/
|
|
1014
|
+
function setBlue(new_blue: any, max: any, blue: number): void;
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* Sets the alpha (transparency) value of a color.The range depends on the
|
|
1018
|
+
* colorMode(). In the default RGB mode it's
|
|
1019
|
+
* between 0 and 255.
|
|
1020
|
+
*
|
|
1021
|
+
* @param the new alpha value.
|
|
1022
|
+
* @example <div>
|
|
1023
|
+
* <code>
|
|
1024
|
+
* function setup() {
|
|
1025
|
+
* createCanvas(100, 100);
|
|
1026
|
+
*
|
|
1027
|
+
* background(200);
|
|
1028
|
+
*
|
|
1029
|
+
* // Create a p5.Color object.
|
|
1030
|
+
* let c = color(255, 128, 128);
|
|
1031
|
+
*
|
|
1032
|
+
* // Draw the left rectangle.
|
|
1033
|
+
* noStroke();
|
|
1034
|
+
* fill(c);
|
|
1035
|
+
* rect(15, 20, 35, 60);
|
|
1036
|
+
*
|
|
1037
|
+
* // Change the alpha value.
|
|
1038
|
+
* c.setAlpha(128);
|
|
1039
|
+
*
|
|
1040
|
+
* // Draw the right rectangle.
|
|
1041
|
+
* fill(c);
|
|
1042
|
+
* rect(50, 20, 35, 60);
|
|
1043
|
+
*
|
|
1044
|
+
* describe('Two rectangles. The left one is salmon pink and the right one is faded pink.');
|
|
1045
|
+
* }
|
|
1046
|
+
* </code>
|
|
1047
|
+
* </div>
|
|
1048
|
+
*/
|
|
1049
|
+
function setAlpha(new_alpha: any, max: any, alpha: number): void;
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Hue is the same in HSB and HSL, but the maximum value may be different.
|
|
1053
|
+
* This function will return the HSB-normalized saturation when supplied with
|
|
1054
|
+
* an HSB color object, but will default to the HSL-normalized saturation
|
|
1055
|
+
* otherwise.
|
|
1056
|
+
*
|
|
1057
|
+
*/
|
|
1058
|
+
function _getHue(max: any): void;
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Saturation is scaled differently in HSB and HSL. This function will return
|
|
1062
|
+
* the HSB saturation when supplied with an HSB color object, but will default
|
|
1063
|
+
* to the HSL saturation otherwise.
|
|
1064
|
+
*
|
|
1065
|
+
*/
|
|
1066
|
+
function _getSaturation(max: any): void;
|
|
1067
|
+
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
export default function p5_Color(p5: any, fn: any): void;
|