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
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { e as CORNER, f as TWO_PI, g as HALF_PI, h as PI } from '../constants-tYr0tCl8.js';
|
|
2
|
+
import canvas from '../core/helpers.js';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* @module Shape
|
|
3
6
|
* @submodule 2D Primitives
|
|
@@ -6,8 +9,6 @@
|
|
|
6
9
|
* @requires constants
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
|
-
import * as constants from '../core/constants';
|
|
10
|
-
import canvas from '../core/helpers';
|
|
11
12
|
|
|
12
13
|
function primitives(p5, fn){
|
|
13
14
|
/**
|
|
@@ -46,8 +47,8 @@ function primitives(p5, fn){
|
|
|
46
47
|
// adjustments made in the steps that precede it.
|
|
47
48
|
|
|
48
49
|
// Constrain both start and stop to [0,TWO_PI).
|
|
49
|
-
start = start -
|
|
50
|
-
stop = stop -
|
|
50
|
+
start = start - TWO_PI * Math.floor(start / TWO_PI);
|
|
51
|
+
stop = stop - TWO_PI * Math.floor(stop / TWO_PI);
|
|
51
52
|
|
|
52
53
|
// Get the angular separation between the requested start and stop points.
|
|
53
54
|
//
|
|
@@ -63,30 +64,30 @@ function primitives(p5, fn){
|
|
|
63
64
|
// epsilon smaller...)
|
|
64
65
|
separation = Math.min(
|
|
65
66
|
Math.abs(start - stop),
|
|
66
|
-
|
|
67
|
+
TWO_PI - Math.abs(start - stop)
|
|
67
68
|
);
|
|
68
69
|
|
|
69
70
|
// Optionally adjust the angles to counter linear scaling.
|
|
70
71
|
if (correctForScaling) {
|
|
71
|
-
if (start <=
|
|
72
|
+
if (start <= HALF_PI) {
|
|
72
73
|
start = Math.atan(width / height * Math.tan(start));
|
|
73
|
-
} else if (start >
|
|
74
|
-
start = Math.atan(width / height * Math.tan(start)) +
|
|
74
|
+
} else if (start > HALF_PI && start <= 3 * HALF_PI) {
|
|
75
|
+
start = Math.atan(width / height * Math.tan(start)) + PI;
|
|
75
76
|
} else {
|
|
76
|
-
start = Math.atan(width / height * Math.tan(start)) +
|
|
77
|
+
start = Math.atan(width / height * Math.tan(start)) + TWO_PI;
|
|
77
78
|
}
|
|
78
|
-
if (stop <=
|
|
79
|
+
if (stop <= HALF_PI) {
|
|
79
80
|
stop = Math.atan(width / height * Math.tan(stop));
|
|
80
|
-
} else if (stop >
|
|
81
|
-
stop = Math.atan(width / height * Math.tan(stop)) +
|
|
81
|
+
} else if (stop > HALF_PI && stop <= 3 * HALF_PI) {
|
|
82
|
+
stop = Math.atan(width / height * Math.tan(stop)) + PI;
|
|
82
83
|
} else {
|
|
83
|
-
stop = Math.atan(width / height * Math.tan(stop)) +
|
|
84
|
+
stop = Math.atan(width / height * Math.tan(stop)) + TWO_PI;
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
// Ensure that start <= stop < start + TWO_PI.
|
|
88
89
|
if (start > stop) {
|
|
89
|
-
stop +=
|
|
90
|
+
stop += TWO_PI;
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
return {
|
|
@@ -1341,7 +1342,7 @@ function primitives(p5, fn){
|
|
|
1341
1342
|
// removed by modeAdjust(). This results in flipped/mirrored rendering,
|
|
1342
1343
|
// which is especially noticable when using WEGBL rendering and texture().
|
|
1343
1344
|
// Note that this behavior only applies to rect(), NOT to ellipse() and arc().
|
|
1344
|
-
if (this._renderer.states.rectMode ===
|
|
1345
|
+
if (this._renderer.states.rectMode === CORNER) {
|
|
1345
1346
|
vals.w = arguments[2];
|
|
1346
1347
|
vals.h = arguments[3];
|
|
1347
1348
|
}
|
|
@@ -1445,8 +1446,8 @@ function primitives(p5, fn){
|
|
|
1445
1446
|
};
|
|
1446
1447
|
}
|
|
1447
1448
|
|
|
1448
|
-
export default primitives;
|
|
1449
|
-
|
|
1450
1449
|
if(typeof p5 !== 'undefined'){
|
|
1451
1450
|
primitives(p5, p5.prototype);
|
|
1452
1451
|
}
|
|
1452
|
+
|
|
1453
|
+
export { primitives as default };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { e as CORNER, i as CORNERS, a as RADIUS, C as CENTER, j as ROUND, S as SQUARE, k as PROJECT, B as BEVEL, l as MITER } from '../constants-tYr0tCl8.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @module Shape
|
|
3
5
|
* @submodule Attributes
|
|
@@ -6,7 +8,6 @@
|
|
|
6
8
|
* @requires constants
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
|
-
import * as constants from '../core/constants';
|
|
10
11
|
|
|
11
12
|
function attributes(p5, fn){
|
|
12
13
|
/**
|
|
@@ -87,10 +88,10 @@ function attributes(p5, fn){
|
|
|
87
88
|
fn.ellipseMode = function(m) {
|
|
88
89
|
// p5._validateParameters('ellipseMode', arguments);
|
|
89
90
|
if (
|
|
90
|
-
m ===
|
|
91
|
-
m ===
|
|
92
|
-
m ===
|
|
93
|
-
m ===
|
|
91
|
+
m === CORNER ||
|
|
92
|
+
m === CORNERS ||
|
|
93
|
+
m === RADIUS ||
|
|
94
|
+
m === CENTER
|
|
94
95
|
) {
|
|
95
96
|
this._renderer.states.setValue('ellipseMode', m);
|
|
96
97
|
}
|
|
@@ -287,10 +288,10 @@ function attributes(p5, fn){
|
|
|
287
288
|
fn.rectMode = function(m) {
|
|
288
289
|
// p5._validateParameters('rectMode', arguments);
|
|
289
290
|
if (
|
|
290
|
-
m ===
|
|
291
|
-
m ===
|
|
292
|
-
m ===
|
|
293
|
-
m ===
|
|
291
|
+
m === CORNER ||
|
|
292
|
+
m === CORNERS ||
|
|
293
|
+
m === RADIUS ||
|
|
294
|
+
m === CENTER
|
|
294
295
|
) {
|
|
295
296
|
this._renderer.states.setValue('rectMode', m);
|
|
296
297
|
}
|
|
@@ -425,9 +426,9 @@ function attributes(p5, fn){
|
|
|
425
426
|
fn.strokeCap = function(cap) {
|
|
426
427
|
// p5._validateParameters('strokeCap', arguments);
|
|
427
428
|
if (
|
|
428
|
-
cap ===
|
|
429
|
-
cap ===
|
|
430
|
-
cap ===
|
|
429
|
+
cap === ROUND ||
|
|
430
|
+
cap === SQUARE ||
|
|
431
|
+
cap === PROJECT
|
|
431
432
|
) {
|
|
432
433
|
this._renderer.strokeCap(cap);
|
|
433
434
|
}
|
|
@@ -524,9 +525,9 @@ function attributes(p5, fn){
|
|
|
524
525
|
fn.strokeJoin = function(join) {
|
|
525
526
|
// p5._validateParameters('strokeJoin', arguments);
|
|
526
527
|
if (
|
|
527
|
-
join ===
|
|
528
|
-
join ===
|
|
529
|
-
join ===
|
|
528
|
+
join === ROUND ||
|
|
529
|
+
join === BEVEL ||
|
|
530
|
+
join === MITER
|
|
530
531
|
) {
|
|
531
532
|
this._renderer.strokeJoin(join);
|
|
532
533
|
}
|
|
@@ -595,8 +596,8 @@ function attributes(p5, fn){
|
|
|
595
596
|
};
|
|
596
597
|
}
|
|
597
598
|
|
|
598
|
-
export default attributes;
|
|
599
|
-
|
|
600
599
|
if(typeof p5 !== 'undefined'){
|
|
601
600
|
attributes(p5, p5.prototype);
|
|
602
601
|
}
|
|
602
|
+
|
|
603
|
+
export { attributes as default };
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { C as Color } from '../creating_reading-Cr8L2Jnm.js';
|
|
2
|
+
import { Vector } from '../math/p5.Vector.js';
|
|
3
|
+
import { I as INCLUDE, m as PATH, E as EMPTY_PATH, O as OPEN, n as CLOSE, o as POINTS, L as LINES, p as TRIANGLES, Q as QUADS, q as TRIANGLE_FAN, r as TRIANGLE_STRIP, s as QUAD_STRIP, t as EXCLUDE, J as JOIN } from '../constants-tYr0tCl8.js';
|
|
4
|
+
import 'colorjs.io/fn';
|
|
5
|
+
import '../color/color_spaces/hsb.js';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* @module Shape
|
|
3
9
|
* @submodule Custom Shapes
|
|
@@ -6,10 +12,6 @@
|
|
|
6
12
|
* @requires constants
|
|
7
13
|
*/
|
|
8
14
|
|
|
9
|
-
// REMINDER: remove .js extension (currently using it to run file locally)
|
|
10
|
-
import { Color } from '../color/p5.Color';
|
|
11
|
-
import { Vector } from '../math/p5.Vector';
|
|
12
|
-
import * as constants from '../core/constants';
|
|
13
15
|
|
|
14
16
|
// ---- UTILITY FUNCTIONS ----
|
|
15
17
|
function polylineLength(vertices) {
|
|
@@ -155,15 +157,15 @@ class Contour {
|
|
|
155
157
|
#kind;
|
|
156
158
|
primitives;
|
|
157
159
|
|
|
158
|
-
constructor(kind =
|
|
160
|
+
constructor(kind = PATH) {
|
|
159
161
|
this.#kind = kind;
|
|
160
162
|
this.primitives = [];
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
get kind() {
|
|
164
166
|
const isEmpty = this.primitives.length === 0;
|
|
165
|
-
const isPath = this.#kind ===
|
|
166
|
-
return isEmpty && isPath ?
|
|
167
|
+
const isPath = this.#kind === PATH;
|
|
168
|
+
return isEmpty && isPath ? EMPTY_PATH : this.#kind;
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
accept(visitor) {
|
|
@@ -281,7 +283,7 @@ to interpolated endpoints (a breaking change)
|
|
|
281
283
|
class SplineSegment extends Segment {
|
|
282
284
|
#vertexCapacity = Infinity;
|
|
283
285
|
_splineProperties = {
|
|
284
|
-
ends:
|
|
286
|
+
ends: INCLUDE,
|
|
285
287
|
tightness: 0
|
|
286
288
|
};
|
|
287
289
|
|
|
@@ -298,7 +300,7 @@ class SplineSegment extends Segment {
|
|
|
298
300
|
}
|
|
299
301
|
|
|
300
302
|
get canOverrideAnchor() {
|
|
301
|
-
return this._splineProperties.ends ===
|
|
303
|
+
return this._splineProperties.ends === EXCLUDE;
|
|
302
304
|
}
|
|
303
305
|
|
|
304
306
|
// assuming for now that the first interpolated vertex is always
|
|
@@ -306,7 +308,7 @@ class SplineSegment extends Segment {
|
|
|
306
308
|
// if this spline segment doesn't follow another segment,
|
|
307
309
|
// the first vertex is in an anchor
|
|
308
310
|
get _firstInterpolatedVertex() {
|
|
309
|
-
if (this._splineProperties.ends ===
|
|
311
|
+
if (this._splineProperties.ends === EXCLUDE) {
|
|
310
312
|
return this._comesAfterSegment ?
|
|
311
313
|
this.vertices[1] :
|
|
312
314
|
this.vertices[0];
|
|
@@ -333,7 +335,7 @@ class SplineSegment extends Segment {
|
|
|
333
335
|
this._splineProperties.ends = shape._splineProperties.ends;
|
|
334
336
|
this._splineProperties.tightness = shape._splineProperties.tightness;
|
|
335
337
|
|
|
336
|
-
if (this._splineProperties.ends !==
|
|
338
|
+
if (this._splineProperties.ends !== EXCLUDE) return added;
|
|
337
339
|
|
|
338
340
|
let verticesPushed = !this._belongsToShape;
|
|
339
341
|
let lastPrimitive = shape.at(-1, -1);
|
|
@@ -369,9 +371,9 @@ class SplineSegment extends Segment {
|
|
|
369
371
|
|
|
370
372
|
// override method on base class
|
|
371
373
|
getEndVertex() {
|
|
372
|
-
if (this._splineProperties.ends ===
|
|
374
|
+
if (this._splineProperties.ends === INCLUDE) {
|
|
373
375
|
return super.getEndVertex();
|
|
374
|
-
} else if (this._splineProperties.ends ===
|
|
376
|
+
} else if (this._splineProperties.ends === EXCLUDE) {
|
|
375
377
|
return this.vertices.at(-2);
|
|
376
378
|
} else {
|
|
377
379
|
return this.getStartVertex();
|
|
@@ -391,10 +393,10 @@ class SplineSegment extends Segment {
|
|
|
391
393
|
}
|
|
392
394
|
|
|
393
395
|
const prevVertex = this.getStartVertex();
|
|
394
|
-
if (this._splineProperties.ends ===
|
|
396
|
+
if (this._splineProperties.ends === INCLUDE) {
|
|
395
397
|
points.unshift(prevVertex);
|
|
396
398
|
points.push(this.vertices.at(-1));
|
|
397
|
-
} else if (this._splineProperties.ends ===
|
|
399
|
+
} else if (this._splineProperties.ends === JOIN) {
|
|
398
400
|
points.unshift(this.vertices.at(-1));
|
|
399
401
|
points.push(prevVertex, this.vertices.at(0));
|
|
400
402
|
}
|
|
@@ -412,7 +414,7 @@ class SplineSegment extends Segment {
|
|
|
412
414
|
}
|
|
413
415
|
|
|
414
416
|
close() {
|
|
415
|
-
this._splineProperties.ends =
|
|
417
|
+
this._splineProperties.ends = JOIN;
|
|
416
418
|
}
|
|
417
419
|
}
|
|
418
420
|
|
|
@@ -535,23 +537,23 @@ class PrimitiveShapeCreators {
|
|
|
535
537
|
*/
|
|
536
538
|
|
|
537
539
|
// vertex
|
|
538
|
-
creators.set(`vertex-${
|
|
539
|
-
creators.set(`vertex-${
|
|
540
|
-
creators.set(`vertex-${
|
|
541
|
-
creators.set(`vertex-${
|
|
542
|
-
creators.set(`vertex-${
|
|
543
|
-
creators.set(`vertex-${
|
|
544
|
-
creators.set(`vertex-${
|
|
545
|
-
creators.set(`vertex-${
|
|
546
|
-
creators.set(`vertex-${
|
|
540
|
+
creators.set(`vertex-${EMPTY_PATH}`, (...vertices) => new Anchor(...vertices));
|
|
541
|
+
creators.set(`vertex-${PATH}`, (...vertices) => new LineSegment(...vertices));
|
|
542
|
+
creators.set(`vertex-${POINTS}`, (...vertices) => new Point(...vertices));
|
|
543
|
+
creators.set(`vertex-${LINES}`, (...vertices) => new Line(...vertices));
|
|
544
|
+
creators.set(`vertex-${TRIANGLES}`, (...vertices) => new Triangle(...vertices));
|
|
545
|
+
creators.set(`vertex-${QUADS}`, (...vertices) => new Quad(...vertices));
|
|
546
|
+
creators.set(`vertex-${TRIANGLE_FAN}`, (...vertices) => new TriangleFan(...vertices));
|
|
547
|
+
creators.set(`vertex-${TRIANGLE_STRIP}`, (...vertices) => new TriangleStrip(...vertices));
|
|
548
|
+
creators.set(`vertex-${QUAD_STRIP}`, (...vertices) => new QuadStrip(...vertices));
|
|
547
549
|
|
|
548
550
|
// bezierVertex (constructors all take order and vertices so they can be called in a uniform way)
|
|
549
|
-
creators.set(`bezierVertex-${
|
|
550
|
-
creators.set(`bezierVertex-${
|
|
551
|
+
creators.set(`bezierVertex-${EMPTY_PATH}`, (order, ...vertices) => new Anchor(...vertices));
|
|
552
|
+
creators.set(`bezierVertex-${PATH}`, (order, ...vertices) => new BezierSegment(order, ...vertices));
|
|
551
553
|
|
|
552
554
|
// splineVertex
|
|
553
|
-
creators.set(`splineVertex-${
|
|
554
|
-
creators.set(`splineVertex-${
|
|
555
|
+
creators.set(`splineVertex-${EMPTY_PATH}`, (...vertices) => new Anchor(...vertices));
|
|
556
|
+
creators.set(`splineVertex-${PATH}`, (...vertices) => new SplineSegment(...vertices));
|
|
555
557
|
|
|
556
558
|
this.creators = creators;
|
|
557
559
|
}
|
|
@@ -587,7 +589,7 @@ class Shape {
|
|
|
587
589
|
contours = [];
|
|
588
590
|
_splineProperties = {
|
|
589
591
|
tightness: 0,
|
|
590
|
-
ends:
|
|
592
|
+
ends: INCLUDE
|
|
591
593
|
};
|
|
592
594
|
userVertexProperties = null;
|
|
593
595
|
|
|
@@ -905,18 +907,18 @@ class Shape {
|
|
|
905
907
|
this.#generalVertex('arcVertex', position, textureCoordinates);
|
|
906
908
|
}
|
|
907
909
|
|
|
908
|
-
beginContour(shapeKind =
|
|
909
|
-
if (this.at(-1)?.kind ===
|
|
910
|
+
beginContour(shapeKind = PATH) {
|
|
911
|
+
if (this.at(-1)?.kind === EMPTY_PATH) {
|
|
910
912
|
this.contours.pop();
|
|
911
913
|
}
|
|
912
914
|
this.contours.push(new Contour(shapeKind));
|
|
913
915
|
}
|
|
914
916
|
|
|
915
|
-
endContour(closeMode =
|
|
917
|
+
endContour(closeMode = OPEN, _index = this.contours.length - 1) {
|
|
916
918
|
const contour = this.at(_index);
|
|
917
|
-
if (closeMode ===
|
|
919
|
+
if (closeMode === CLOSE) {
|
|
918
920
|
// shape characteristics
|
|
919
|
-
const isPath = contour.kind ===
|
|
921
|
+
const isPath = contour.kind === PATH;
|
|
920
922
|
|
|
921
923
|
// anchor characteristics
|
|
922
924
|
const anchorVertex = this.at(_index, 0, 0);
|
|
@@ -952,7 +954,7 @@ class Shape {
|
|
|
952
954
|
}
|
|
953
955
|
}
|
|
954
956
|
|
|
955
|
-
beginShape(shapeKind =
|
|
957
|
+
beginShape(shapeKind = PATH) {
|
|
956
958
|
this.kind = shapeKind;
|
|
957
959
|
// Implicitly start a contour
|
|
958
960
|
this.beginContour(shapeKind);
|
|
@@ -963,8 +965,8 @@ class Shape {
|
|
|
963
965
|
- Might combine conditions at top, and rely on shortcircuiting.
|
|
964
966
|
Does nothing if shape is not a path or has multiple contours. Might discuss this.
|
|
965
967
|
*/
|
|
966
|
-
endShape(closeMode =
|
|
967
|
-
if (closeMode ===
|
|
968
|
+
endShape(closeMode = OPEN) {
|
|
969
|
+
if (closeMode === CLOSE) {
|
|
968
970
|
// Close the first contour, the one implicitly used for shape data
|
|
969
971
|
// added without an explicit contour
|
|
970
972
|
this.endContour(closeMode, 0);
|
|
@@ -1083,7 +1085,7 @@ class PrimitiveToPath2DConverter extends PrimitiveVisitor {
|
|
|
1083
1085
|
const shape = splineSegment._shape;
|
|
1084
1086
|
|
|
1085
1087
|
if (
|
|
1086
|
-
splineSegment._splineProperties.ends ===
|
|
1088
|
+
splineSegment._splineProperties.ends === EXCLUDE &&
|
|
1087
1089
|
!splineSegment._comesAfterSegment
|
|
1088
1090
|
) {
|
|
1089
1091
|
let startVertex = splineSegment._firstInterpolatedVertex;
|
|
@@ -2590,35 +2592,13 @@ function customShapes(p5, fn) {
|
|
|
2590
2592
|
* </code>
|
|
2591
2593
|
* </div>
|
|
2592
2594
|
*/
|
|
2593
|
-
fn.endContour = function(mode =
|
|
2595
|
+
fn.endContour = function(mode = OPEN) {
|
|
2594
2596
|
this._renderer.endContour(mode);
|
|
2595
2597
|
};
|
|
2596
2598
|
}
|
|
2597
2599
|
|
|
2598
|
-
export default customShapes;
|
|
2599
|
-
export {
|
|
2600
|
-
Shape,
|
|
2601
|
-
Contour,
|
|
2602
|
-
ShapePrimitive,
|
|
2603
|
-
Vertex,
|
|
2604
|
-
Anchor,
|
|
2605
|
-
Segment,
|
|
2606
|
-
LineSegment,
|
|
2607
|
-
BezierSegment,
|
|
2608
|
-
SplineSegment,
|
|
2609
|
-
Point,
|
|
2610
|
-
Line,
|
|
2611
|
-
Triangle,
|
|
2612
|
-
Quad,
|
|
2613
|
-
TriangleFan,
|
|
2614
|
-
TriangleStrip,
|
|
2615
|
-
QuadStrip,
|
|
2616
|
-
PrimitiveVisitor,
|
|
2617
|
-
PrimitiveToPath2DConverter,
|
|
2618
|
-
PrimitiveToVerticesConverter,
|
|
2619
|
-
PointAtLengthGetter
|
|
2620
|
-
};
|
|
2621
|
-
|
|
2622
2600
|
if (typeof p5 !== 'undefined') {
|
|
2623
2601
|
customShapes(p5, p5.prototype);
|
|
2624
2602
|
}
|
|
2603
|
+
|
|
2604
|
+
export { Anchor, BezierSegment, Contour, Line, LineSegment, Point, PointAtLengthGetter, PrimitiveToPath2DConverter, PrimitiveToVerticesConverter, PrimitiveVisitor, Quad, QuadStrip, Segment, Shape, ShapePrimitive, SplineSegment, Triangle, TriangleFan, TriangleStrip, Vertex, customShapes as default };
|
|
@@ -3,11 +3,19 @@ import attributes from './attributes.js';
|
|
|
3
3
|
import curves from './curves.js';
|
|
4
4
|
import vertex from './vertex.js';
|
|
5
5
|
import customShapes from './custom_shapes.js';
|
|
6
|
+
import '../constants-tYr0tCl8.js';
|
|
7
|
+
import '../core/helpers.js';
|
|
8
|
+
import '../creating_reading-Cr8L2Jnm.js';
|
|
9
|
+
import 'colorjs.io/fn';
|
|
10
|
+
import '../color/color_spaces/hsb.js';
|
|
11
|
+
import '../math/p5.Vector.js';
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
function shape(p5){
|
|
8
14
|
p5.registerAddon(primitives);
|
|
9
15
|
p5.registerAddon(attributes);
|
|
10
16
|
p5.registerAddon(curves);
|
|
11
17
|
p5.registerAddon(vertex);
|
|
12
18
|
p5.registerAddon(customShapes);
|
|
13
|
-
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { shape as default };
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* @requires constants
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import * as constants from '../core/constants';
|
|
10
9
|
|
|
11
10
|
function vertex(p5, fn){
|
|
12
11
|
/**
|
|
@@ -1248,8 +1247,8 @@ function vertex(p5, fn){
|
|
|
1248
1247
|
};
|
|
1249
1248
|
}
|
|
1250
1249
|
|
|
1251
|
-
export default vertex;
|
|
1252
|
-
|
|
1253
1250
|
if(typeof p5 !== 'undefined'){
|
|
1254
1251
|
vertex(p5, p5.prototype);
|
|
1255
1252
|
}
|
|
1253
|
+
|
|
1254
|
+
export { vertex as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import textCore from './textCore.js';
|
|
2
|
+
import font from './p5.Font.js';
|
|
3
|
+
import '../p5.Renderer-Swjl9HQO.js';
|
|
4
|
+
import '../creating_reading-Cr8L2Jnm.js';
|
|
5
|
+
import 'colorjs.io/fn';
|
|
6
|
+
import '../color/color_spaces/hsb.js';
|
|
7
|
+
import '../constants-tYr0tCl8.js';
|
|
8
|
+
import '../image/filters.js';
|
|
9
|
+
import '../math/p5.Vector.js';
|
|
10
|
+
import '../shape/custom_shapes.js';
|
|
11
|
+
import '../core/States.js';
|
|
12
|
+
import '../io/utilities.js';
|
|
13
|
+
import 'file-saver';
|
|
14
|
+
import '@japont/unicode-range';
|
|
15
|
+
import './unicodeRanges.js';
|
|
16
|
+
import './lib/Typr.js';
|
|
17
|
+
import 'pako';
|
|
18
|
+
import '@davepagurek/bezier-path';
|
|
19
|
+
|
|
20
|
+
function type(p5){
|
|
21
|
+
p5.registerAddon(textCore);
|
|
22
|
+
p5.registerAddon(font);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { type as default };
|