p5 2.0.1 → 2.0.3

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.
Files changed (160) hide show
  1. package/dist/accessibility/color_namer.js +5 -5
  2. package/dist/accessibility/describe.js +10 -0
  3. package/dist/accessibility/index.js +5 -5
  4. package/dist/accessibility/outputs.js +21 -0
  5. package/dist/app.js +5 -5
  6. package/dist/color/color_conversion.js +5 -5
  7. package/dist/color/creating_reading.js +1 -1
  8. package/dist/color/index.js +2 -2
  9. package/dist/color/p5.Color.js +1 -1
  10. package/dist/color/setting.js +2 -2
  11. package/dist/{constants-C-g_eAdC.js → constants-BRcElHU3.js} +19 -3
  12. package/dist/core/constants.js +1 -1
  13. package/dist/core/environment.js +6 -5
  14. package/dist/core/friendly_errors/fes_core.js +1 -1
  15. package/dist/core/friendly_errors/index.js +1 -1
  16. package/dist/core/friendly_errors/param_validator.js +46 -93
  17. package/dist/core/friendly_errors/sketch_reader.js +5 -5
  18. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  19. package/dist/core/friendly_errors/validate_params.js +5 -5
  20. package/dist/core/helpers.js +1 -1
  21. package/dist/core/init.js +5 -5
  22. package/dist/core/legacy.js +5 -5
  23. package/dist/core/main.js +5 -5
  24. package/dist/core/p5.Graphics.js +4 -4
  25. package/dist/core/p5.Renderer.js +3 -3
  26. package/dist/core/p5.Renderer2D.js +5 -5
  27. package/dist/core/rendering.js +4 -4
  28. package/dist/{creating_reading-D4AAKRbx.js → creating_reading-Cr8L2Jnm.js} +2 -2
  29. package/dist/dom/dom.js +10 -10
  30. package/dist/dom/index.js +2 -2
  31. package/dist/dom/p5.Element.js +2 -2
  32. package/dist/dom/p5.MediaElement.js +2 -2
  33. package/dist/events/acceleration.js +24 -24
  34. package/dist/events/keyboard.js +11 -6
  35. package/dist/image/const.js +1 -1
  36. package/dist/image/filterRenderer2D.js +4 -4
  37. package/dist/image/image.js +4 -4
  38. package/dist/image/index.js +4 -4
  39. package/dist/image/loading_displaying.js +4 -4
  40. package/dist/image/p5.Image.js +3 -3
  41. package/dist/image/pixels.js +1 -0
  42. package/dist/io/files.js +4 -4
  43. package/dist/io/index.js +4 -4
  44. package/dist/io/p5.TableRow.js +2 -2
  45. package/dist/{main-s72KWcUy.js → main-BKN5yFoS.js} +12 -9
  46. package/dist/math/Matrices/Matrix.js +1 -1
  47. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  48. package/dist/math/index.js +1 -1
  49. package/dist/math/math.js +1 -1
  50. package/dist/math/p5.Matrix.js +1 -1
  51. package/dist/math/p5.Vector.js +1 -1
  52. package/dist/math/trigonometry.js +1 -1
  53. package/dist/{p5.Renderer-CwAYZOC2.js → p5.Renderer-R23xoC7s.js} +5 -5
  54. package/dist/{rendering--aAe5aq3.js → rendering-CvUVN-Vb.js} +101 -66
  55. package/dist/shape/2d_primitives.js +1 -1
  56. package/dist/shape/attributes.js +1 -1
  57. package/dist/shape/custom_shapes.js +2 -2
  58. package/dist/shape/index.js +2 -2
  59. package/dist/type/index.js +3 -3
  60. package/dist/type/p5.Font.js +3 -5
  61. package/dist/type/textCore.js +4 -4
  62. package/dist/webgl/3d_primitives.js +4 -4
  63. package/dist/webgl/GeometryBuilder.js +1 -1
  64. package/dist/webgl/ShapeBuilder.js +1 -1
  65. package/dist/webgl/index.js +4 -4
  66. package/dist/webgl/interaction.js +1 -1
  67. package/dist/webgl/light.js +4 -4
  68. package/dist/webgl/loading.js +5 -4
  69. package/dist/webgl/material.js +4 -4
  70. package/dist/webgl/p5.Camera.js +4 -4
  71. package/dist/webgl/p5.Framebuffer.js +4 -4
  72. package/dist/webgl/p5.Geometry.js +1 -1
  73. package/dist/webgl/p5.Quat.js +1 -1
  74. package/dist/webgl/p5.RendererGL.js +4 -4
  75. package/dist/webgl/p5.Shader.js +4 -4
  76. package/dist/webgl/p5.Texture.js +4 -4
  77. package/dist/webgl/text.js +32 -34
  78. package/lib/p5.esm.js +289 -247
  79. package/lib/p5.js +289 -247
  80. package/lib/p5.min.js +1 -1
  81. package/package.json +1 -2
  82. package/types/accessibility/color_namer.d.ts +8 -0
  83. package/types/accessibility/describe.d.ts +184 -0
  84. package/types/accessibility/gridOutput.d.ts +8 -0
  85. package/types/accessibility/outputs.d.ts +235 -0
  86. package/types/accessibility/textOutput.d.ts +8 -0
  87. package/types/color/color_conversion.d.ts +47 -0
  88. package/types/color/creating_reading.d.ts +1348 -0
  89. package/types/color/p5.Color.d.ts +1070 -0
  90. package/types/color/setting.d.ts +2085 -0
  91. package/types/core/constants.d.ts +341 -0
  92. package/types/core/environment.d.ts +668 -0
  93. package/types/core/friendly_errors/fes_core.d.ts +8 -0
  94. package/types/core/friendly_errors/file_errors.d.ts +8 -0
  95. package/types/core/friendly_errors/param_validator.d.ts +30 -0
  96. package/types/core/friendly_errors/sketch_reader.d.ts +8 -0
  97. package/types/core/friendly_errors/stacktrace.d.ts +11 -0
  98. package/types/core/friendly_errors/validate_params.d.ts +8 -0
  99. package/types/core/helpers.d.ts +8 -0
  100. package/types/core/legacy.d.ts +8 -0
  101. package/types/core/main.d.ts +5999 -0
  102. package/types/core/p5.Graphics.d.ts +484 -0
  103. package/types/core/p5.Renderer.d.ts +14 -0
  104. package/types/core/reference.d.ts +8 -0
  105. package/types/core/rendering.d.ts +481 -0
  106. package/types/core/structure.d.ts +492 -0
  107. package/types/core/transform.d.ts +1638 -0
  108. package/types/data/local_storage.d.ts +323 -0
  109. package/types/dom/dom.d.ts +1295 -0
  110. package/types/dom/p5.Element.d.ts +2011 -0
  111. package/types/dom/p5.File.d.ts +13 -0
  112. package/types/dom/p5.MediaElement.d.ts +1249 -0
  113. package/types/events/acceleration.d.ts +193 -0
  114. package/types/events/keyboard.d.ts +501 -0
  115. package/types/events/pointer.d.ts +782 -0
  116. package/types/global.d.ts +5544 -0
  117. package/types/image/filterRenderer2D.d.ts +54 -0
  118. package/types/image/image.d.ts +326 -0
  119. package/types/image/loading_displaying.d.ts +580 -0
  120. package/types/image/p5.Image.d.ts +5882 -0
  121. package/types/image/pixels.d.ts +832 -0
  122. package/types/io/files.d.ts +1447 -0
  123. package/types/io/p5.Table.d.ts +1247 -0
  124. package/types/io/p5.TableRow.d.ts +343 -0
  125. package/types/io/p5.XML.d.ts +1188 -0
  126. package/types/math/Matrices/Matrix.d.ts +1029 -0
  127. package/types/math/Matrices/MatrixNumjs.d.ts +8 -0
  128. package/types/math/calculation.d.ts +923 -0
  129. package/types/math/math.d.ts +90 -0
  130. package/types/math/noise.d.ts +311 -0
  131. package/types/math/p5.Matrix.d.ts +8 -0
  132. package/types/math/p5.Vector.d.ts +3416 -0
  133. package/types/math/random.d.ts +267 -0
  134. package/types/math/trigonometry.d.ts +663 -0
  135. package/types/p5.d.ts +6666 -0
  136. package/types/shape/2d_primitives.d.ts +1033 -0
  137. package/types/shape/attributes.d.ts +466 -0
  138. package/types/shape/curves.d.ts +740 -0
  139. package/types/shape/custom_shapes.d.ts +888 -0
  140. package/types/shape/vertex.d.ts +1141 -0
  141. package/types/type/p5.Font.d.ts +575 -0
  142. package/types/type/textCore.d.ts +1198 -0
  143. package/types/utilities/conversion.d.ts +894 -0
  144. package/types/utilities/time_date.d.ts +295 -0
  145. package/types/utilities/utility_functions.d.ts +587 -0
  146. package/types/webgl/3d_primitives.d.ts +1432 -0
  147. package/types/webgl/ShaderGenerator.d.ts +8 -0
  148. package/types/webgl/interaction.d.ts +371 -0
  149. package/types/webgl/light.d.ts +1184 -0
  150. package/types/webgl/loading.d.ts +482 -0
  151. package/types/webgl/material.d.ts +2656 -0
  152. package/types/webgl/p5.Camera.d.ts +3023 -0
  153. package/types/webgl/p5.DataArray.d.ts +61 -0
  154. package/types/webgl/p5.Framebuffer.d.ts +760 -0
  155. package/types/webgl/p5.Geometry.d.ts +1191 -0
  156. package/types/webgl/p5.Quat.d.ts +45 -0
  157. package/types/webgl/p5.RendererGL.d.ts +234 -0
  158. package/types/webgl/p5.Shader.d.ts +660 -0
  159. package/types/webgl/p5.Texture.d.ts +61 -0
  160. package/types/webgl/text.d.ts +74 -0
