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,2085 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Starts defining a shape that will mask any shapes drawn afterward.Any shapes drawn between `beginClip()` and
|
|
9
|
+
* endClip() will add to the mask shape. The mask
|
|
10
|
+
* will apply to anything drawn after endClip().The parameter, `options`, is optional. If an object with an `invert`
|
|
11
|
+
* property is passed, as in `beginClip({ invert: true })`, it will be used to
|
|
12
|
+
* set the masking mode. `{ invert: true }` inverts the mask, creating holes
|
|
13
|
+
* in shapes that are masked. `invert` is `false` by default.Masks can be contained between the
|
|
14
|
+
* push() and pop() functions.
|
|
15
|
+
* Doing so allows unmasked shapes to be drawn after masked shapes.Masks can also be defined in a callback function that's passed to
|
|
16
|
+
* clip().
|
|
17
|
+
*
|
|
18
|
+
* @param an object containing clip settings.
|
|
19
|
+
* @example <div>
|
|
20
|
+
* <code>
|
|
21
|
+
* function setup() {
|
|
22
|
+
* createCanvas(100, 100);
|
|
23
|
+
*
|
|
24
|
+
* background(200);
|
|
25
|
+
*
|
|
26
|
+
* // Create a mask.
|
|
27
|
+
* beginClip();
|
|
28
|
+
* triangle(15, 37, 30, 13, 43, 37);
|
|
29
|
+
* circle(45, 45, 7);
|
|
30
|
+
* endClip();
|
|
31
|
+
*
|
|
32
|
+
* // Draw a backing shape.
|
|
33
|
+
* square(5, 5, 45);
|
|
34
|
+
*
|
|
35
|
+
* describe('A white triangle and circle on a gray background.');
|
|
36
|
+
* }
|
|
37
|
+
* </code>
|
|
38
|
+
* </div>
|
|
39
|
+
* @example <div>
|
|
40
|
+
* <code>
|
|
41
|
+
* function setup() {
|
|
42
|
+
* createCanvas(100, 100);
|
|
43
|
+
*
|
|
44
|
+
* background(200);
|
|
45
|
+
*
|
|
46
|
+
* // Create an inverted mask.
|
|
47
|
+
* beginClip({ invert: true });
|
|
48
|
+
* triangle(15, 37, 30, 13, 43, 37);
|
|
49
|
+
* circle(45, 45, 7);
|
|
50
|
+
* endClip();
|
|
51
|
+
*
|
|
52
|
+
* // Draw a backing shape.
|
|
53
|
+
* square(5, 5, 45);
|
|
54
|
+
*
|
|
55
|
+
* describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.');
|
|
56
|
+
* }
|
|
57
|
+
* </code>
|
|
58
|
+
* </div>
|
|
59
|
+
*
|
|
60
|
+
* <div>
|
|
61
|
+
* <code>
|
|
62
|
+
* function setup() {
|
|
63
|
+
* createCanvas(100, 100);
|
|
64
|
+
*
|
|
65
|
+
* background(200);
|
|
66
|
+
*
|
|
67
|
+
* noStroke();
|
|
68
|
+
*
|
|
69
|
+
* // Draw a masked shape.
|
|
70
|
+
* push();
|
|
71
|
+
* // Create a mask.
|
|
72
|
+
* beginClip();
|
|
73
|
+
* triangle(15, 37, 30, 13, 43, 37);
|
|
74
|
+
* circle(45, 45, 7);
|
|
75
|
+
* endClip();
|
|
76
|
+
*
|
|
77
|
+
* // Draw a backing shape.
|
|
78
|
+
* square(5, 5, 45);
|
|
79
|
+
* pop();
|
|
80
|
+
*
|
|
81
|
+
* // Translate the origin to the center.
|
|
82
|
+
* translate(50, 50);
|
|
83
|
+
*
|
|
84
|
+
* // Draw an inverted masked shape.
|
|
85
|
+
* push();
|
|
86
|
+
* // Create an inverted mask.
|
|
87
|
+
* beginClip({ invert: true });
|
|
88
|
+
* triangle(15, 37, 30, 13, 43, 37);
|
|
89
|
+
* circle(45, 45, 7);
|
|
90
|
+
* endClip();
|
|
91
|
+
*
|
|
92
|
+
* // Draw a backing shape.
|
|
93
|
+
* square(5, 5, 45);
|
|
94
|
+
* pop();
|
|
95
|
+
*
|
|
96
|
+
* describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.');
|
|
97
|
+
* }
|
|
98
|
+
* </code>
|
|
99
|
+
* </div>
|
|
100
|
+
* @example <div>
|
|
101
|
+
* <code>
|
|
102
|
+
* function setup() {
|
|
103
|
+
* createCanvas(100, 100, WEBGL);
|
|
104
|
+
*
|
|
105
|
+
* describe('A silhouette of a rotating torus colored fuchsia.');
|
|
106
|
+
* }
|
|
107
|
+
*
|
|
108
|
+
* function draw() {
|
|
109
|
+
* background(200);
|
|
110
|
+
*
|
|
111
|
+
* // Create a mask.
|
|
112
|
+
* beginClip();
|
|
113
|
+
* push();
|
|
114
|
+
* rotateX(frameCount * 0.01);
|
|
115
|
+
* rotateY(frameCount * 0.01);
|
|
116
|
+
* scale(0.5);
|
|
117
|
+
* torus(30, 15);
|
|
118
|
+
* pop();
|
|
119
|
+
* endClip();
|
|
120
|
+
*
|
|
121
|
+
* // Draw a backing shape.
|
|
122
|
+
* noStroke();
|
|
123
|
+
* fill('fuchsia');
|
|
124
|
+
* plane(100);
|
|
125
|
+
* }
|
|
126
|
+
* </code>
|
|
127
|
+
* </div>
|
|
128
|
+
* @example <div>
|
|
129
|
+
* <code>
|
|
130
|
+
* function setup() {
|
|
131
|
+
* createCanvas(100, 100, WEBGL);
|
|
132
|
+
*
|
|
133
|
+
* describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.');
|
|
134
|
+
* }
|
|
135
|
+
*
|
|
136
|
+
* function draw() {
|
|
137
|
+
* background(200);
|
|
138
|
+
*
|
|
139
|
+
* // Create a mask.
|
|
140
|
+
* beginClip();
|
|
141
|
+
* push();
|
|
142
|
+
* rotateX(frameCount * 0.01);
|
|
143
|
+
* rotateY(frameCount * 0.01);
|
|
144
|
+
* scale(0.5);
|
|
145
|
+
* torus(30, 15);
|
|
146
|
+
* pop();
|
|
147
|
+
* endClip();
|
|
148
|
+
*
|
|
149
|
+
* // Draw a backing shape.
|
|
150
|
+
* noStroke();
|
|
151
|
+
* beginShape(QUAD_STRIP);
|
|
152
|
+
* fill(0, 255, 255);
|
|
153
|
+
* vertex(-width / 2, -height / 2);
|
|
154
|
+
* vertex(width / 2, -height / 2);
|
|
155
|
+
* fill(100, 0, 100);
|
|
156
|
+
* vertex(-width / 2, height / 2);
|
|
157
|
+
* vertex(width / 2, height / 2);
|
|
158
|
+
* endShape();
|
|
159
|
+
* }
|
|
160
|
+
* </code>
|
|
161
|
+
* </div>
|
|
162
|
+
*/
|
|
163
|
+
function beginClip(options?: object): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Ends defining a mask that was started with
|
|
167
|
+
* beginClip().
|
|
168
|
+
*
|
|
169
|
+
* @example <div>
|
|
170
|
+
* <code>
|
|
171
|
+
* function setup() {
|
|
172
|
+
* createCanvas(100, 100);
|
|
173
|
+
*
|
|
174
|
+
* background(200);
|
|
175
|
+
*
|
|
176
|
+
* // Create a mask.
|
|
177
|
+
* beginClip();
|
|
178
|
+
* triangle(15, 37, 30, 13, 43, 37);
|
|
179
|
+
* circle(45, 45, 7);
|
|
180
|
+
* endClip();
|
|
181
|
+
*
|
|
182
|
+
* // Draw a backing shape.
|
|
183
|
+
* square(5, 5, 45);
|
|
184
|
+
*
|
|
185
|
+
* describe('A white triangle and circle on a gray background.');
|
|
186
|
+
* }
|
|
187
|
+
* </code>
|
|
188
|
+
* </div>
|
|
189
|
+
*/
|
|
190
|
+
function endClip(): void;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Defines a shape that will mask any shapes drawn afterward.The first parameter, `callback`, is a function that defines the mask.
|
|
194
|
+
* Any shapes drawn in `callback` will add to the mask shape. The mask
|
|
195
|
+
* will apply to anything drawn after `clip()` is called.The second parameter, `options`, is optional. If an object with an `invert`
|
|
196
|
+
* property is passed, as in `beginClip({ invert: true })`, it will be used to
|
|
197
|
+
* set the masking mode. `{ invert: true }` inverts the mask, creating holes
|
|
198
|
+
* in shapes that are masked. `invert` is `false` by default.Masks can be contained between the
|
|
199
|
+
* push() and pop() functions.
|
|
200
|
+
* Doing so allows unmasked shapes to be drawn after masked shapes.Masks can also be defined with beginClip()
|
|
201
|
+
* and endClip().
|
|
202
|
+
*
|
|
203
|
+
* @param a function that draws the mask shape.
|
|
204
|
+
* @param an object containing clip settings.
|
|
205
|
+
* @example <div>
|
|
206
|
+
* <code>
|
|
207
|
+
* function setup() {
|
|
208
|
+
* createCanvas(100, 100);
|
|
209
|
+
*
|
|
210
|
+
* background(200);
|
|
211
|
+
*
|
|
212
|
+
* // Create a mask.
|
|
213
|
+
* clip(mask);
|
|
214
|
+
*
|
|
215
|
+
* // Draw a backing shape.
|
|
216
|
+
* square(5, 5, 45);
|
|
217
|
+
*
|
|
218
|
+
* describe('A white triangle and circle on a gray background.');
|
|
219
|
+
* }
|
|
220
|
+
*
|
|
221
|
+
* // Declare a function that defines the mask.
|
|
222
|
+
* function mask() {
|
|
223
|
+
* triangle(15, 37, 30, 13, 43, 37);
|
|
224
|
+
* circle(45, 45, 7);
|
|
225
|
+
* }
|
|
226
|
+
* </code>
|
|
227
|
+
* </div>
|
|
228
|
+
* @example <div>
|
|
229
|
+
* <code>
|
|
230
|
+
* function setup() {
|
|
231
|
+
* createCanvas(100, 100);
|
|
232
|
+
*
|
|
233
|
+
* background(200);
|
|
234
|
+
*
|
|
235
|
+
* // Create an inverted mask.
|
|
236
|
+
* clip(mask, { invert: true });
|
|
237
|
+
*
|
|
238
|
+
* // Draw a backing shape.
|
|
239
|
+
* square(5, 5, 45);
|
|
240
|
+
*
|
|
241
|
+
* describe('A white square at the top-left corner of a gray square. The white square has a triangle and a circle cut out of it.');
|
|
242
|
+
* }
|
|
243
|
+
*
|
|
244
|
+
* // Declare a function that defines the mask.
|
|
245
|
+
* function mask() {
|
|
246
|
+
* triangle(15, 37, 30, 13, 43, 37);
|
|
247
|
+
* circle(45, 45, 7);
|
|
248
|
+
* }
|
|
249
|
+
* </code>
|
|
250
|
+
* </div>
|
|
251
|
+
*
|
|
252
|
+
* <div>
|
|
253
|
+
* <code>
|
|
254
|
+
* function setup() {
|
|
255
|
+
* createCanvas(100, 100);
|
|
256
|
+
*
|
|
257
|
+
* background(200);
|
|
258
|
+
*
|
|
259
|
+
* noStroke();
|
|
260
|
+
*
|
|
261
|
+
* // Draw a masked shape.
|
|
262
|
+
* push();
|
|
263
|
+
* // Create a mask.
|
|
264
|
+
* clip(mask);
|
|
265
|
+
*
|
|
266
|
+
* // Draw a backing shape.
|
|
267
|
+
* square(5, 5, 45);
|
|
268
|
+
* pop();
|
|
269
|
+
*
|
|
270
|
+
* // Translate the origin to the center.
|
|
271
|
+
* translate(50, 50);
|
|
272
|
+
*
|
|
273
|
+
* // Draw an inverted masked shape.
|
|
274
|
+
* push();
|
|
275
|
+
* // Create an inverted mask.
|
|
276
|
+
* clip(mask, { invert: true });
|
|
277
|
+
*
|
|
278
|
+
* // Draw a backing shape.
|
|
279
|
+
* square(5, 5, 45);
|
|
280
|
+
* pop();
|
|
281
|
+
*
|
|
282
|
+
* describe('In the top left, a white triangle and circle. In the bottom right, a white square with a triangle and circle cut out of it.');
|
|
283
|
+
* }
|
|
284
|
+
*
|
|
285
|
+
* // Declare a function that defines the mask.
|
|
286
|
+
* function mask() {
|
|
287
|
+
* triangle(15, 37, 30, 13, 43, 37);
|
|
288
|
+
* circle(45, 45, 7);
|
|
289
|
+
* }
|
|
290
|
+
* </code>
|
|
291
|
+
* </div>
|
|
292
|
+
* @example <div>
|
|
293
|
+
* <code>
|
|
294
|
+
* function setup() {
|
|
295
|
+
* createCanvas(100, 100, WEBGL);
|
|
296
|
+
*
|
|
297
|
+
* describe('A silhouette of a rotating torus colored fuchsia.');
|
|
298
|
+
* }
|
|
299
|
+
*
|
|
300
|
+
* function draw() {
|
|
301
|
+
* background(200);
|
|
302
|
+
*
|
|
303
|
+
* // Create a mask.
|
|
304
|
+
* clip(mask);
|
|
305
|
+
*
|
|
306
|
+
* // Draw a backing shape.
|
|
307
|
+
* noStroke();
|
|
308
|
+
* fill('fuchsia');
|
|
309
|
+
* plane(100);
|
|
310
|
+
* }
|
|
311
|
+
*
|
|
312
|
+
* // Declare a function that defines the mask.
|
|
313
|
+
* function mask() {
|
|
314
|
+
* push();
|
|
315
|
+
* rotateX(frameCount * 0.01);
|
|
316
|
+
* rotateY(frameCount * 0.01);
|
|
317
|
+
* scale(0.5);
|
|
318
|
+
* torus(30, 15);
|
|
319
|
+
* pop();
|
|
320
|
+
* }
|
|
321
|
+
* </code>
|
|
322
|
+
* </div>
|
|
323
|
+
* @example <div>
|
|
324
|
+
* <code>
|
|
325
|
+
* function setup() {
|
|
326
|
+
* createCanvas(100, 100, WEBGL);
|
|
327
|
+
*
|
|
328
|
+
* describe('A silhouette of a rotating torus colored with a gradient from cyan to purple.');
|
|
329
|
+
* }
|
|
330
|
+
*
|
|
331
|
+
* function draw() {
|
|
332
|
+
* background(200);
|
|
333
|
+
*
|
|
334
|
+
* // Create a mask.
|
|
335
|
+
* clip(mask);
|
|
336
|
+
*
|
|
337
|
+
* // Draw a backing shape.
|
|
338
|
+
* noStroke();
|
|
339
|
+
* beginShape(QUAD_STRIP);
|
|
340
|
+
* fill(0, 255, 255);
|
|
341
|
+
* vertex(-width / 2, -height / 2);
|
|
342
|
+
* vertex(width / 2, -height / 2);
|
|
343
|
+
* fill(100, 0, 100);
|
|
344
|
+
* vertex(-width / 2, height / 2);
|
|
345
|
+
* vertex(width / 2, height / 2);
|
|
346
|
+
* endShape();
|
|
347
|
+
* }
|
|
348
|
+
*
|
|
349
|
+
* // Declare a function that defines the mask.
|
|
350
|
+
* function mask() {
|
|
351
|
+
* push();
|
|
352
|
+
* rotateX(frameCount * 0.01);
|
|
353
|
+
* rotateY(frameCount * 0.01);
|
|
354
|
+
* scale(0.5);
|
|
355
|
+
* torus(30, 15);
|
|
356
|
+
* pop();
|
|
357
|
+
* }
|
|
358
|
+
* </code>
|
|
359
|
+
* </div>
|
|
360
|
+
*/
|
|
361
|
+
function clip(callback: Function, options?: object): void;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Sets the color used for the background of the canvas.By default, the background is transparent. `background()` is typically used
|
|
365
|
+
* within draw() to clear the display window at the
|
|
366
|
+
* beginning of each frame. It can also be used inside
|
|
367
|
+
* setup() to set the background on the first frame
|
|
368
|
+
* of animation.The version of `background()` with one parameter interprets the value one
|
|
369
|
+
* of four ways. If the parameter is a `Number`, it's interpreted as a grayscale
|
|
370
|
+
* value. If the parameter is a `String`, it's interpreted as a CSS color string.
|
|
371
|
+
* RGB, RGBA, HSL, HSLA, hex, and named color strings are supported. If the
|
|
372
|
+
* parameter is a p5.Color object, it will be used as
|
|
373
|
+
* the background color. If the parameter is a
|
|
374
|
+
* p5.Image object, it will be used as the background
|
|
375
|
+
* image.The version of `background()` with two parameters interprets the first one
|
|
376
|
+
* as a grayscale value. The second parameter sets the alpha (transparency)
|
|
377
|
+
* value.The version of `background()` with three parameters interprets them as RGB,
|
|
378
|
+
* HSB, or HSL colors, depending on the current
|
|
379
|
+
* colorMode(). By default, colors are specified
|
|
380
|
+
* in RGB values. Calling `background(255, 204, 0)` sets the background a bright
|
|
381
|
+
* yellow color.
|
|
382
|
+
*
|
|
383
|
+
* @param any value created by the <a href="#/p5/color">color()</a> function
|
|
384
|
+
* @example <div>
|
|
385
|
+
* <code>
|
|
386
|
+
* function setup() {
|
|
387
|
+
* createCanvas(100, 100);
|
|
388
|
+
*
|
|
389
|
+
* // A grayscale value.
|
|
390
|
+
* background(51);
|
|
391
|
+
*
|
|
392
|
+
* describe('A canvas with a dark charcoal gray background.');
|
|
393
|
+
* }
|
|
394
|
+
* </code>
|
|
395
|
+
* </div>
|
|
396
|
+
*
|
|
397
|
+
* <div>
|
|
398
|
+
* <code>
|
|
399
|
+
* function setup() {
|
|
400
|
+
* createCanvas(100, 100);
|
|
401
|
+
*
|
|
402
|
+
* // A grayscale value and an alpha value.
|
|
403
|
+
* background(51, 0.4);
|
|
404
|
+
* describe('A canvas with a transparent gray background.');
|
|
405
|
+
* }
|
|
406
|
+
* </code>
|
|
407
|
+
* </div>
|
|
408
|
+
*
|
|
409
|
+
* <div>
|
|
410
|
+
* <code>
|
|
411
|
+
* function setup() {
|
|
412
|
+
* createCanvas(100, 100);
|
|
413
|
+
*
|
|
414
|
+
* // R, G & B values.
|
|
415
|
+
* background(255, 204, 0);
|
|
416
|
+
*
|
|
417
|
+
* describe('A canvas with a yellow background.');
|
|
418
|
+
* }
|
|
419
|
+
* </code>
|
|
420
|
+
* </div>
|
|
421
|
+
*
|
|
422
|
+
* <div>
|
|
423
|
+
* <code>
|
|
424
|
+
* function setup() {
|
|
425
|
+
* createCanvas(100, 100);
|
|
426
|
+
*
|
|
427
|
+
* // Use HSB color.
|
|
428
|
+
* colorMode(HSB);
|
|
429
|
+
*
|
|
430
|
+
* // H, S & B values.
|
|
431
|
+
* background(255, 204, 100);
|
|
432
|
+
*
|
|
433
|
+
* describe('A canvas with a royal blue background.');
|
|
434
|
+
* }
|
|
435
|
+
* </code>
|
|
436
|
+
* </div>
|
|
437
|
+
*
|
|
438
|
+
* <div>
|
|
439
|
+
* <code>
|
|
440
|
+
* function setup() {
|
|
441
|
+
* createCanvas(100, 100);
|
|
442
|
+
*
|
|
443
|
+
* // A CSS named color.
|
|
444
|
+
* background('red');
|
|
445
|
+
*
|
|
446
|
+
* describe('A canvas with a red background.');
|
|
447
|
+
* }
|
|
448
|
+
* </code>
|
|
449
|
+
* </div>
|
|
450
|
+
*
|
|
451
|
+
* <div>
|
|
452
|
+
* <code>
|
|
453
|
+
* function setup() {
|
|
454
|
+
* createCanvas(100, 100);
|
|
455
|
+
*
|
|
456
|
+
* // Three-digit hex RGB notation.
|
|
457
|
+
* background('#fae');
|
|
458
|
+
*
|
|
459
|
+
* describe('A canvas with a pink background.');
|
|
460
|
+
* }
|
|
461
|
+
* </code>
|
|
462
|
+
* </div>
|
|
463
|
+
*
|
|
464
|
+
* <div>
|
|
465
|
+
* <code>
|
|
466
|
+
* function setup() {
|
|
467
|
+
* createCanvas(100, 100);
|
|
468
|
+
*
|
|
469
|
+
* // Six-digit hex RGB notation.
|
|
470
|
+
* background('#222222');
|
|
471
|
+
*
|
|
472
|
+
* describe('A canvas with a black background.');
|
|
473
|
+
* }
|
|
474
|
+
* </code>
|
|
475
|
+
* </div>
|
|
476
|
+
*
|
|
477
|
+
* <div>
|
|
478
|
+
* <code>
|
|
479
|
+
* function setup() {
|
|
480
|
+
* createCanvas(100, 100);
|
|
481
|
+
*
|
|
482
|
+
* // Integer RGB notation.
|
|
483
|
+
* background('rgb(0, 255, 0)');
|
|
484
|
+
*
|
|
485
|
+
* describe('A canvas with a bright green background.');
|
|
486
|
+
* }
|
|
487
|
+
* </code>
|
|
488
|
+
* </div>
|
|
489
|
+
*
|
|
490
|
+
* <div>
|
|
491
|
+
* <code>
|
|
492
|
+
* function setup() {
|
|
493
|
+
* createCanvas(100, 100);
|
|
494
|
+
*
|
|
495
|
+
* // Integer RGBA notation.
|
|
496
|
+
* background('rgba(0, 255, 0, 0.25)');
|
|
497
|
+
*
|
|
498
|
+
* describe('A canvas with a transparent green background.');
|
|
499
|
+
* }
|
|
500
|
+
* </code>
|
|
501
|
+
* </div>
|
|
502
|
+
*
|
|
503
|
+
* <div>
|
|
504
|
+
* <code>
|
|
505
|
+
* function setup() {
|
|
506
|
+
* createCanvas(100, 100);
|
|
507
|
+
*
|
|
508
|
+
* // Percentage RGB notation.
|
|
509
|
+
* background('rgb(100%, 0%, 10%)');
|
|
510
|
+
*
|
|
511
|
+
* describe('A canvas with a red background.');
|
|
512
|
+
* }
|
|
513
|
+
* </code>
|
|
514
|
+
* </div>
|
|
515
|
+
*
|
|
516
|
+
* <div>
|
|
517
|
+
* <code>
|
|
518
|
+
* function setup() {
|
|
519
|
+
* createCanvas(100, 100);
|
|
520
|
+
*
|
|
521
|
+
* // Percentage RGBA notation.
|
|
522
|
+
* background('rgba(100%, 0%, 100%, 0.5)');
|
|
523
|
+
*
|
|
524
|
+
* describe('A canvas with a transparent purple background.');
|
|
525
|
+
* }
|
|
526
|
+
* </code>
|
|
527
|
+
* </div>
|
|
528
|
+
*
|
|
529
|
+
* <div>
|
|
530
|
+
* <code>
|
|
531
|
+
* function setup() {
|
|
532
|
+
* createCanvas(100, 100);
|
|
533
|
+
*
|
|
534
|
+
* // A p5.Color object.
|
|
535
|
+
* let c = color(0, 0, 255);
|
|
536
|
+
* background(c);
|
|
537
|
+
*
|
|
538
|
+
* describe('A canvas with a blue background.');
|
|
539
|
+
* }
|
|
540
|
+
* </code>
|
|
541
|
+
* </div>
|
|
542
|
+
*/
|
|
543
|
+
function background(color: p5.Color): void;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* @param color string, possible formats include: integer
|
|
547
|
+
* rgb() or rgba(), percentage rgb() or rgba(),
|
|
548
|
+
* 3-digit hex, 6-digit hex.
|
|
549
|
+
* @param opacity of the background relative to current
|
|
550
|
+
* color range (default is 0-255).
|
|
551
|
+
*/
|
|
552
|
+
function background(colorstring: string, a?: number): void;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* @param specifies a value between white and black.
|
|
556
|
+
*/
|
|
557
|
+
function background(gray: number, a?: number): void;
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* @param red value if color mode is RGB, or hue value if color mode is HSB.
|
|
561
|
+
* @param green value if color mode is RGB, or saturation value if color mode is HSB.
|
|
562
|
+
* @param blue value if color mode is RGB, or brightness value if color mode is HSB.
|
|
563
|
+
*/
|
|
564
|
+
function background(v1: number, v2: number, v3: number, a?: number): void;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* @param an array containing the red, green, blue
|
|
568
|
+
* and alpha components of the color.
|
|
569
|
+
*/
|
|
570
|
+
function background(values: number[]): void;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* @param image created with <a href="#/p5/loadImage">loadImage()</a>
|
|
574
|
+
* or <a href="#/p5/createImage">createImage()</a>,
|
|
575
|
+
* to set as background.
|
|
576
|
+
* (must be same size as the sketch window).
|
|
577
|
+
*/
|
|
578
|
+
function background(image: p5.Image, a?: number): void;
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Clears the pixels on the canvas.`clear()` makes every pixel 100% transparent. Calling `clear()` doesn't
|
|
582
|
+
* clear objects created by `createX()` functions such as
|
|
583
|
+
* createGraphics(),
|
|
584
|
+
* createVideo(), and
|
|
585
|
+
* createImg(). These objects will remain
|
|
586
|
+
* unchanged after calling `clear()` and can be redrawn.In WebGL mode, this function can clear the screen to a specific color. It
|
|
587
|
+
* interprets four numeric parameters as normalized RGBA color values. It also
|
|
588
|
+
* clears the depth buffer. If you are not using the WebGL renderer, these
|
|
589
|
+
* parameters will have no effect.
|
|
590
|
+
*
|
|
591
|
+
* @example <div>
|
|
592
|
+
* <code>
|
|
593
|
+
* function setup() {
|
|
594
|
+
* createCanvas(100, 100);
|
|
595
|
+
*
|
|
596
|
+
* background(200);
|
|
597
|
+
*
|
|
598
|
+
* describe('A gray square. White circles are drawn as the user moves the mouse. The circles disappear when the user presses the mouse.');
|
|
599
|
+
* }
|
|
600
|
+
*
|
|
601
|
+
* function draw() {
|
|
602
|
+
* circle(mouseX, mouseY, 20);
|
|
603
|
+
* }
|
|
604
|
+
*
|
|
605
|
+
* function mousePressed() {
|
|
606
|
+
* clear();
|
|
607
|
+
* background(200);
|
|
608
|
+
* }
|
|
609
|
+
* </code>
|
|
610
|
+
* </div>
|
|
611
|
+
*
|
|
612
|
+
* <div>
|
|
613
|
+
* <code>
|
|
614
|
+
* let pg;
|
|
615
|
+
*
|
|
616
|
+
* function setup() {
|
|
617
|
+
* createCanvas(100, 100);
|
|
618
|
+
* background(200);
|
|
619
|
+
*
|
|
620
|
+
* pg = createGraphics(60, 60);
|
|
621
|
+
* pg.background(200);
|
|
622
|
+
* pg.noStroke();
|
|
623
|
+
* pg.circle(pg.width / 2, pg.height / 2, 15);
|
|
624
|
+
* image(pg, 20, 20);
|
|
625
|
+
*
|
|
626
|
+
* describe('A white circle drawn on a gray square. The square gets smaller when the mouse is pressed.');
|
|
627
|
+
* }
|
|
628
|
+
*
|
|
629
|
+
* function mousePressed() {
|
|
630
|
+
* clear();
|
|
631
|
+
* image(pg, 20, 20);
|
|
632
|
+
* }
|
|
633
|
+
* </code>
|
|
634
|
+
* </div>
|
|
635
|
+
* @param normalized red value.
|
|
636
|
+
* @param normalized green value.
|
|
637
|
+
* @param normalized blue value.
|
|
638
|
+
* @param normalized alpha value.
|
|
639
|
+
*/
|
|
640
|
+
function clear(r?: number, g?: number, b?: number, a?: number): void;
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Changes the way color values are interpreted.By default, the `Number` parameters for fill(),
|
|
644
|
+
* stroke(),
|
|
645
|
+
* background(), and
|
|
646
|
+
* color() are defined by values between 0 and 255
|
|
647
|
+
* using the RGB color model. This is equivalent to calling
|
|
648
|
+
* `colorMode(RGB, 255)`. Pure red is `color(255, 0, 0)` in this model.Calling `colorMode(RGB, 100)` sets colors to use RGB color values
|
|
649
|
+
* between 0 and 100. Pure red is `color(100, 0, 0)` in this model.Calling `colorMode(HSB)` or `colorMode(HSL)` changes to HSB or HSL systems instead of RGB.
|
|
650
|
+
* Pure red is `color(0, 100, 100)` in HSB and `color(0, 100, 50)` in HSL.Some additional color modes that p5.js supports are:`RGBHDR` - High Dynamic Range RGB defined within the Display P3 color space.
|
|
651
|
+
* Colors are expressed with an extended dynamic range. To render these colors
|
|
652
|
+
* accurately, you must use the HDR canvas.`HWB` - Hue, Whiteness, Blackness.
|
|
653
|
+
* Similar to HSB and HSL, this mode uses a hue angle.
|
|
654
|
+
* Instead of saturation and lightness, HWB defines colors based on the percentage
|
|
655
|
+
* of whiteness and blackness. This is the color model used by Chrome's GUI color picker.
|
|
656
|
+
* Pure red in HWB is represented as `color(0, 0, 0)` (i.e., hue 0 with 0% whiteness and 0% blackness).` <img src="assets/hwb.png"></img>``LAB` - Also known as CIE Lab, this color mode defines colors with Lightness, Alpha, and Beta.
|
|
657
|
+
* It is widely used in professional color measurement contexts due to its perceptual uniformity.`LCH` - A more intuitive representation of the CIE Lab color space using Lightness, Chroma, and Hue.
|
|
658
|
+
* This mode separates the color's chromatic intensity (chroma) from its lightness,
|
|
659
|
+
* simplifying color selection and manipulation.`OKLAB` - A variant of the CIE Lab color space that corrects for non-uniformities inherent in LAB.
|
|
660
|
+
* The adjustment provides a more perceptually accurate and uniform representation,
|
|
661
|
+
* which is particularly beneficial for smooth color transitions.`OKLCH` - An easier-to-use representation of OKLAB, expressing colors in terms of Lightness, Chroma, and Hue.
|
|
662
|
+
* This mode retains the perceptual benefits of OKLAB while offering a more intuitive format for color manipulation.p5.Color objects remember the mode that they were
|
|
663
|
+
* created in. Changing modes doesn't affect their appearance.`Single-value (Grayscale) Colors`:When a color is specified with only one parameter (e.g., `color(g)`), p5.js will interpret it
|
|
664
|
+
* as a grayscale color. However, how that single parameter translates into a grayscale value
|
|
665
|
+
* depends on the color mode:
|
|
666
|
+
*
|
|
667
|
+
* @param either RGB, HSB, HSL,
|
|
668
|
+
* or one of the extended modes described above.
|
|
669
|
+
* @param range for all values.
|
|
670
|
+
* @example <div>
|
|
671
|
+
* <code>
|
|
672
|
+
* function setup() {
|
|
673
|
+
* createCanvas(100, 100);
|
|
674
|
+
*
|
|
675
|
+
* background(200);
|
|
676
|
+
*
|
|
677
|
+
* // Fill with pure red.
|
|
678
|
+
* fill(255, 0, 0);
|
|
679
|
+
*
|
|
680
|
+
* circle(50, 50, 25);
|
|
681
|
+
*
|
|
682
|
+
* describe('A gray square with a red circle at its center.');
|
|
683
|
+
* }
|
|
684
|
+
* </code>
|
|
685
|
+
* </div>
|
|
686
|
+
* @example <div>
|
|
687
|
+
* <code>
|
|
688
|
+
* function setup() {
|
|
689
|
+
* createCanvas(100, 100);
|
|
690
|
+
*
|
|
691
|
+
* background(200);
|
|
692
|
+
*
|
|
693
|
+
* // Use RGB color with values in the range 0-100.
|
|
694
|
+
* colorMode(RGB, 100);
|
|
695
|
+
*
|
|
696
|
+
* // Fill with pure red.
|
|
697
|
+
* fill(100, 0, 0);
|
|
698
|
+
*
|
|
699
|
+
* circle(50, 50, 25);
|
|
700
|
+
*
|
|
701
|
+
* describe('A gray square with a red circle at its center.');
|
|
702
|
+
* }
|
|
703
|
+
* </code>
|
|
704
|
+
* </div>
|
|
705
|
+
* @example <div>
|
|
706
|
+
* <code>
|
|
707
|
+
* function setup() {
|
|
708
|
+
* createCanvas(100, 100);
|
|
709
|
+
*
|
|
710
|
+
* background(200);
|
|
711
|
+
*
|
|
712
|
+
* // Use HSB color.
|
|
713
|
+
* colorMode(HSB);
|
|
714
|
+
*
|
|
715
|
+
* // Fill with pure red.
|
|
716
|
+
* fill(0, 100, 100);
|
|
717
|
+
*
|
|
718
|
+
* circle(50, 50, 25);
|
|
719
|
+
*
|
|
720
|
+
* describe('A gray square with a red circle at its center.');
|
|
721
|
+
* }
|
|
722
|
+
* </code>
|
|
723
|
+
* </div>
|
|
724
|
+
* @example <div>
|
|
725
|
+
* <code>
|
|
726
|
+
* function setup() {
|
|
727
|
+
* createCanvas(100, 100);
|
|
728
|
+
*
|
|
729
|
+
* background(200);
|
|
730
|
+
*
|
|
731
|
+
* // Use HSL color.
|
|
732
|
+
* colorMode(HSL);
|
|
733
|
+
*
|
|
734
|
+
* // Fill with pure red.
|
|
735
|
+
* fill(0, 100, 50);
|
|
736
|
+
*
|
|
737
|
+
* circle(50, 50, 25);
|
|
738
|
+
*
|
|
739
|
+
* describe('A gray square with a red circle at its center.');
|
|
740
|
+
* }
|
|
741
|
+
* </code>
|
|
742
|
+
* </div>
|
|
743
|
+
* @example <div>
|
|
744
|
+
* <code>
|
|
745
|
+
* function setup() {
|
|
746
|
+
* createCanvas(100, 100);
|
|
747
|
+
*
|
|
748
|
+
* // Draw a neutral gray background using the default color mode.
|
|
749
|
+
* background(200);
|
|
750
|
+
*
|
|
751
|
+
* // Switch to HWB color mode.
|
|
752
|
+
* // (Assuming p5.js supports HWB with a range of:
|
|
753
|
+
* // hue: 0–360, whiteness: 0–100, blackness: 0–100.)
|
|
754
|
+
* colorMode(HWB);
|
|
755
|
+
*
|
|
756
|
+
* // Set fill to pure red in HWB.
|
|
757
|
+
* // Pure red in HWB is: hue = 0°, whiteness = 0%, blackness = 0%.
|
|
758
|
+
* fill(0, 0, 0);
|
|
759
|
+
*
|
|
760
|
+
* // Draw a circle at the center.
|
|
761
|
+
* circle(50, 50, 25);
|
|
762
|
+
*
|
|
763
|
+
* describe('A gray square with a red circle at its center, drawn using HWB color mode.');
|
|
764
|
+
* }
|
|
765
|
+
* </code>
|
|
766
|
+
* </div>
|
|
767
|
+
* @example <div>
|
|
768
|
+
* <code>
|
|
769
|
+
* function setup() {
|
|
770
|
+
* createCanvas(100, 100);
|
|
771
|
+
*
|
|
772
|
+
* // Draw a neutral gray background using the default color mode.
|
|
773
|
+
* background(200);
|
|
774
|
+
*
|
|
775
|
+
* // Switch to LAB color mode.
|
|
776
|
+
* // In this mode, L typically ranges from 0 to 100 while a and b span roughly -128 to 127.
|
|
777
|
+
* colorMode(LAB);
|
|
778
|
+
*
|
|
779
|
+
* // Set fill to pure red in LAB.
|
|
780
|
+
* // The sRGB red (255, 0, 0) converts approximately to LAB as:
|
|
781
|
+
* // L = 53, a = 80, b = 67.
|
|
782
|
+
* fill(53, 80, 67);
|
|
783
|
+
*
|
|
784
|
+
* // Draw a circle at the center.
|
|
785
|
+
* circle(50, 50, 25);
|
|
786
|
+
*
|
|
787
|
+
* describe('A gray square with a red circle at its center, drawn using LAB color mode.');
|
|
788
|
+
* }
|
|
789
|
+
* </code>
|
|
790
|
+
* </div>
|
|
791
|
+
* @example <div>
|
|
792
|
+
* <code>
|
|
793
|
+
* function setup() {
|
|
794
|
+
* createCanvas(100, 100);
|
|
795
|
+
*
|
|
796
|
+
* // Draw a neutral gray background.
|
|
797
|
+
* background(200);
|
|
798
|
+
*
|
|
799
|
+
* // Switch to LCH color mode.
|
|
800
|
+
* // In LCH, colors are defined by Lightness, Chroma, and Hue (in degrees).
|
|
801
|
+
* colorMode(LCH);
|
|
802
|
+
*
|
|
803
|
+
* // Set fill to an approximation of pure red in LCH:
|
|
804
|
+
* // Lightness ≈ 53, Chroma ≈ 104, Hue ≈ 40°.
|
|
805
|
+
* fill(53, 104, 40);
|
|
806
|
+
*
|
|
807
|
+
* // Draw a circle at the center.
|
|
808
|
+
* circle(50, 50, 25);
|
|
809
|
+
*
|
|
810
|
+
* describe('A gray square with a red circle at its center, drawn using LCH color mode.');
|
|
811
|
+
* }
|
|
812
|
+
* </code>
|
|
813
|
+
* </div>
|
|
814
|
+
* @example <div>
|
|
815
|
+
* <code>
|
|
816
|
+
* function setup() {
|
|
817
|
+
* createCanvas(100, 100);
|
|
818
|
+
*
|
|
819
|
+
* // Use RGB color with values in the range 0-100.
|
|
820
|
+
* colorMode(RGB, 100);
|
|
821
|
+
*
|
|
822
|
+
* for (let x = 0; x < 100; x += 1) {
|
|
823
|
+
* for (let y = 0; y < 100; y += 1) {
|
|
824
|
+
* stroke(x, y, 0);
|
|
825
|
+
* point(x, y);
|
|
826
|
+
* }
|
|
827
|
+
* }
|
|
828
|
+
*
|
|
829
|
+
* describe(
|
|
830
|
+
* 'A diagonal green to red gradient from bottom-left to top-right with shading transitioning to black at top-left corner.'
|
|
831
|
+
* );
|
|
832
|
+
* }
|
|
833
|
+
* </code>
|
|
834
|
+
* </div>
|
|
835
|
+
*
|
|
836
|
+
* <div>
|
|
837
|
+
* <code>
|
|
838
|
+
* function setup() {
|
|
839
|
+
* createCanvas(100, 100);
|
|
840
|
+
*
|
|
841
|
+
* // Use HSB color with values in the range 0-100.
|
|
842
|
+
* colorMode(HSB, 100);
|
|
843
|
+
*
|
|
844
|
+
* for (let x = 0; x < 100; x += 1) {
|
|
845
|
+
* for (let y = 0; y < 100; y += 1) {
|
|
846
|
+
* stroke(x, y, 100);
|
|
847
|
+
* point(x, y);
|
|
848
|
+
* }
|
|
849
|
+
* }
|
|
850
|
+
*
|
|
851
|
+
* describe('A rainbow gradient from left-to-right. Brightness transitions to white at the top.');
|
|
852
|
+
* }
|
|
853
|
+
* </code>
|
|
854
|
+
* </div>
|
|
855
|
+
*
|
|
856
|
+
* <div>
|
|
857
|
+
* <code>
|
|
858
|
+
* function setup() {
|
|
859
|
+
* createCanvas(100, 100);
|
|
860
|
+
*
|
|
861
|
+
* // Create a p5.Color object.
|
|
862
|
+
* let myColor = color(180, 175, 230);
|
|
863
|
+
* background(myColor);
|
|
864
|
+
*
|
|
865
|
+
* // Use RGB color with values in the range 0-1.
|
|
866
|
+
* colorMode(RGB, 1);
|
|
867
|
+
*
|
|
868
|
+
* // Get the red, green, and blue color components.
|
|
869
|
+
* let redValue = red(myColor);
|
|
870
|
+
* let greenValue = green(myColor);
|
|
871
|
+
* let blueValue = blue(myColor);
|
|
872
|
+
*
|
|
873
|
+
* // Round the color components for display.
|
|
874
|
+
* redValue = round(redValue, 2);
|
|
875
|
+
* greenValue = round(greenValue, 2);
|
|
876
|
+
* blueValue = round(blueValue, 2);
|
|
877
|
+
*
|
|
878
|
+
* // Display the color components.
|
|
879
|
+
* text(`Red: ${redValue}`, 10, 10, 80, 80);
|
|
880
|
+
* text(`Green: ${greenValue}`, 10, 40, 80, 80);
|
|
881
|
+
* text(`Blue: ${blueValue}`, 10, 70, 80, 80);
|
|
882
|
+
*
|
|
883
|
+
* describe('A purple canvas with the red, green, and blue decimal values of the color written on it.');
|
|
884
|
+
* }
|
|
885
|
+
* </code>
|
|
886
|
+
* </div>
|
|
887
|
+
*
|
|
888
|
+
* <div>
|
|
889
|
+
* <code>
|
|
890
|
+
* function setup() {
|
|
891
|
+
* createCanvas(100, 100);
|
|
892
|
+
*
|
|
893
|
+
* background(255);
|
|
894
|
+
*
|
|
895
|
+
* // Use RGB color with alpha values in the range 0-1.
|
|
896
|
+
* colorMode(RGB, 255, 255, 255, 1);
|
|
897
|
+
*
|
|
898
|
+
* noFill();
|
|
899
|
+
* strokeWeight(4);
|
|
900
|
+
* stroke(255, 0, 10, 0.3);
|
|
901
|
+
* circle(40, 40, 50);
|
|
902
|
+
* circle(50, 60, 50);
|
|
903
|
+
*
|
|
904
|
+
* describe('Two overlapping translucent pink circle outlines.');
|
|
905
|
+
* }
|
|
906
|
+
* </code>
|
|
907
|
+
* </div>
|
|
908
|
+
* @example <div>
|
|
909
|
+
* <code>
|
|
910
|
+
* let hslGraphic, lchGraphic, oklchGraphic;
|
|
911
|
+
*
|
|
912
|
+
* function setup() {
|
|
913
|
+
* createCanvas(600, 200);
|
|
914
|
+
* noLoop();
|
|
915
|
+
*
|
|
916
|
+
* // Create three graphics objects for HSL, LCH, and OKLCH color modes
|
|
917
|
+
* hslGraphic = createGraphics(200, 200);
|
|
918
|
+
* lchGraphic = createGraphics(200, 200);
|
|
919
|
+
* oklchGraphic = createGraphics(200, 200);
|
|
920
|
+
*
|
|
921
|
+
* // Draw HSL color wheel
|
|
922
|
+
* colorMode(HSL);
|
|
923
|
+
* hslGraphic.translate(100, 100);
|
|
924
|
+
* for (let i = 0; i < 1000; i++) {
|
|
925
|
+
* hslGraphic.stroke(360 / 1000 * i, 70, 50);
|
|
926
|
+
* hslGraphic.line(0, 0, hslGraphic.width / 2, 0);
|
|
927
|
+
* hslGraphic.rotate(TAU / 1000);
|
|
928
|
+
* }
|
|
929
|
+
*
|
|
930
|
+
* // Draw LCH color wheel
|
|
931
|
+
* colorMode(LCH);
|
|
932
|
+
* lchGraphic.translate(100, 100);
|
|
933
|
+
* for (let i = 0; i < 1000; i++) {
|
|
934
|
+
* lchGraphic.stroke(54, 106, 360 / 1000 * i);
|
|
935
|
+
* lchGraphic.line(0, 0, lchGraphic.width / 2, 0);
|
|
936
|
+
* lchGraphic.rotate(TAU / 1000);
|
|
937
|
+
* }
|
|
938
|
+
*
|
|
939
|
+
* // Draw OKLCH color wheel
|
|
940
|
+
* colorMode(OKLCH);
|
|
941
|
+
* oklchGraphic.translate(100, 100);
|
|
942
|
+
* for (let i = 0; i < 1000; i++) {
|
|
943
|
+
* oklchGraphic.stroke(54, 106, 360 / 1000 * i);
|
|
944
|
+
* oklchGraphic.line(0, 0, oklchGraphic.width / 2, 0);
|
|
945
|
+
* oklchGraphic.rotate(TAU / 1000);
|
|
946
|
+
* }
|
|
947
|
+
* }
|
|
948
|
+
*
|
|
949
|
+
* function draw() {
|
|
950
|
+
* // Set the styles
|
|
951
|
+
* colorMode(RGB);
|
|
952
|
+
* background(220);
|
|
953
|
+
*
|
|
954
|
+
* // Display the color wheels
|
|
955
|
+
* image(hslGraphic, 0, 0);
|
|
956
|
+
* image(lchGraphic, 200, 0);
|
|
957
|
+
* image(oklchGraphic, 400, 0);
|
|
958
|
+
* }
|
|
959
|
+
* </code>
|
|
960
|
+
* </div>
|
|
961
|
+
* @example <div>
|
|
962
|
+
* <code>
|
|
963
|
+
* // Example: Single-value (Grayscale) colors in different color modes.
|
|
964
|
+
* // The rectangle is filled with one parameter, but its final color depends
|
|
965
|
+
* // on how that parameter is interpreted by the current color mode.
|
|
966
|
+
*
|
|
967
|
+
* function setup() {
|
|
968
|
+
* createCanvas(100, 100);
|
|
969
|
+
* noStroke();
|
|
970
|
+
* noLoop();
|
|
971
|
+
* }
|
|
972
|
+
*
|
|
973
|
+
* function draw() {
|
|
974
|
+
* // Set color mode to RGB with range 0-255
|
|
975
|
+
* colorMode(RGB, 255);
|
|
976
|
+
*
|
|
977
|
+
* // Fill with single grayscale value
|
|
978
|
+
* fill(128);
|
|
979
|
+
* rect(0, 0, 100, 100);
|
|
980
|
+
*
|
|
981
|
+
* // Add text label
|
|
982
|
+
* fill(0); // Switch to black text for clarity
|
|
983
|
+
* textSize(14);
|
|
984
|
+
* text("RGB (128)", 10, 20);
|
|
985
|
+
* }
|
|
986
|
+
* </code>
|
|
987
|
+
* </div>
|
|
988
|
+
*/
|
|
989
|
+
function colorMode(mode: RGB | HSB | HSL | RGBHDR | HWB | LAB | LCH | OKLAB | OKLCH, max?: number): void;
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* @param range for the red or hue depending on the
|
|
993
|
+
* current color mode.
|
|
994
|
+
* @param range for the green or saturation depending
|
|
995
|
+
* on the current color mode.
|
|
996
|
+
* @param range for the blue or brightness/lightness
|
|
997
|
+
* depending on the current color mode.
|
|
998
|
+
* @param range for the alpha.
|
|
999
|
+
* @return The current color mode.
|
|
1000
|
+
*/
|
|
1001
|
+
function colorMode(mode: RGB | HSB | HSL | RGBHDR | HWB | LAB | LCH | OKLAB | OKLCH, max1: number, max2: number, max3: number, maxA?: number): string;
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Sets the color used to fill shapes.Calling `fill(255, 165, 0)` or `fill('orange')` means all shapes drawn
|
|
1005
|
+
* after the fill command will be filled with the color orange.The version of `fill()` with one parameter interprets the value one of
|
|
1006
|
+
* three ways. If the parameter is a `Number`, it's interpreted as a grayscale
|
|
1007
|
+
* value. If the parameter is a `String`, it's interpreted as a CSS color
|
|
1008
|
+
* string. A p5.Color object can also be provided to
|
|
1009
|
+
* set the fill color.The version of `fill()` with three parameters interprets them as RGB, HSB,
|
|
1010
|
+
* or HSL colors, depending on the current
|
|
1011
|
+
* colorMode(). The default color space is RGB,
|
|
1012
|
+
* with each value in the range from 0 to 255.
|
|
1013
|
+
*
|
|
1014
|
+
* @param red value if color mode is RGB or hue value if color mode is HSB.
|
|
1015
|
+
* @param green value if color mode is RGB or saturation value if color mode is HSB.
|
|
1016
|
+
* @param blue value if color mode is RGB or brightness value if color mode is HSB.
|
|
1017
|
+
* @param alpha value, controls transparency (0 - transparent, 255 - opaque).
|
|
1018
|
+
* @example <div>
|
|
1019
|
+
* <code>
|
|
1020
|
+
* function setup() {
|
|
1021
|
+
* createCanvas(100, 100);
|
|
1022
|
+
*
|
|
1023
|
+
* background(200);
|
|
1024
|
+
*
|
|
1025
|
+
* // A grayscale value.
|
|
1026
|
+
* fill(51);
|
|
1027
|
+
* square(20, 20, 60);
|
|
1028
|
+
*
|
|
1029
|
+
* describe('A dark charcoal gray square with a black outline.');
|
|
1030
|
+
* }
|
|
1031
|
+
* </code>
|
|
1032
|
+
* </div>
|
|
1033
|
+
*
|
|
1034
|
+
* <div>
|
|
1035
|
+
* <code>
|
|
1036
|
+
* function setup() {
|
|
1037
|
+
* createCanvas(100, 100);
|
|
1038
|
+
*
|
|
1039
|
+
* background(200);
|
|
1040
|
+
*
|
|
1041
|
+
* // R, G & B values.
|
|
1042
|
+
* fill(255, 204, 0);
|
|
1043
|
+
* square(20, 20, 60);
|
|
1044
|
+
*
|
|
1045
|
+
* describe('A yellow square with a black outline.');
|
|
1046
|
+
* }
|
|
1047
|
+
* </code>
|
|
1048
|
+
* </div>
|
|
1049
|
+
*
|
|
1050
|
+
* <div>
|
|
1051
|
+
* <code>
|
|
1052
|
+
* function setup() {
|
|
1053
|
+
* createCanvas(100, 100);
|
|
1054
|
+
*
|
|
1055
|
+
* background(100);
|
|
1056
|
+
*
|
|
1057
|
+
* // Use HSB color.
|
|
1058
|
+
* colorMode(HSB);
|
|
1059
|
+
*
|
|
1060
|
+
* // H, S & B values.
|
|
1061
|
+
* fill(255, 204, 100);
|
|
1062
|
+
* square(20, 20, 60);
|
|
1063
|
+
*
|
|
1064
|
+
* describe('A royal blue square with a black outline.');
|
|
1065
|
+
* }
|
|
1066
|
+
* </code>
|
|
1067
|
+
* </div>
|
|
1068
|
+
*
|
|
1069
|
+
* <div>
|
|
1070
|
+
* <code>
|
|
1071
|
+
* function setup() {
|
|
1072
|
+
* createCanvas(100, 100);
|
|
1073
|
+
*
|
|
1074
|
+
* background(200);
|
|
1075
|
+
*
|
|
1076
|
+
* // A CSS named color.
|
|
1077
|
+
* fill('red');
|
|
1078
|
+
* square(20, 20, 60);
|
|
1079
|
+
*
|
|
1080
|
+
* describe('A red square with a black outline.');
|
|
1081
|
+
* }
|
|
1082
|
+
* </code>
|
|
1083
|
+
* </div>
|
|
1084
|
+
*
|
|
1085
|
+
* <div>
|
|
1086
|
+
* <code>
|
|
1087
|
+
* function setup() {
|
|
1088
|
+
* createCanvas(100, 100);
|
|
1089
|
+
*
|
|
1090
|
+
* background(200);
|
|
1091
|
+
*
|
|
1092
|
+
* // Three-digit hex RGB notation.
|
|
1093
|
+
* fill('#fae');
|
|
1094
|
+
* square(20, 20, 60);
|
|
1095
|
+
*
|
|
1096
|
+
* describe('A pink square with a black outline.');
|
|
1097
|
+
* }
|
|
1098
|
+
* </code>
|
|
1099
|
+
* </div>
|
|
1100
|
+
*
|
|
1101
|
+
* <div>
|
|
1102
|
+
* <code>
|
|
1103
|
+
* function setup() {
|
|
1104
|
+
* createCanvas(100, 100);
|
|
1105
|
+
*
|
|
1106
|
+
* background(200);
|
|
1107
|
+
*
|
|
1108
|
+
* // Six-digit hex RGB notation.
|
|
1109
|
+
* fill('#A251FA');
|
|
1110
|
+
* square(20, 20, 60);
|
|
1111
|
+
*
|
|
1112
|
+
* describe('A purple square with a black outline.');
|
|
1113
|
+
* }
|
|
1114
|
+
* </code>
|
|
1115
|
+
* </div>
|
|
1116
|
+
*
|
|
1117
|
+
* <div>
|
|
1118
|
+
* <code>
|
|
1119
|
+
* function setup() {
|
|
1120
|
+
* createCanvas(100, 100);
|
|
1121
|
+
*
|
|
1122
|
+
* background(200);
|
|
1123
|
+
*
|
|
1124
|
+
* // Integer RGB notation.
|
|
1125
|
+
* fill('rgb(0, 255, 0)');
|
|
1126
|
+
* square(20, 20, 60);
|
|
1127
|
+
*
|
|
1128
|
+
* describe('A bright green square with a black outline.');
|
|
1129
|
+
* }
|
|
1130
|
+
* </code>
|
|
1131
|
+
* </div>
|
|
1132
|
+
*
|
|
1133
|
+
* <div>
|
|
1134
|
+
* <code>
|
|
1135
|
+
* function setup() {
|
|
1136
|
+
* createCanvas(100, 100);
|
|
1137
|
+
*
|
|
1138
|
+
* background(200);
|
|
1139
|
+
*
|
|
1140
|
+
* // Integer RGBA notation.
|
|
1141
|
+
* fill('rgba(0, 255, 0, 0.25)');
|
|
1142
|
+
* square(20, 20, 60);
|
|
1143
|
+
*
|
|
1144
|
+
* describe('A soft green rectange with a black outline.');
|
|
1145
|
+
* }
|
|
1146
|
+
* </code>
|
|
1147
|
+
* </div>
|
|
1148
|
+
*
|
|
1149
|
+
* <div>
|
|
1150
|
+
* <code>
|
|
1151
|
+
* function setup() {
|
|
1152
|
+
* createCanvas(100, 100);
|
|
1153
|
+
*
|
|
1154
|
+
* background(200);
|
|
1155
|
+
*
|
|
1156
|
+
* // Percentage RGB notation.
|
|
1157
|
+
* fill('rgb(100%, 0%, 10%)');
|
|
1158
|
+
* square(20, 20, 60);
|
|
1159
|
+
*
|
|
1160
|
+
* describe('A red square with a black outline.');
|
|
1161
|
+
* }
|
|
1162
|
+
* </code>
|
|
1163
|
+
* </div>
|
|
1164
|
+
*
|
|
1165
|
+
* <div>
|
|
1166
|
+
* <code>
|
|
1167
|
+
* function setup() {
|
|
1168
|
+
* createCanvas(100, 100);
|
|
1169
|
+
*
|
|
1170
|
+
* background(200);
|
|
1171
|
+
*
|
|
1172
|
+
* // Percentage RGBA notation.
|
|
1173
|
+
* fill('rgba(100%, 0%, 100%, 0.5)');
|
|
1174
|
+
* square(20, 20, 60);
|
|
1175
|
+
*
|
|
1176
|
+
* describe('A dark fuchsia square with a black outline.');
|
|
1177
|
+
* }
|
|
1178
|
+
* </code>
|
|
1179
|
+
* </div>
|
|
1180
|
+
*
|
|
1181
|
+
* <div>
|
|
1182
|
+
* <code>
|
|
1183
|
+
* function setup() {
|
|
1184
|
+
* createCanvas(100, 100);
|
|
1185
|
+
*
|
|
1186
|
+
* background(200);
|
|
1187
|
+
*
|
|
1188
|
+
* // A p5.Color object.
|
|
1189
|
+
* let c = color(0, 0, 255);
|
|
1190
|
+
* fill(c);
|
|
1191
|
+
* square(20, 20, 60);
|
|
1192
|
+
*
|
|
1193
|
+
* describe('A blue square with a black outline.');
|
|
1194
|
+
* }
|
|
1195
|
+
* </code>
|
|
1196
|
+
* </div>
|
|
1197
|
+
*/
|
|
1198
|
+
function fill(v1: number, v2: number, v3: number, alpha?: number): void;
|
|
1199
|
+
|
|
1200
|
+
/**
|
|
1201
|
+
* @param a color string.
|
|
1202
|
+
*/
|
|
1203
|
+
function fill(value: string): void;
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* @param a grayscale value.
|
|
1207
|
+
*/
|
|
1208
|
+
function fill(gray: number, alpha?: number): void;
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* @param an array containing the red, green, blue &
|
|
1212
|
+
* and alpha components of the color.
|
|
1213
|
+
*/
|
|
1214
|
+
function fill(values: number[]): void;
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* @param the fill color.
|
|
1218
|
+
*/
|
|
1219
|
+
function fill(color: p5.Color): void;
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* Disables setting the fill color for shapes.Calling `noFill()` is the same as making the fill completely transparent,
|
|
1223
|
+
* as in `fill(0, 0)`. If both noStroke() and
|
|
1224
|
+
* `noFill()` are called, nothing will be drawn to the screen.
|
|
1225
|
+
*
|
|
1226
|
+
* @example <div>
|
|
1227
|
+
* <code>
|
|
1228
|
+
* function setup() {
|
|
1229
|
+
* createCanvas(100, 100);
|
|
1230
|
+
*
|
|
1231
|
+
* background(200);
|
|
1232
|
+
*
|
|
1233
|
+
* // Draw the top square.
|
|
1234
|
+
* square(32, 10, 35);
|
|
1235
|
+
*
|
|
1236
|
+
* // Draw the bottom square.
|
|
1237
|
+
* noFill();
|
|
1238
|
+
* square(32, 55, 35);
|
|
1239
|
+
*
|
|
1240
|
+
* describe('A white square on above an empty square. Both squares have black outlines.');
|
|
1241
|
+
* }
|
|
1242
|
+
* </code>
|
|
1243
|
+
* </div>
|
|
1244
|
+
*
|
|
1245
|
+
* <div modernizr='webgl'>
|
|
1246
|
+
* <code>
|
|
1247
|
+
* function setup() {
|
|
1248
|
+
* createCanvas(100, 100, WEBGL);
|
|
1249
|
+
*
|
|
1250
|
+
* describe('A purple cube wireframe spinning on a black canvas.');
|
|
1251
|
+
* }
|
|
1252
|
+
*
|
|
1253
|
+
* function draw() {
|
|
1254
|
+
* background(0);
|
|
1255
|
+
*
|
|
1256
|
+
* // Style the box.
|
|
1257
|
+
* noFill();
|
|
1258
|
+
* stroke(100, 100, 240);
|
|
1259
|
+
*
|
|
1260
|
+
* // Rotate the coordinates.
|
|
1261
|
+
* rotateX(frameCount * 0.01);
|
|
1262
|
+
* rotateY(frameCount * 0.01);
|
|
1263
|
+
*
|
|
1264
|
+
* // Draw the box.
|
|
1265
|
+
* box(45);
|
|
1266
|
+
* }
|
|
1267
|
+
* </code>
|
|
1268
|
+
* </div>
|
|
1269
|
+
*/
|
|
1270
|
+
function noFill(): void;
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* Disables drawing points, lines, and the outlines of shapes.Calling `noStroke()` is the same as making the stroke completely transparent,
|
|
1274
|
+
* as in `stroke(0, 0)`. If both `noStroke()` and
|
|
1275
|
+
* noFill() are called, nothing will be drawn to the
|
|
1276
|
+
* screen.
|
|
1277
|
+
*
|
|
1278
|
+
* @example <div>
|
|
1279
|
+
* <code>
|
|
1280
|
+
* function setup() {
|
|
1281
|
+
* createCanvas(100, 100);
|
|
1282
|
+
*
|
|
1283
|
+
* background(200);
|
|
1284
|
+
*
|
|
1285
|
+
* noStroke();
|
|
1286
|
+
* square(20, 20, 60);
|
|
1287
|
+
*
|
|
1288
|
+
* describe('A white square with no outline.');
|
|
1289
|
+
* }
|
|
1290
|
+
* </code>
|
|
1291
|
+
* </div>
|
|
1292
|
+
*
|
|
1293
|
+
* <div modernizr='webgl'>
|
|
1294
|
+
* <code>
|
|
1295
|
+
* function setup() {
|
|
1296
|
+
* createCanvas(100, 100, WEBGL);
|
|
1297
|
+
*
|
|
1298
|
+
* describe('A pink cube with no edge outlines spinning on a black canvas.');
|
|
1299
|
+
* }
|
|
1300
|
+
*
|
|
1301
|
+
* function draw() {
|
|
1302
|
+
* background(0);
|
|
1303
|
+
*
|
|
1304
|
+
* // Style the box.
|
|
1305
|
+
* noStroke();
|
|
1306
|
+
* fill(240, 150, 150);
|
|
1307
|
+
*
|
|
1308
|
+
* // Rotate the coordinates.
|
|
1309
|
+
* rotateX(frameCount * 0.01);
|
|
1310
|
+
* rotateY(frameCount * 0.01);
|
|
1311
|
+
*
|
|
1312
|
+
* // Draw the box.
|
|
1313
|
+
* box(45);
|
|
1314
|
+
* }
|
|
1315
|
+
* </code>
|
|
1316
|
+
* </div>
|
|
1317
|
+
*/
|
|
1318
|
+
function noStroke(): void;
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* Sets the color used to draw points, lines, and the outlines of shapes.Calling `stroke(255, 165, 0)` or `stroke('orange')` means all shapes drawn
|
|
1322
|
+
* after calling `stroke()` will be filled with the color orange. The way
|
|
1323
|
+
* these parameters are interpreted may be changed with the
|
|
1324
|
+
* colorMode() function.The version of `stroke()` with one parameter interprets the value one of
|
|
1325
|
+
* three ways. If the parameter is a `Number`, it's interpreted as a grayscale
|
|
1326
|
+
* value. If the parameter is a `String`, it's interpreted as a CSS color
|
|
1327
|
+
* string. A p5.Color object can also be provided to
|
|
1328
|
+
* set the stroke color.The version of `stroke()` with two parameters interprets the first one as a
|
|
1329
|
+
* grayscale value. The second parameter sets the alpha (transparency) value.The version of `stroke()` with three parameters interprets them as RGB, HSB,
|
|
1330
|
+
* or HSL colors, depending on the current `colorMode()`.The version of `stroke()` with four parameters interprets them as RGBA, HSBA,
|
|
1331
|
+
* or HSLA colors, depending on the current `colorMode()`. The last parameter
|
|
1332
|
+
* sets the alpha (transparency) value.
|
|
1333
|
+
*
|
|
1334
|
+
* @param red value if color mode is RGB or hue value if color mode is HSB.
|
|
1335
|
+
* @param green value if color mode is RGB or saturation value if color mode is HSB.
|
|
1336
|
+
* @param blue value if color mode is RGB or brightness value if color mode is HSB.
|
|
1337
|
+
* @param alpha value, controls transparency (0 - transparent, 255 - opaque).
|
|
1338
|
+
* @example <div>
|
|
1339
|
+
* <code>
|
|
1340
|
+
* function setup() {
|
|
1341
|
+
* createCanvas(100, 100);
|
|
1342
|
+
*
|
|
1343
|
+
* background(200);
|
|
1344
|
+
*
|
|
1345
|
+
* // A grayscale value.
|
|
1346
|
+
* strokeWeight(4);
|
|
1347
|
+
* stroke(51);
|
|
1348
|
+
* square(20, 20, 60);
|
|
1349
|
+
*
|
|
1350
|
+
* describe('A white square with a dark charcoal gray outline.');
|
|
1351
|
+
* }
|
|
1352
|
+
* </code>
|
|
1353
|
+
* </div>
|
|
1354
|
+
*
|
|
1355
|
+
* <div>
|
|
1356
|
+
* <code>
|
|
1357
|
+
* function setup() {
|
|
1358
|
+
* createCanvas(100, 100);
|
|
1359
|
+
*
|
|
1360
|
+
* background(200);
|
|
1361
|
+
*
|
|
1362
|
+
* // R, G & B values.
|
|
1363
|
+
* stroke(255, 204, 0);
|
|
1364
|
+
* strokeWeight(4);
|
|
1365
|
+
* square(20, 20, 60);
|
|
1366
|
+
*
|
|
1367
|
+
* describe('A white square with a yellow outline.');
|
|
1368
|
+
* }
|
|
1369
|
+
* </code>
|
|
1370
|
+
* </div>
|
|
1371
|
+
*
|
|
1372
|
+
* <div>
|
|
1373
|
+
* <code>
|
|
1374
|
+
* function setup() {
|
|
1375
|
+
* createCanvas(100, 100);
|
|
1376
|
+
*
|
|
1377
|
+
* background(200);
|
|
1378
|
+
*
|
|
1379
|
+
* // Use HSB color.
|
|
1380
|
+
* colorMode(HSB);
|
|
1381
|
+
*
|
|
1382
|
+
* // H, S & B values.
|
|
1383
|
+
* strokeWeight(4);
|
|
1384
|
+
* stroke(255, 204, 100);
|
|
1385
|
+
* square(20, 20, 60);
|
|
1386
|
+
*
|
|
1387
|
+
* describe('A white square with a royal blue outline.');
|
|
1388
|
+
* }
|
|
1389
|
+
* </code>
|
|
1390
|
+
* </div>
|
|
1391
|
+
*
|
|
1392
|
+
* <div>
|
|
1393
|
+
* <code>
|
|
1394
|
+
* function setup() {
|
|
1395
|
+
* createCanvas(100, 100);
|
|
1396
|
+
*
|
|
1397
|
+
* background(200);
|
|
1398
|
+
*
|
|
1399
|
+
* // A CSS named color.
|
|
1400
|
+
* stroke('red');
|
|
1401
|
+
* strokeWeight(4);
|
|
1402
|
+
* square(20, 20, 60);
|
|
1403
|
+
*
|
|
1404
|
+
* describe('A white square with a red outline.');
|
|
1405
|
+
* }
|
|
1406
|
+
* </code>
|
|
1407
|
+
* </div>
|
|
1408
|
+
*
|
|
1409
|
+
* <div>
|
|
1410
|
+
* <code>
|
|
1411
|
+
* function setup() {
|
|
1412
|
+
* createCanvas(100, 100);
|
|
1413
|
+
*
|
|
1414
|
+
* background(200);
|
|
1415
|
+
*
|
|
1416
|
+
* // Three-digit hex RGB notation.
|
|
1417
|
+
* stroke('#fae');
|
|
1418
|
+
* strokeWeight(4);
|
|
1419
|
+
* square(20, 20, 60);
|
|
1420
|
+
*
|
|
1421
|
+
* describe('A white square with a pink outline.');
|
|
1422
|
+
* }
|
|
1423
|
+
* </code>
|
|
1424
|
+
* </div>
|
|
1425
|
+
*
|
|
1426
|
+
* <div>
|
|
1427
|
+
* <code>
|
|
1428
|
+
* function setup() {
|
|
1429
|
+
* createCanvas(100, 100);
|
|
1430
|
+
*
|
|
1431
|
+
* background(200);
|
|
1432
|
+
*
|
|
1433
|
+
* // Six-digit hex RGB notation.
|
|
1434
|
+
* stroke('#222222');
|
|
1435
|
+
* strokeWeight(4);
|
|
1436
|
+
* square(20, 20, 60);
|
|
1437
|
+
*
|
|
1438
|
+
* describe('A white square with a black outline.');
|
|
1439
|
+
* }
|
|
1440
|
+
* </code>
|
|
1441
|
+
* </div>
|
|
1442
|
+
*
|
|
1443
|
+
* <div>
|
|
1444
|
+
* <code>
|
|
1445
|
+
* function setup() {
|
|
1446
|
+
* createCanvas(100, 100);
|
|
1447
|
+
*
|
|
1448
|
+
* background(200);
|
|
1449
|
+
*
|
|
1450
|
+
* // Integer RGB notation.
|
|
1451
|
+
* stroke('rgb(0, 255, 0)');
|
|
1452
|
+
* strokeWeight(4);
|
|
1453
|
+
* square(20, 20, 60);
|
|
1454
|
+
*
|
|
1455
|
+
* describe('A white square with a bright green outline.');
|
|
1456
|
+
* }
|
|
1457
|
+
* </code>
|
|
1458
|
+
* </div>
|
|
1459
|
+
*
|
|
1460
|
+
* <div>
|
|
1461
|
+
* <code>
|
|
1462
|
+
* function setup() {
|
|
1463
|
+
* createCanvas(100, 100);
|
|
1464
|
+
*
|
|
1465
|
+
* background(200);
|
|
1466
|
+
*
|
|
1467
|
+
* // Integer RGBA notation.
|
|
1468
|
+
* stroke('rgba(0, 255, 0, 0.25)');
|
|
1469
|
+
* strokeWeight(4);
|
|
1470
|
+
* square(20, 20, 60);
|
|
1471
|
+
*
|
|
1472
|
+
* describe('A white square with a soft green outline.');
|
|
1473
|
+
* }
|
|
1474
|
+
* </code>
|
|
1475
|
+
* </div>
|
|
1476
|
+
*
|
|
1477
|
+
* <div>
|
|
1478
|
+
* <code>
|
|
1479
|
+
* function setup() {
|
|
1480
|
+
* createCanvas(100, 100);
|
|
1481
|
+
*
|
|
1482
|
+
* background(200);
|
|
1483
|
+
*
|
|
1484
|
+
* // Percentage RGB notation.
|
|
1485
|
+
* stroke('rgb(100%, 0%, 10%)');
|
|
1486
|
+
* strokeWeight(4);
|
|
1487
|
+
* square(20, 20, 60);
|
|
1488
|
+
*
|
|
1489
|
+
* describe('A white square with a red outline.');
|
|
1490
|
+
* }
|
|
1491
|
+
* </code>
|
|
1492
|
+
* </div>
|
|
1493
|
+
*
|
|
1494
|
+
* <div>
|
|
1495
|
+
* <code>
|
|
1496
|
+
* function setup() {
|
|
1497
|
+
* createCanvas(100, 100);
|
|
1498
|
+
*
|
|
1499
|
+
* background(200);
|
|
1500
|
+
*
|
|
1501
|
+
* // Percentage RGBA notation.
|
|
1502
|
+
* stroke('rgba(100%, 0%, 100%, 0.5)');
|
|
1503
|
+
* strokeWeight(4);
|
|
1504
|
+
* square(20, 20, 60);
|
|
1505
|
+
*
|
|
1506
|
+
* describe('A white square with a dark fuchsia outline.');
|
|
1507
|
+
* }
|
|
1508
|
+
* </code>
|
|
1509
|
+
* </div>
|
|
1510
|
+
*
|
|
1511
|
+
* <div>
|
|
1512
|
+
* <code>
|
|
1513
|
+
* function setup() {
|
|
1514
|
+
* createCanvas(100, 100);
|
|
1515
|
+
*
|
|
1516
|
+
* background(200);
|
|
1517
|
+
*
|
|
1518
|
+
* // A p5.Color object.
|
|
1519
|
+
* stroke(color(0, 0, 255));
|
|
1520
|
+
* strokeWeight(4);
|
|
1521
|
+
* square(20, 20, 60);
|
|
1522
|
+
*
|
|
1523
|
+
* describe('A white square with a blue outline.');
|
|
1524
|
+
* }
|
|
1525
|
+
* </code>
|
|
1526
|
+
* </div>
|
|
1527
|
+
*/
|
|
1528
|
+
function stroke(v1: number, v2: number, v3: number, alpha?: number): void;
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
* @param a color string.
|
|
1532
|
+
*/
|
|
1533
|
+
function stroke(value: string): void;
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* @param a grayscale value.
|
|
1537
|
+
*/
|
|
1538
|
+
function stroke(gray: number, alpha?: number): void;
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* @param an array containing the red, green, blue,
|
|
1542
|
+
* and alpha components of the color.
|
|
1543
|
+
*/
|
|
1544
|
+
function stroke(values: number[]): void;
|
|
1545
|
+
|
|
1546
|
+
/**
|
|
1547
|
+
* @param the stroke color.
|
|
1548
|
+
*/
|
|
1549
|
+
function stroke(color: p5.Color): void;
|
|
1550
|
+
|
|
1551
|
+
/**
|
|
1552
|
+
* Starts using shapes to erase parts of the canvas.All drawing that follows `erase()` will subtract from the canvas, revealing
|
|
1553
|
+
* the web page underneath. The erased areas will become transparent, allowing
|
|
1554
|
+
* the content behind the canvas to show through. The
|
|
1555
|
+
* fill(), stroke(), and
|
|
1556
|
+
* blendMode() have no effect once `erase()` is
|
|
1557
|
+
* called.The `erase()` function has two optional parameters. The first parameter
|
|
1558
|
+
* sets the strength of erasing by the shape's interior. A value of 0 means
|
|
1559
|
+
* that no erasing will occur. A value of 255 means that the shape's interior
|
|
1560
|
+
* will fully erase the content underneath. The default value is 255
|
|
1561
|
+
* (full strength).The second parameter sets the strength of erasing by the shape's edge. A
|
|
1562
|
+
* value of 0 means that no erasing will occur. A value of 255 means that the
|
|
1563
|
+
* shape's edge will fully erase the content underneath. The default value is
|
|
1564
|
+
* 255 (full strength).To cancel the erasing effect, use the noErase()
|
|
1565
|
+
* function.`erase()` has no effect on drawing done with the
|
|
1566
|
+
* image() and
|
|
1567
|
+
* background() functions.
|
|
1568
|
+
*
|
|
1569
|
+
* @param a number (0-255) for the strength of erasing under a shape's interior.
|
|
1570
|
+
* Defaults to 255, which is full strength.
|
|
1571
|
+
* @param a number (0-255) for the strength of erasing under a shape's edge.
|
|
1572
|
+
* Defaults to 255, which is full strength.
|
|
1573
|
+
* @example <div>
|
|
1574
|
+
* <code>
|
|
1575
|
+
* function setup() {
|
|
1576
|
+
* createCanvas(100, 100);
|
|
1577
|
+
*
|
|
1578
|
+
* background(100, 100, 250);
|
|
1579
|
+
*
|
|
1580
|
+
* // Draw a pink square.
|
|
1581
|
+
* fill(250, 100, 100);
|
|
1582
|
+
* square(20, 20, 60);
|
|
1583
|
+
*
|
|
1584
|
+
* // Erase a circular area.
|
|
1585
|
+
* erase();
|
|
1586
|
+
* circle(25, 30, 30);
|
|
1587
|
+
* noErase();
|
|
1588
|
+
*
|
|
1589
|
+
* describe('A purple canvas with a pink square in the middle. A circle is erased from the top-left, leaving a hole.');
|
|
1590
|
+
* }
|
|
1591
|
+
* </code>
|
|
1592
|
+
* </div>
|
|
1593
|
+
* @example <div>
|
|
1594
|
+
* <code>
|
|
1595
|
+
* function setup() {
|
|
1596
|
+
* createCanvas(100, 100);
|
|
1597
|
+
*
|
|
1598
|
+
* background(100, 100, 250);
|
|
1599
|
+
*
|
|
1600
|
+
* // Draw a pink square.
|
|
1601
|
+
* fill(250, 100, 100);
|
|
1602
|
+
* square(20, 20, 60);
|
|
1603
|
+
*
|
|
1604
|
+
* // Erase a circular area.
|
|
1605
|
+
* strokeWeight(5);
|
|
1606
|
+
* erase(150, 255);
|
|
1607
|
+
* circle(25, 30, 30);
|
|
1608
|
+
* noErase();
|
|
1609
|
+
*
|
|
1610
|
+
* describe('A purple canvas with a pink square in the middle. A circle at the top-left partially erases its interior and a fully erases its outline.');
|
|
1611
|
+
* }
|
|
1612
|
+
* </code>
|
|
1613
|
+
* </div>
|
|
1614
|
+
*/
|
|
1615
|
+
function erase(strengthFill?: number, strengthStroke?: number): void;
|
|
1616
|
+
|
|
1617
|
+
/**
|
|
1618
|
+
* Ends erasing that was started with erase().The fill(), stroke(), and
|
|
1619
|
+
* blendMode() settings will return to what they
|
|
1620
|
+
* were prior to calling erase().
|
|
1621
|
+
*
|
|
1622
|
+
* @example <div>
|
|
1623
|
+
* <code>
|
|
1624
|
+
* function setup() {
|
|
1625
|
+
* createCanvas(100, 100);
|
|
1626
|
+
*
|
|
1627
|
+
* background(235, 145, 15);
|
|
1628
|
+
*
|
|
1629
|
+
* // Draw the left rectangle.
|
|
1630
|
+
* noStroke();
|
|
1631
|
+
* fill(30, 45, 220);
|
|
1632
|
+
* rect(30, 10, 10, 80);
|
|
1633
|
+
*
|
|
1634
|
+
* // Erase a circle.
|
|
1635
|
+
* erase();
|
|
1636
|
+
* circle(50, 50, 60);
|
|
1637
|
+
* noErase();
|
|
1638
|
+
*
|
|
1639
|
+
* // Draw the right rectangle.
|
|
1640
|
+
* rect(70, 10, 10, 80);
|
|
1641
|
+
*
|
|
1642
|
+
* describe('An orange canvas with two tall blue rectangles. A circular hole in the center erases the rectangle on the left but not the one on the right.');
|
|
1643
|
+
* }
|
|
1644
|
+
* </code>
|
|
1645
|
+
* </div>
|
|
1646
|
+
*/
|
|
1647
|
+
function noErase(): void;
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* Sets the way colors blend when added to the canvas.By default, drawing with a solid color paints over the current pixel values
|
|
1651
|
+
* on the canvas. `blendMode()` offers many options for blending colors.Shapes, images, and text can be used as sources for drawing to the canvas.
|
|
1652
|
+
* A source pixel changes the color of the canvas pixel where it's drawn. The
|
|
1653
|
+
* final color results from blending the source pixel's color with the canvas
|
|
1654
|
+
* pixel's color. RGB color values from the source and canvas pixels are
|
|
1655
|
+
* compared, added, subtracted, multiplied, and divided to create different
|
|
1656
|
+
* effects. Red values with red values, greens with greens, and blues with
|
|
1657
|
+
* blues.The parameter, `mode`, sets the blend mode. For example, calling
|
|
1658
|
+
* `blendMode(ADD)` sets the blend mode to `ADD`. The following blend modes
|
|
1659
|
+
* are available in both 2D and WebGL mode:The following blend modes are only available in 2D mode:The following blend modes are only available in WebGL mode:
|
|
1660
|
+
*
|
|
1661
|
+
* @param blend mode to set.
|
|
1662
|
+
* either BLEND, DARKEST, LIGHTEST, DIFFERENCE, MULTIPLY,
|
|
1663
|
+
* EXCLUSION, SCREEN, REPLACE, OVERLAY, HARD_LIGHT,
|
|
1664
|
+
* SOFT_LIGHT, DODGE, BURN, ADD, REMOVE or SUBTRACT
|
|
1665
|
+
* @example <div>
|
|
1666
|
+
* <code>
|
|
1667
|
+
* function setup() {
|
|
1668
|
+
* createCanvas(100, 100);
|
|
1669
|
+
*
|
|
1670
|
+
* background(200);
|
|
1671
|
+
*
|
|
1672
|
+
* // Use the default blend mode.
|
|
1673
|
+
* blendMode(BLEND);
|
|
1674
|
+
*
|
|
1675
|
+
* // Style the lines.
|
|
1676
|
+
* strokeWeight(30);
|
|
1677
|
+
*
|
|
1678
|
+
* // Draw the blue line.
|
|
1679
|
+
* stroke('blue');
|
|
1680
|
+
* line(25, 25, 75, 75);
|
|
1681
|
+
*
|
|
1682
|
+
* // Draw the red line.
|
|
1683
|
+
* stroke('red');
|
|
1684
|
+
* line(75, 25, 25, 75);
|
|
1685
|
+
*
|
|
1686
|
+
* describe('A blue line and a red line form an X on a gray background.');
|
|
1687
|
+
* }
|
|
1688
|
+
* </code>
|
|
1689
|
+
* </div>
|
|
1690
|
+
*
|
|
1691
|
+
* <div>
|
|
1692
|
+
* <code>
|
|
1693
|
+
* function setup() {
|
|
1694
|
+
* createCanvas(100, 100);
|
|
1695
|
+
*
|
|
1696
|
+
* background(200);
|
|
1697
|
+
*
|
|
1698
|
+
* // Set the blend mode.
|
|
1699
|
+
* blendMode(ADD);
|
|
1700
|
+
*
|
|
1701
|
+
* // Style the lines.
|
|
1702
|
+
* strokeWeight(30);
|
|
1703
|
+
*
|
|
1704
|
+
* // Draw the blue line.
|
|
1705
|
+
* stroke('blue');
|
|
1706
|
+
* line(25, 25, 75, 75);
|
|
1707
|
+
*
|
|
1708
|
+
* // Draw the red line.
|
|
1709
|
+
* stroke('red');
|
|
1710
|
+
* line(75, 25, 25, 75);
|
|
1711
|
+
*
|
|
1712
|
+
* describe('A faint blue line and a faint red line form an X on a gray background. The area where they overlap is faint magenta.');
|
|
1713
|
+
* }
|
|
1714
|
+
* </code>
|
|
1715
|
+
* </div>
|
|
1716
|
+
*
|
|
1717
|
+
* <div>
|
|
1718
|
+
* <code>
|
|
1719
|
+
* function setup() {
|
|
1720
|
+
* createCanvas(100, 100);
|
|
1721
|
+
*
|
|
1722
|
+
* background(200);
|
|
1723
|
+
*
|
|
1724
|
+
* // Set the blend mode.
|
|
1725
|
+
* blendMode(DARKEST);
|
|
1726
|
+
*
|
|
1727
|
+
* // Style the lines.
|
|
1728
|
+
* strokeWeight(30);
|
|
1729
|
+
*
|
|
1730
|
+
* // Draw the blue line.
|
|
1731
|
+
* stroke('blue');
|
|
1732
|
+
* line(25, 25, 75, 75);
|
|
1733
|
+
*
|
|
1734
|
+
* // Draw the red line.
|
|
1735
|
+
* stroke('red');
|
|
1736
|
+
* line(75, 25, 25, 75);
|
|
1737
|
+
*
|
|
1738
|
+
* describe('A blue line and a red line form an X on a gray background. The area where they overlap is black.');
|
|
1739
|
+
* }
|
|
1740
|
+
* </code>
|
|
1741
|
+
* </div>
|
|
1742
|
+
*
|
|
1743
|
+
* <div>
|
|
1744
|
+
* <code>
|
|
1745
|
+
* function setup() {
|
|
1746
|
+
* createCanvas(100, 100);
|
|
1747
|
+
*
|
|
1748
|
+
* background(200);
|
|
1749
|
+
*
|
|
1750
|
+
* // Set the blend mode.
|
|
1751
|
+
* blendMode(LIGHTEST);
|
|
1752
|
+
*
|
|
1753
|
+
* // Style the lines.
|
|
1754
|
+
* strokeWeight(30);
|
|
1755
|
+
*
|
|
1756
|
+
* // Draw the blue line.
|
|
1757
|
+
* stroke('blue');
|
|
1758
|
+
* line(25, 25, 75, 75);
|
|
1759
|
+
*
|
|
1760
|
+
* // Draw the red line.
|
|
1761
|
+
* stroke('red');
|
|
1762
|
+
* line(75, 25, 25, 75);
|
|
1763
|
+
*
|
|
1764
|
+
* describe('A faint blue line and a faint red line form an X on a gray background. The area where they overlap is faint magenta.');
|
|
1765
|
+
* }
|
|
1766
|
+
* </code>
|
|
1767
|
+
* </div>
|
|
1768
|
+
*
|
|
1769
|
+
* <div>
|
|
1770
|
+
* <code>
|
|
1771
|
+
* function setup() {
|
|
1772
|
+
* createCanvas(100, 100);
|
|
1773
|
+
*
|
|
1774
|
+
* background(200);
|
|
1775
|
+
*
|
|
1776
|
+
* // Set the blend mode.
|
|
1777
|
+
* blendMode(EXCLUSION);
|
|
1778
|
+
*
|
|
1779
|
+
* // Style the lines.
|
|
1780
|
+
* strokeWeight(30);
|
|
1781
|
+
*
|
|
1782
|
+
* // Draw the blue line.
|
|
1783
|
+
* stroke('blue');
|
|
1784
|
+
* line(25, 25, 75, 75);
|
|
1785
|
+
*
|
|
1786
|
+
* // Draw the red line.
|
|
1787
|
+
* stroke('red');
|
|
1788
|
+
* line(75, 25, 25, 75);
|
|
1789
|
+
*
|
|
1790
|
+
* describe('A yellow line and a cyan line form an X on a gray background. The area where they overlap is green.');
|
|
1791
|
+
* }
|
|
1792
|
+
* </code>
|
|
1793
|
+
* </div>
|
|
1794
|
+
*
|
|
1795
|
+
* <div>
|
|
1796
|
+
* <code>
|
|
1797
|
+
* function setup() {
|
|
1798
|
+
* createCanvas(100, 100);
|
|
1799
|
+
*
|
|
1800
|
+
* background(200);
|
|
1801
|
+
*
|
|
1802
|
+
* // Set the blend mode.
|
|
1803
|
+
* blendMode(MULTIPLY);
|
|
1804
|
+
*
|
|
1805
|
+
* // Style the lines.
|
|
1806
|
+
* strokeWeight(30);
|
|
1807
|
+
*
|
|
1808
|
+
* // Draw the blue line.
|
|
1809
|
+
* stroke('blue');
|
|
1810
|
+
* line(25, 25, 75, 75);
|
|
1811
|
+
*
|
|
1812
|
+
* // Draw the red line.
|
|
1813
|
+
* stroke('red');
|
|
1814
|
+
* line(75, 25, 25, 75);
|
|
1815
|
+
*
|
|
1816
|
+
* describe('A blue line and a red line form an X on a gray background. The area where they overlap is black.');
|
|
1817
|
+
* }
|
|
1818
|
+
* </code>
|
|
1819
|
+
* </div>
|
|
1820
|
+
*
|
|
1821
|
+
* <div>
|
|
1822
|
+
* <code>
|
|
1823
|
+
* function setup() {
|
|
1824
|
+
* createCanvas(100, 100);
|
|
1825
|
+
*
|
|
1826
|
+
* background(200);
|
|
1827
|
+
*
|
|
1828
|
+
* // Set the blend mode.
|
|
1829
|
+
* blendMode(SCREEN);
|
|
1830
|
+
*
|
|
1831
|
+
* // Style the lines.
|
|
1832
|
+
* strokeWeight(30);
|
|
1833
|
+
*
|
|
1834
|
+
* // Draw the blue line.
|
|
1835
|
+
* stroke('blue');
|
|
1836
|
+
* line(25, 25, 75, 75);
|
|
1837
|
+
*
|
|
1838
|
+
* // Draw the red line.
|
|
1839
|
+
* stroke('red');
|
|
1840
|
+
* line(75, 25, 25, 75);
|
|
1841
|
+
*
|
|
1842
|
+
* describe('A faint blue line and a faint red line form an X on a gray background. The area where they overlap is faint magenta.');
|
|
1843
|
+
* }
|
|
1844
|
+
* </code>
|
|
1845
|
+
* </div>
|
|
1846
|
+
*
|
|
1847
|
+
* <div>
|
|
1848
|
+
* <code>
|
|
1849
|
+
* function setup() {
|
|
1850
|
+
* createCanvas(100, 100);
|
|
1851
|
+
*
|
|
1852
|
+
* background(200);
|
|
1853
|
+
*
|
|
1854
|
+
* // Set the blend mode.
|
|
1855
|
+
* blendMode(REPLACE);
|
|
1856
|
+
*
|
|
1857
|
+
* // Style the lines.
|
|
1858
|
+
* strokeWeight(30);
|
|
1859
|
+
*
|
|
1860
|
+
* // Draw the blue line.
|
|
1861
|
+
* stroke('blue');
|
|
1862
|
+
* line(25, 25, 75, 75);
|
|
1863
|
+
*
|
|
1864
|
+
* // Draw the red line.
|
|
1865
|
+
* stroke('red');
|
|
1866
|
+
* line(75, 25, 25, 75);
|
|
1867
|
+
*
|
|
1868
|
+
* describe('A diagonal red line.');
|
|
1869
|
+
* }
|
|
1870
|
+
* </code>
|
|
1871
|
+
* </div>
|
|
1872
|
+
*
|
|
1873
|
+
* <div>
|
|
1874
|
+
* <code>
|
|
1875
|
+
* function setup() {
|
|
1876
|
+
* createCanvas(100, 100);
|
|
1877
|
+
*
|
|
1878
|
+
* background(200);
|
|
1879
|
+
*
|
|
1880
|
+
* // Set the blend mode.
|
|
1881
|
+
* blendMode(REMOVE);
|
|
1882
|
+
*
|
|
1883
|
+
* // Style the lines.
|
|
1884
|
+
* strokeWeight(30);
|
|
1885
|
+
*
|
|
1886
|
+
* // Draw the blue line.
|
|
1887
|
+
* stroke('blue');
|
|
1888
|
+
* line(25, 25, 75, 75);
|
|
1889
|
+
*
|
|
1890
|
+
* // Draw the red line.
|
|
1891
|
+
* stroke('red');
|
|
1892
|
+
* line(75, 25, 25, 75);
|
|
1893
|
+
*
|
|
1894
|
+
* describe('The silhouette of an X is missing from a gray background.');
|
|
1895
|
+
* }
|
|
1896
|
+
* </code>
|
|
1897
|
+
* </div>
|
|
1898
|
+
*
|
|
1899
|
+
* <div>
|
|
1900
|
+
* <code>
|
|
1901
|
+
* function setup() {
|
|
1902
|
+
* createCanvas(100, 100);
|
|
1903
|
+
*
|
|
1904
|
+
* background(200);
|
|
1905
|
+
*
|
|
1906
|
+
* // Set the blend mode.
|
|
1907
|
+
* blendMode(DIFFERENCE);
|
|
1908
|
+
*
|
|
1909
|
+
* // Style the lines.
|
|
1910
|
+
* strokeWeight(30);
|
|
1911
|
+
*
|
|
1912
|
+
* // Draw the blue line.
|
|
1913
|
+
* stroke('blue');
|
|
1914
|
+
* line(25, 25, 75, 75);
|
|
1915
|
+
*
|
|
1916
|
+
* // Draw the red line.
|
|
1917
|
+
* stroke('red');
|
|
1918
|
+
* line(75, 25, 25, 75);
|
|
1919
|
+
*
|
|
1920
|
+
* describe('A yellow line and a cyan line form an X on a gray background. The area where they overlap is green.');
|
|
1921
|
+
* }
|
|
1922
|
+
* </code>
|
|
1923
|
+
* </div>
|
|
1924
|
+
*
|
|
1925
|
+
* <div>
|
|
1926
|
+
* <code>
|
|
1927
|
+
* function setup() {
|
|
1928
|
+
* createCanvas(100, 100);
|
|
1929
|
+
*
|
|
1930
|
+
* background(200);
|
|
1931
|
+
*
|
|
1932
|
+
* // Set the blend mode.
|
|
1933
|
+
* blendMode(OVERLAY);
|
|
1934
|
+
*
|
|
1935
|
+
* // Style the lines.
|
|
1936
|
+
* strokeWeight(30);
|
|
1937
|
+
*
|
|
1938
|
+
* // Draw the blue line.
|
|
1939
|
+
* stroke('blue');
|
|
1940
|
+
* line(25, 25, 75, 75);
|
|
1941
|
+
*
|
|
1942
|
+
* // Draw the red line.
|
|
1943
|
+
* stroke('red');
|
|
1944
|
+
* line(75, 25, 25, 75);
|
|
1945
|
+
*
|
|
1946
|
+
* describe('A faint blue line and a faint red line form an X on a gray background. The area where they overlap is bright magenta.');
|
|
1947
|
+
* }
|
|
1948
|
+
* </code>
|
|
1949
|
+
* </div>
|
|
1950
|
+
*
|
|
1951
|
+
* <div>
|
|
1952
|
+
* <code>
|
|
1953
|
+
* function setup() {
|
|
1954
|
+
* createCanvas(100, 100);
|
|
1955
|
+
*
|
|
1956
|
+
* background(200);
|
|
1957
|
+
*
|
|
1958
|
+
* // Set the blend mode.
|
|
1959
|
+
* blendMode(HARD_LIGHT);
|
|
1960
|
+
*
|
|
1961
|
+
* // Style the lines.
|
|
1962
|
+
* strokeWeight(30);
|
|
1963
|
+
*
|
|
1964
|
+
* // Draw the blue line.
|
|
1965
|
+
* stroke('blue');
|
|
1966
|
+
* line(25, 25, 75, 75);
|
|
1967
|
+
*
|
|
1968
|
+
* // Draw the red line.
|
|
1969
|
+
* stroke('red');
|
|
1970
|
+
* line(75, 25, 25, 75);
|
|
1971
|
+
*
|
|
1972
|
+
* describe('A blue line and a red line form an X on a gray background.');
|
|
1973
|
+
* }
|
|
1974
|
+
* </code>
|
|
1975
|
+
* </div>
|
|
1976
|
+
*
|
|
1977
|
+
* <div>
|
|
1978
|
+
* <code>
|
|
1979
|
+
* function setup() {
|
|
1980
|
+
* createCanvas(100, 100);
|
|
1981
|
+
*
|
|
1982
|
+
* background(200);
|
|
1983
|
+
*
|
|
1984
|
+
* // Set the blend mode.
|
|
1985
|
+
* blendMode(SOFT_LIGHT);
|
|
1986
|
+
*
|
|
1987
|
+
* // Style the lines.
|
|
1988
|
+
* strokeWeight(30);
|
|
1989
|
+
*
|
|
1990
|
+
* // Draw the blue line.
|
|
1991
|
+
* stroke('blue');
|
|
1992
|
+
* line(25, 25, 75, 75);
|
|
1993
|
+
*
|
|
1994
|
+
* // Draw the red line.
|
|
1995
|
+
* stroke('red');
|
|
1996
|
+
* line(75, 25, 25, 75);
|
|
1997
|
+
*
|
|
1998
|
+
* describe('A faint blue line and a faint red line form an X on a gray background. The area where they overlap is violet.');
|
|
1999
|
+
* }
|
|
2000
|
+
* </code>
|
|
2001
|
+
* </div>
|
|
2002
|
+
*
|
|
2003
|
+
* <div>
|
|
2004
|
+
* <code>
|
|
2005
|
+
* function setup() {
|
|
2006
|
+
* createCanvas(100, 100);
|
|
2007
|
+
*
|
|
2008
|
+
* background(200);
|
|
2009
|
+
*
|
|
2010
|
+
* // Set the blend mode.
|
|
2011
|
+
* blendMode(DODGE);
|
|
2012
|
+
*
|
|
2013
|
+
* // Style the lines.
|
|
2014
|
+
* strokeWeight(30);
|
|
2015
|
+
*
|
|
2016
|
+
* // Draw the blue line.
|
|
2017
|
+
* stroke('blue');
|
|
2018
|
+
* line(25, 25, 75, 75);
|
|
2019
|
+
*
|
|
2020
|
+
* // Draw the red line.
|
|
2021
|
+
* stroke('red');
|
|
2022
|
+
* line(75, 25, 25, 75);
|
|
2023
|
+
*
|
|
2024
|
+
* describe('A faint blue line and a faint red line form an X on a gray background. The area where they overlap is faint violet.');
|
|
2025
|
+
* }
|
|
2026
|
+
* </code>
|
|
2027
|
+
* </div>
|
|
2028
|
+
*
|
|
2029
|
+
* <div>
|
|
2030
|
+
* <code>
|
|
2031
|
+
* function setup() {
|
|
2032
|
+
* createCanvas(100, 100);
|
|
2033
|
+
*
|
|
2034
|
+
* background(200);
|
|
2035
|
+
*
|
|
2036
|
+
* // Set the blend mode.
|
|
2037
|
+
* blendMode(BURN);
|
|
2038
|
+
*
|
|
2039
|
+
* // Style the lines.
|
|
2040
|
+
* strokeWeight(30);
|
|
2041
|
+
*
|
|
2042
|
+
* // Draw the blue line.
|
|
2043
|
+
* stroke('blue');
|
|
2044
|
+
* line(25, 25, 75, 75);
|
|
2045
|
+
*
|
|
2046
|
+
* // Draw the red line.
|
|
2047
|
+
* stroke('red');
|
|
2048
|
+
* line(75, 25, 25, 75);
|
|
2049
|
+
*
|
|
2050
|
+
* describe('A blue line and a red line form an X on a gray background. The area where they overlap is black.');
|
|
2051
|
+
* }
|
|
2052
|
+
* </code>
|
|
2053
|
+
* </div>
|
|
2054
|
+
*
|
|
2055
|
+
* <div>
|
|
2056
|
+
* <code>
|
|
2057
|
+
* function setup() {
|
|
2058
|
+
* createCanvas(100, 100);
|
|
2059
|
+
*
|
|
2060
|
+
* background(200);
|
|
2061
|
+
*
|
|
2062
|
+
* // Set the blend mode.
|
|
2063
|
+
* blendMode(SUBTRACT);
|
|
2064
|
+
*
|
|
2065
|
+
* // Style the lines.
|
|
2066
|
+
* strokeWeight(30);
|
|
2067
|
+
*
|
|
2068
|
+
* // Draw the blue line.
|
|
2069
|
+
* stroke('blue');
|
|
2070
|
+
* line(25, 25, 75, 75);
|
|
2071
|
+
*
|
|
2072
|
+
* // Draw the red line.
|
|
2073
|
+
* stroke('red');
|
|
2074
|
+
* line(75, 25, 25, 75);
|
|
2075
|
+
*
|
|
2076
|
+
* describe('A yellow line and a turquoise line form an X on a gray background. The area where they overlap is green.');
|
|
2077
|
+
* }
|
|
2078
|
+
* </code>
|
|
2079
|
+
* </div>
|
|
2080
|
+
*/
|
|
2081
|
+
function blendMode(mode: BLEND | DARKEST | LIGHTEST | DIFFERENCE | MULTIPLY | EXCLUSION | SCREEN | REPLACE | OVERLAY | HARD_LIGHT | SOFT_LIGHT | DODGE | BURN | ADD | REMOVE | SUBTRACT): void;
|
|
2082
|
+
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
export default function setting(p5: any, fn: any): void;
|