p5 2.2.3-rc.0 → 2.2.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.
- package/README.md +4 -5
- package/dist/accessibility/color_namer.js +5 -5
- package/dist/accessibility/index.js +5 -5
- package/dist/app.js +5 -5
- package/dist/color/color_conversion.js +5 -5
- package/dist/color/index.js +1 -1
- package/dist/color/setting.js +1 -1
- package/dist/{constants-D3ryGa0m.js → constants-BdTiYOQI.js} +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/environment.js +1 -1
- package/dist/core/filterShaders.js +1 -1
- package/dist/core/friendly_errors/fes_core.js +1 -1
- package/dist/core/friendly_errors/file_errors.js +1 -1
- package/dist/core/friendly_errors/index.js +1 -1
- package/dist/core/friendly_errors/param_validator.js +1 -1
- package/dist/core/friendly_errors/sketch_verifier.js +1 -1
- package/dist/core/helpers.js +1 -1
- package/dist/core/init.js +5 -5
- package/dist/core/internationalization.js +1 -1
- package/dist/core/legacy.js +5 -5
- package/dist/core/main.js +5 -5
- package/dist/core/p5.Graphics.js +3 -3
- package/dist/core/p5.Renderer.js +2 -2
- package/dist/core/p5.Renderer2D.js +5 -5
- package/dist/core/p5.Renderer3D.js +3 -3
- package/dist/core/rendering.js +3 -3
- package/dist/data/local_storage.js +13 -9
- package/dist/dom/dom.js +30 -29
- package/dist/dom/index.js +1 -1
- package/dist/dom/p5.Element.js +3 -3
- package/dist/dom/p5.MediaElement.js +4 -5
- package/dist/events/pointer.js +1 -1
- package/dist/image/const.js +1 -1
- package/dist/image/filterRenderer2D.js +4 -4
- package/dist/image/image.js +3 -3
- package/dist/image/index.js +3 -3
- package/dist/image/loading_displaying.js +3 -3
- package/dist/image/p5.Image.js +2 -2
- package/dist/io/files.js +3 -3
- package/dist/io/index.js +3 -3
- package/dist/io/p5.XML.js +8 -8
- package/dist/{ir_builders-DMfaOLIL.js → ir_builders-Cd6rU9Vm.js} +0 -6
- package/dist/{main-CGwYa9-f.js → main-H_nu4eDs.js} +3 -3
- package/dist/math/Matrices/Matrix.js +1 -1
- package/dist/math/Matrices/MatrixNumjs.js +1 -1
- package/dist/math/index.js +1 -1
- package/dist/math/p5.Matrix.js +1 -1
- package/dist/math/p5.Vector.js +1 -1
- package/dist/math/trigonometry.js +1 -1
- package/dist/{p5.Renderer-C0e0XesC.js → p5.Renderer-BmD2P6Wv.js} +4 -3
- package/dist/{rendering-4Z2qdE_W.js → rendering-CC8JNTwG.js} +21 -58
- package/dist/shape/2d_primitives.js +1 -1
- package/dist/shape/attributes.js +1 -1
- package/dist/shape/custom_shapes.js +1 -1
- package/dist/shape/index.js +1 -1
- package/dist/strands/ir_builders.js +1 -1
- package/dist/strands/p5.strands.js +10 -34
- package/dist/strands/strands_api.js +1 -2
- package/dist/strands/strands_codegen.js +0 -12
- 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/type/index.js +2 -2
- package/dist/type/p5.Font.js +2 -2
- package/dist/type/textCore.js +2 -2
- package/dist/webgl/3d_primitives.js +3 -3
- package/dist/webgl/GeometryBuilder.js +1 -1
- package/dist/webgl/ShapeBuilder.js +1 -1
- package/dist/webgl/enums.js +1 -1
- package/dist/webgl/index.js +4 -4
- package/dist/webgl/interaction.js +1 -1
- package/dist/webgl/light.js +3 -3
- package/dist/webgl/loading.js +4 -6
- package/dist/webgl/material.js +3 -3
- package/dist/webgl/p5.Camera.js +3 -3
- package/dist/webgl/p5.Framebuffer.js +3 -3
- package/dist/webgl/p5.Geometry.js +1 -1
- package/dist/webgl/p5.Quat.js +1 -1
- package/dist/webgl/p5.RendererGL.js +4 -4
- package/dist/webgl/p5.Shader.js +14 -6
- package/dist/webgl/p5.Texture.js +3 -3
- package/dist/webgl/strands_glslBackend.js +1 -1
- package/dist/webgl/text.js +3 -3
- package/dist/webgl/utils.js +3 -3
- package/dist/webgpu/index.js +2 -2
- package/dist/webgpu/p5.RendererWebGPU.js +2 -2
- package/dist/webgpu/strands_wgslBackend.js +1 -1
- package/lib/p5.esm.js +104 -173
- package/lib/p5.esm.min.js +1 -1
- package/lib/p5.js +104 -173
- package/lib/p5.min.js +1 -1
- package/lib/p5.webgpu.esm.js +1 -7
- package/lib/p5.webgpu.js +1 -7
- package/lib/p5.webgpu.min.js +1 -1
- package/package.json +1 -1
- package/types/global.d.ts +1170 -1210
- package/types/p5.d.ts +645 -658
package/lib/p5.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! p5.js v2.2.3
|
|
1
|
+
/*! p5.js v2.2.3 March 21, 2026 */
|
|
2
2
|
/**
|
|
3
3
|
* @module Constants
|
|
4
4
|
* @submodule Constants
|
|
@@ -12,7 +12,7 @@ const _PI = Math.PI;
|
|
|
12
12
|
* @property {String} VERSION
|
|
13
13
|
* @final
|
|
14
14
|
*/
|
|
15
|
-
const VERSION = '2.2.3
|
|
15
|
+
const VERSION = '2.2.3';
|
|
16
16
|
|
|
17
17
|
// GRAPHICS RENDERER
|
|
18
18
|
/**
|
|
@@ -12788,7 +12788,7 @@ class XML {
|
|
|
12788
12788
|
* Returns the element's name as a `String`.
|
|
12789
12789
|
*
|
|
12790
12790
|
* An XML element's name is given by its tag. For example, the element
|
|
12791
|
-
*
|
|
12791
|
+
* `<language>JavaScript</language>` has the name `language`.
|
|
12792
12792
|
*
|
|
12793
12793
|
* @return {String} name of the element.
|
|
12794
12794
|
*
|
|
@@ -12831,11 +12831,11 @@ class XML {
|
|
|
12831
12831
|
* Sets the element's tag name.
|
|
12832
12832
|
*
|
|
12833
12833
|
* An XML element's name is given by its tag. For example, the element
|
|
12834
|
-
*
|
|
12834
|
+
* `<language>JavaScript</language>` has the name `language`.
|
|
12835
12835
|
*
|
|
12836
12836
|
* The parameter, `name`, is the element's new name as a string. For example,
|
|
12837
12837
|
* calling `myXML.setName('planet')` will make the element's new tag name
|
|
12838
|
-
*
|
|
12838
|
+
* `<planet></planet>`.
|
|
12839
12839
|
*
|
|
12840
12840
|
* @param {String} name new tag name of the element.
|
|
12841
12841
|
*
|
|
@@ -12977,7 +12977,7 @@ class XML {
|
|
|
12977
12977
|
*
|
|
12978
12978
|
* The parameter, `name`, is optional. If a string is passed, as in
|
|
12979
12979
|
* `myXML.getChildren('cat')`, then the method will only return child elements
|
|
12980
|
-
* with the tag
|
|
12980
|
+
* with the tag `<cat>`.
|
|
12981
12981
|
*
|
|
12982
12982
|
* @param {String} [name] name of the elements to return.
|
|
12983
12983
|
* @return {p5.XML[]} child elements.
|
|
@@ -13071,7 +13071,7 @@ class XML {
|
|
|
13071
13071
|
*
|
|
13072
13072
|
* The parameter, `name`, is optional. If a string is passed, as in
|
|
13073
13073
|
* `myXML.getChild('cat')`, then the first child element with the tag
|
|
13074
|
-
*
|
|
13074
|
+
* `<cat>` will be returned. If a number is passed, as in
|
|
13075
13075
|
* `myXML.getChild(1)`, then the child element at that index will be returned.
|
|
13076
13076
|
*
|
|
13077
13077
|
* @param {String|Integer} name element name or index.
|
|
@@ -13204,7 +13204,7 @@ class XML {
|
|
|
13204
13204
|
*
|
|
13205
13205
|
* The parameter, `name`, is the child element to remove. If a string is
|
|
13206
13206
|
* passed, as in `myXML.removeChild('cat')`, then the first child element
|
|
13207
|
-
* with the tag
|
|
13207
|
+
* with the tag `<cat>` will be removed. If a number is passed, as in
|
|
13208
13208
|
* `myXML.removeChild(1)`, then the child element at that index will be
|
|
13209
13209
|
* removed.
|
|
13210
13210
|
*
|
|
@@ -13758,7 +13758,7 @@ class XML {
|
|
|
13758
13758
|
* Sets the element's content.
|
|
13759
13759
|
*
|
|
13760
13760
|
* An element's content is the text between its tags. For example, the element
|
|
13761
|
-
*
|
|
13761
|
+
* `<language>JavaScript</language>` has the content `JavaScript`.
|
|
13762
13762
|
*
|
|
13763
13763
|
* The parameter, `content`, is a string with the element's new content.
|
|
13764
13764
|
*
|
|
@@ -13876,7 +13876,7 @@ function xml(p5, fn){
|
|
|
13876
13876
|
* (<a href="https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction" target="_blank">XML</a>)
|
|
13877
13877
|
* is a standard format for sending data between applications. Like HTML, the
|
|
13878
13878
|
* XML format is based on tags and attributes, as in
|
|
13879
|
-
*
|
|
13879
|
+
* `<time units="s">1234</time>`.
|
|
13880
13880
|
*
|
|
13881
13881
|
* Note: Use <a href="#/p5/loadXML">loadXML()</a> to load external XML files.
|
|
13882
13882
|
*
|
|
@@ -14370,9 +14370,9 @@ class Element {
|
|
|
14370
14370
|
/**
|
|
14371
14371
|
* Attaches the element to a parent element.
|
|
14372
14372
|
*
|
|
14373
|
-
* For example, a
|
|
14373
|
+
* For example, a `<div></div>` element may be used as a box to
|
|
14374
14374
|
* hold two pieces of text, a header and a paragraph. The
|
|
14375
|
-
*
|
|
14375
|
+
* `<div></div>` is the parent element of both the header and
|
|
14376
14376
|
* paragraph.
|
|
14377
14377
|
*
|
|
14378
14378
|
* The parameter `parent` can have one of three types. `parent` can be a
|
|
@@ -18943,8 +18943,9 @@ class Image {
|
|
|
18943
18943
|
props.displayIndex = index;
|
|
18944
18944
|
this.drawingContext.putImageData(props.frames[index].image, 0, 0);
|
|
18945
18945
|
} else {
|
|
18946
|
-
|
|
18947
|
-
'Cannot set GIF to a frame number that is higher than total number of frames or below zero.'
|
|
18946
|
+
p5._friendlyError(
|
|
18947
|
+
'Cannot set GIF to a frame number that is higher than total number of frames or below zero.',
|
|
18948
|
+
'setFrame'
|
|
18948
18949
|
);
|
|
18949
18950
|
}
|
|
18950
18951
|
}
|
|
@@ -27690,7 +27691,6 @@ class MediaElement extends Element {
|
|
|
27690
27691
|
removeCue(id) {
|
|
27691
27692
|
for (let i = 0; i < this._cues.length; i++) {
|
|
27692
27693
|
if (this._cues[i].id === id) {
|
|
27693
|
-
console.log(id);
|
|
27694
27694
|
this._cues.splice(i, 1);
|
|
27695
27695
|
}
|
|
27696
27696
|
}
|
|
@@ -27840,7 +27840,7 @@ function media(p5, fn){
|
|
|
27840
27840
|
}
|
|
27841
27841
|
|
|
27842
27842
|
/**
|
|
27843
|
-
* Creates a
|
|
27843
|
+
* Creates a `<video>` element for simple audio/video playback.
|
|
27844
27844
|
*
|
|
27845
27845
|
* `createVideo()` returns a new
|
|
27846
27846
|
* <a href="#/p5.MediaElement">p5.MediaElement</a> object. Videos are shown by
|
|
@@ -27928,7 +27928,7 @@ function media(p5, fn){
|
|
|
27928
27928
|
/* AUDIO STUFF */
|
|
27929
27929
|
|
|
27930
27930
|
/**
|
|
27931
|
-
* Creates a hidden
|
|
27931
|
+
* Creates a hidden `<audio>` element for simple audio playback.
|
|
27932
27932
|
*
|
|
27933
27933
|
* `createAudio()` returns a new
|
|
27934
27934
|
* <a href="#/p5.MediaElement">p5.MediaElement</a> object.
|
|
@@ -28005,7 +28005,7 @@ function media(p5, fn){
|
|
|
28005
28005
|
}
|
|
28006
28006
|
|
|
28007
28007
|
/**
|
|
28008
|
-
* Creates a
|
|
28008
|
+
* Creates a `<video>` element that "captures" the audio/video stream from
|
|
28009
28009
|
* the webcam and microphone.
|
|
28010
28010
|
*
|
|
28011
28011
|
* `createCapture()` returns a new
|
|
@@ -36807,7 +36807,7 @@ function files(p5, fn){
|
|
|
36807
36807
|
* (<a href="https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction" target="_blank">XML</a>)
|
|
36808
36808
|
* is a standard format for sending data between applications. Like HTML, the
|
|
36809
36809
|
* XML format is based on tags and attributes, as in
|
|
36810
|
-
*
|
|
36810
|
+
* `<time units="s">1234</time>`.
|
|
36811
36811
|
*
|
|
36812
36812
|
* The first parameter, `path`, is always a string with the path to the file.
|
|
36813
36813
|
* Paths to local files should be relative, as in
|
|
@@ -55124,11 +55124,6 @@ function primitives3D(p5, fn){
|
|
|
55124
55124
|
* The parameter, `callback`, is a function with the drawing instructions for
|
|
55125
55125
|
* the new <a href="#/p5.Geometry">p5.Geometry</a> object. It will be called
|
|
55126
55126
|
* once to create the new 3D shape.
|
|
55127
|
-
*
|
|
55128
|
-
* See <a href="#/p5/beginGeometry">beginGeometry()</a> and
|
|
55129
|
-
* <a href="#/p5/endGeometry">endGeometry()</a> for another way to build 3D
|
|
55130
|
-
* shapes.
|
|
55131
|
-
*
|
|
55132
55127
|
* Note: `buildGeometry()` can only be used in WebGL mode.
|
|
55133
55128
|
*
|
|
55134
55129
|
* @method buildGeometry
|
|
@@ -55332,12 +55327,8 @@ function primitives3D(p5, fn){
|
|
|
55332
55327
|
* <a href="#/p5.Geometry">p5.Geometry</a> objects can contain lots of data
|
|
55333
55328
|
* about their vertices, surface normals, colors, and so on. Complex 3D shapes
|
|
55334
55329
|
* can use lots of memory which is a limited resource in many GPUs. Calling
|
|
55335
|
-
* `freeGeometry()` can improve performance by freeing a
|
|
55336
|
-
* <a href="#/p5.Geometry">p5.Geometry</a> object’s resources from GPU memory.
|
|
55337
55330
|
* `freeGeometry()` works with <a href="#/p5.Geometry">p5.Geometry</a> objects
|
|
55338
|
-
* created with <a href="#/p5/
|
|
55339
|
-
* <a href="#/p5/endGeometry">endGeometry()</a>,
|
|
55340
|
-
* <a href="#/p5/buildGeometry">buildGeometry()</a>, and
|
|
55331
|
+
* created with <a href="#/p5/buildGeometry">buildGeometry()</a> and
|
|
55341
55332
|
* <a href="#/p5/loadModel">loadModel()</a>.
|
|
55342
55333
|
*
|
|
55343
55334
|
* The parameter, `geometry`, is the <a href="#/p5.Geometry">p5.Geometry</a>
|
|
@@ -55353,24 +55344,6 @@ function primitives3D(p5, fn){
|
|
|
55353
55344
|
* @param {p5.Geometry} geometry 3D shape whose resources should be freed.
|
|
55354
55345
|
*
|
|
55355
55346
|
* @example
|
|
55356
|
-
* function setup() {
|
|
55357
|
-
* createCanvas(100, 100, WEBGL);
|
|
55358
|
-
*
|
|
55359
|
-
* background(200);
|
|
55360
|
-
*
|
|
55361
|
-
* // Create a p5.Geometry object.
|
|
55362
|
-
* beginGeometry();
|
|
55363
|
-
* cone();
|
|
55364
|
-
* let shape = endGeometry();
|
|
55365
|
-
*
|
|
55366
|
-
* // Draw the shape.
|
|
55367
|
-
* model(shape);
|
|
55368
|
-
*
|
|
55369
|
-
* // Free the shape's resources.
|
|
55370
|
-
* freeGeometry(shape);
|
|
55371
|
-
* }
|
|
55372
|
-
*
|
|
55373
|
-
* @example
|
|
55374
55347
|
* // Click and drag the mouse to view the scene from different angles.
|
|
55375
55348
|
*
|
|
55376
55349
|
* let button;
|
|
@@ -59607,24 +59580,28 @@ class Shader {
|
|
|
59607
59580
|
*
|
|
59608
59581
|
* In addition to calling hooks, you can create uniforms, which are special variables
|
|
59609
59582
|
* used to pass data from p5.js into the shader. They can be created by calling `uniform` + the
|
|
59610
|
-
* type of the data, such as `uniformFloat` for a number
|
|
59583
|
+
* type of the data, such as `uniformFloat` for a number or `uniformVector2` for a two-component vector.
|
|
59611
59584
|
* They take in a function that returns the data for the variable. You can then reference these
|
|
59612
59585
|
* variables in your hooks, and their values will update every time you apply
|
|
59613
|
-
* the shader with the result of your function.
|
|
59586
|
+
* the shader with the result of your function.
|
|
59587
|
+
*
|
|
59588
|
+
* Move the mouse over this sketch to increase the moveCounter which will be passed to the shader as a uniform.
|
|
59614
59589
|
*
|
|
59615
59590
|
* ```js example
|
|
59616
59591
|
* let myShader;
|
|
59617
|
-
*
|
|
59592
|
+
* //count of frames in which mouse has been moved
|
|
59593
|
+
* let moveCounter = 0;
|
|
59594
|
+
*
|
|
59618
59595
|
* function setup() {
|
|
59619
59596
|
* createCanvas(200, 200, WEBGL);
|
|
59620
59597
|
* myShader = baseMaterialShader().modify(() => {
|
|
59621
|
-
* // Get the
|
|
59622
|
-
* let
|
|
59598
|
+
* // Get the move counter from our sketch
|
|
59599
|
+
* let count = uniformFloat(() => moveCounter);
|
|
59623
59600
|
*
|
|
59624
59601
|
* getPixelInputs((inputs) => {
|
|
59625
59602
|
* inputs.color = [
|
|
59626
59603
|
* inputs.texCoord,
|
|
59627
|
-
* sin(
|
|
59604
|
+
* sin(count/100) / 2 + 0.5,
|
|
59628
59605
|
* 1,
|
|
59629
59606
|
* ];
|
|
59630
59607
|
* return inputs;
|
|
@@ -59632,6 +59609,10 @@ class Shader {
|
|
|
59632
59609
|
* });
|
|
59633
59610
|
* }
|
|
59634
59611
|
*
|
|
59612
|
+
* function mouseDragged(){
|
|
59613
|
+
* moveCounter += 1;
|
|
59614
|
+
* }
|
|
59615
|
+
*
|
|
59635
59616
|
* function draw() {
|
|
59636
59617
|
* background(255);
|
|
59637
59618
|
* noStroke(255);
|
|
@@ -61010,7 +60991,7 @@ function material(p5, fn) {
|
|
|
61010
60991
|
* // Make a version of the shader with a hook overridden
|
|
61011
60992
|
* modifiedShader = myShader.modify(() => {
|
|
61012
60993
|
* // Create new uniforms and override the getColor hook
|
|
61013
|
-
* let t =
|
|
60994
|
+
* let t = millis() / 1000;
|
|
61014
60995
|
* getColor(() => {
|
|
61015
60996
|
* return [0, 0.5 + 0.5 * sin(t), 1, 1];
|
|
61016
60997
|
* });
|
|
@@ -61256,7 +61237,7 @@ function material(p5, fn) {
|
|
|
61256
61237
|
* }
|
|
61257
61238
|
* ```
|
|
61258
61239
|
*
|
|
61259
|
-
* You can also animate your filters over time
|
|
61240
|
+
* You can also animate your filters over time using the `millis()` function.
|
|
61260
61241
|
*
|
|
61261
61242
|
* ```js example
|
|
61262
61243
|
* let myFilter;
|
|
@@ -61267,7 +61248,7 @@ function material(p5, fn) {
|
|
|
61267
61248
|
* }
|
|
61268
61249
|
*
|
|
61269
61250
|
* function gradient() {
|
|
61270
|
-
* let time =
|
|
61251
|
+
* let time = millis();
|
|
61271
61252
|
* filterColor.begin();
|
|
61272
61253
|
* filterColor.set(mix(
|
|
61273
61254
|
* [1, 0, 0, 1], // Red
|
|
@@ -61278,12 +61259,11 @@ function material(p5, fn) {
|
|
|
61278
61259
|
* }
|
|
61279
61260
|
*
|
|
61280
61261
|
* function draw() {
|
|
61281
|
-
* myFilter.setUniform('time', millis());
|
|
61282
61262
|
* filter(myFilter);
|
|
61283
61263
|
* }
|
|
61284
61264
|
* ```
|
|
61285
61265
|
*
|
|
61286
|
-
* We can use the `noise()` function built into strands to generate a color for each pixel. (Again no need here for underlying content for the filter to operate on.) Again we'll animate by
|
|
61266
|
+
* We can use the `noise()` function built into strands to generate a color for each pixel. (Again no need here for underlying content for the filter to operate on.) Again we'll animate by using the millis() function to get an up-to-date time value.
|
|
61287
61267
|
*
|
|
61288
61268
|
* ```js example
|
|
61289
61269
|
* let myFilter;
|
|
@@ -61295,7 +61275,7 @@ function material(p5, fn) {
|
|
|
61295
61275
|
* }
|
|
61296
61276
|
*
|
|
61297
61277
|
* function noiseShaderCallback() {
|
|
61298
|
-
* let time =
|
|
61278
|
+
* let time = millis();
|
|
61299
61279
|
* filterColor.begin();
|
|
61300
61280
|
* let coord = filterColor.texCoord;
|
|
61301
61281
|
*
|
|
@@ -61312,7 +61292,6 @@ function material(p5, fn) {
|
|
|
61312
61292
|
* }
|
|
61313
61293
|
*
|
|
61314
61294
|
* function draw() {
|
|
61315
|
-
* myFilter.setUniform("time", millis());
|
|
61316
61295
|
* filter(myFilter);
|
|
61317
61296
|
* }
|
|
61318
61297
|
* ```
|
|
@@ -61526,7 +61505,7 @@ function material(p5, fn) {
|
|
|
61526
61505
|
* }
|
|
61527
61506
|
*
|
|
61528
61507
|
* function material() {
|
|
61529
|
-
* let time =
|
|
61508
|
+
* let time = millis() / 1000;
|
|
61530
61509
|
* finalColor.begin();
|
|
61531
61510
|
* let r = 0.2 + 0.5 * abs(sin(time + 0));
|
|
61532
61511
|
* let g = 0.2 + 0.5 * abs(sin(time + 1));
|
|
@@ -61537,7 +61516,6 @@ function material(p5, fn) {
|
|
|
61537
61516
|
*
|
|
61538
61517
|
* function draw() {
|
|
61539
61518
|
* background(245, 245, 220);
|
|
61540
|
-
* myShader.setUniform('time', millis() / 1000);
|
|
61541
61519
|
* shader(myShader);
|
|
61542
61520
|
*
|
|
61543
61521
|
* rectMode(CENTER);
|
|
@@ -62013,7 +61991,7 @@ function material(p5, fn) {
|
|
|
62013
61991
|
* }
|
|
62014
61992
|
*
|
|
62015
61993
|
* function material() {
|
|
62016
|
-
* let time =
|
|
61994
|
+
* let time = millis();
|
|
62017
61995
|
* worldInputs.begin();
|
|
62018
61996
|
* worldInputs.position.y +=
|
|
62019
61997
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -62023,7 +62001,6 @@ function material(p5, fn) {
|
|
|
62023
62001
|
* function draw() {
|
|
62024
62002
|
* background(255);
|
|
62025
62003
|
* shader(myShader);
|
|
62026
|
-
* myShader.setUniform('time', millis());
|
|
62027
62004
|
* lights();
|
|
62028
62005
|
* noStroke();
|
|
62029
62006
|
* fill('red');
|
|
@@ -62192,7 +62169,6 @@ function material(p5, fn) {
|
|
|
62192
62169
|
* function draw() {
|
|
62193
62170
|
* background(255);
|
|
62194
62171
|
* shader(myShader);
|
|
62195
|
-
* myShader.setUniform('time', millis());
|
|
62196
62172
|
* lights();
|
|
62197
62173
|
* noStroke();
|
|
62198
62174
|
* fill('red');
|
|
@@ -62206,7 +62182,7 @@ function material(p5, fn) {
|
|
|
62206
62182
|
*
|
|
62207
62183
|
* ```js
|
|
62208
62184
|
* // myMaterial.js
|
|
62209
|
-
* let time =
|
|
62185
|
+
* let time = millis();
|
|
62210
62186
|
* worldInputs.begin();
|
|
62211
62187
|
* worldInputs.position.y +=
|
|
62212
62188
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -62315,7 +62291,7 @@ function material(p5, fn) {
|
|
|
62315
62291
|
* }
|
|
62316
62292
|
*
|
|
62317
62293
|
* function material() {
|
|
62318
|
-
* let time =
|
|
62294
|
+
* let time = millis();
|
|
62319
62295
|
* worldInputs.begin();
|
|
62320
62296
|
* worldInputs.position.y +=
|
|
62321
62297
|
* 20. * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -62325,7 +62301,6 @@ function material(p5, fn) {
|
|
|
62325
62301
|
* function draw() {
|
|
62326
62302
|
* background(255);
|
|
62327
62303
|
* shader(myShader);
|
|
62328
|
-
* myShader.setUniform('time', millis());
|
|
62329
62304
|
* noStroke();
|
|
62330
62305
|
* sphere(50);
|
|
62331
62306
|
* }
|
|
@@ -62411,7 +62386,6 @@ function material(p5, fn) {
|
|
|
62411
62386
|
* function draw() {
|
|
62412
62387
|
* background(255);
|
|
62413
62388
|
* shader(myShader);
|
|
62414
|
-
* myShader.setUniform('time', millis());
|
|
62415
62389
|
* lights();
|
|
62416
62390
|
* noStroke();
|
|
62417
62391
|
* fill('red');
|
|
@@ -62425,7 +62399,7 @@ function material(p5, fn) {
|
|
|
62425
62399
|
*
|
|
62426
62400
|
* ```js
|
|
62427
62401
|
* // myMaterial.js
|
|
62428
|
-
* let time =
|
|
62402
|
+
* let time = millis();
|
|
62429
62403
|
* worldInputs.begin();
|
|
62430
62404
|
* worldInputs.position.y +=
|
|
62431
62405
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -62518,7 +62492,7 @@ function material(p5, fn) {
|
|
|
62518
62492
|
* }
|
|
62519
62493
|
*
|
|
62520
62494
|
* function material() {
|
|
62521
|
-
* let time =
|
|
62495
|
+
* let time = millis();
|
|
62522
62496
|
* worldInputs.begin();
|
|
62523
62497
|
* worldInputs.position.y +=
|
|
62524
62498
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -62528,7 +62502,6 @@ function material(p5, fn) {
|
|
|
62528
62502
|
* function draw() {
|
|
62529
62503
|
* background(255);
|
|
62530
62504
|
* shader(myShader);
|
|
62531
|
-
* myShader.setUniform('time', millis());
|
|
62532
62505
|
* noStroke();
|
|
62533
62506
|
* fill('red');
|
|
62534
62507
|
* circle(0, 0, 50);
|
|
@@ -62577,7 +62550,6 @@ function material(p5, fn) {
|
|
|
62577
62550
|
* function draw() {
|
|
62578
62551
|
* background(255);
|
|
62579
62552
|
* shader(myShader);
|
|
62580
|
-
* myShader.setUniform('time', millis());
|
|
62581
62553
|
* lights();
|
|
62582
62554
|
* noStroke();
|
|
62583
62555
|
* fill('red');
|
|
@@ -62591,7 +62563,7 @@ function material(p5, fn) {
|
|
|
62591
62563
|
*
|
|
62592
62564
|
* ```js
|
|
62593
62565
|
* // myMaterial.js
|
|
62594
|
-
* let time =
|
|
62566
|
+
* let time = millis();
|
|
62595
62567
|
* worldInputs.begin();
|
|
62596
62568
|
* worldInputs.position.y +=
|
|
62597
62569
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -62763,7 +62735,7 @@ function material(p5, fn) {
|
|
|
62763
62735
|
* }
|
|
62764
62736
|
*
|
|
62765
62737
|
* function material() {
|
|
62766
|
-
* let time =
|
|
62738
|
+
* let time = millis();
|
|
62767
62739
|
* worldInputs.begin();
|
|
62768
62740
|
* // Add a somewhat random offset to the weight
|
|
62769
62741
|
* // that varies based on position and time
|
|
@@ -62779,7 +62751,6 @@ function material(p5, fn) {
|
|
|
62779
62751
|
* function draw() {
|
|
62780
62752
|
* background(255);
|
|
62781
62753
|
* strokeShader(myShader);
|
|
62782
|
-
* myShader.setUniform('time', millis());
|
|
62783
62754
|
* strokeWeight(10);
|
|
62784
62755
|
* beginShape();
|
|
62785
62756
|
* for (let i = 0; i <= 50; i++) {
|
|
@@ -65476,7 +65447,7 @@ class Graphics {
|
|
|
65476
65447
|
* Removes the graphics buffer from the web page.
|
|
65477
65448
|
*
|
|
65478
65449
|
* Calling `myGraphics.remove()` removes the graphics buffer's
|
|
65479
|
-
*
|
|
65450
|
+
* `<canvas>` element from the web page. The graphics buffer also uses
|
|
65480
65451
|
* a bit of memory on the CPU that can be freed like so:
|
|
65481
65452
|
*
|
|
65482
65453
|
* ```js
|
|
@@ -65832,7 +65803,7 @@ function graphics(p5, fn){
|
|
|
65832
65803
|
* @param {Number} h height height of the graphics buffer in pixels.
|
|
65833
65804
|
* @param {(P2D|WEBGL|P2DHDR)} renderer the renderer to use, either P2D or WEBGL.
|
|
65834
65805
|
* @param {p5} [pInst] sketch instance.
|
|
65835
|
-
* @param {HTMLCanvasElement} [canvas] existing
|
|
65806
|
+
* @param {HTMLCanvasElement} [canvas] existing `<canvas>` element to use.
|
|
65836
65807
|
*
|
|
65837
65808
|
* @example
|
|
65838
65809
|
* let pg;
|
|
@@ -68811,9 +68782,9 @@ function rendering(p5, fn){
|
|
|
68811
68782
|
|
|
68812
68783
|
/**
|
|
68813
68784
|
* A system variable that provides direct access to the sketch's
|
|
68814
|
-
*
|
|
68785
|
+
* `<canvas>` element.
|
|
68815
68786
|
*
|
|
68816
|
-
* The
|
|
68787
|
+
* The `<canvas>` element provides many specialized features that aren't
|
|
68817
68788
|
* included in the p5.js library. The `drawingContext` system variable
|
|
68818
68789
|
* provides access to these features by exposing the sketch's
|
|
68819
68790
|
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D">CanvasRenderingContext2D</a>
|
|
@@ -69364,9 +69335,6 @@ class StrandsNode {
|
|
|
69364
69335
|
const assignmentID = getOrCreateNode(dag, assignmentNode);
|
|
69365
69336
|
recordInBasicBlock(cfg, cfg.currentBlock, assignmentID);
|
|
69366
69337
|
|
|
69367
|
-
// Track for global assignments processing
|
|
69368
|
-
this.strandsContext.globalAssignments.push(assignmentID);
|
|
69369
|
-
|
|
69370
69338
|
// Simply update this node to be a variable node with the identifier
|
|
69371
69339
|
// This ensures it always generates the variable name in expressions
|
|
69372
69340
|
const variableNodeData = createNodeData({
|
|
@@ -69430,9 +69398,6 @@ class StrandsNode {
|
|
|
69430
69398
|
const assignmentID = getOrCreateNode(dag, assignmentNode);
|
|
69431
69399
|
recordInBasicBlock(cfg, cfg.currentBlock, assignmentID);
|
|
69432
69400
|
|
|
69433
|
-
// Track for global assignments processing in the current hook context
|
|
69434
|
-
this.strandsContext.globalAssignments.push(assignmentID);
|
|
69435
|
-
|
|
69436
69401
|
// Simply update this node to be a variable node with the identifier
|
|
69437
69402
|
// This ensures it always generates the variable name in expressions
|
|
69438
69403
|
const variableNodeData = createNodeData({
|
|
@@ -97302,18 +97267,20 @@ function storage(p5, fn){
|
|
|
97302
97267
|
*/
|
|
97303
97268
|
fn.storeItem = function(key, value) {
|
|
97304
97269
|
if (typeof key !== 'string') {
|
|
97305
|
-
|
|
97306
|
-
`The argument that you passed to storeItem() - ${key} is not a string
|
|
97270
|
+
p5._friendlyError(
|
|
97271
|
+
`The argument that you passed to storeItem() - ${key} is not a string.`,
|
|
97272
|
+
'storeItem'
|
|
97307
97273
|
);
|
|
97308
97274
|
}
|
|
97309
97275
|
if (key.endsWith('p5TypeID')) {
|
|
97310
|
-
|
|
97311
|
-
`The argument that you passed to storeItem() - ${key} must not end with 'p5TypeID'
|
|
97276
|
+
p5._friendlyError(
|
|
97277
|
+
`The argument that you passed to storeItem() - ${key} must not end with 'p5TypeID'.`,
|
|
97278
|
+
'storeItem'
|
|
97312
97279
|
);
|
|
97313
97280
|
}
|
|
97314
97281
|
|
|
97315
97282
|
if (typeof value === 'undefined') {
|
|
97316
|
-
|
|
97283
|
+
p5._friendlyError('You cannot store undefined variables using storeItem().', 'storeItem');
|
|
97317
97284
|
}
|
|
97318
97285
|
let type = typeof value;
|
|
97319
97286
|
switch (type) {
|
|
@@ -97448,8 +97415,9 @@ function storage(p5, fn){
|
|
|
97448
97415
|
let value = localStorage.getItem(key);
|
|
97449
97416
|
const type = localStorage.getItem(`${key}p5TypeID`);
|
|
97450
97417
|
if (typeof type === 'undefined') {
|
|
97451
|
-
|
|
97452
|
-
`Unable to determine type of item stored under ${key}in local storage. Did you save the item with something other than setItem()
|
|
97418
|
+
p5._friendlyError(
|
|
97419
|
+
`Unable to determine type of item stored under ${key}in local storage. Did you save the item with something other than setItem()?`,
|
|
97420
|
+
'getItem'
|
|
97453
97421
|
);
|
|
97454
97422
|
} else if (value !== null) {
|
|
97455
97423
|
switch (type) {
|
|
@@ -97600,8 +97568,9 @@ function storage(p5, fn){
|
|
|
97600
97568
|
*/
|
|
97601
97569
|
fn.removeItem = function(key) {
|
|
97602
97570
|
if (typeof key !== 'string') {
|
|
97603
|
-
|
|
97604
|
-
`The argument that you passed to removeItem() - ${key} is not a string
|
|
97571
|
+
p5._friendlyError(
|
|
97572
|
+
`The argument that you passed to removeItem() - ${key} is not a string.`,
|
|
97573
|
+
'removeItem'
|
|
97605
97574
|
);
|
|
97606
97575
|
}
|
|
97607
97576
|
localStorage.removeItem(key);
|
|
@@ -97987,16 +97956,16 @@ function dom$1(p5, fn){
|
|
|
97987
97956
|
}
|
|
97988
97957
|
|
|
97989
97958
|
/**
|
|
97990
|
-
* Creates a
|
|
97959
|
+
* Creates a `<div></div>` element.
|
|
97991
97960
|
*
|
|
97992
|
-
*
|
|
97961
|
+
* `<div></div>` elements are commonly used as containers for
|
|
97993
97962
|
* other elements.
|
|
97994
97963
|
*
|
|
97995
97964
|
* The parameter `html` is optional. It accepts a string that sets the
|
|
97996
|
-
* inner HTML of the new
|
|
97965
|
+
* inner HTML of the new `<div></div>`.
|
|
97997
97966
|
*
|
|
97998
97967
|
* @method createDiv
|
|
97999
|
-
* @param {String} [html] inner HTML for the new
|
|
97968
|
+
* @param {String} [html] inner HTML for the new `<div></div>` element.
|
|
98000
97969
|
* @return {p5.Element} new <a href="#/p5.Element">p5.Element</a> object.
|
|
98001
97970
|
*
|
|
98002
97971
|
* @example
|
|
@@ -98034,13 +98003,13 @@ function dom$1(p5, fn){
|
|
|
98034
98003
|
/**
|
|
98035
98004
|
* Creates a paragraph element.
|
|
98036
98005
|
*
|
|
98037
|
-
*
|
|
98006
|
+
* `<p></p>` elements are commonly used for paragraph-length text.
|
|
98038
98007
|
*
|
|
98039
98008
|
* The parameter `html` is optional. It accepts a string that sets the
|
|
98040
|
-
* inner HTML of the new
|
|
98009
|
+
* inner HTML of the new `<p></p>`.
|
|
98041
98010
|
*
|
|
98042
98011
|
* @method createP
|
|
98043
|
-
* @param {String} [html] inner HTML for the new
|
|
98012
|
+
* @param {String} [html] inner HTML for the new `<p></p>` element.
|
|
98044
98013
|
* @return {p5.Element} new <a href="#/p5.Element">p5.Element</a> object.
|
|
98045
98014
|
*
|
|
98046
98015
|
* @example
|
|
@@ -98063,18 +98032,18 @@ function dom$1(p5, fn){
|
|
|
98063
98032
|
};
|
|
98064
98033
|
|
|
98065
98034
|
/**
|
|
98066
|
-
* Creates a
|
|
98035
|
+
* Creates a `<span></span>` element.
|
|
98067
98036
|
*
|
|
98068
|
-
*
|
|
98069
|
-
* for inline elements. For example, a
|
|
98037
|
+
* `<span></span>` elements are commonly used as containers
|
|
98038
|
+
* for inline elements. For example, a `<span></span>`
|
|
98070
98039
|
* can hold part of a sentence that's a
|
|
98071
98040
|
* <span style="color: deeppink;">different</span> style.
|
|
98072
98041
|
*
|
|
98073
98042
|
* The parameter `html` is optional. It accepts a string that sets the
|
|
98074
|
-
* inner HTML of the new
|
|
98043
|
+
* inner HTML of the new `<span></span>`.
|
|
98075
98044
|
*
|
|
98076
98045
|
* @method createSpan
|
|
98077
|
-
* @param {String} [html] inner HTML for the new
|
|
98046
|
+
* @param {String} [html] inner HTML for the new `<span></span>` element.
|
|
98078
98047
|
* @return {p5.Element} new <a href="#/p5.Element">p5.Element</a> object.
|
|
98079
98048
|
*
|
|
98080
98049
|
* @example
|
|
@@ -98127,7 +98096,7 @@ function dom$1(p5, fn){
|
|
|
98127
98096
|
};
|
|
98128
98097
|
|
|
98129
98098
|
/**
|
|
98130
|
-
* Creates an
|
|
98099
|
+
* Creates an `<img>` element that can appear outside of the canvas.
|
|
98131
98100
|
*
|
|
98132
98101
|
* The first parameter, `src`, is a string with the path to the image file.
|
|
98133
98102
|
* `src` should be a relative path, as in `'assets/image.png'`, or a URL, as
|
|
@@ -98198,7 +98167,7 @@ function dom$1(p5, fn){
|
|
|
98198
98167
|
};
|
|
98199
98168
|
|
|
98200
98169
|
/**
|
|
98201
|
-
* Creates an
|
|
98170
|
+
* Creates an `<a></a>` element that links to another web page.
|
|
98202
98171
|
*
|
|
98203
98172
|
* The first parmeter, `href`, is a string that sets the URL of the linked
|
|
98204
98173
|
* page.
|
|
@@ -98255,7 +98224,7 @@ function dom$1(p5, fn){
|
|
|
98255
98224
|
|
|
98256
98225
|
/* INPUT */
|
|
98257
98226
|
/**
|
|
98258
|
-
* Creates a slider
|
|
98227
|
+
* Creates a slider `<input></input>` element.
|
|
98259
98228
|
*
|
|
98260
98229
|
* Range sliders are useful for quickly selecting numbers from a given range.
|
|
98261
98230
|
*
|
|
@@ -98377,7 +98346,7 @@ function dom$1(p5, fn){
|
|
|
98377
98346
|
};
|
|
98378
98347
|
|
|
98379
98348
|
/**
|
|
98380
|
-
* Creates a
|
|
98349
|
+
* Creates a `<button></button>` element.
|
|
98381
98350
|
*
|
|
98382
98351
|
* The first parameter, `label`, is a string that sets the label displayed on
|
|
98383
98352
|
* the button.
|
|
@@ -98454,7 +98423,7 @@ function dom$1(p5, fn){
|
|
|
98454
98423
|
};
|
|
98455
98424
|
|
|
98456
98425
|
/**
|
|
98457
|
-
* Creates a checkbox
|
|
98426
|
+
* Creates a checkbox `<input></input>` element.
|
|
98458
98427
|
*
|
|
98459
98428
|
* Checkboxes extend the <a href="#/p5.Element">p5.Element</a> class with a
|
|
98460
98429
|
* `checked()` method. Calling `myBox.checked()` returns `true` if it the box
|
|
@@ -98595,11 +98564,11 @@ function dom$1(p5, fn){
|
|
|
98595
98564
|
};
|
|
98596
98565
|
|
|
98597
98566
|
/**
|
|
98598
|
-
* Creates a dropdown menu
|
|
98567
|
+
* Creates a dropdown menu `<select></select>` element.
|
|
98599
98568
|
*
|
|
98600
98569
|
* The parameter is optional. If `true` is passed, as in
|
|
98601
98570
|
* `let mySelect = createSelect(true)`, then the dropdown will support
|
|
98602
|
-
* multiple selections. If an existing
|
|
98571
|
+
* multiple selections. If an existing `<select></select>` element
|
|
98603
98572
|
* is passed, as in `let mySelect = createSelect(otherSelect)`, the existing
|
|
98604
98573
|
* element will be wrapped in a new <a href="#/p5.Element">p5.Element</a>
|
|
98605
98574
|
* object.
|
|
@@ -98866,8 +98835,8 @@ function dom$1(p5, fn){
|
|
|
98866
98835
|
*
|
|
98867
98836
|
* The parameter is optional. If a string is passed, as in
|
|
98868
98837
|
* `let myRadio = createSelect('food')`, then each radio option will
|
|
98869
|
-
* have `"food"` as its `name` parameter:
|
|
98870
|
-
* If an existing
|
|
98838
|
+
* have `"food"` as its `name` parameter: `<input name="food"></input>`.
|
|
98839
|
+
* If an existing `<div></div>` or `<span></span>`
|
|
98871
98840
|
* element is passed, as in `let myRadio = createSelect(container)`, it will
|
|
98872
98841
|
* become the radio button's parent element.
|
|
98873
98842
|
*
|
|
@@ -98880,8 +98849,8 @@ function dom$1(p5, fn){
|
|
|
98880
98849
|
* - `myRadio.disable(shouldDisable)` enables the entire radio button if `true` is passed and disables it if `false` is passed.
|
|
98881
98850
|
*
|
|
98882
98851
|
* @method createRadio
|
|
98883
|
-
* @param {Object} [containerElement] container HTML Element, either a
|
|
98884
|
-
* or
|
|
98852
|
+
* @param {Object} [containerElement] container HTML Element, either a `<div></div>`
|
|
98853
|
+
* or `<span></span>`.
|
|
98885
98854
|
* @return {p5.Element} new <a href="#/p5.Element">p5.Element</a> object.
|
|
98886
98855
|
*
|
|
98887
98856
|
* @example
|
|
@@ -99000,7 +98969,7 @@ function dom$1(p5, fn){
|
|
|
99000
98969
|
*/
|
|
99001
98970
|
/**
|
|
99002
98971
|
* @method createRadio
|
|
99003
|
-
* @param {String} [name] name parameter assigned to each option's
|
|
98972
|
+
* @param {String} [name] name parameter assigned to each option's `<input></input>` element.
|
|
99004
98973
|
* @return {p5.Element} new <a href="#/p5.Element">p5.Element</a> object.
|
|
99005
98974
|
*/
|
|
99006
98975
|
/**
|
|
@@ -99267,7 +99236,7 @@ function dom$1(p5, fn){
|
|
|
99267
99236
|
};
|
|
99268
99237
|
|
|
99269
99238
|
/**
|
|
99270
|
-
* Creates a text
|
|
99239
|
+
* Creates a text `<input></input>` element.
|
|
99271
99240
|
*
|
|
99272
99241
|
* Call `myInput.size()` to set the length of the text box.
|
|
99273
99242
|
*
|
|
@@ -99343,7 +99312,7 @@ function dom$1(p5, fn){
|
|
|
99343
99312
|
};
|
|
99344
99313
|
|
|
99345
99314
|
/**
|
|
99346
|
-
* Creates an
|
|
99315
|
+
* Creates an `<input></input>` element of type `'file'`.
|
|
99347
99316
|
*
|
|
99348
99317
|
* `createFileInput()` allows users to select local files for use in a sketch.
|
|
99349
99318
|
* It returns a <a href="#/p5.File">p5.File</a> object.
|
|
@@ -99448,8 +99417,9 @@ function dom$1(p5, fn){
|
|
|
99448
99417
|
|
|
99449
99418
|
// If File API's are not supported, throw Error
|
|
99450
99419
|
if (!(window.File && window.FileReader && window.FileList && window.Blob)) {
|
|
99451
|
-
|
|
99452
|
-
'The File APIs are not fully supported in this browser. Cannot create element.'
|
|
99420
|
+
p5._friendlyError(
|
|
99421
|
+
'The File APIs are not fully supported in this browser. Cannot create element.',
|
|
99422
|
+
'createFileInput'
|
|
99453
99423
|
);
|
|
99454
99424
|
return;
|
|
99455
99425
|
}
|
|
@@ -103148,7 +103118,7 @@ function pointer(p5, fn, lifecycles){
|
|
|
103148
103118
|
canvas.requestPointerLock =
|
|
103149
103119
|
canvas.requestPointerLock || canvas.mozRequestPointerLock;
|
|
103150
103120
|
if (!canvas.requestPointerLock) {
|
|
103151
|
-
|
|
103121
|
+
p5._friendlyError('requestPointerLock is not implemented in this browser', 'requestPointerLock');
|
|
103152
103122
|
return false;
|
|
103153
103123
|
}
|
|
103154
103124
|
canvas.requestPointerLock();
|
|
@@ -110742,9 +110712,7 @@ function loading$1(p5, fn){
|
|
|
110742
110712
|
* The parameter, `model`, is the
|
|
110743
110713
|
* <a href="#/p5.Geometry">p5.Geometry</a> object to draw.
|
|
110744
110714
|
* <a href="#/p5.Geometry">p5.Geometry</a> objects can be built with
|
|
110745
|
-
* <a href="#/p5/buildGeometry">buildGeometry()</a
|
|
110746
|
-
* <a href="#/p5/beginGeometry">beginGeometry()</a> and
|
|
110747
|
-
* <a href="#/p5/endGeometry">endGeometry()</a>. They can also be loaded from
|
|
110715
|
+
* <a href="#/p5/buildGeometry">buildGeometry()</a>. They can also be loaded from
|
|
110748
110716
|
* a file with <a href="#/p5/loadGeometry">loadGeometry()</a>.
|
|
110749
110717
|
*
|
|
110750
110718
|
* Note: `model()` can only be used in WebGL mode.
|
|
@@ -132405,18 +132373,6 @@ function generateShaderCode(strandsContext) {
|
|
|
132405
132373
|
backend.generateBlock(blockID, strandsContext, generationContext);
|
|
132406
132374
|
}
|
|
132407
132375
|
|
|
132408
|
-
// Process any unvisited global assignments to ensure side effects are generated
|
|
132409
|
-
for (const assignmentNodeID of strandsContext.globalAssignments) {
|
|
132410
|
-
if (!generationContext.visitedNodes.has(assignmentNodeID)) {
|
|
132411
|
-
// This assignment hasn't been visited yet, so we need to generate it
|
|
132412
|
-
backend.generateAssignment(generationContext, strandsContext.dag, assignmentNodeID);
|
|
132413
|
-
generationContext.visitedNodes.add(assignmentNodeID);
|
|
132414
|
-
}
|
|
132415
|
-
}
|
|
132416
|
-
|
|
132417
|
-
// Reset global assignments for next hook
|
|
132418
|
-
strandsContext.globalAssignments = [];
|
|
132419
|
-
|
|
132420
132376
|
const firstLine = backend.hookEntry(hookType);
|
|
132421
132377
|
let returnType;
|
|
132422
132378
|
if (hookType.returnType.properties) {
|
|
@@ -133461,7 +133417,6 @@ function initGlobalStrandsAPI(p5, fn, strandsContext) {
|
|
|
133461
133417
|
typeInfo,
|
|
133462
133418
|
usedInVertex: false,
|
|
133463
133419
|
usedInFragment: false,
|
|
133464
|
-
declared: false
|
|
133465
133420
|
});
|
|
133466
133421
|
|
|
133467
133422
|
return createStrandsNode(id, dimension, strandsContext);
|
|
@@ -133825,7 +133780,6 @@ function strands(p5, fn) {
|
|
|
133825
133780
|
ctx.vertexDeclarations = new Set();
|
|
133826
133781
|
ctx.fragmentDeclarations = new Set();
|
|
133827
133782
|
ctx.hooks = [];
|
|
133828
|
-
ctx.globalAssignments = [];
|
|
133829
133783
|
ctx.backend = backend;
|
|
133830
133784
|
ctx.active = active;
|
|
133831
133785
|
ctx.renderer = renderer;
|
|
@@ -133847,7 +133801,6 @@ function strands(p5, fn) {
|
|
|
133847
133801
|
ctx.vertexDeclarations = new Set();
|
|
133848
133802
|
ctx.fragmentDeclarations = new Set();
|
|
133849
133803
|
ctx.hooks = [];
|
|
133850
|
-
ctx.globalAssignments = [];
|
|
133851
133804
|
ctx.active = false;
|
|
133852
133805
|
p5.disableFriendlyErrors = ctx.previousFES;
|
|
133853
133806
|
for (const key in ctx.windowOverrides) {
|
|
@@ -133992,7 +133945,7 @@ if (typeof p5 !== "undefined") {
|
|
|
133992
133945
|
* }
|
|
133993
133946
|
*
|
|
133994
133947
|
* function material() {
|
|
133995
|
-
* let t =
|
|
133948
|
+
* let t = millis();
|
|
133996
133949
|
* worldInputs.begin();
|
|
133997
133950
|
* // Move the vertex up and down in a wave in world space
|
|
133998
133951
|
* // In world space, moving the object (e.g., with translate()) will affect these coordinates
|
|
@@ -134004,7 +133957,6 @@ if (typeof p5 !== "undefined") {
|
|
|
134004
133957
|
* function draw() {
|
|
134005
133958
|
* background(255);
|
|
134006
133959
|
* shader(myShader);
|
|
134007
|
-
* myShader.setUniform('t', millis());
|
|
134008
133960
|
* lights();
|
|
134009
133961
|
* noStroke();
|
|
134010
133962
|
* fill('red');
|
|
@@ -134093,9 +134045,7 @@ if (typeof p5 !== "undefined") {
|
|
|
134093
134045
|
* A value between `0.0` and `1.0`
|
|
134094
134046
|
*
|
|
134095
134047
|
* @example
|
|
134096
|
-
*
|
|
134097
|
-
* <code>
|
|
134098
|
-
* // Example 1: A soft vertical fade using smoothstep (no uniforms)
|
|
134048
|
+
* // Example 1: A soft vertical fade using smoothstep
|
|
134099
134049
|
*
|
|
134100
134050
|
* let fadeShader;
|
|
134101
134051
|
*
|
|
@@ -134114,31 +134064,25 @@ if (typeof p5 !== "undefined") {
|
|
|
134114
134064
|
*
|
|
134115
134065
|
* function setup() {
|
|
134116
134066
|
* createCanvas(300, 200, WEBGL);
|
|
134117
|
-
* fadeShader =
|
|
134067
|
+
* fadeShader = buildFilterShader(fadeCallback);
|
|
134118
134068
|
* }
|
|
134119
134069
|
*
|
|
134120
134070
|
* function draw() {
|
|
134121
134071
|
* background(0);
|
|
134122
134072
|
* filter(fadeShader);
|
|
134123
134073
|
* }
|
|
134124
|
-
* </code>
|
|
134125
|
-
* </div>
|
|
134126
134074
|
*
|
|
134127
134075
|
* @example
|
|
134128
|
-
*
|
|
134129
|
-
* <code>
|
|
134130
|
-
* // Example 2: Animate the smooth transition using a uniform
|
|
134076
|
+
* // Example 2: Animate the smooth transition over time
|
|
134131
134077
|
*
|
|
134132
134078
|
* let animatedShader;
|
|
134133
134079
|
*
|
|
134134
134080
|
* function animatedFadeCallback() {
|
|
134135
|
-
* const time = uniformFloat(() => millis() * 0.001);
|
|
134136
|
-
*
|
|
134137
134081
|
* getColor((inputs) => {
|
|
134138
134082
|
* let x = inputs.texCoord.x;
|
|
134139
134083
|
*
|
|
134140
134084
|
* // Move the smoothstep band back and forth over time
|
|
134141
|
-
* let center = 0.5 + 0.25 * sin(
|
|
134085
|
+
* let center = 0.5 + 0.25 * sin(millis() * 0.001);
|
|
134142
134086
|
* let t = smoothstep(center - 0.05, center + 0.05, x);
|
|
134143
134087
|
*
|
|
134144
134088
|
* return [t, t, t, 1];
|
|
@@ -134147,15 +134091,13 @@ if (typeof p5 !== "undefined") {
|
|
|
134147
134091
|
*
|
|
134148
134092
|
* function setup() {
|
|
134149
134093
|
* createCanvas(300, 200, WEBGL);
|
|
134150
|
-
* animatedShader =
|
|
134094
|
+
* animatedShader = buildFilterShader(animatedFadeCallback);
|
|
134151
134095
|
* }
|
|
134152
134096
|
*
|
|
134153
134097
|
* function draw() {
|
|
134154
134098
|
* background(0);
|
|
134155
134099
|
* filter(animatedShader);
|
|
134156
134100
|
* }
|
|
134157
|
-
* </code>
|
|
134158
|
-
* </div>
|
|
134159
134101
|
*/
|
|
134160
134102
|
|
|
134161
134103
|
/**
|
|
@@ -134272,7 +134214,7 @@ if (typeof p5 !== "undefined") {
|
|
|
134272
134214
|
* }
|
|
134273
134215
|
*
|
|
134274
134216
|
* function material() {
|
|
134275
|
-
* let t =
|
|
134217
|
+
* let t = millis();
|
|
134276
134218
|
* pixelInputs.begin();
|
|
134277
134219
|
* // Animate alpha (transparency) based on x position
|
|
134278
134220
|
* pixelInputs.color.a = 0.5 + 0.5 *
|
|
@@ -134283,7 +134225,6 @@ if (typeof p5 !== "undefined") {
|
|
|
134283
134225
|
* function draw() {
|
|
134284
134226
|
* background(240);
|
|
134285
134227
|
* shader(myShader);
|
|
134286
|
-
* myShader.setUniform('t', millis());
|
|
134287
134228
|
* lights();
|
|
134288
134229
|
* noStroke();
|
|
134289
134230
|
* fill('purple');
|
|
@@ -134474,7 +134415,7 @@ if (typeof p5 !== "undefined") {
|
|
|
134474
134415
|
* }
|
|
134475
134416
|
*
|
|
134476
134417
|
* function material() {
|
|
134477
|
-
* let t =
|
|
134418
|
+
* let t = millis();
|
|
134478
134419
|
* objectInputs.begin();
|
|
134479
134420
|
* // Create a sine wave along the object
|
|
134480
134421
|
* objectInputs.position.y += sin(t * 0.001 + objectInputs.position.x);
|
|
@@ -134484,7 +134425,6 @@ if (typeof p5 !== "undefined") {
|
|
|
134484
134425
|
* function draw() {
|
|
134485
134426
|
* background(220);
|
|
134486
134427
|
* shader(myShader);
|
|
134487
|
-
* myShader.setUniform('t', millis());
|
|
134488
134428
|
* noStroke();
|
|
134489
134429
|
* fill('orange');
|
|
134490
134430
|
* sphere(50);
|
|
@@ -134516,7 +134456,7 @@ if (typeof p5 !== "undefined") {
|
|
|
134516
134456
|
* }
|
|
134517
134457
|
*
|
|
134518
134458
|
* function material() {
|
|
134519
|
-
* let t =
|
|
134459
|
+
* let t = millis();
|
|
134520
134460
|
* cameraInputs.begin();
|
|
134521
134461
|
* // Move vertices in camera space based on their x position
|
|
134522
134462
|
* cameraInputs.position.y += 30 * sin(cameraInputs.position.x * 0.05 + t * 0.001);
|
|
@@ -134528,7 +134468,6 @@ if (typeof p5 !== "undefined") {
|
|
|
134528
134468
|
* function draw() {
|
|
134529
134469
|
* background(200);
|
|
134530
134470
|
* shader(myShader);
|
|
134531
|
-
* myShader.setUniform('t', millis());
|
|
134532
134471
|
* noStroke();
|
|
134533
134472
|
* fill('red');
|
|
134534
134473
|
* sphere(50);
|
|
@@ -134575,8 +134514,6 @@ if (typeof p5 !== "undefined") {
|
|
|
134575
134514
|
* will behave as a vec4 holding components r, g, b, and a (alpha), with each component being in the range 0.0 to 1.0.
|
|
134576
134515
|
*
|
|
134577
134516
|
* @example
|
|
134578
|
-
* <div modernizr='webgl'>
|
|
134579
|
-
* <code>
|
|
134580
134517
|
* // A filter shader (using p5.strands) which will
|
|
134581
134518
|
* // sample and invert the color of each pixel
|
|
134582
134519
|
* // from the canvas.
|
|
@@ -134609,12 +134546,8 @@ if (typeof p5 !== "undefined") {
|
|
|
134609
134546
|
*
|
|
134610
134547
|
* filterColor.end();
|
|
134611
134548
|
* }
|
|
134612
|
-
* </code>
|
|
134613
|
-
*
|
|
134614
134549
|
*
|
|
134615
134550
|
* @example
|
|
134616
|
-
* <div modernizr='webgl'>
|
|
134617
|
-
* <code>
|
|
134618
134551
|
* // This primitive edge-detection filter samples
|
|
134619
134552
|
* // and compares the colors of the current pixel
|
|
134620
134553
|
* // on the canvas, and a little to the right.
|
|
@@ -134671,8 +134604,6 @@ if (typeof p5 !== "undefined") {
|
|
|
134671
134604
|
* rotate(frameCount / 300);
|
|
134672
134605
|
* square(0, 0, 30);
|
|
134673
134606
|
* }
|
|
134674
|
-
* </code>
|
|
134675
|
-
* </div>
|
|
134676
134607
|
*/
|
|
134677
134608
|
|
|
134678
134609
|
/**
|