p5 2.2.3 → 2.3.0-rc.1
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/dist/accessibility/color_namer.js +9 -11
- package/dist/accessibility/describe.js +0 -1
- package/dist/accessibility/gridOutput.js +0 -1
- package/dist/accessibility/index.js +9 -10
- package/dist/accessibility/outputs.js +0 -1
- package/dist/accessibility/textOutput.js +0 -1
- package/dist/app.js +11 -10
- package/dist/app.node.js +122 -0
- package/dist/color/color_conversion.js +9 -11
- package/dist/color/creating_reading.js +1 -1
- package/dist/color/index.js +2 -2
- package/dist/color/p5.Color.js +1 -1
- package/dist/color/setting.js +25 -12
- package/dist/{constants-BdTiYOQI.js → constants-0wkVUfqa.js} +2 -2
- package/dist/core/States.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/environment.js +28 -29
- package/dist/core/filterShaders.js +1 -1
- package/dist/core/friendly_errors/fes_core.js +9 -8
- package/dist/core/friendly_errors/file_errors.js +1 -2
- package/dist/core/friendly_errors/index.js +1 -1
- package/dist/core/friendly_errors/param_validator.js +737 -640
- package/dist/core/friendly_errors/sketch_verifier.js +1 -1
- package/dist/core/friendly_errors/stacktrace.js +0 -1
- package/dist/core/helpers.js +3 -4
- package/dist/core/init.js +24 -21
- package/dist/core/internationalization.js +1 -1
- package/dist/core/legacy.js +9 -11
- package/dist/core/main.js +9 -10
- package/dist/core/p5.Graphics.js +5 -5
- package/dist/core/p5.Renderer.js +3 -3
- package/dist/core/p5.Renderer2D.js +9 -10
- package/dist/core/p5.Renderer3D.js +5 -5
- package/dist/core/rendering.js +5 -5
- package/dist/core/structure.js +0 -1
- package/dist/core/transform.js +7 -16
- package/dist/{creating_reading-C7hu6sg1.js → creating_reading-DLkHH80h.js} +11 -8
- package/dist/data/local_storage.js +0 -1
- package/dist/dom/dom.js +2 -3
- package/dist/dom/index.js +2 -2
- package/dist/dom/p5.Element.js +2 -2
- package/dist/dom/p5.MediaElement.js +2 -2
- package/dist/events/acceleration.js +5 -3
- package/dist/events/keyboard.js +0 -1
- package/dist/events/pointer.js +0 -2
- package/dist/image/const.js +1 -1
- package/dist/image/filterRenderer2D.js +19 -12
- package/dist/image/image.js +5 -5
- package/dist/image/index.js +5 -5
- package/dist/image/loading_displaying.js +5 -5
- package/dist/image/p5.Image.js +3 -3
- package/dist/image/pixels.js +0 -1
- package/dist/io/files.js +5 -5
- package/dist/io/index.js +5 -5
- package/dist/io/p5.Table.js +0 -1
- package/dist/io/p5.TableRow.js +0 -1
- package/dist/io/p5.XML.js +0 -1
- package/dist/{ir_builders-Cd6rU9Vm.js → ir_builders-C2ebb6Lu.js} +234 -1
- package/dist/{main-H_nu4eDs.js → main-D2kqeMXM.js} +107 -136
- package/dist/math/Matrices/Matrix.js +1 -1
- package/dist/math/Matrices/MatrixNumjs.js +1 -1
- package/dist/math/calculation.js +0 -1
- package/dist/math/index.js +3 -1
- package/dist/math/math.js +3 -17
- package/dist/math/noise.js +0 -1
- package/dist/math/p5.Matrix.js +1 -2
- package/dist/math/p5.Vector.js +237 -279
- package/dist/math/patch-vector.js +75 -0
- package/dist/math/random.js +0 -1
- package/dist/math/trigonometry.js +3 -4
- package/dist/{p5.Renderer-BmD2P6Wv.js → p5.Renderer-CQI8PO1F.js} +31 -24
- package/dist/{rendering-CC8JNTwG.js → rendering-ltTIxpF2.js} +732 -44
- package/dist/shape/2d_primitives.js +1 -4
- package/dist/shape/attributes.js +43 -8
- package/dist/shape/curves.js +0 -1
- package/dist/shape/custom_shapes.js +260 -5
- package/dist/shape/index.js +2 -2
- package/dist/shape/vertex.js +0 -2
- package/dist/strands/ir_builders.js +1 -1
- package/dist/strands/ir_types.js +5 -1
- package/dist/strands/p5.strands.js +286 -31
- package/dist/strands/strands_api.js +179 -8
- package/dist/strands/strands_codegen.js +26 -8
- package/dist/strands/strands_conditionals.js +1 -1
- package/dist/strands/strands_for.js +1 -1
- package/dist/strands/strands_node.js +1 -1
- package/dist/strands/strands_ternary.js +56 -0
- package/dist/strands/strands_transpiler.js +416 -251
- package/dist/strands_glslBackend-i-ReKgZo.js +423 -0
- package/dist/type/index.js +3 -3
- package/dist/type/lib/Typr.js +1 -1
- package/dist/type/p5.Font.js +3 -3
- package/dist/type/textCore.js +31 -24
- package/dist/utilities/conversion.js +0 -1
- package/dist/utilities/time_date.js +0 -1
- package/dist/utilities/utility_functions.js +0 -1
- package/dist/webgl/3d_primitives.js +5 -5
- package/dist/webgl/GeometryBuilder.js +1 -1
- package/dist/webgl/ShapeBuilder.js +26 -1
- package/dist/webgl/enums.js +1 -1
- package/dist/webgl/index.js +8 -9
- package/dist/webgl/interaction.js +8 -4
- package/dist/webgl/light.js +5 -5
- package/dist/webgl/loading.js +60 -21
- package/dist/webgl/material.js +5 -5
- package/dist/webgl/p5.Camera.js +5 -5
- package/dist/webgl/p5.Framebuffer.js +5 -5
- package/dist/webgl/p5.Geometry.js +3 -5
- package/dist/webgl/p5.Quat.js +1 -1
- package/dist/webgl/p5.RendererGL.js +17 -21
- package/dist/webgl/p5.Shader.js +129 -36
- package/dist/webgl/p5.Texture.js +5 -5
- package/dist/webgl/strands_glslBackend.js +5 -386
- package/dist/webgl/text.js +5 -5
- package/dist/webgl/utils.js +5 -5
- package/dist/webgl2Compatibility-DA7DLMuq.js +7 -0
- package/dist/webgpu/index.js +7 -3
- package/dist/webgpu/p5.RendererWebGPU.js +1146 -180
- package/dist/webgpu/shaders/color.js +1 -1
- package/dist/webgpu/shaders/compute.js +32 -0
- package/dist/webgpu/shaders/functions/randomComputeWGSL.js +31 -0
- package/dist/webgpu/shaders/functions/randomVertWGSL.js +30 -0
- package/dist/webgpu/shaders/functions/randomWGSL.js +30 -0
- package/dist/webgpu/shaders/line.js +1 -1
- package/dist/webgpu/shaders/material.js +3 -3
- package/dist/webgpu/strands_wgslBackend.js +137 -15
- package/lib/p5.esm.js +4092 -1950
- package/lib/p5.esm.min.js +1 -1
- package/lib/p5.js +4092 -1950
- package/lib/p5.min.js +1 -1
- package/lib/p5.webgpu.esm.js +1748 -306
- package/lib/p5.webgpu.js +1747 -305
- package/lib/p5.webgpu.min.js +1 -1
- package/package.json +6 -1
- package/types/global.d.ts +4182 -2441
- package/types/p5.d.ts +2776 -1675
- package/dist/noise3DGLSL-Bwrdi4gi.js +0 -9
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Vector } from './p5.Vector.js';
|
|
2
|
+
import '../constants-0wkVUfqa.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
function _defaultEmptyVector(target){
|
|
9
|
+
return function(...args){
|
|
10
|
+
if(args.length === 0){
|
|
11
|
+
this._friendlyError(
|
|
12
|
+
'In 1.x, createVector() was a shortcut for createVector(0, 0, 0). In 2.x, p5.js has vectors of any dimension, so you must provide your desired number of zeros. Use createVector(0, 0) for a 2D vector and createVector(0, 0, 0) for a 3D vector.',
|
|
13
|
+
'p5.createVector'
|
|
14
|
+
);
|
|
15
|
+
return target.call(this, 0, 0, 0);
|
|
16
|
+
}else {
|
|
17
|
+
if (Array.isArray(args[0])) {
|
|
18
|
+
args = args[0];
|
|
19
|
+
}
|
|
20
|
+
return target.call(this, ...args);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @private
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
function _validatedVectorOperation(expectsSoloNumberArgument){
|
|
31
|
+
return function(target){
|
|
32
|
+
return function(...args){
|
|
33
|
+
if (args.length === 0) {
|
|
34
|
+
// No arguments? No action
|
|
35
|
+
return this;
|
|
36
|
+
} else if (args[0] instanceof Vector) {
|
|
37
|
+
// First argument is a vector? Make it an array
|
|
38
|
+
args = args[0].values;
|
|
39
|
+
} else if (Array.isArray(args[0])) {
|
|
40
|
+
// First argument is an array? Great, keep it!
|
|
41
|
+
args = args[0];
|
|
42
|
+
} else if (expectsSoloNumberArgument && args.length === 1){
|
|
43
|
+
// Special case for a solo numeric arguments only applies sometimes
|
|
44
|
+
args = new Array(3).fill(args[0]);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if(Array.isArray(args) && !args.every(v => typeof v === 'number' && Number.isFinite(v))){
|
|
48
|
+
this._friendlyError(
|
|
49
|
+
'Arguments contain non-finite numbers',
|
|
50
|
+
target.name
|
|
51
|
+
);
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
return target.call(this, ...args);
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Each of the following decorators validates the data on vector operations.
|
|
61
|
+
* These ensure that the arguments are consistently formatted, and that
|
|
62
|
+
* pre-conditions are met.
|
|
63
|
+
*/
|
|
64
|
+
function vectorValidation(p5, fn, lifecycles){
|
|
65
|
+
|
|
66
|
+
p5.registerDecorator('p5.prototype.createVector', _defaultEmptyVector);
|
|
67
|
+
p5.registerDecorator('p5.Vector.prototype.mult', _validatedVectorOperation(true));
|
|
68
|
+
p5.registerDecorator('p5.Vector.prototype.rem', _validatedVectorOperation(true));
|
|
69
|
+
p5.registerDecorator('p5.Vector.prototype.div', _validatedVectorOperation(true));
|
|
70
|
+
p5.registerDecorator('p5.Vector.prototype.add', _validatedVectorOperation(false));
|
|
71
|
+
p5.registerDecorator('p5.Vector.prototype.sub', _validatedVectorOperation(false));
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { _defaultEmptyVector, _validatedVectorOperation, vectorValidation as default };
|
package/dist/math/random.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a3 as RAD_TO_DEG, a4 as DEG_TO_RAD } from '../constants-0wkVUfqa.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @module Math
|
|
5
5
|
* @submodule Trigonometry
|
|
6
6
|
* @for p5
|
|
7
|
-
* @requires core
|
|
8
|
-
* @requires constants
|
|
9
7
|
*/
|
|
10
8
|
|
|
11
9
|
|
|
@@ -775,7 +773,8 @@ function trigonometry(p5, fn){
|
|
|
775
773
|
* @returns {Number}
|
|
776
774
|
*/
|
|
777
775
|
fn._toRadians = function(angle) {
|
|
778
|
-
|
|
776
|
+
// returns undefined if no argument
|
|
777
|
+
if (typeof angle !== 'undefined' && this._angleMode === DEGREES) {
|
|
779
778
|
return angle * DEG_TO_RAD;
|
|
780
779
|
}
|
|
781
780
|
return angle;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Color } from './creating_reading-
|
|
2
|
-
import {
|
|
1
|
+
import { C as Color } from './creating_reading-DLkHH80h.js';
|
|
2
|
+
import { a1 as NORMAL, aA as WORD, ax as BASELINE, av as LEFT, t as CENTER, n as CORNER, I as INCLUDE } from './constants-0wkVUfqa.js';
|
|
3
3
|
import Filters from './image/filters.js';
|
|
4
4
|
import { Vector } from './math/p5.Vector.js';
|
|
5
5
|
import { Shape } from './shape/custom_shapes.js';
|
|
@@ -9,9 +9,6 @@ import { _checkFileExtension, downloadFile } from './io/utilities.js';
|
|
|
9
9
|
/**
|
|
10
10
|
* @module Image
|
|
11
11
|
* @submodule Image
|
|
12
|
-
* @requires core
|
|
13
|
-
* @requires constants
|
|
14
|
-
* @requires filters
|
|
15
12
|
*/
|
|
16
13
|
|
|
17
14
|
|
|
@@ -32,6 +29,9 @@ class Image {
|
|
|
32
29
|
this.pixels = [];
|
|
33
30
|
}
|
|
34
31
|
|
|
32
|
+
// This will get overwritten when exported as part of p5.
|
|
33
|
+
_friendlyError(_e) {}
|
|
34
|
+
|
|
35
35
|
/**
|
|
36
36
|
* Gets or sets the pixel density for high pixel density displays.
|
|
37
37
|
*
|
|
@@ -1601,7 +1601,7 @@ class Image {
|
|
|
1601
1601
|
props.displayIndex = index;
|
|
1602
1602
|
this.drawingContext.putImageData(props.frames[index].image, 0, 0);
|
|
1603
1603
|
} else {
|
|
1604
|
-
|
|
1604
|
+
this._friendlyError(
|
|
1605
1605
|
'Cannot set GIF to a frame number that is higher than total number of frames or below zero.',
|
|
1606
1606
|
'setFrame'
|
|
1607
1607
|
);
|
|
@@ -2099,6 +2099,8 @@ function image(p5, fn){
|
|
|
2099
2099
|
*/
|
|
2100
2100
|
p5.Image = Image;
|
|
2101
2101
|
|
|
2102
|
+
Image.prototype._friendlyError = p5._friendlyError;
|
|
2103
|
+
|
|
2102
2104
|
/**
|
|
2103
2105
|
* The image's width in pixels.
|
|
2104
2106
|
*
|
|
@@ -2291,6 +2293,11 @@ class Renderer {
|
|
|
2291
2293
|
rectMode: CORNER,
|
|
2292
2294
|
ellipseMode: CENTER,
|
|
2293
2295
|
strokeWeight: 1,
|
|
2296
|
+
bezierOrder: 3,
|
|
2297
|
+
splineProperties: new ClonableObject({
|
|
2298
|
+
ends: INCLUDE,
|
|
2299
|
+
tightness: 0
|
|
2300
|
+
}),
|
|
2294
2301
|
|
|
2295
2302
|
textFont: { family: 'sans-serif' },
|
|
2296
2303
|
textLeading: 15,
|
|
@@ -2298,15 +2305,8 @@ class Renderer {
|
|
|
2298
2305
|
textSize: 12,
|
|
2299
2306
|
textAlign: LEFT,
|
|
2300
2307
|
textBaseline: BASELINE,
|
|
2301
|
-
bezierOrder: 3,
|
|
2302
|
-
splineProperties: new ClonableObject({
|
|
2303
|
-
ends: INCLUDE,
|
|
2304
|
-
tightness: 0
|
|
2305
|
-
}),
|
|
2306
2308
|
textWrap: WORD,
|
|
2307
|
-
|
|
2308
|
-
// added v2.0
|
|
2309
|
-
fontStyle: NORMAL, // v1: textStyle
|
|
2309
|
+
fontStyle: NORMAL, // v1: was textStyle
|
|
2310
2310
|
fontStretch: NORMAL,
|
|
2311
2311
|
fontWeight: NORMAL,
|
|
2312
2312
|
lineHeight: NORMAL,
|
|
@@ -2319,12 +2319,14 @@ class Renderer {
|
|
|
2319
2319
|
this._isMainCanvas = isMainCanvas;
|
|
2320
2320
|
this.pixels = [];
|
|
2321
2321
|
|
|
2322
|
+
const defaultRatio = typeof window !== 'undefined' ?
|
|
2323
|
+
Math.ceil(window.devicePixelRatio) :
|
|
2324
|
+
1;
|
|
2322
2325
|
if (isMainCanvas) {
|
|
2323
|
-
this._pixelDensity =
|
|
2326
|
+
this._pixelDensity = defaultRatio;
|
|
2324
2327
|
} else {
|
|
2325
|
-
|
|
2326
2328
|
const parentDensity = pInst._pInst?._renderer?._pixelDensity;
|
|
2327
|
-
this._pixelDensity = parentDensity ||
|
|
2329
|
+
this._pixelDensity = parentDensity || defaultRatio;
|
|
2328
2330
|
}
|
|
2329
2331
|
|
|
2330
2332
|
this.width = w;
|
|
@@ -2381,7 +2383,7 @@ class Renderer {
|
|
|
2381
2383
|
// and push it into the push pop stack
|
|
2382
2384
|
push() {
|
|
2383
2385
|
this._pushPopDepth++;
|
|
2384
|
-
this._pushPopStack.push(this.states.
|
|
2386
|
+
this._pushPopStack.push(this.states.takeDiff());
|
|
2385
2387
|
}
|
|
2386
2388
|
|
|
2387
2389
|
// Pop the previous states out of the push pop stack and
|
|
@@ -2576,9 +2578,12 @@ class Renderer {
|
|
|
2576
2578
|
}
|
|
2577
2579
|
|
|
2578
2580
|
fill(...args) {
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2581
|
+
if (args.length > 0) {
|
|
2582
|
+
this.states.setValue('fillSet', true);
|
|
2583
|
+
this.states.setValue('fillColor', this._pInst.color(...args));
|
|
2584
|
+
this.updateShapeVertexProperties();
|
|
2585
|
+
}
|
|
2586
|
+
return this.states.fillColor;
|
|
2582
2587
|
}
|
|
2583
2588
|
|
|
2584
2589
|
noFill() {
|
|
@@ -2586,14 +2591,16 @@ class Renderer {
|
|
|
2586
2591
|
}
|
|
2587
2592
|
|
|
2588
2593
|
strokeWeight(w) {
|
|
2589
|
-
if (w === undefined) {
|
|
2594
|
+
if (typeof w === 'undefined') {
|
|
2590
2595
|
return this.states.strokeWeight;
|
|
2591
|
-
} else {
|
|
2592
|
-
this.states.setValue('strokeWeight', w);
|
|
2593
2596
|
}
|
|
2597
|
+
this.states.setValue('strokeWeight', w);
|
|
2594
2598
|
}
|
|
2595
2599
|
|
|
2596
2600
|
stroke(...args) {
|
|
2601
|
+
if (args.length === 0) {
|
|
2602
|
+
return this.states.strokeColor;
|
|
2603
|
+
}
|
|
2597
2604
|
this.states.setValue('strokeSet', true);
|
|
2598
2605
|
this.states.setValue('strokeColor', this._pInst.color(...args));
|
|
2599
2606
|
this.updateShapeVertexProperties();
|