p5 2.2.3 → 2.3.0-rc.0
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-CYF6mp5_.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-D2MtO721.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 +233 -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-C0Kzy71d.js} +31 -24
- package/dist/{rendering-CC8JNTwG.js → rendering-CvNr0bB8.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 +1036 -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 +4088 -1950
- package/lib/p5.esm.min.js +1 -1
- package/lib/p5.js +4088 -1950
- package/lib/p5.min.js +1 -1
- package/lib/p5.webgpu.esm.js +1638 -306
- package/lib/p5.webgpu.js +1637 -305
- package/lib/p5.webgpu.min.js +1 -1
- package/package.json +6 -1
- package/types/global.d.ts +4137 -2396
- package/types/p5.d.ts +2702 -1658
- package/dist/noise3DGLSL-Bwrdi4gi.js +0 -9
package/dist/core/environment.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as ARROW, i as CROSS, j as HAND, k as MOVE, l as TEXT, m as WAIT, P as P2D } from '../constants-CYF6mp5_.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @module Environment
|
|
5
5
|
* @submodule Environment
|
|
6
6
|
* @for p5
|
|
7
|
-
* @requires core
|
|
8
|
-
* @requires constants
|
|
9
7
|
*/
|
|
10
8
|
|
|
11
9
|
// import { Vector } from '../math/p5.Vector';
|
|
12
10
|
|
|
13
11
|
function environment(p5, fn, lifecycles){
|
|
14
12
|
const standardCursors = [ARROW, CROSS, HAND, MOVE, TEXT, WAIT];
|
|
13
|
+
const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
15
14
|
|
|
16
15
|
fn._frameRate = 0;
|
|
17
|
-
fn._lastFrameTime =
|
|
16
|
+
fn._lastFrameTime = globalThis.performance.now();
|
|
18
17
|
fn._targetFrameRate = 60;
|
|
19
18
|
|
|
20
|
-
const
|
|
19
|
+
const windowPrint = isBrowser ? window.print : null;
|
|
21
20
|
let windowPrintDisabled = false;
|
|
22
21
|
|
|
23
22
|
lifecycles.presetup = function(){
|
|
@@ -25,11 +24,13 @@ function environment(p5, fn, lifecycles){
|
|
|
25
24
|
'resize'
|
|
26
25
|
];
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
if(isBrowser){
|
|
28
|
+
for(const event of events){
|
|
29
|
+
window.addEventListener(event, this[`_on${event}`].bind(this), {
|
|
30
|
+
passive: false,
|
|
31
|
+
signal: this._removeSignal
|
|
32
|
+
});
|
|
33
|
+
}
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
|
|
@@ -60,9 +61,9 @@ function environment(p5, fn, lifecycles){
|
|
|
60
61
|
* }
|
|
61
62
|
*/
|
|
62
63
|
fn.print = function(...args) {
|
|
63
|
-
if (!args.length) {
|
|
64
|
+
if (!args.length && windowPrint !== null) {
|
|
64
65
|
if (!windowPrintDisabled) {
|
|
65
|
-
|
|
66
|
+
windowPrint();
|
|
66
67
|
if (
|
|
67
68
|
window.confirm(
|
|
68
69
|
'You just tried to print the webpage. Do you want to prevent this from running again?'
|
|
@@ -199,7 +200,7 @@ function environment(p5, fn, lifecycles){
|
|
|
199
200
|
* }
|
|
200
201
|
* }
|
|
201
202
|
*/
|
|
202
|
-
fn.focused = document.hasFocus();
|
|
203
|
+
fn.focused = isBrowser ? document.hasFocus() : true;
|
|
203
204
|
|
|
204
205
|
/**
|
|
205
206
|
* Changes the cursor's appearance.
|
|
@@ -216,6 +217,8 @@ function environment(p5, fn, lifecycles){
|
|
|
216
217
|
* cursor, `x` and `y` set the location pointed to within the image. They are
|
|
217
218
|
* both 0 by default, so the cursor points to the image's top-left corner. `x`
|
|
218
219
|
* and `y` must be less than the image's width and height, respectively.
|
|
220
|
+
*
|
|
221
|
+
* Calling `cursor()` without an argument returns the current cursor type as a string.
|
|
219
222
|
*
|
|
220
223
|
* @method cursor
|
|
221
224
|
* @param {(ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String)} type Built-in: either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT.
|
|
@@ -282,9 +285,17 @@ function environment(p5, fn, lifecycles){
|
|
|
282
285
|
* }
|
|
283
286
|
* }
|
|
284
287
|
*/
|
|
288
|
+
/**
|
|
289
|
+
* @method cursor
|
|
290
|
+
* @return {(ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String)} the current cursor type
|
|
291
|
+
*/
|
|
285
292
|
fn.cursor = function(type, x, y) {
|
|
286
293
|
let cursor = 'auto';
|
|
287
294
|
const canvas = this._curElement.elt;
|
|
295
|
+
if (typeof type === 'undefined') {
|
|
296
|
+
let curstr = canvas.style.cursor;
|
|
297
|
+
return curstr.length ? curstr : 'default';
|
|
298
|
+
}
|
|
288
299
|
if (standardCursors.includes(type)) {
|
|
289
300
|
// Standard css cursor
|
|
290
301
|
cursor = type;
|
|
@@ -571,7 +582,7 @@ function environment(p5, fn, lifecycles){
|
|
|
571
582
|
* @alt
|
|
572
583
|
* This example does not render anything.
|
|
573
584
|
*/
|
|
574
|
-
fn.displayWidth = screen.width;
|
|
585
|
+
fn.displayWidth = isBrowser ? window.screen.width : 0;
|
|
575
586
|
|
|
576
587
|
/**
|
|
577
588
|
* A `Number` variable that stores the height of the screen display.
|
|
@@ -599,7 +610,7 @@ function environment(p5, fn, lifecycles){
|
|
|
599
610
|
* @alt
|
|
600
611
|
* This example does not render anything.
|
|
601
612
|
*/
|
|
602
|
-
fn.displayHeight = screen.height;
|
|
613
|
+
fn.displayHeight = isBrowser ? window.screen.height : 0;
|
|
603
614
|
|
|
604
615
|
/**
|
|
605
616
|
* A `Number` variable that stores the width of the browser's viewport.
|
|
@@ -725,21 +736,11 @@ function environment(p5, fn, lifecycles){
|
|
|
725
736
|
};
|
|
726
737
|
|
|
727
738
|
function getWindowWidth() {
|
|
728
|
-
return
|
|
729
|
-
window.innerWidth ||
|
|
730
|
-
(document.documentElement && document.documentElement.clientWidth) ||
|
|
731
|
-
(document.body && document.body.clientWidth) ||
|
|
732
|
-
0
|
|
733
|
-
);
|
|
739
|
+
return isBrowser ? document.documentElement.clientWidth : 0;
|
|
734
740
|
}
|
|
735
741
|
|
|
736
742
|
function getWindowHeight() {
|
|
737
|
-
return
|
|
738
|
-
window.innerHeight ||
|
|
739
|
-
(document.documentElement && document.documentElement.clientHeight) ||
|
|
740
|
-
(document.body && document.body.clientHeight) ||
|
|
741
|
-
0
|
|
742
|
-
);
|
|
743
|
+
return isBrowser ? document.documentElement.clientHeight : 0;
|
|
743
744
|
}
|
|
744
745
|
|
|
745
746
|
/**
|
|
@@ -799,7 +800,6 @@ function environment(p5, fn, lifecycles){
|
|
|
799
800
|
* }
|
|
800
801
|
*/
|
|
801
802
|
fn.fullscreen = function(val) {
|
|
802
|
-
// p5._validateParameters('fullscreen', arguments);
|
|
803
803
|
// no arguments, return fullscreen or not
|
|
804
804
|
if (typeof val === 'undefined') {
|
|
805
805
|
return (
|
|
@@ -870,7 +870,6 @@ function environment(p5, fn, lifecycles){
|
|
|
870
870
|
* @returns {Number} current pixel density of the sketch.
|
|
871
871
|
*/
|
|
872
872
|
fn.pixelDensity = function(val) {
|
|
873
|
-
// p5._validateParameters('pixelDensity', arguments);
|
|
874
873
|
let returnValue;
|
|
875
874
|
if (typeof val === 'number') {
|
|
876
875
|
if (val !== this._renderer._pixelDensity) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ah as OPAQUE, ai as DILATE, aj as ERODE, ac as BLUR, ag as POSTERIZE, af as THRESHOLD, ak as INVERT, al as GRAY } from '../constants-CYF6mp5_.js';
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* Creates p5.strands filter shaders for cross-platform compatibility.
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { translator } from '../internationalization.js';
|
|
2
2
|
import strings from './browser_errors.js';
|
|
3
|
-
import {
|
|
3
|
+
import { am as constants } from '../../constants-CYF6mp5_.js';
|
|
4
4
|
import 'i18next';
|
|
5
5
|
import 'i18next-browser-languagedetector';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @for p5
|
|
9
|
-
* @requires core
|
|
10
9
|
*
|
|
11
10
|
* This is the main file for the Friendly Error System (FES), containing
|
|
12
11
|
* the core as well as miscellaneous functionality of the FES. Here is a
|
|
@@ -29,7 +28,7 @@ import 'i18next-browser-languagedetector';
|
|
|
29
28
|
* https://github.com/processing/p5.js/blob/main/contributor_docs/fes_reference_dev_notes.md
|
|
30
29
|
*/
|
|
31
30
|
|
|
32
|
-
function fesCore(p5, fn){
|
|
31
|
+
function fesCore(p5, fn, lifecycles){
|
|
33
32
|
// p5.js blue, p5.js orange, auto dark green; fallback p5.js darkened magenta
|
|
34
33
|
// See testColors below for all the color codes and names
|
|
35
34
|
const typeColors = ['#2D7BB6', '#EE9900', '#4DB200', '#C83C00'];
|
|
@@ -942,9 +941,11 @@ function fesCore(p5, fn){
|
|
|
942
941
|
p5._fesLogger = null;
|
|
943
942
|
p5._fesLogCache = {};
|
|
944
943
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
944
|
+
lifecycles.presetup = function () {
|
|
945
|
+
window.addEventListener('load', checkForUserDefinedFunctions, false);
|
|
946
|
+
window.addEventListener('error', p5._fesErrorMonitor, false);
|
|
947
|
+
window.addEventListener('unhandledrejection', p5._fesErrorMonitor, false);
|
|
948
|
+
};
|
|
948
949
|
|
|
949
950
|
/**
|
|
950
951
|
* Prints out all the colors in the color pallete with white text.
|
|
@@ -1104,7 +1105,7 @@ function fesCore(p5, fn){
|
|
|
1104
1105
|
// Exposing this primarily for unit testing.
|
|
1105
1106
|
fn._helpForMisusedAtTopLevelCode = helpForMisusedAtTopLevelCode;
|
|
1106
1107
|
|
|
1107
|
-
if (document.readyState !== 'complete') {
|
|
1108
|
+
if (typeof document !== 'undefined' && document.readyState !== 'complete') {
|
|
1108
1109
|
window.addEventListener('error', helpForMisusedAtTopLevelCode, false);
|
|
1109
1110
|
|
|
1110
1111
|
// Our job is only to catch ReferenceErrors that are thrown when
|
|
@@ -1118,7 +1119,7 @@ function fesCore(p5, fn){
|
|
|
1118
1119
|
}
|
|
1119
1120
|
|
|
1120
1121
|
if (typeof p5 !== 'undefined') {
|
|
1121
|
-
|
|
1122
|
+
p5.registerAddon(fesCore);
|
|
1122
1123
|
}
|
|
1123
1124
|
|
|
1124
1125
|
export { fesCore as default };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { translator } from '../internationalization.js';
|
|
2
2
|
import 'i18next';
|
|
3
3
|
import 'i18next-browser-languagedetector';
|
|
4
|
-
import '../../constants-
|
|
4
|
+
import '../../constants-CYF6mp5_.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @for p5
|
|
8
|
-
* @requires core
|
|
9
8
|
*/
|
|
10
9
|
|
|
11
10
|
function fileErrors(p5, fn){
|
|
@@ -6,7 +6,7 @@ import fileErrors from './file_errors.js';
|
|
|
6
6
|
import '../internationalization.js';
|
|
7
7
|
import 'i18next';
|
|
8
8
|
import 'i18next-browser-languagedetector';
|
|
9
|
-
import '../../constants-
|
|
9
|
+
import '../../constants-CYF6mp5_.js';
|
|
10
10
|
import './browser_errors.js';
|
|
11
11
|
import 'zod/v4';
|
|
12
12
|
import 'acorn';
|