@@ -0,0 +1,740 @@
1
+ // This file is auto-generated from JSDoc documentation
2
+
3
+ import p5 from 'p5';
4
+
5
+ declare module 'p5' {
6
+ /**
7
+ * Draws a Bézier curve.Bézier curves can form shapes and curves that slope gently. They're defined
8
+ * by two anchor points and two control points. Bézier curves provide more
9
+ * control than the spline curves created with the
10
+ * curve() function.The first two parameters, `x1` and `y1`, set the first anchor point. The
11
+ * first anchor point is where the curve starts.The next four parameters, `x2`, `y2`, `x3`, and `y3`, set the two control
12
+ * points. The control points "pull" the curve towards them.The seventh and eighth parameters, `x4` and `y4`, set the last anchor
13
+ * point. The last anchor point is where the curve ends.Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of
14
+ * `bezier()` has twelve arguments because each point has x-, y-,
15
+ * and z-coordinates.
16
+ *
17
+ * @param x-coordinate of the first anchor point.
18
+ * @param y-coordinate of the first anchor point.
19
+ * @param x-coordinate of the first control point.
20
+ * @param y-coordinate of the first control point.
21
+ * @param x-coordinate of the second control point.
22
+ * @param y-coordinate of the second control point.
23
+ * @param x-coordinate of the second anchor point.
24
+ * @param y-coordinate of the second anchor point.
25
+ * @example <div>
26
+ * <code>
27
+ * function setup() {
28
+ * createCanvas(100, 100);
29
+ *
30
+ * background(200);
31
+ *
32
+ * // Draw the anchor points in black.
33
+ * stroke(0);
34
+ * strokeWeight(5);
35
+ * point(85, 20);
36
+ * point(15, 80);
37
+ *
38
+ * // Draw the control points in red.
39
+ * stroke(255, 0, 0);
40
+ * point(10, 10);
41
+ * point(90, 90);
42
+ *
43
+ * // Draw a black bezier curve.
44
+ * noFill();
45
+ * stroke(0);
46
+ * strokeWeight(1);
47
+ * bezier(85, 20, 10, 10, 90, 90, 15, 80);
48
+ *
49
+ * // Draw red lines from the anchor points to the control points.
50
+ * stroke(255, 0, 0);
51
+ * line(85, 20, 10, 10);
52
+ * line(15, 80, 90, 90);
53
+ *
54
+ * describe(
55
+ * 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.'
56
+ * );
57
+ * }
58
+ * </code>
59
+ * </div>
60
+ *
61
+ * <div>
62
+ * <code>
63
+ * // Click the mouse near the red dot in the top-left corner
64
+ * // and drag to change the curve's shape.
65
+ *
66
+ * let x2 = 10;
67
+ * let y2 = 10;
68
+ * let isChanging = false;
69
+ *
70
+ * function setup() {
71
+ * createCanvas(100, 100);
72
+ *
73
+ * describe(
74
+ * 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.'
75
+ * );
76
+ * }
77
+ *
78
+ * function draw() {
79
+ * background(200);
80
+ *
81
+ * // Draw the anchor points in black.
82
+ * stroke(0);
83
+ * strokeWeight(5);
84
+ * point(85, 20);
85
+ * point(15, 80);
86
+ *
87
+ * // Draw the control points in red.
88
+ * stroke(255, 0, 0);
89
+ * point(x2, y2);
90
+ * point(90, 90);
91
+ *
92
+ * // Draw a black bezier curve.
93
+ * noFill();
94
+ * stroke(0);
95
+ * strokeWeight(1);
96
+ * bezier(85, 20, x2, y2, 90, 90, 15, 80);
97
+ *
98
+ * // Draw red lines from the anchor points to the control points.
99
+ * stroke(255, 0, 0);
100
+ * line(85, 20, x2, y2);
101
+ * line(15, 80, 90, 90);
102
+ * }
103
+ *
104
+ * // Start changing the first control point if the user clicks near it.
105
+ * function mousePressed() {
106
+ * if (dist(mouseX, mouseY, x2, y2) < 20) {
107
+ * isChanging = true;
108
+ * }
109
+ * }
110
+ *
111
+ * // Stop changing the first control point when the user releases the mouse.
112
+ * function mouseReleased() {
113
+ * isChanging = false;
114
+ * }
115
+ *
116
+ * // Update the first control point while the user drags the mouse.
117
+ * function mouseDragged() {
118
+ * if (isChanging === true) {
119
+ * x2 = mouseX;
120
+ * y2 = mouseY;
121
+ * }
122
+ * }
123
+ * </code>
124
+ * </div>
125
+ *
126
+ * <div>
127
+ * <code>
128
+ * function setup() {
129
+ * createCanvas(100, 100);
130
+ *
131
+ * background('skyblue');
132
+ *
133
+ * // Draw the red balloon.
134
+ * fill('red');
135
+ * bezier(50, 60, 5, 15, 95, 15, 50, 60);
136
+ *
137
+ * // Draw the balloon string.
138
+ * line(50, 60, 50, 80);
139
+ *
140
+ * describe('A red balloon in a blue sky.');
141
+ * }
142
+ * </code>
143
+ * </div>
144
+ *
145
+ * <div>
146
+ * <code>
147
+ * function setup() {
148
+ * createCanvas(100, 100, WEBGL);
149
+ *
150
+ * describe('A red balloon in a blue sky. The balloon rotates slowly, revealing that it is flat.');
151
+ * }
152
+ *
153
+ * function draw() {
154
+ * background('skyblue');
155
+ *
156
+ * // Rotate around the y-axis.
157
+ * rotateY(frameCount * 0.01);
158
+ *
159
+ * // Draw the red balloon.
160
+ * fill('red');
161
+ * bezier(0, 0, 0, -45, -45, 0, 45, -45, 0, 0, 0, 0);
162
+ *
163
+ * // Draw the balloon string.
164
+ * line(0, 0, 0, 0, 20, 0);
165
+ * }
166
+ * </code>
167
+ * </div>
168
+ */
169
+ function bezier(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
170
+
171
+ /**
172
+ * @param z-coordinate of the first anchor point.
173
+ * @param z-coordinate of the first control point.
174
+ * @param z-coordinate of the second control point.
175
+ * @param z-coordinate of the second anchor point.
176
+ */
177
+ function bezier(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, x3: number, y3: number, z3: number, x4: number, y4: number, z4: number): void;
178
+
179
+ /**
180
+ * Calculates coordinates along a Bézier curve using interpolation.`bezierPoint()` calculates coordinates along a Bézier curve using the
181
+ * anchor and control points. It expects points in the same order as the
182
+ * bezier() function. `bezierPoint()` works one axis
183
+ * at a time. Passing the anchor and control points' x-coordinates will
184
+ * calculate the x-coordinate of a point on the curve. Passing the anchor and
185
+ * control points' y-coordinates will calculate the y-coordinate of a point on
186
+ * the curve.The first parameter, `a`, is the coordinate of the first anchor point.The second and third parameters, `b` and `c`, are the coordinates of the
187
+ * control points.The fourth parameter, `d`, is the coordinate of the last anchor point.The fifth parameter, `t`, is the amount to interpolate along the curve. 0
188
+ * is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
189
+ * between them.
190
+ *
191
+ * @param coordinate of first control point.
192
+ * @param coordinate of first anchor point.
193
+ * @param coordinate of second anchor point.
194
+ * @param coordinate of second control point.
195
+ * @param amount to interpolate between 0 and 1.
196
+ * @return coordinate of the point on the curve.
197
+ * @example <div>
198
+ * <code>
199
+ * function setup() {
200
+ * createCanvas(100, 100);
201
+ *
202
+ * background(200);
203
+ *
204
+ * // Set the coordinates for the curve's anchor and control points.
205
+ * let x1 = 85;
206
+ * let x2 = 10;
207
+ * let x3 = 90;
208
+ * let x4 = 15;
209
+ * let y1 = 20;
210
+ * let y2 = 10;
211
+ * let y3 = 90;
212
+ * let y4 = 80;
213
+ *
214
+ * // Style the curve.
215
+ * noFill();
216
+ *
217
+ * // Draw the curve.
218
+ * bezier(x1, y1, x2, y2, x3, y3, x4, y4);
219
+ *
220
+ * // Draw circles along the curve's path.
221
+ * fill(255);
222
+ *
223
+ * // Top-right.
224
+ * let x = bezierPoint(x1, x2, x3, x4, 0);
225
+ * let y = bezierPoint(y1, y2, y3, y4, 0);
226
+ * circle(x, y, 5);
227
+ *
228
+ * // Center.
229
+ * x = bezierPoint(x1, x2, x3, x4, 0.5);
230
+ * y = bezierPoint(y1, y2, y3, y4, 0.5);
231
+ * circle(x, y, 5);
232
+ *
233
+ * // Bottom-left.
234
+ * x = bezierPoint(x1, x2, x3, x4, 1);
235
+ * y = bezierPoint(y1, y2, y3, y4, 1);
236
+ * circle(x, y, 5);
237
+ *
238
+ * describe('A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles.');
239
+ * }
240
+ * </code>
241
+ * </div>
242
+ *
243
+ * <div>
244
+ * <code>
245
+ * function setup() {
246
+ * createCanvas(100, 100);
247
+ *
248
+ * describe('A black s-curve on a gray square. A white circle moves back and forth along the curve.');
249
+ * }
250
+ *
251
+ * function draw() {
252
+ * background(200);
253
+ *
254
+ * // Set the coordinates for the curve's anchor and control points.
255
+ * let x1 = 85;
256
+ * let x2 = 10;
257
+ * let x3 = 90;
258
+ * let x4 = 15;
259
+ * let y1 = 20;
260
+ * let y2 = 10;
261
+ * let y3 = 90;
262
+ * let y4 = 80;
263
+ *
264
+ * // Draw the curve.
265
+ * noFill();
266
+ * bezier(x1, y1, x2, y2, x3, y3, x4, y4);
267
+ *
268
+ * // Calculate the circle's coordinates.
269
+ * let t = 0.5 * sin(frameCount * 0.01) + 0.5;
270
+ * let x = bezierPoint(x1, x2, x3, x4, t);
271
+ * let y = bezierPoint(y1, y2, y3, y4, t);
272
+ *
273
+ * // Draw the circle.
274
+ * fill(255);
275
+ * circle(x, y, 5);
276
+ * }
277
+ * </code>
278
+ * </div>
279
+ */
280
+ function bezierPoint(a: number, b: number, c: number, d: number, t: number): number;
281
+
282
+ /**
283
+ * Calculates coordinates along a line that's tangent to a Bézier curve.Tangent lines skim the surface of a curve. A tangent line's slope equals
284
+ * the curve's slope at the point where it intersects.`bezierTangent()` calculates coordinates along a tangent line using the
285
+ * Bézier curve's anchor and control points. It expects points in the same
286
+ * order as the bezier() function. `bezierTangent()`
287
+ * works one axis at a time. Passing the anchor and control points'
288
+ * x-coordinates will calculate the x-coordinate of a point on the tangent
289
+ * line. Passing the anchor and control points' y-coordinates will calculate
290
+ * the y-coordinate of a point on the tangent line.The first parameter, `a`, is the coordinate of the first anchor point.The second and third parameters, `b` and `c`, are the coordinates of the
291
+ * control points.The fourth parameter, `d`, is the coordinate of the last anchor point.The fifth parameter, `t`, is the amount to interpolate along the curve. 0
292
+ * is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
293
+ * between them.
294
+ *
295
+ * @param coordinate of first anchor point.
296
+ * @param coordinate of first control point.
297
+ * @param coordinate of second control point.
298
+ * @param coordinate of second anchor point.
299
+ * @param amount to interpolate between 0 and 1.
300
+ * @return coordinate of a point on the tangent line.
301
+ * @example <div>
302
+ * <code>
303
+ * function setup() {
304
+ * createCanvas(100, 100);
305
+ *
306
+ * background(200);
307
+ *
308
+ * // Set the coordinates for the curve's anchor and control points.
309
+ * let x1 = 85;
310
+ * let x2 = 10;
311
+ * let x3 = 90;
312
+ * let x4 = 15;
313
+ * let y1 = 20;
314
+ * let y2 = 10;
315
+ * let y3 = 90;
316
+ * let y4 = 80;
317
+ *
318
+ * // Style the curve.
319
+ * noFill();
320
+ *
321
+ * // Draw the curve.
322
+ * bezier(x1, y1, x2, y2, x3, y3, x4, y4);
323
+ *
324
+ * // Draw tangents along the curve's path.
325
+ * fill(255);
326
+ *
327
+ * // Top-right circle.
328
+ * stroke(0);
329
+ * let x = bezierPoint(x1, x2, x3, x4, 0);
330
+ * let y = bezierPoint(y1, y2, y3, y4, 0);
331
+ * circle(x, y, 5);
332
+ *
333
+ * // Top-right tangent line.
334
+ * // Scale the tangent point to draw a shorter line.
335
+ * stroke(255, 0, 0);
336
+ * let tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0);
337
+ * let ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0);
338
+ * line(x + tx, y + ty, x - tx, y - ty);
339
+ *
340
+ * // Center circle.
341
+ * stroke(0);
342
+ * x = bezierPoint(x1, x2, x3, x4, 0.5);
343
+ * y = bezierPoint(y1, y2, y3, y4, 0.5);
344
+ * circle(x, y, 5);
345
+ *
346
+ * // Center tangent line.
347
+ * // Scale the tangent point to draw a shorter line.
348
+ * stroke(255, 0, 0);
349
+ * tx = 0.1 * bezierTangent(x1, x2, x3, x4, 0.5);
350
+ * ty = 0.1 * bezierTangent(y1, y2, y3, y4, 0.5);
351
+ * line(x + tx, y + ty, x - tx, y - ty);
352
+ *
353
+ * // Bottom-left circle.
354
+ * stroke(0);
355
+ * x = bezierPoint(x1, x2, x3, x4, 1);
356
+ * y = bezierPoint(y1, y2, y3, y4, 1);
357
+ * circle(x, y, 5);
358
+ *
359
+ * // Bottom-left tangent.
360
+ * // Scale the tangent point to draw a shorter line.
361
+ * stroke(255, 0, 0);
362
+ * tx = 0.1 * bezierTangent(x1, x2, x3, x4, 1);
363
+ * ty = 0.1 * bezierTangent(y1, y2, y3, y4, 1);
364
+ * line(x + tx, y + ty, x - tx, y - ty);
365
+ *
366
+ * describe(
367
+ * 'A black s-curve on a gray square. The endpoints and center of the curve are marked with white circles. Red tangent lines extend from the white circles.'
368
+ * );
369
+ * }
370
+ * </code>
371
+ * </div>
372
+ */
373
+ function bezierTangent(a: number, b: number, c: number, d: number, t: number): number;
374
+
375
+ /**
376
+ * Draws a curve using a Catmull-Rom spline.Spline curves can form shapes and curves that slope gently. They’re like
377
+ * cables that are attached to a set of points. Splines are defined by two
378
+ * anchor points and two control points.The first two parameters, `x1` and `y1`, set the first control point. This
379
+ * point isn’t drawn and can be thought of as the curve’s starting point.The next four parameters, `x2`, `y2`, `x3`, and `y3`, set the two anchor
380
+ * points. The anchor points are the start and end points of the curve’s
381
+ * visible segment.The seventh and eighth parameters, `x4` and `y4`, set the last control
382
+ * point. This point isn’t drawn and can be thought of as the curve’s ending
383
+ * point.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
384
+ * `spline()` has twelve arguments because each point has x-, y-, and
385
+ * z-coordinates.
386
+ *
387
+ * @param x-coordinate of the first control point.
388
+ * @param y-coordinate of the first control point.
389
+ * @param x-coordinate of the first anchor point.
390
+ * @param y-coordinate of the first anchor point.
391
+ * @param x-coordinate of the second anchor point.
392
+ * @param y-coordinate of the second anchor point.
393
+ * @param x-coordinate of the second control point.
394
+ * @param y-coordinate of the second control point.
395
+ * @example <div>
396
+ * <code>
397
+ * function setup() {
398
+ * createCanvas(100, 100);
399
+ *
400
+ * background(200);
401
+ *
402
+ * // Draw a black spline curve.
403
+ * noFill();
404
+ * strokeWeight(1);
405
+ * stroke(0);
406
+ * spline(5, 26, 73, 24, 73, 61, 15, 65);
407
+ *
408
+ * // Draw red spline curves from the anchor points to the control points.
409
+ * stroke(255, 0, 0);
410
+ * spline(5, 26, 5, 26, 73, 24, 73, 61);
411
+ * spline(73, 24, 73, 61, 15, 65, 15, 65);
412
+ *
413
+ * // Draw the anchor points in black.
414
+ * strokeWeight(5);
415
+ * stroke(0);
416
+ * point(73, 24);
417
+ * point(73, 61);
418
+ *
419
+ * // Draw the control points in red.
420
+ * stroke(255, 0, 0);
421
+ * point(5, 26);
422
+ * point(15, 65);
423
+ *
424
+ * describe(
425
+ * 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.'
426
+ * );
427
+ * }
428
+ * </code>
429
+ * </div>
430
+ *
431
+ * <div>
432
+ * <code>
433
+ * let x1 = 5;
434
+ * let y1 = 26;
435
+ * let isChanging = false;
436
+ *
437
+ * function setup() {
438
+ * createCanvas(100, 100);
439
+ *
440
+ * describe(
441
+ * 'A gray square with a curve drawn in three segments. The curve is a sideways U shape with red segments on top and bottom, and a black segment on the right. The endpoints of all the segments are marked with dots.'
442
+ * );
443
+ * }
444
+ *
445
+ * function draw() {
446
+ * background(200);
447
+ *
448
+ * // Draw a black spline curve.
449
+ * noFill();
450
+ * strokeWeight(1);
451
+ * stroke(0);
452
+ * spline(x1, y1, 73, 24, 73, 61, 15, 65);
453
+ *
454
+ * // Draw red spline curves from the anchor points to the control points.
455
+ * stroke(255, 0, 0);
456
+ * spline(x1, y1, x1, y1, 73, 24, 73, 61);
457
+ * spline(73, 24, 73, 61, 15, 65, 15, 65);
458
+ *
459
+ * // Draw the anchor points in black.
460
+ * strokeWeight(5);
461
+ * stroke(0);
462
+ * point(73, 24);
463
+ * point(73, 61);
464
+ *
465
+ * // Draw the control points in red.
466
+ * stroke(255, 0, 0);
467
+ * point(x1, y1);
468
+ * point(15, 65);
469
+ * }
470
+ *
471
+ * // Start changing the first control point if the user clicks near it.
472
+ * function mousePressed() {
473
+ * if (dist(mouseX, mouseY, x1, y1) < 20) {
474
+ * isChanging = true;
475
+ * }
476
+ * }
477
+ *
478
+ * // Stop changing the first control point when the user releases the mouse.
479
+ * function mouseReleased() {
480
+ * isChanging = false;
481
+ * }
482
+ *
483
+ * // Update the first control point while the user drags the mouse.
484
+ * function mouseDragged() {
485
+ * if (isChanging === true) {
486
+ * x1 = mouseX;
487
+ * y1 = mouseY;
488
+ * }
489
+ * }
490
+ * </code>
491
+ * </div>
492
+ *
493
+ * <div>
494
+ * <code>
495
+ * function setup() {
496
+ * createCanvas(100, 100);
497
+ *
498
+ * background('skyblue');
499
+ *
500
+ * // Draw the red balloon.
501
+ * fill('red');
502
+ * spline(-150, 275, 50, 60, 50, 60, 250, 275);
503
+ *
504
+ * // Draw the balloon string.
505
+ * line(50, 60, 50, 80);
506
+ *
507
+ * describe('A red balloon in a blue sky.');
508
+ * }
509
+ * </code>
510
+ * </div>
511
+ *
512
+ * <div>
513
+ * <code>
514
+ * function setup() {
515
+ * createCanvas(100, 100, WEBGL);
516
+ *
517
+ * describe('A red balloon in a blue sky.');
518
+ * }
519
+ *
520
+ * function draw() {
521
+ * background('skyblue');
522
+ *
523
+ * // Rotate around the y-axis.
524
+ * rotateY(frameCount * 0.01);
525
+ *
526
+ * // Draw the red balloon.
527
+ * fill('red');
528
+ * spline(-200, 225, 0, 0, 10, 0, 0, 10, 0, 200, 225, 0);
529
+ *
530
+ * // Draw the balloon string.
531
+ * line(0, 10, 0, 0, 30, 0);
532
+ * }
533
+ * </code>
534
+ * </div>
535
+ */
536
+ function spline(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
537
+
538
+ /**
539
+ * @param z-coordinate of the first control point.
540
+ * @param z-coordinate of the first anchor point.
541
+ * @param z-coordinate of the second anchor point.
542
+ * @param z-coordinate of the second control point.
543
+ */
544
+ function spline(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, x3: number, y3: number, z3: number, x4: number, y4: number, z4: number): void;
545
+
546
+ /**
547
+ * Calculates coordinates along a spline curve using interpolation.`splinePoint()` calculates coordinates along a spline curve using the
548
+ * anchor and control points. It expects points in the same order as the
549
+ * spline() function. `splinePoint()` works one axis
550
+ * at a time. Passing the anchor and control points' x-coordinates will
551
+ * calculate the x-coordinate of a point on the curve. Passing the anchor and
552
+ * control points' y-coordinates will calculate the y-coordinate of a point on
553
+ * the curve.The first parameter, `a`, is the coordinate of the first control point.The second and third parameters, `b` and `c`, are the coordinates of the
554
+ * anchor points.The fourth parameter, `d`, is the coordinate of the last control point.The fifth parameter, `t`, is the amount to interpolate along the curve. 0
555
+ * is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
556
+ * between them.
557
+ *
558
+ * @param coordinate of first anchor point.
559
+ * @param coordinate of first control point.
560
+ * @param coordinate of second control point.
561
+ * @param coordinate of second anchor point.
562
+ * @param amount to interpolate between 0 and 1.
563
+ * @return coordinate of a point on the curve.
564
+ * @example <div>
565
+ * <code>
566
+ * function setup() {
567
+ * createCanvas(100, 100);
568
+ *
569
+ * background(200);
570
+ *
571
+ * // Set the coordinates for the curve's anchor and control points.
572
+ * let x1 = 5;
573
+ * let y1 = 26;
574
+ * let x2 = 73;
575
+ * let y2 = 24;
576
+ * let x3 = 73;
577
+ * let y3 = 61;
578
+ * let x4 = 15;
579
+ * let y4 = 65;
580
+ *
581
+ * // Draw the curve.
582
+ * noFill();
583
+ * spline(x1, y1, x2, y2, x3, y3, x4, y4);
584
+ *
585
+ * // Draw circles along the curve's path.
586
+ * fill(255);
587
+ *
588
+ * // Top.
589
+ * let x = splinePoint(x1, x2, x3, x4, 0);
590
+ * let y = splinePoint(y1, y2, y3, y4, 0);
591
+ * circle(x, y, 5);
592
+ *
593
+ * // Center.
594
+ * x = splinePoint(x1, x2, x3, x4, 0.5);
595
+ * y = splinePoint(y1, y2, y3, y4, 0.5);
596
+ * circle(x, y, 5);
597
+ *
598
+ * // Bottom.
599
+ * x = splinePoint(x1, x2, x3, x4, 1);
600
+ * y = splinePoint(y1, y2, y3, y4, 1);
601
+ * circle(x, y, 5);
602
+ *
603
+ * describe('A black curve on a gray square. The endpoints and center of the curve are marked with white circles.');
604
+ * }
605
+ * </code>
606
+ * </div>
607
+ *
608
+ * <div>
609
+ * <code>
610
+ * function setup() {
611
+ * createCanvas(100, 100);
612
+ *
613
+ * describe('A black curve on a gray square. A white circle moves back and forth along the curve.');
614
+ * }
615
+ *
616
+ * function draw() {
617
+ * background(200);
618
+ *
619
+ * // Set the coordinates for the curve's anchor and control points.
620
+ * let x1 = 5;
621
+ * let y1 = 26;
622
+ * let x2 = 73;
623
+ * let y2 = 24;
624
+ * let x3 = 73;
625
+ * let y3 = 61;
626
+ * let x4 = 15;
627
+ * let y4 = 65;
628
+ *
629
+ * // Draw the curve.
630
+ * noFill();
631
+ * spline(x1, y1, x2, y2, x3, y3, x4, y4);
632
+ *
633
+ * // Calculate the circle's coordinates.
634
+ * let t = 0.5 * sin(frameCount * 0.01) + 0.5;
635
+ * let x = splinePoint(x1, x2, x3, x4, t);
636
+ * let y = splinePoint(y1, y2, y3, y4, t);
637
+ *
638
+ * // Draw the circle.
639
+ * fill(255);
640
+ * circle(x, y, 5);
641
+ * }
642
+ * </code>
643
+ * </div>
644
+ */
645
+ function splinePoint(a: number, b: number, c: number, d: number, t: number): number;
646
+
647
+ /**
648
+ * Calculates coordinates along a line that's tangent to a spline curve.Tangent lines skim the surface of a curve. A tangent line's slope equals
649
+ * the curve's slope at the point where it intersects.`splineTangent()` calculates coordinates along a tangent line using the
650
+ * spline curve's anchor and control points. It expects points in the same
651
+ * order as the spline() function. `splineTangent()`
652
+ * works one axis at a time. Passing the anchor and control points'
653
+ * x-coordinates will calculate the x-coordinate of a point on the tangent
654
+ * line. Passing the anchor and control points' y-coordinates will calculate
655
+ * the y-coordinate of a point on the tangent line.The first parameter, `a`, is the coordinate of the first control point.The second and third parameters, `b` and `c`, are the coordinates of the
656
+ * anchor points.The fourth parameter, `d`, is the coordinate of the last control point.The fifth parameter, `t`, is the amount to interpolate along the curve. 0
657
+ * is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
658
+ * between them.
659
+ *
660
+ * @param coordinate of first control point.
661
+ * @param coordinate of first anchor point.
662
+ * @param coordinate of second anchor point.
663
+ * @param coordinate of second control point.
664
+ * @param amount to interpolate between 0 and 1.
665
+ * @return coordinate of a point on the tangent line.
666
+ * @example <div>
667
+ * <code>
668
+ * function setup() {
669
+ * createCanvas(100, 100);
670
+ *
671
+ * background(200);
672
+ *
673
+ * // Set the coordinates for the curve's anchor and control points.
674
+ * let x1 = 5;
675
+ * let y1 = 26;
676
+ * let x2 = 73;
677
+ * let y2 = 24;
678
+ * let x3 = 73;
679
+ * let y3 = 61;
680
+ * let x4 = 15;
681
+ * let y4 = 65;
682
+ *
683
+ * // Draw the curve.
684
+ * noFill();
685
+ * spline(x1, y1, x2, y2, x3, y3, x4, y4);
686
+ *
687
+ * // Draw tangents along the curve's path.
688
+ * fill(255);
689
+ *
690
+ * // Top circle.
691
+ * stroke(0);
692
+ * let x = splinePoint(x1, x2, x3, x4, 0);
693
+ * let y = splinePoint(y1, y2, y3, y4, 0);
694
+ * circle(x, y, 5);
695
+ *
696
+ * // Top tangent line.
697
+ * // Scale the tangent point to draw a shorter line.
698
+ * stroke(255, 0, 0);
699
+ * let tx = 0.2 * splineTangent(x1, x2, x3, x4, 0);
700
+ * let ty = 0.2 * splineTangent(y1, y2, y3, y4, 0);
701
+ * line(x + tx, y + ty, x - tx, y - ty);
702
+ *
703
+ * // Center circle.
704
+ * stroke(0);
705
+ * x = splinePoint(x1, x2, x3, x4, 0.5);
706
+ * y = splinePoint(y1, y2, y3, y4, 0.5);
707
+ * circle(x, y, 5);
708
+ *
709
+ * // Center tangent line.
710
+ * // Scale the tangent point to draw a shorter line.
711
+ * stroke(255, 0, 0);
712
+ * tx = 0.2 * splineTangent(x1, x2, x3, x4, 0.5);
713
+ * ty = 0.2 * splineTangent(y1, y2, y3, y4, 0.5);
714
+ * line(x + tx, y + ty, x - tx, y - ty);
715
+ *
716
+ * // Bottom circle.
717
+ * stroke(0);
718
+ * x = splinePoint(x1, x2, x3, x4, 1);
719
+ * y = splinePoint(y1, y2, y3, y4, 1);
720
+ * circle(x, y, 5);
721
+ *
722
+ * // Bottom tangent line.
723
+ * // Scale the tangent point to draw a shorter line.
724
+ * stroke(255, 0, 0);
725
+ * tx = 0.2 * splineTangent(x1, x2, x3, x4, 1);
726
+ * ty = 0.2 * splineTangent(y1, y2, y3, y4, 1);
727
+ * line(x + tx, y + ty, x - tx, y - ty);
728
+ *
729
+ * describe(
730
+ * 'A black curve on a gray square. A white circle moves back and forth along the curve.'
731
+ * );
732
+ * }
733
+ * </code>
734
+ * </div>
735
+ */
736
+ function splineTangent(a: number, b: number, c: number, d: number, t: number): number;
737
+
738
+ }
739
+
740
+ export default function curves(p5: any, fn: any): void;