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/types/global.d.ts
CHANGED
|
@@ -965,9 +965,9 @@ BOTTOM: typeof P5.BOTTOM;
|
|
|
965
965
|
|
|
966
966
|
/**
|
|
967
967
|
* A system variable that provides direct access to the sketch's
|
|
968
|
-
*
|
|
968
|
+
* `<canvas>` element.
|
|
969
969
|
*
|
|
970
|
-
* The
|
|
970
|
+
* The `<canvas>` element provides many specialized features that aren't
|
|
971
971
|
* included in the p5.js library. The `drawingContext` system variable
|
|
972
972
|
* provides access to these features by exposing the sketch's
|
|
973
973
|
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D">CanvasRenderingContext2D</a>
|
|
@@ -2897,6 +2897,26 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
2897
2897
|
byte(n: string | boolean | number): number;
|
|
2898
2898
|
byte(ns: any[]): number[];
|
|
2899
2899
|
|
|
2900
|
+
/**
|
|
2901
|
+
* Creates a custom <a href="#/p5.Geometry">p5.Geometry</a> object from
|
|
2902
|
+
* simpler 3D shapes.
|
|
2903
|
+
*
|
|
2904
|
+
* `buildGeometry()` helps with creating complex 3D shapes from simpler ones
|
|
2905
|
+
* such as <a href="#/p5/sphere">sphere()</a>. It can help to make sketches
|
|
2906
|
+
* more performant. For example, if a complex 3D shape doesn’t change while a
|
|
2907
|
+
* sketch runs, then it can be created with `buildGeometry()`. Creating a
|
|
2908
|
+
* <a href="#/p5.Geometry">p5.Geometry</a> object once and then drawing it
|
|
2909
|
+
* will run faster than repeatedly drawing the individual pieces.
|
|
2910
|
+
*
|
|
2911
|
+
* The parameter, `callback`, is a function with the drawing instructions for
|
|
2912
|
+
* the new <a href="#/p5.Geometry">p5.Geometry</a> object. It will be called
|
|
2913
|
+
* once to create the new 3D shape.
|
|
2914
|
+
* Note: `buildGeometry()` can only be used in WebGL mode.
|
|
2915
|
+
* @param callback function that draws the shape.
|
|
2916
|
+
* @returns new 3D shape.
|
|
2917
|
+
*/
|
|
2918
|
+
buildGeometry(callback: Function): P5.Geometry;
|
|
2919
|
+
|
|
2900
2920
|
/**
|
|
2901
2921
|
* Calculates coordinates along a Bézier curve using interpolation.
|
|
2902
2922
|
*
|
|
@@ -2927,31 +2947,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
2927
2947
|
*/
|
|
2928
2948
|
bezierPoint(a: number, b: number, c: number, d: number, t: number): number;
|
|
2929
2949
|
|
|
2930
|
-
/**
|
|
2931
|
-
* Creates a custom <a href="#/p5.Geometry">p5.Geometry</a> object from
|
|
2932
|
-
* simpler 3D shapes.
|
|
2933
|
-
*
|
|
2934
|
-
* `buildGeometry()` helps with creating complex 3D shapes from simpler ones
|
|
2935
|
-
* such as <a href="#/p5/sphere">sphere()</a>. It can help to make sketches
|
|
2936
|
-
* more performant. For example, if a complex 3D shape doesn’t change while a
|
|
2937
|
-
* sketch runs, then it can be created with `buildGeometry()`. Creating a
|
|
2938
|
-
* <a href="#/p5.Geometry">p5.Geometry</a> object once and then drawing it
|
|
2939
|
-
* will run faster than repeatedly drawing the individual pieces.
|
|
2940
|
-
*
|
|
2941
|
-
* The parameter, `callback`, is a function with the drawing instructions for
|
|
2942
|
-
* the new <a href="#/p5.Geometry">p5.Geometry</a> object. It will be called
|
|
2943
|
-
* once to create the new 3D shape.
|
|
2944
|
-
*
|
|
2945
|
-
* See <a href="#/p5/beginGeometry">beginGeometry()</a> and
|
|
2946
|
-
* <a href="#/p5/endGeometry">endGeometry()</a> for another way to build 3D
|
|
2947
|
-
* shapes.
|
|
2948
|
-
*
|
|
2949
|
-
* Note: `buildGeometry()` can only be used in WebGL mode.
|
|
2950
|
-
* @param callback function that draws the shape.
|
|
2951
|
-
* @returns new 3D shape.
|
|
2952
|
-
*/
|
|
2953
|
-
buildGeometry(callback: Function): P5.Geometry;
|
|
2954
|
-
|
|
2955
2950
|
/**
|
|
2956
2951
|
* Loads a 3D model to create a
|
|
2957
2952
|
* <a href="#/p5.Geometry">p5.Geometry</a> object.
|
|
@@ -3111,20 +3106,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
3111
3106
|
*/
|
|
3112
3107
|
smooth(): void;
|
|
3113
3108
|
|
|
3114
|
-
/**
|
|
3115
|
-
* Removes all items in the web browser's local storage.
|
|
3116
|
-
*
|
|
3117
|
-
* Web browsers can save small amounts of data using the built-in
|
|
3118
|
-
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
|
|
3119
|
-
* Data stored in `localStorage` can be retrieved at any point, even after
|
|
3120
|
-
* refreshing a page or restarting the browser. Data are stored as key-value
|
|
3121
|
-
* pairs. Calling `clearStorage()` removes all data from `localStorage`.
|
|
3122
|
-
*
|
|
3123
|
-
* Note: Sensitive data such as passwords or personal information shouldn't be
|
|
3124
|
-
* stored in `localStorage`.
|
|
3125
|
-
*/
|
|
3126
|
-
clearStorage(): void;
|
|
3127
|
-
|
|
3128
3109
|
/**
|
|
3129
3110
|
* Converts a `Number` into a `String` with a plus or minus sign.
|
|
3130
3111
|
*
|
|
@@ -3160,6 +3141,20 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
3160
3141
|
nfp(num: number, left?: number, right?: number): string;
|
|
3161
3142
|
nfp(nums: number[], left?: number, right?: number): string[];
|
|
3162
3143
|
|
|
3144
|
+
/**
|
|
3145
|
+
* Removes all items in the web browser's local storage.
|
|
3146
|
+
*
|
|
3147
|
+
* Web browsers can save small amounts of data using the built-in
|
|
3148
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
|
|
3149
|
+
* Data stored in `localStorage` can be retrieved at any point, even after
|
|
3150
|
+
* refreshing a page or restarting the browser. Data are stored as key-value
|
|
3151
|
+
* pairs. Calling `clearStorage()` removes all data from `localStorage`.
|
|
3152
|
+
*
|
|
3153
|
+
* Note: Sensitive data such as passwords or personal information shouldn't be
|
|
3154
|
+
* stored in `localStorage`.
|
|
3155
|
+
*/
|
|
3156
|
+
clearStorage(): void;
|
|
3157
|
+
|
|
3163
3158
|
/**
|
|
3164
3159
|
* Removes all elements created by p5.js, including any event handlers.
|
|
3165
3160
|
*
|
|
@@ -3402,6 +3397,29 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
3402
3397
|
frameRate(fps: number): number;
|
|
3403
3398
|
frameRate(): number;
|
|
3404
3399
|
|
|
3400
|
+
/**
|
|
3401
|
+
* Clears a <a href="#/p5.Geometry">p5.Geometry</a> object from the graphics
|
|
3402
|
+
* processing unit (GPU) memory.
|
|
3403
|
+
*
|
|
3404
|
+
* <a href="#/p5.Geometry">p5.Geometry</a> objects can contain lots of data
|
|
3405
|
+
* about their vertices, surface normals, colors, and so on. Complex 3D shapes
|
|
3406
|
+
* can use lots of memory which is a limited resource in many GPUs. Calling
|
|
3407
|
+
* `freeGeometry()` works with <a href="#/p5.Geometry">p5.Geometry</a> objects
|
|
3408
|
+
* created with <a href="#/p5/buildGeometry">buildGeometry()</a> and
|
|
3409
|
+
* <a href="#/p5/loadModel">loadModel()</a>.
|
|
3410
|
+
*
|
|
3411
|
+
* The parameter, `geometry`, is the <a href="#/p5.Geometry">p5.Geometry</a>
|
|
3412
|
+
* object to be freed.
|
|
3413
|
+
*
|
|
3414
|
+
* Note: A <a href="#/p5.Geometry">p5.Geometry</a> object can still be drawn
|
|
3415
|
+
* after its resources are cleared from GPU memory. It may take longer to draw
|
|
3416
|
+
* the first time it’s redrawn.
|
|
3417
|
+
*
|
|
3418
|
+
* Note: `freeGeometry()` can only be used in WebGL mode.
|
|
3419
|
+
* @param geometry 3D shape whose resources should be freed.
|
|
3420
|
+
*/
|
|
3421
|
+
freeGeometry(geometry: P5.Geometry): void;
|
|
3422
|
+
|
|
3405
3423
|
/**
|
|
3406
3424
|
* Calculates the cosine of an angle.
|
|
3407
3425
|
*
|
|
@@ -3464,14 +3482,14 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
3464
3482
|
specularColor(color: P5.Color): void;
|
|
3465
3483
|
|
|
3466
3484
|
/**
|
|
3467
|
-
* Creates a
|
|
3485
|
+
* Creates a `<div></div>` element.
|
|
3468
3486
|
*
|
|
3469
|
-
*
|
|
3487
|
+
* `<div></div>` elements are commonly used as containers for
|
|
3470
3488
|
* other elements.
|
|
3471
3489
|
*
|
|
3472
3490
|
* The parameter `html` is optional. It accepts a string that sets the
|
|
3473
|
-
* inner HTML of the new
|
|
3474
|
-
* @param html inner HTML for the new
|
|
3491
|
+
* inner HTML of the new `<div></div>`.
|
|
3492
|
+
* @param html inner HTML for the new `<div></div>` element.
|
|
3475
3493
|
* @returns new <a href="#/p5.Element">p5.Element</a> object.
|
|
3476
3494
|
*/
|
|
3477
3495
|
createDiv(html?: string): P5.Element;
|
|
@@ -3529,27 +3547,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
3529
3547
|
boolean(n: string | boolean | number): boolean;
|
|
3530
3548
|
boolean(ns: any[]): boolean[];
|
|
3531
3549
|
|
|
3532
|
-
/**
|
|
3533
|
-
* Removes an item from the web browser's local storage.
|
|
3534
|
-
*
|
|
3535
|
-
* Web browsers can save small amounts of data using the built-in
|
|
3536
|
-
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
|
|
3537
|
-
* Data stored in `localStorage` can be retrieved at any point, even after
|
|
3538
|
-
* refreshing a page or restarting the browser. Data are stored as key-value
|
|
3539
|
-
* pairs.
|
|
3540
|
-
*
|
|
3541
|
-
* <a href="#/p5/storeItem">storeItem()</a> makes it easy to store values in
|
|
3542
|
-
* `localStorage` and `removeItem()` makes it easy to delete them.
|
|
3543
|
-
*
|
|
3544
|
-
* The parameter, `key`, is the name of the value to remove as a string. For
|
|
3545
|
-
* example, calling `removeItem('size')` removes the item with the key `size`.
|
|
3546
|
-
*
|
|
3547
|
-
* Note: Sensitive data such as passwords or personal information shouldn't be
|
|
3548
|
-
* stored in `localStorage`.
|
|
3549
|
-
* @param key name of the value to remove.
|
|
3550
|
-
*/
|
|
3551
|
-
removeItem(key: string): void;
|
|
3552
|
-
|
|
3553
3550
|
/**
|
|
3554
3551
|
* Rotates the coordinate system.
|
|
3555
3552
|
*
|
|
@@ -3585,31 +3582,25 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
3585
3582
|
rotate(angle: number, axis?: P5.Vector | number[]): void;
|
|
3586
3583
|
|
|
3587
3584
|
/**
|
|
3588
|
-
*
|
|
3589
|
-
* processing unit (GPU) memory.
|
|
3585
|
+
* Removes an item from the web browser's local storage.
|
|
3590
3586
|
*
|
|
3591
|
-
*
|
|
3592
|
-
*
|
|
3593
|
-
*
|
|
3594
|
-
*
|
|
3595
|
-
*
|
|
3596
|
-
* `freeGeometry()` works with <a href="#/p5.Geometry">p5.Geometry</a> objects
|
|
3597
|
-
* created with <a href="#/p5/beginGeometry">beginGeometry()</a> and
|
|
3598
|
-
* <a href="#/p5/endGeometry">endGeometry()</a>,
|
|
3599
|
-
* <a href="#/p5/buildGeometry">buildGeometry()</a>, and
|
|
3600
|
-
* <a href="#/p5/loadModel">loadModel()</a>.
|
|
3587
|
+
* Web browsers can save small amounts of data using the built-in
|
|
3588
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
|
|
3589
|
+
* Data stored in `localStorage` can be retrieved at any point, even after
|
|
3590
|
+
* refreshing a page or restarting the browser. Data are stored as key-value
|
|
3591
|
+
* pairs.
|
|
3601
3592
|
*
|
|
3602
|
-
*
|
|
3603
|
-
*
|
|
3593
|
+
* <a href="#/p5/storeItem">storeItem()</a> makes it easy to store values in
|
|
3594
|
+
* `localStorage` and `removeItem()` makes it easy to delete them.
|
|
3604
3595
|
*
|
|
3605
|
-
*
|
|
3606
|
-
*
|
|
3607
|
-
* the first time it’s redrawn.
|
|
3596
|
+
* The parameter, `key`, is the name of the value to remove as a string. For
|
|
3597
|
+
* example, calling `removeItem('size')` removes the item with the key `size`.
|
|
3608
3598
|
*
|
|
3609
|
-
* Note:
|
|
3610
|
-
*
|
|
3599
|
+
* Note: Sensitive data such as passwords or personal information shouldn't be
|
|
3600
|
+
* stored in `localStorage`.
|
|
3601
|
+
* @param key name of the value to remove.
|
|
3611
3602
|
*/
|
|
3612
|
-
|
|
3603
|
+
removeItem(key: string): void;
|
|
3613
3604
|
|
|
3614
3605
|
/**
|
|
3615
3606
|
* The <a href="#/p5/setMoveThreshold">setMoveThreshold()</a> function is used to set the movement threshold for
|
|
@@ -3699,11 +3690,11 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
3699
3690
|
/**
|
|
3700
3691
|
* Creates a paragraph element.
|
|
3701
3692
|
*
|
|
3702
|
-
*
|
|
3693
|
+
* `<p></p>` elements are commonly used for paragraph-length text.
|
|
3703
3694
|
*
|
|
3704
3695
|
* The parameter `html` is optional. It accepts a string that sets the
|
|
3705
|
-
* inner HTML of the new
|
|
3706
|
-
* @param html inner HTML for the new
|
|
3696
|
+
* inner HTML of the new `<p></p>`.
|
|
3697
|
+
* @param html inner HTML for the new `<p></p>` element.
|
|
3707
3698
|
* @returns new <a href="#/p5.Element">p5.Element</a> object.
|
|
3708
3699
|
*/
|
|
3709
3700
|
createP(html?: string): P5.Element;
|
|
@@ -3947,7 +3938,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
3947
3938
|
* // Make a version of the shader with a hook overridden
|
|
3948
3939
|
* modifiedShader = myShader.modify(() => {
|
|
3949
3940
|
* // Create new uniforms and override the getColor hook
|
|
3950
|
-
* let t =
|
|
3941
|
+
* let t = millis() / 1000;
|
|
3951
3942
|
* getColor(() => {
|
|
3952
3943
|
* return [0, 0.5 + 0.5 * sin(t), 1, 1];
|
|
3953
3944
|
* });
|
|
@@ -4137,6 +4128,38 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
4137
4128
|
*/
|
|
4138
4129
|
loadTable(filename: string | Request, separator?: string, header?: string, callback?: Function, errorCallback?: Function): Promise<object>;
|
|
4139
4130
|
|
|
4131
|
+
/**
|
|
4132
|
+
* Draws a plane.
|
|
4133
|
+
*
|
|
4134
|
+
* A plane is a four-sided, flat shape with every angle measuring 90˚. It’s
|
|
4135
|
+
* similar to a rectangle and offers advanced drawing features in WebGL mode.
|
|
4136
|
+
*
|
|
4137
|
+
* The first parameter, `width`, is optional. If a `Number` is passed, as in
|
|
4138
|
+
* `plane(20)`, it sets the plane’s width and height. By default, `width` is
|
|
4139
|
+
* 50.
|
|
4140
|
+
*
|
|
4141
|
+
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
4142
|
+
* as in `plane(20, 30)`, it sets the plane’s height. By default, `height` is
|
|
4143
|
+
* set to the plane’s `width`.
|
|
4144
|
+
*
|
|
4145
|
+
* The third parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
4146
|
+
* as in `plane(20, 30, 5)` it sets the number of triangle subdivisions to use
|
|
4147
|
+
* along the x-axis. All 3D shapes are made by connecting triangles to form
|
|
4148
|
+
* their surfaces. By default, `detailX` is 1.
|
|
4149
|
+
*
|
|
4150
|
+
* The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
4151
|
+
* as in `plane(20, 30, 5, 7)` it sets the number of triangle subdivisions to
|
|
4152
|
+
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
4153
|
+
* form their surfaces. By default, `detailY` is 1.
|
|
4154
|
+
*
|
|
4155
|
+
* Note: `plane()` can only be used in WebGL mode.
|
|
4156
|
+
* @param width width of the plane.
|
|
4157
|
+
* @param height height of the plane.
|
|
4158
|
+
* @param detailX number of triangle subdivisions along the x-axis.
|
|
4159
|
+
* @param detailY number of triangle subdivisions along the y-axis.
|
|
4160
|
+
*/
|
|
4161
|
+
plane(width?: number, height?: number, detailX?: number, detailY?: number): void;
|
|
4162
|
+
|
|
4140
4163
|
/**
|
|
4141
4164
|
* Gets the red value of a color.
|
|
4142
4165
|
*
|
|
@@ -4222,16 +4245,16 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
4222
4245
|
tan(angle: number): number;
|
|
4223
4246
|
|
|
4224
4247
|
/**
|
|
4225
|
-
* Creates a
|
|
4248
|
+
* Creates a `<span></span>` element.
|
|
4226
4249
|
*
|
|
4227
|
-
*
|
|
4228
|
-
* for inline elements. For example, a
|
|
4250
|
+
* `<span></span>` elements are commonly used as containers
|
|
4251
|
+
* for inline elements. For example, a `<span></span>`
|
|
4229
4252
|
* can hold part of a sentence that's a
|
|
4230
4253
|
* <span style="color: deeppink;">different</span> style.
|
|
4231
4254
|
*
|
|
4232
4255
|
* The parameter `html` is optional. It accepts a string that sets the
|
|
4233
|
-
* inner HTML of the new
|
|
4234
|
-
* @param html inner HTML for the new
|
|
4256
|
+
* inner HTML of the new `<span></span>`.
|
|
4257
|
+
* @param html inner HTML for the new `<span></span>` element.
|
|
4235
4258
|
* @returns new <a href="#/p5.Element">p5.Element</a> object.
|
|
4236
4259
|
*/
|
|
4237
4260
|
createSpan(html?: string): P5.Element;
|
|
@@ -4284,38 +4307,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
4284
4307
|
*/
|
|
4285
4308
|
loadFilterShader(filename: string, successCallback?: Function, failureCallback?: Function): Promise<P5.Shader>;
|
|
4286
4309
|
|
|
4287
|
-
/**
|
|
4288
|
-
* Draws a plane.
|
|
4289
|
-
*
|
|
4290
|
-
* A plane is a four-sided, flat shape with every angle measuring 90˚. It’s
|
|
4291
|
-
* similar to a rectangle and offers advanced drawing features in WebGL mode.
|
|
4292
|
-
*
|
|
4293
|
-
* The first parameter, `width`, is optional. If a `Number` is passed, as in
|
|
4294
|
-
* `plane(20)`, it sets the plane’s width and height. By default, `width` is
|
|
4295
|
-
* 50.
|
|
4296
|
-
*
|
|
4297
|
-
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
4298
|
-
* as in `plane(20, 30)`, it sets the plane’s height. By default, `height` is
|
|
4299
|
-
* set to the plane’s `width`.
|
|
4300
|
-
*
|
|
4301
|
-
* The third parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
4302
|
-
* as in `plane(20, 30, 5)` it sets the number of triangle subdivisions to use
|
|
4303
|
-
* along the x-axis. All 3D shapes are made by connecting triangles to form
|
|
4304
|
-
* their surfaces. By default, `detailX` is 1.
|
|
4305
|
-
*
|
|
4306
|
-
* The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
4307
|
-
* as in `plane(20, 30, 5, 7)` it sets the number of triangle subdivisions to
|
|
4308
|
-
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
4309
|
-
* form their surfaces. By default, `detailY` is 1.
|
|
4310
|
-
*
|
|
4311
|
-
* Note: `plane()` can only be used in WebGL mode.
|
|
4312
|
-
* @param width width of the plane.
|
|
4313
|
-
* @param height height of the plane.
|
|
4314
|
-
* @param detailX number of triangle subdivisions along the x-axis.
|
|
4315
|
-
* @param detailY number of triangle subdivisions along the y-axis.
|
|
4316
|
-
*/
|
|
4317
|
-
plane(width?: number, height?: number, detailX?: number, detailY?: number): void;
|
|
4318
|
-
|
|
4319
4310
|
/**
|
|
4320
4311
|
* Creates and a new <a href="#/p5.Framebuffer">p5.Framebuffer</a> object.
|
|
4321
4312
|
*
|
|
@@ -4425,7 +4416,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
4425
4416
|
map(value: number, start1: number, stop1: number, start2: number, stop2: number, withinBounds?: boolean): number;
|
|
4426
4417
|
|
|
4427
4418
|
/**
|
|
4428
|
-
* Creates an
|
|
4419
|
+
* Creates an `<img>` element that can appear outside of the canvas.
|
|
4429
4420
|
*
|
|
4430
4421
|
* The first parameter, `src`, is a string with the path to the image file.
|
|
4431
4422
|
* `src` should be a relative path, as in `'assets/image.png'`, or a URL, as
|
|
@@ -4683,6 +4674,42 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
4683
4674
|
*/
|
|
4684
4675
|
green(color: P5.Color | number[] | string): number;
|
|
4685
4676
|
|
|
4677
|
+
/**
|
|
4678
|
+
* Draws a box (rectangular prism).
|
|
4679
|
+
*
|
|
4680
|
+
* A box is a 3D shape with six faces. Each face makes a 90˚ with four
|
|
4681
|
+
* neighboring faces.
|
|
4682
|
+
*
|
|
4683
|
+
* The first parameter, `width`, is optional. If a `Number` is passed, as in
|
|
4684
|
+
* `box(20)`, it sets the box’s width and height. By default, `width` is 50.
|
|
4685
|
+
*
|
|
4686
|
+
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
4687
|
+
* as in `box(20, 30)`, it sets the box’s height. By default, `height` is set
|
|
4688
|
+
* to the box’s `width`.
|
|
4689
|
+
*
|
|
4690
|
+
* The third parameter, `depth`, is also optional. If a `Number` is passed, as
|
|
4691
|
+
* in `box(20, 30, 40)`, it sets the box’s depth. By default, `depth` is set
|
|
4692
|
+
* to the box’s `height`.
|
|
4693
|
+
*
|
|
4694
|
+
* The fourth parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
4695
|
+
* as in `box(20, 30, 40, 5)`, it sets the number of triangle subdivisions to
|
|
4696
|
+
* use along the x-axis. All 3D shapes are made by connecting triangles to
|
|
4697
|
+
* form their surfaces. By default, `detailX` is 1.
|
|
4698
|
+
*
|
|
4699
|
+
* The fifth parameter, `detailY`, is also optional. If a number is passed, as
|
|
4700
|
+
* in `box(20, 30, 40, 5, 7)`, it sets the number of triangle subdivisions to
|
|
4701
|
+
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
4702
|
+
* form their surfaces. By default, `detailY` is 1.
|
|
4703
|
+
*
|
|
4704
|
+
* Note: `box()` can only be used in WebGL mode.
|
|
4705
|
+
* @param width width of the box.
|
|
4706
|
+
* @param height height of the box.
|
|
4707
|
+
* @param depth depth of the box.
|
|
4708
|
+
* @param detailX number of triangle subdivisions along the x-axis.
|
|
4709
|
+
* @param detailY number of triangle subdivisions along the y-axis.
|
|
4710
|
+
*/
|
|
4711
|
+
box(width?: number, height?: number, depth?: number, detailX?: number, detailY?: number): void;
|
|
4712
|
+
|
|
4686
4713
|
/**
|
|
4687
4714
|
* Returns the largest value in a sequence of numbers.
|
|
4688
4715
|
*
|
|
@@ -4733,7 +4760,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
4733
4760
|
bezierVertex(x: number, y: number, z: number, u?: number, v?: number): void;
|
|
4734
4761
|
|
|
4735
4762
|
/**
|
|
4736
|
-
* Creates an
|
|
4763
|
+
* Creates an `<a></a>` element that links to another web page.
|
|
4737
4764
|
*
|
|
4738
4765
|
* The first parmeter, `href`, is a string that sets the URL of the linked
|
|
4739
4766
|
* page.
|
|
@@ -4891,52 +4918,16 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
4891
4918
|
clear(): void;
|
|
4892
4919
|
|
|
4893
4920
|
/**
|
|
4894
|
-
*
|
|
4921
|
+
* Converts a `Number` or `String` to a single-character `String`.
|
|
4895
4922
|
*
|
|
4896
|
-
*
|
|
4897
|
-
* neighboring faces.
|
|
4923
|
+
* `char()` converts numbers to their single-character string representations.
|
|
4898
4924
|
*
|
|
4899
|
-
* The
|
|
4900
|
-
* `
|
|
4901
|
-
*
|
|
4902
|
-
*
|
|
4903
|
-
* as in `
|
|
4904
|
-
*
|
|
4905
|
-
*
|
|
4906
|
-
* The third parameter, `depth`, is also optional. If a `Number` is passed, as
|
|
4907
|
-
* in `box(20, 30, 40)`, it sets the box’s depth. By default, `depth` is set
|
|
4908
|
-
* to the box’s `height`.
|
|
4909
|
-
*
|
|
4910
|
-
* The fourth parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
4911
|
-
* as in `box(20, 30, 40, 5)`, it sets the number of triangle subdivisions to
|
|
4912
|
-
* use along the x-axis. All 3D shapes are made by connecting triangles to
|
|
4913
|
-
* form their surfaces. By default, `detailX` is 1.
|
|
4914
|
-
*
|
|
4915
|
-
* The fifth parameter, `detailY`, is also optional. If a number is passed, as
|
|
4916
|
-
* in `box(20, 30, 40, 5, 7)`, it sets the number of triangle subdivisions to
|
|
4917
|
-
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
4918
|
-
* form their surfaces. By default, `detailY` is 1.
|
|
4919
|
-
*
|
|
4920
|
-
* Note: `box()` can only be used in WebGL mode.
|
|
4921
|
-
* @param width width of the box.
|
|
4922
|
-
* @param height height of the box.
|
|
4923
|
-
* @param depth depth of the box.
|
|
4924
|
-
* @param detailX number of triangle subdivisions along the x-axis.
|
|
4925
|
-
* @param detailY number of triangle subdivisions along the y-axis.
|
|
4926
|
-
*/
|
|
4927
|
-
box(width?: number, height?: number, depth?: number, detailX?: number, detailY?: number): void;
|
|
4928
|
-
|
|
4929
|
-
/**
|
|
4930
|
-
* Converts a `Number` or `String` to a single-character `String`.
|
|
4931
|
-
*
|
|
4932
|
-
* `char()` converts numbers to their single-character string representations.
|
|
4933
|
-
*
|
|
4934
|
-
* The parameter, `n`, is the value to convert. If a number is passed, as in
|
|
4935
|
-
* `char(65)`, the corresponding single-character string is returned. If a
|
|
4936
|
-
* string is passed, as in `char('65')`, the string is converted to an integer
|
|
4937
|
-
* (whole number) and the corresponding single-character string is returned.
|
|
4938
|
-
* If an array is passed, as in `char([65, 66, 67])`, an array of
|
|
4939
|
-
* single-character strings is returned.
|
|
4925
|
+
* The parameter, `n`, is the value to convert. If a number is passed, as in
|
|
4926
|
+
* `char(65)`, the corresponding single-character string is returned. If a
|
|
4927
|
+
* string is passed, as in `char('65')`, the string is converted to an integer
|
|
4928
|
+
* (whole number) and the corresponding single-character string is returned.
|
|
4929
|
+
* If an array is passed, as in `char([65, 66, 67])`, an array of
|
|
4930
|
+
* single-character strings is returned.
|
|
4940
4931
|
*
|
|
4941
4932
|
* See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode" target="_blank">MDN</a>
|
|
4942
4933
|
* for more information about conversions.
|
|
@@ -5070,7 +5061,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5070
5061
|
* (<a href="https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction" target="_blank">XML</a>)
|
|
5071
5062
|
* is a standard format for sending data between applications. Like HTML, the
|
|
5072
5063
|
* XML format is based on tags and attributes, as in
|
|
5073
|
-
*
|
|
5064
|
+
* `<time units="s">1234</time>`.
|
|
5074
5065
|
*
|
|
5075
5066
|
* The first parameter, `path`, is always a string with the path to the file.
|
|
5076
5067
|
* Paths to local files should be relative, as in
|
|
@@ -5239,6 +5230,33 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5239
5230
|
angleMode(mode: typeof P5.RADIANS | typeof P5.DEGREES): typeof P5.RADIANS | typeof P5.DEGREES;
|
|
5240
5231
|
angleMode(): typeof P5.RADIANS | typeof P5.DEGREES;
|
|
5241
5232
|
|
|
5233
|
+
/**
|
|
5234
|
+
* Draws a sphere.
|
|
5235
|
+
*
|
|
5236
|
+
* A sphere is a 3D shape with triangular faces that connect to form a round
|
|
5237
|
+
* surface. Spheres with few faces look like crystals. Spheres with many faces
|
|
5238
|
+
* have smooth surfaces and look like balls.
|
|
5239
|
+
*
|
|
5240
|
+
* The first parameter, `radius`, is optional. If a `Number` is passed, as in
|
|
5241
|
+
* `sphere(20)`, it sets the radius of the sphere. By default, `radius` is 50.
|
|
5242
|
+
*
|
|
5243
|
+
* The second parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
5244
|
+
* as in `sphere(20, 5)`, it sets the number of triangle subdivisions to use
|
|
5245
|
+
* along the x-axis. All 3D shapes are made by connecting triangles to form
|
|
5246
|
+
* their surfaces. By default, `detailX` is 24.
|
|
5247
|
+
*
|
|
5248
|
+
* The third parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
5249
|
+
* as in `sphere(20, 5, 2)`, it sets the number of triangle subdivisions to
|
|
5250
|
+
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
5251
|
+
* form their surfaces. By default, `detailY` is 16.
|
|
5252
|
+
*
|
|
5253
|
+
* Note: `sphere()` can only be used in WebGL mode.
|
|
5254
|
+
* @param radius radius of the sphere. Defaults to 50.
|
|
5255
|
+
* @param detailX number of triangle subdivisions along the x-axis. Defaults to 24.
|
|
5256
|
+
* @param detailY number of triangle subdivisions along the y-axis. Defaults to 16.
|
|
5257
|
+
*/
|
|
5258
|
+
sphere(radius?: number, detailX?: number, detailY?: number): void;
|
|
5259
|
+
|
|
5242
5260
|
/**
|
|
5243
5261
|
* Loads the current value of each pixel on the canvas into the
|
|
5244
5262
|
* <a href="#/p5/pixels">pixels</a> array.
|
|
@@ -5248,17 +5266,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5248
5266
|
*/
|
|
5249
5267
|
loadPixels(): void;
|
|
5250
5268
|
|
|
5251
|
-
/**
|
|
5252
|
-
* This method is suitable for fetching files up to size of 64MB.
|
|
5253
|
-
* @param file name of the file or URL to load
|
|
5254
|
-
* @param callback function to be executed after <a href="#/p5/loadBytes">loadBytes()</a>
|
|
5255
|
-
* completes
|
|
5256
|
-
* @param errorCallback function to be executed if there
|
|
5257
|
-
* is an error
|
|
5258
|
-
* @returns a Uint8Array containing the loaded buffer
|
|
5259
|
-
*/
|
|
5260
|
-
loadBytes(file: string | Request, callback?: Function, errorCallback?: Function): Promise<Uint8Array>;
|
|
5261
|
-
|
|
5262
5269
|
/**
|
|
5263
5270
|
* Creates a <a href="#/p5.Shader">p5.Shader</a> object to be used with the
|
|
5264
5271
|
* <a href="#/p5/filter">filter()</a> function.
|
|
@@ -5355,7 +5362,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5355
5362
|
* filterColor.texCoord.x // x coordinate, from 0 to 1
|
|
5356
5363
|
* ));
|
|
5357
5364
|
* filterColor.end();
|
|
5358
|
-
* }`You can also animate your filters over time
|
|
5365
|
+
* }`You can also animate your filters over time using the `millis()` function.
|
|
5359
5366
|
*
|
|
5360
5367
|
* `let myFilter;
|
|
5361
5368
|
* function setup() {
|
|
@@ -5365,7 +5372,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5365
5372
|
* }
|
|
5366
5373
|
*
|
|
5367
5374
|
* function gradient() {
|
|
5368
|
-
* let time =
|
|
5375
|
+
* let time = millis();
|
|
5369
5376
|
* filterColor.begin();
|
|
5370
5377
|
* filterColor.set(mix(
|
|
5371
5378
|
* [1, 0, 0, 1], // Red
|
|
@@ -5376,9 +5383,8 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5376
5383
|
* }
|
|
5377
5384
|
*
|
|
5378
5385
|
* function draw() {
|
|
5379
|
-
* myFilter.setUniform('time', millis());
|
|
5380
5386
|
* filter(myFilter);
|
|
5381
|
-
* }`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
|
|
5387
|
+
* }`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.
|
|
5382
5388
|
*
|
|
5383
5389
|
* `let myFilter;
|
|
5384
5390
|
*
|
|
@@ -5389,7 +5395,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5389
5395
|
* }
|
|
5390
5396
|
*
|
|
5391
5397
|
* function noiseShaderCallback() {
|
|
5392
|
-
* let time =
|
|
5398
|
+
* let time = millis();
|
|
5393
5399
|
* filterColor.begin();
|
|
5394
5400
|
* let coord = filterColor.texCoord;
|
|
5395
5401
|
*
|
|
@@ -5406,7 +5412,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5406
5412
|
* }
|
|
5407
5413
|
*
|
|
5408
5414
|
* function draw() {
|
|
5409
|
-
* myFilter.setUniform("time", millis());
|
|
5410
5415
|
* filter(myFilter);
|
|
5411
5416
|
* }`Like the `modify()` method on shaders,
|
|
5412
5417
|
* advanced users can also fill in `filterColor` using <a href="https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders" target="_blank">GLSL</a>
|
|
@@ -5425,7 +5430,18 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5425
5430
|
buildFilterShader(hooks: object, scope?: object): P5.Shader;
|
|
5426
5431
|
|
|
5427
5432
|
/**
|
|
5428
|
-
*
|
|
5433
|
+
* This method is suitable for fetching files up to size of 64MB.
|
|
5434
|
+
* @param file name of the file or URL to load
|
|
5435
|
+
* @param callback function to be executed after <a href="#/p5/loadBytes">loadBytes()</a>
|
|
5436
|
+
* completes
|
|
5437
|
+
* @param errorCallback function to be executed if there
|
|
5438
|
+
* is an error
|
|
5439
|
+
* @returns a Uint8Array containing the loaded buffer
|
|
5440
|
+
*/
|
|
5441
|
+
loadBytes(file: string | Request, callback?: Function, errorCallback?: Function): Promise<Uint8Array>;
|
|
5442
|
+
|
|
5443
|
+
/**
|
|
5444
|
+
* Creates a slider `<input></input>` element.
|
|
5429
5445
|
*
|
|
5430
5446
|
* Range sliders are useful for quickly selecting numbers from a given range.
|
|
5431
5447
|
*
|
|
@@ -5462,33 +5478,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5462
5478
|
*/
|
|
5463
5479
|
norm(value: number, start: number, stop: number): number;
|
|
5464
5480
|
|
|
5465
|
-
/**
|
|
5466
|
-
* Draws a sphere.
|
|
5467
|
-
*
|
|
5468
|
-
* A sphere is a 3D shape with triangular faces that connect to form a round
|
|
5469
|
-
* surface. Spheres with few faces look like crystals. Spheres with many faces
|
|
5470
|
-
* have smooth surfaces and look like balls.
|
|
5471
|
-
*
|
|
5472
|
-
* The first parameter, `radius`, is optional. If a `Number` is passed, as in
|
|
5473
|
-
* `sphere(20)`, it sets the radius of the sphere. By default, `radius` is 50.
|
|
5474
|
-
*
|
|
5475
|
-
* The second parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
5476
|
-
* as in `sphere(20, 5)`, it sets the number of triangle subdivisions to use
|
|
5477
|
-
* along the x-axis. All 3D shapes are made by connecting triangles to form
|
|
5478
|
-
* their surfaces. By default, `detailX` is 24.
|
|
5479
|
-
*
|
|
5480
|
-
* The third parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
5481
|
-
* as in `sphere(20, 5, 2)`, it sets the number of triangle subdivisions to
|
|
5482
|
-
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
5483
|
-
* form their surfaces. By default, `detailY` is 16.
|
|
5484
|
-
*
|
|
5485
|
-
* Note: `sphere()` can only be used in WebGL mode.
|
|
5486
|
-
* @param radius radius of the sphere. Defaults to 50.
|
|
5487
|
-
* @param detailX number of triangle subdivisions along the x-axis. Defaults to 24.
|
|
5488
|
-
* @param detailY number of triangle subdivisions along the y-axis. Defaults to 16.
|
|
5489
|
-
*/
|
|
5490
|
-
sphere(radius?: number, detailX?: number, detailY?: number): void;
|
|
5491
|
-
|
|
5492
5481
|
/**
|
|
5493
5482
|
* A function that's called once when any key is released.
|
|
5494
5483
|
*
|
|
@@ -5679,7 +5668,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5679
5668
|
alpha(color: P5.Color | number[] | string): number;
|
|
5680
5669
|
|
|
5681
5670
|
/**
|
|
5682
|
-
* Creates a
|
|
5671
|
+
* Creates a `<button></button>` element.
|
|
5683
5672
|
*
|
|
5684
5673
|
* The first parameter, `label`, is a string that sets the label displayed on
|
|
5685
5674
|
* the button.
|
|
@@ -5970,7 +5959,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
5970
5959
|
panorama(img: P5.Image): void;
|
|
5971
5960
|
|
|
5972
5961
|
/**
|
|
5973
|
-
* Creates a checkbox
|
|
5962
|
+
* Creates a checkbox `<input></input>` element.
|
|
5974
5963
|
*
|
|
5975
5964
|
* Checkboxes extend the <a href="#/p5.Element">p5.Element</a> class with a
|
|
5976
5965
|
* `checked()` method. Calling `myBox.checked()` returns `true` if it the box
|
|
@@ -6046,6 +6035,50 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
6046
6035
|
*/
|
|
6047
6036
|
hue(color: P5.Color | number[] | string): number;
|
|
6048
6037
|
|
|
6038
|
+
/**
|
|
6039
|
+
* Draws a cylinder.
|
|
6040
|
+
*
|
|
6041
|
+
* A cylinder is a 3D shape with triangular faces that connect a flat bottom
|
|
6042
|
+
* to a flat top. Cylinders with few faces look like boxes. Cylinders with
|
|
6043
|
+
* many faces have smooth surfaces.
|
|
6044
|
+
*
|
|
6045
|
+
* The first parameter, `radius`, is optional. If a `Number` is passed, as in
|
|
6046
|
+
* `cylinder(20)`, it sets the radius of the cylinder’s base. By default,
|
|
6047
|
+
* `radius` is 50.
|
|
6048
|
+
*
|
|
6049
|
+
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
6050
|
+
* as in `cylinder(20, 30)`, it sets the cylinder’s height. By default,
|
|
6051
|
+
* `height` is set to the cylinder’s `radius`.
|
|
6052
|
+
*
|
|
6053
|
+
* The third parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
6054
|
+
* as in `cylinder(20, 30, 5)`, it sets the number of edges used to form the
|
|
6055
|
+
* cylinder's top and bottom. Using more edges makes the top and bottom look
|
|
6056
|
+
* more like circles. By default, `detailX` is 24.
|
|
6057
|
+
*
|
|
6058
|
+
* The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
6059
|
+
* as in `cylinder(20, 30, 5, 2)`, it sets the number of triangle subdivisions
|
|
6060
|
+
* to use along the y-axis, between cylinder's the top and bottom. All 3D
|
|
6061
|
+
* shapes are made by connecting triangles to form their surfaces. By default,
|
|
6062
|
+
* `detailY` is 1.
|
|
6063
|
+
*
|
|
6064
|
+
* The fifth parameter, `bottomCap`, is also optional. If a `false` is passed,
|
|
6065
|
+
* as in `cylinder(20, 30, 5, 2, false)` the cylinder’s bottom won’t be drawn.
|
|
6066
|
+
* By default, `bottomCap` is `true`.
|
|
6067
|
+
*
|
|
6068
|
+
* The sixth parameter, `topCap`, is also optional. If a `false` is passed, as
|
|
6069
|
+
* in `cylinder(20, 30, 5, 2, false, false)` the cylinder’s top won’t be
|
|
6070
|
+
* drawn. By default, `topCap` is `true`.
|
|
6071
|
+
*
|
|
6072
|
+
* Note: `cylinder()` can only be used in WebGL mode.
|
|
6073
|
+
* @param radius radius of the cylinder. Defaults to 50.
|
|
6074
|
+
* @param height height of the cylinder. Defaults to the value of `radius`.
|
|
6075
|
+
* @param detailX number of edges along the top and bottom. Defaults to 24.
|
|
6076
|
+
* @param detailY number of triangle subdivisions along the y-axis. Defaults to 1.
|
|
6077
|
+
* @param bottomCap whether to draw the cylinder's bottom. Defaults to `true`.
|
|
6078
|
+
* @param topCap whether to draw the cylinder's top. Defaults to `true`.
|
|
6079
|
+
*/
|
|
6080
|
+
cylinder(radius?: number, height?: number, detailX?: number, detailY?: number, bottomCap?: boolean, topCap?: boolean): void;
|
|
6081
|
+
|
|
6049
6082
|
/**
|
|
6050
6083
|
* Scales the coordinate system.
|
|
6051
6084
|
*
|
|
@@ -6165,50 +6198,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
6165
6198
|
httpPost(path: string | Request, data: object | boolean, callback?: Function, errorCallback?: Function): Promise<any>;
|
|
6166
6199
|
httpPost(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
|
|
6167
6200
|
|
|
6168
|
-
/**
|
|
6169
|
-
* Draws a cylinder.
|
|
6170
|
-
*
|
|
6171
|
-
* A cylinder is a 3D shape with triangular faces that connect a flat bottom
|
|
6172
|
-
* to a flat top. Cylinders with few faces look like boxes. Cylinders with
|
|
6173
|
-
* many faces have smooth surfaces.
|
|
6174
|
-
*
|
|
6175
|
-
* The first parameter, `radius`, is optional. If a `Number` is passed, as in
|
|
6176
|
-
* `cylinder(20)`, it sets the radius of the cylinder’s base. By default,
|
|
6177
|
-
* `radius` is 50.
|
|
6178
|
-
*
|
|
6179
|
-
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
6180
|
-
* as in `cylinder(20, 30)`, it sets the cylinder’s height. By default,
|
|
6181
|
-
* `height` is set to the cylinder’s `radius`.
|
|
6182
|
-
*
|
|
6183
|
-
* The third parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
6184
|
-
* as in `cylinder(20, 30, 5)`, it sets the number of edges used to form the
|
|
6185
|
-
* cylinder's top and bottom. Using more edges makes the top and bottom look
|
|
6186
|
-
* more like circles. By default, `detailX` is 24.
|
|
6187
|
-
*
|
|
6188
|
-
* The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
6189
|
-
* as in `cylinder(20, 30, 5, 2)`, it sets the number of triangle subdivisions
|
|
6190
|
-
* to use along the y-axis, between cylinder's the top and bottom. All 3D
|
|
6191
|
-
* shapes are made by connecting triangles to form their surfaces. By default,
|
|
6192
|
-
* `detailY` is 1.
|
|
6193
|
-
*
|
|
6194
|
-
* The fifth parameter, `bottomCap`, is also optional. If a `false` is passed,
|
|
6195
|
-
* as in `cylinder(20, 30, 5, 2, false)` the cylinder’s bottom won’t be drawn.
|
|
6196
|
-
* By default, `bottomCap` is `true`.
|
|
6197
|
-
*
|
|
6198
|
-
* The sixth parameter, `topCap`, is also optional. If a `false` is passed, as
|
|
6199
|
-
* in `cylinder(20, 30, 5, 2, false, false)` the cylinder’s top won’t be
|
|
6200
|
-
* drawn. By default, `topCap` is `true`.
|
|
6201
|
-
*
|
|
6202
|
-
* Note: `cylinder()` can only be used in WebGL mode.
|
|
6203
|
-
* @param radius radius of the cylinder. Defaults to 50.
|
|
6204
|
-
* @param height height of the cylinder. Defaults to the value of `radius`.
|
|
6205
|
-
* @param detailX number of edges along the top and bottom. Defaults to 24.
|
|
6206
|
-
* @param detailY number of triangle subdivisions along the y-axis. Defaults to 1.
|
|
6207
|
-
* @param bottomCap whether to draw the cylinder's bottom. Defaults to `true`.
|
|
6208
|
-
* @param topCap whether to draw the cylinder's top. Defaults to `true`.
|
|
6209
|
-
*/
|
|
6210
|
-
cylinder(radius?: number, height?: number, detailX?: number, detailY?: number, bottomCap?: boolean, topCap?: boolean): void;
|
|
6211
|
-
|
|
6212
6201
|
/**
|
|
6213
6202
|
* Returns the sketch's current
|
|
6214
6203
|
* <a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL" target="_blank">URL</a>
|
|
@@ -6543,143 +6532,45 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
6543
6532
|
lightFalloff(constant: number, linear: number, quadratic: number): void;
|
|
6544
6533
|
|
|
6545
6534
|
/**
|
|
6546
|
-
*
|
|
6535
|
+
* Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply while drawing.
|
|
6547
6536
|
*
|
|
6548
|
-
*
|
|
6549
|
-
*
|
|
6550
|
-
*
|
|
6537
|
+
* Shaders are programs that run on the graphics processing unit (GPU). They
|
|
6538
|
+
* can process many pixels or vertices at the same time, making them fast for
|
|
6539
|
+
* many graphics tasks.
|
|
6551
6540
|
*
|
|
6552
|
-
*
|
|
6553
|
-
*
|
|
6554
|
-
*
|
|
6555
|
-
* <a href="#/p5/
|
|
6556
|
-
*
|
|
6541
|
+
* You can make new shaders using p5.strands with the
|
|
6542
|
+
* <a href="#/p5/buildMaterialShader">`buildMaterialShader`</a>,
|
|
6543
|
+
* <a href="#/p5/buildColorShader">`buildColorShader`</a>, and
|
|
6544
|
+
* <a href="#/p5/buildNormalShader">`buildNormalShader`</a> functions. You can also use
|
|
6545
|
+
* <a href="#/p5/buildFilterShader">`buildFilterShader`</a> alongside
|
|
6546
|
+
* <a href="#/p5/filter">`filter`</a>, and
|
|
6547
|
+
* <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a> alongside
|
|
6548
|
+
* <a href="#/p5/stroke">`stroke`</a>.
|
|
6557
6549
|
*
|
|
6558
|
-
* `
|
|
6559
|
-
*
|
|
6560
|
-
*
|
|
6561
|
-
*
|
|
6550
|
+
* The parameter, `s`, is the <a href="#/p5.Shader">p5.Shader</a> object to
|
|
6551
|
+
* apply. For example, calling `shader(myShader)` applies `myShader` to
|
|
6552
|
+
* process each pixel on the canvas. This only changes the fill (the inner part of shapes),
|
|
6553
|
+
* but does not affect the outlines (strokes) or any images drawn using the `image()` function.
|
|
6554
|
+
* The source code from a <a href="#/p5.Shader">p5.Shader</a> object's
|
|
6555
|
+
* fragment and vertex shaders will be compiled the first time it's passed to
|
|
6556
|
+
* `shader()`.
|
|
6562
6557
|
*
|
|
6563
|
-
*
|
|
6564
|
-
*
|
|
6565
|
-
*
|
|
6566
|
-
*
|
|
6567
|
-
*
|
|
6568
|
-
*
|
|
6569
|
-
*
|
|
6570
|
-
*
|
|
6571
|
-
*
|
|
6572
|
-
*
|
|
6573
|
-
*
|
|
6574
|
-
*
|
|
6575
|
-
* pressing a mouse button. To prevent any default behavior for this event,
|
|
6576
|
-
* add `return false;` to the end of the function.
|
|
6577
|
-
* @param event optional `MouseEvent` argument.
|
|
6578
|
-
*/
|
|
6579
|
-
mouseMoved(event?: MouseEvent): void;
|
|
6580
|
-
|
|
6581
|
-
/**
|
|
6582
|
-
* A function that's called when the mouse moves while a button is pressed.
|
|
6583
|
-
*
|
|
6584
|
-
* Declaring the function `mouseDragged()` sets a code block to run
|
|
6585
|
-
* automatically when the user clicks and drags the mouse:
|
|
6586
|
-
*
|
|
6587
|
-
* `function mouseDragged() {
|
|
6588
|
-
* // Code to run.
|
|
6589
|
-
* }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
|
|
6590
|
-
* <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
|
|
6591
|
-
* value when `mouseDragged()` is called by p5.js:
|
|
6592
|
-
*
|
|
6593
|
-
* `function mouseDragged() {
|
|
6594
|
-
* if (mouseX < 50) {
|
|
6595
|
-
* // Code to run if the mouse is on the left.
|
|
6596
|
-
* }
|
|
6597
|
-
*
|
|
6598
|
-
* if (mouseY > 50) {
|
|
6599
|
-
* // Code to run if the mouse is near the bottom.
|
|
6600
|
-
* }
|
|
6601
|
-
* }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
|
|
6602
|
-
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
|
|
6603
|
-
* object with properties that describe the mouse drag event:
|
|
6604
|
-
*
|
|
6605
|
-
* `function mouseDragged(event) {
|
|
6606
|
-
* // Code to run that uses the event.
|
|
6607
|
-
* console.log(event);
|
|
6608
|
-
* }`On touchscreen devices, `mouseDragged()` will run when a user moves a touch
|
|
6609
|
-
* point.
|
|
6610
|
-
*
|
|
6611
|
-
* Browsers may have default behaviors attached to various mouse events. For
|
|
6612
|
-
* example, some browsers highlight text when the user moves the mouse while
|
|
6613
|
-
* pressing a mouse button. To prevent any default behavior for this event,
|
|
6614
|
-
* add `return false;` to the end of the function.
|
|
6615
|
-
* @param event optional `MouseEvent` argument.
|
|
6616
|
-
*/
|
|
6617
|
-
mouseDragged(event?: MouseEvent): void;
|
|
6618
|
-
|
|
6619
|
-
/**
|
|
6620
|
-
* Returns `true` if the key it’s checking is pressed and `false` if not.
|
|
6621
|
-
*
|
|
6622
|
-
* `keyIsDown()` is helpful when checking for multiple different key presses.
|
|
6623
|
-
* For example, `keyIsDown()` can be used to check if both `LEFT_ARROW` and
|
|
6624
|
-
* `UP_ARROW` are pressed:
|
|
6625
|
-
*
|
|
6626
|
-
* `if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
|
|
6627
|
-
* // Move diagonally.
|
|
6628
|
-
* }``keyIsDown()` can check for key presses using strings based on
|
|
6629
|
-
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
|
|
6630
|
-
* or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
|
|
6631
|
-
* such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
|
|
6632
|
-
*
|
|
6633
|
-
* Note: In p5.js 2.0 and newer, numeric keycodes (such as 88 for 'X') are no longer supported.
|
|
6634
|
-
* This is a breaking change from previous versions.
|
|
6635
|
-
*
|
|
6636
|
-
* You can still use the p5 constants like `LEFT_ARROW` which now map to string values
|
|
6637
|
-
* internally rather than numeric codes.
|
|
6638
|
-
* @param code key to check.
|
|
6639
|
-
* @returns whether the key is down or not.
|
|
6640
|
-
*/
|
|
6641
|
-
keyIsDown(code: number | string): boolean;
|
|
6642
|
-
|
|
6643
|
-
/**
|
|
6644
|
-
* Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply while drawing.
|
|
6645
|
-
*
|
|
6646
|
-
* Shaders are programs that run on the graphics processing unit (GPU). They
|
|
6647
|
-
* can process many pixels or vertices at the same time, making them fast for
|
|
6648
|
-
* many graphics tasks.
|
|
6649
|
-
*
|
|
6650
|
-
* You can make new shaders using p5.strands with the
|
|
6651
|
-
* <a href="#/p5/buildMaterialShader">`buildMaterialShader`</a>,
|
|
6652
|
-
* <a href="#/p5/buildColorShader">`buildColorShader`</a>, and
|
|
6653
|
-
* <a href="#/p5/buildNormalShader">`buildNormalShader`</a> functions. You can also use
|
|
6654
|
-
* <a href="#/p5/buildFilterShader">`buildFilterShader`</a> alongside
|
|
6655
|
-
* <a href="#/p5/filter">`filter`</a>, and
|
|
6656
|
-
* <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a> alongside
|
|
6657
|
-
* <a href="#/p5/stroke">`stroke`</a>.
|
|
6658
|
-
*
|
|
6659
|
-
* The parameter, `s`, is the <a href="#/p5.Shader">p5.Shader</a> object to
|
|
6660
|
-
* apply. For example, calling `shader(myShader)` applies `myShader` to
|
|
6661
|
-
* process each pixel on the canvas. This only changes the fill (the inner part of shapes),
|
|
6662
|
-
* but does not affect the outlines (strokes) or any images drawn using the `image()` function.
|
|
6663
|
-
* The source code from a <a href="#/p5.Shader">p5.Shader</a> object's
|
|
6664
|
-
* fragment and vertex shaders will be compiled the first time it's passed to
|
|
6665
|
-
* `shader()`.
|
|
6666
|
-
*
|
|
6667
|
-
* Calling <a href="#/p5/resetShader">resetShader()</a> restores a sketch’s
|
|
6668
|
-
* default shaders.
|
|
6669
|
-
*
|
|
6670
|
-
* Note: Shaders can only be used in WebGL mode.
|
|
6671
|
-
*
|
|
6672
|
-
* `let myShader;
|
|
6673
|
-
*
|
|
6674
|
-
* function setup() {
|
|
6675
|
-
* createCanvas(200, 200, WEBGL);
|
|
6676
|
-
* myShader = buildMaterialShader(material);
|
|
6677
|
-
* noStroke();
|
|
6678
|
-
* describe('A square with dynamically changing colors on a beige background.');
|
|
6558
|
+
* Calling <a href="#/p5/resetShader">resetShader()</a> restores a sketch’s
|
|
6559
|
+
* default shaders.
|
|
6560
|
+
*
|
|
6561
|
+
* Note: Shaders can only be used in WebGL mode.
|
|
6562
|
+
*
|
|
6563
|
+
* `let myShader;
|
|
6564
|
+
*
|
|
6565
|
+
* function setup() {
|
|
6566
|
+
* createCanvas(200, 200, WEBGL);
|
|
6567
|
+
* myShader = buildMaterialShader(material);
|
|
6568
|
+
* noStroke();
|
|
6569
|
+
* describe('A square with dynamically changing colors on a beige background.');
|
|
6679
6570
|
* }
|
|
6680
6571
|
*
|
|
6681
6572
|
* function material() {
|
|
6682
|
-
* let time =
|
|
6573
|
+
* let time = millis() / 1000;
|
|
6683
6574
|
* finalColor.begin();
|
|
6684
6575
|
* let r = 0.2 + 0.5 * abs(sin(time + 0));
|
|
6685
6576
|
* let g = 0.2 + 0.5 * abs(sin(time + 1));
|
|
@@ -6690,7 +6581,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
6690
6581
|
*
|
|
6691
6582
|
* function draw() {
|
|
6692
6583
|
* background(245, 245, 220);
|
|
6693
|
-
* myShader.setUniform('time', millis() / 1000);
|
|
6694
6584
|
* shader(myShader);
|
|
6695
6585
|
*
|
|
6696
6586
|
* rectMode(CENTER);
|
|
@@ -6803,11 +6693,109 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
6803
6693
|
*/
|
|
6804
6694
|
shader(s: P5.Shader): void;
|
|
6805
6695
|
|
|
6696
|
+
/**
|
|
6697
|
+
* A function that's called when the mouse moves.
|
|
6698
|
+
*
|
|
6699
|
+
* Declaring the function `mouseMoved()` sets a code block to run
|
|
6700
|
+
* automatically when the user moves the mouse without clicking any mouse
|
|
6701
|
+
* buttons:
|
|
6702
|
+
*
|
|
6703
|
+
* `function mouseMoved() {
|
|
6704
|
+
* // Code to run.
|
|
6705
|
+
* }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
|
|
6706
|
+
* <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
|
|
6707
|
+
* value when `mouseMoved()` is called by p5.js:
|
|
6708
|
+
*
|
|
6709
|
+
* `function mouseMoved() {
|
|
6710
|
+
* if (mouseX < 50) {
|
|
6711
|
+
* // Code to run if the mouse is on the left.
|
|
6712
|
+
* }
|
|
6713
|
+
*
|
|
6714
|
+
* if (mouseY > 50) {
|
|
6715
|
+
* // Code to run if the mouse is near the bottom.
|
|
6716
|
+
* }
|
|
6717
|
+
* }`The parameter, `event`, is optional. `mouseMoved()` is always passed a
|
|
6718
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
|
|
6719
|
+
* object with properties that describe the mouse move event:
|
|
6720
|
+
*
|
|
6721
|
+
* `function mouseMoved(event) {
|
|
6722
|
+
* // Code to run that uses the event.
|
|
6723
|
+
* console.log(event);
|
|
6724
|
+
* }`Browsers may have default behaviors attached to various mouse events. For
|
|
6725
|
+
* example, some browsers highlight text when the user moves the mouse while
|
|
6726
|
+
* pressing a mouse button. To prevent any default behavior for this event,
|
|
6727
|
+
* add `return false;` to the end of the function.
|
|
6728
|
+
* @param event optional `MouseEvent` argument.
|
|
6729
|
+
*/
|
|
6730
|
+
mouseMoved(event?: MouseEvent): void;
|
|
6731
|
+
|
|
6732
|
+
/**
|
|
6733
|
+
* A function that's called when the mouse moves while a button is pressed.
|
|
6734
|
+
*
|
|
6735
|
+
* Declaring the function `mouseDragged()` sets a code block to run
|
|
6736
|
+
* automatically when the user clicks and drags the mouse:
|
|
6737
|
+
*
|
|
6738
|
+
* `function mouseDragged() {
|
|
6739
|
+
* // Code to run.
|
|
6740
|
+
* }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
|
|
6741
|
+
* <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
|
|
6742
|
+
* value when `mouseDragged()` is called by p5.js:
|
|
6743
|
+
*
|
|
6744
|
+
* `function mouseDragged() {
|
|
6745
|
+
* if (mouseX < 50) {
|
|
6746
|
+
* // Code to run if the mouse is on the left.
|
|
6747
|
+
* }
|
|
6748
|
+
*
|
|
6749
|
+
* if (mouseY > 50) {
|
|
6750
|
+
* // Code to run if the mouse is near the bottom.
|
|
6751
|
+
* }
|
|
6752
|
+
* }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
|
|
6753
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
|
|
6754
|
+
* object with properties that describe the mouse drag event:
|
|
6755
|
+
*
|
|
6756
|
+
* `function mouseDragged(event) {
|
|
6757
|
+
* // Code to run that uses the event.
|
|
6758
|
+
* console.log(event);
|
|
6759
|
+
* }`On touchscreen devices, `mouseDragged()` will run when a user moves a touch
|
|
6760
|
+
* point.
|
|
6761
|
+
*
|
|
6762
|
+
* Browsers may have default behaviors attached to various mouse events. For
|
|
6763
|
+
* example, some browsers highlight text when the user moves the mouse while
|
|
6764
|
+
* pressing a mouse button. To prevent any default behavior for this event,
|
|
6765
|
+
* add `return false;` to the end of the function.
|
|
6766
|
+
* @param event optional `MouseEvent` argument.
|
|
6767
|
+
*/
|
|
6768
|
+
mouseDragged(event?: MouseEvent): void;
|
|
6769
|
+
|
|
6770
|
+
/**
|
|
6771
|
+
* Returns `true` if the key it’s checking is pressed and `false` if not.
|
|
6772
|
+
*
|
|
6773
|
+
* `keyIsDown()` is helpful when checking for multiple different key presses.
|
|
6774
|
+
* For example, `keyIsDown()` can be used to check if both `LEFT_ARROW` and
|
|
6775
|
+
* `UP_ARROW` are pressed:
|
|
6776
|
+
*
|
|
6777
|
+
* `if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
|
|
6778
|
+
* // Move diagonally.
|
|
6779
|
+
* }``keyIsDown()` can check for key presses using strings based on
|
|
6780
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
|
|
6781
|
+
* or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
|
|
6782
|
+
* such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
|
|
6783
|
+
*
|
|
6784
|
+
* Note: In p5.js 2.0 and newer, numeric keycodes (such as 88 for 'X') are no longer supported.
|
|
6785
|
+
* This is a breaking change from previous versions.
|
|
6786
|
+
*
|
|
6787
|
+
* You can still use the p5 constants like `LEFT_ARROW` which now map to string values
|
|
6788
|
+
* internally rather than numeric codes.
|
|
6789
|
+
* @param code key to check.
|
|
6790
|
+
* @returns whether the key is down or not.
|
|
6791
|
+
*/
|
|
6792
|
+
keyIsDown(code: number | string): boolean;
|
|
6793
|
+
|
|
6806
6794
|
/**
|
|
6807
6795
|
* Sets the element's content.
|
|
6808
6796
|
*
|
|
6809
6797
|
* An element's content is the text between its tags. For example, the element
|
|
6810
|
-
*
|
|
6798
|
+
* `<language>JavaScript</language>` has the content `JavaScript`.
|
|
6811
6799
|
*
|
|
6812
6800
|
* The parameter, `content`, is a string with the element's new content.
|
|
6813
6801
|
* @param content new content for the element.
|
|
@@ -6820,9 +6808,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
6820
6808
|
* The parameter, `model`, is the
|
|
6821
6809
|
* <a href="#/p5.Geometry">p5.Geometry</a> object to draw.
|
|
6822
6810
|
* <a href="#/p5.Geometry">p5.Geometry</a> objects can be built with
|
|
6823
|
-
* <a href="#/p5/buildGeometry">buildGeometry()</a
|
|
6824
|
-
* <a href="#/p5/beginGeometry">beginGeometry()</a> and
|
|
6825
|
-
* <a href="#/p5/endGeometry">endGeometry()</a>. They can also be loaded from
|
|
6811
|
+
* <a href="#/p5/buildGeometry">buildGeometry()</a>. They can also be loaded from
|
|
6826
6812
|
* a file with <a href="#/p5/loadGeometry">loadGeometry()</a>.
|
|
6827
6813
|
*
|
|
6828
6814
|
* Note: `model()` can only be used in WebGL mode.
|
|
@@ -6930,11 +6916,11 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
6930
6916
|
saturation(color: P5.Color | number[] | string): number;
|
|
6931
6917
|
|
|
6932
6918
|
/**
|
|
6933
|
-
* Creates a dropdown menu
|
|
6919
|
+
* Creates a dropdown menu `<select></select>` element.
|
|
6934
6920
|
*
|
|
6935
6921
|
* The parameter is optional. If `true` is passed, as in
|
|
6936
6922
|
* `let mySelect = createSelect(true)`, then the dropdown will support
|
|
6937
|
-
* multiple selections. If an existing
|
|
6923
|
+
* multiple selections. If an existing `<select></select>` element
|
|
6938
6924
|
* is passed, as in `let mySelect = createSelect(otherSelect)`, the existing
|
|
6939
6925
|
* element will be wrapped in a new <a href="#/p5.Element">p5.Element</a>
|
|
6940
6926
|
* object.
|
|
@@ -6963,20 +6949,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
6963
6949
|
createSelect(multiple?: boolean): P5.Element;
|
|
6964
6950
|
createSelect(existing: object): P5.Element;
|
|
6965
6951
|
|
|
6966
|
-
/**
|
|
6967
|
-
* Converts 3D world coordinates to 2D screen coordinates.
|
|
6968
|
-
*
|
|
6969
|
-
* This function takes a 3D vector and converts its coordinates
|
|
6970
|
-
* from the world space to screen space. This can be useful for placing
|
|
6971
|
-
* 2D elements in a 3D scene or for determining the screen position
|
|
6972
|
-
* of 3D objects.
|
|
6973
|
-
* @param x The x coordinate in world space. (Or a vector for all three coordinates.)
|
|
6974
|
-
* @param y The y coordinate in world space.
|
|
6975
|
-
* @param z The z coordinate in world space.
|
|
6976
|
-
* @returns A vector containing the 2D screen coordinates.
|
|
6977
|
-
*/
|
|
6978
|
-
worldToScreen(x: number | P5.Vector, y: number, z?: number): P5.Vector;
|
|
6979
|
-
|
|
6980
6952
|
/**
|
|
6981
6953
|
* Draws a cone.
|
|
6982
6954
|
*
|
|
@@ -7015,6 +6987,20 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
7015
6987
|
*/
|
|
7016
6988
|
cone(radius?: number, height?: number, detailX?: number, detailY?: number, cap?: boolean): void;
|
|
7017
6989
|
|
|
6990
|
+
/**
|
|
6991
|
+
* Converts 3D world coordinates to 2D screen coordinates.
|
|
6992
|
+
*
|
|
6993
|
+
* This function takes a 3D vector and converts its coordinates
|
|
6994
|
+
* from the world space to screen space. This can be useful for placing
|
|
6995
|
+
* 2D elements in a 3D scene or for determining the screen position
|
|
6996
|
+
* of 3D objects.
|
|
6997
|
+
* @param x The x coordinate in world space. (Or a vector for all three coordinates.)
|
|
6998
|
+
* @param y The y coordinate in world space.
|
|
6999
|
+
* @param z The z coordinate in world space.
|
|
7000
|
+
* @returns A vector containing the 2D screen coordinates.
|
|
7001
|
+
*/
|
|
7002
|
+
worldToScreen(x: number | P5.Vector, y: number, z?: number): P5.Vector;
|
|
7003
|
+
|
|
7018
7004
|
/**
|
|
7019
7005
|
* Load a 3d model from an OBJ or STL string.
|
|
7020
7006
|
*
|
|
@@ -7816,6 +7802,25 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
7816
7802
|
*/
|
|
7817
7803
|
lightness(color: P5.Color | number[] | string): number;
|
|
7818
7804
|
|
|
7805
|
+
/**
|
|
7806
|
+
* Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply for images.
|
|
7807
|
+
*
|
|
7808
|
+
* This method allows the user to apply a custom shader to images, enabling
|
|
7809
|
+
* advanced visual effects such as pixel manipulation, color adjustments,
|
|
7810
|
+
* or dynamic behavior. The shader will be applied to the image drawn using
|
|
7811
|
+
* the <a href="#/p5/image">image()</a> function.
|
|
7812
|
+
*
|
|
7813
|
+
* The shader will be used exclusively for:
|
|
7814
|
+
*
|
|
7815
|
+
* - `image()` calls, applying only when drawing 2D images.
|
|
7816
|
+
*
|
|
7817
|
+
* - This shader will NOT apply to images used in <a href="#/p5/texture">texture()</a> or other 3D contexts.
|
|
7818
|
+
* Any attempts to use the imageShader in these cases will be ignored.
|
|
7819
|
+
* @param s <a href="#/p5.Shader">p5.Shader</a> object
|
|
7820
|
+
* to apply for images.
|
|
7821
|
+
*/
|
|
7822
|
+
imageShader(s: P5.Shader): void;
|
|
7823
|
+
|
|
7819
7824
|
/**
|
|
7820
7825
|
* Changes the location from which images are drawn when
|
|
7821
7826
|
* <a href="#/p5/image">image()</a> is called.
|
|
@@ -7837,25 +7842,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
7837
7842
|
*/
|
|
7838
7843
|
imageMode(mode: typeof P5.CORNER | typeof P5.CORNERS | typeof P5.CENTER): void;
|
|
7839
7844
|
|
|
7840
|
-
/**
|
|
7841
|
-
* Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply for images.
|
|
7842
|
-
*
|
|
7843
|
-
* This method allows the user to apply a custom shader to images, enabling
|
|
7844
|
-
* advanced visual effects such as pixel manipulation, color adjustments,
|
|
7845
|
-
* or dynamic behavior. The shader will be applied to the image drawn using
|
|
7846
|
-
* the <a href="#/p5/image">image()</a> function.
|
|
7847
|
-
*
|
|
7848
|
-
* The shader will be used exclusively for:
|
|
7849
|
-
*
|
|
7850
|
-
* - `image()` calls, applying only when drawing 2D images.
|
|
7851
|
-
*
|
|
7852
|
-
* - This shader will NOT apply to images used in <a href="#/p5/texture">texture()</a> or other 3D contexts.
|
|
7853
|
-
* Any attempts to use the imageShader in these cases will be ignored.
|
|
7854
|
-
* @param s <a href="#/p5.Shader">p5.Shader</a> object
|
|
7855
|
-
* to apply for images.
|
|
7856
|
-
*/
|
|
7857
|
-
imageShader(s: P5.Shader): void;
|
|
7858
|
-
|
|
7859
7845
|
/**
|
|
7860
7846
|
* A function that's called once when a mouse button is released.
|
|
7861
7847
|
*
|
|
@@ -7929,8 +7915,8 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
7929
7915
|
*
|
|
7930
7916
|
* The parameter is optional. If a string is passed, as in
|
|
7931
7917
|
* `let myRadio = createSelect('food')`, then each radio option will
|
|
7932
|
-
* have `"food"` as its `name` parameter:
|
|
7933
|
-
* If an existing
|
|
7918
|
+
* have `"food"` as its `name` parameter: `<input name="food"></input>`.
|
|
7919
|
+
* If an existing `<div></div>` or `<span></span>`
|
|
7934
7920
|
* element is passed, as in `let myRadio = createSelect(container)`, it will
|
|
7935
7921
|
* become the radio button's parent element.
|
|
7936
7922
|
*
|
|
@@ -7946,8 +7932,8 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
7946
7932
|
* - `myRadio.selected(value)` selects the given option and returns it as an <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement" target="_blank">`HTMLInputElement`</a>.
|
|
7947
7933
|
*
|
|
7948
7934
|
* - `myRadio.disable(shouldDisable)` enables the entire radio button if `true` is passed and disables it if `false` is passed.
|
|
7949
|
-
* @param containerElement container HTML Element, either a
|
|
7950
|
-
* or
|
|
7935
|
+
* @param containerElement container HTML Element, either a `<div></div>`
|
|
7936
|
+
* or `<span></span>`.
|
|
7951
7937
|
* @returns new <a href="#/p5.Element">p5.Element</a> object.
|
|
7952
7938
|
*/
|
|
7953
7939
|
createRadio(containerElement?: object): P5.Element;
|
|
@@ -7955,7 +7941,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
7955
7941
|
createRadio(): P5.Element;
|
|
7956
7942
|
|
|
7957
7943
|
/**
|
|
7958
|
-
* Creates a
|
|
7944
|
+
* Creates a `<video>` element for simple audio/video playback.
|
|
7959
7945
|
*
|
|
7960
7946
|
* `createVideo()` returns a new
|
|
7961
7947
|
* <a href="#/p5.MediaElement">p5.MediaElement</a> object. Videos are shown by
|
|
@@ -8044,7 +8030,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8044
8030
|
lerpColor(c1: P5.Color, c2: P5.Color, amt: number): P5.Color;
|
|
8045
8031
|
|
|
8046
8032
|
/**
|
|
8047
|
-
* Creates a hidden
|
|
8033
|
+
* Creates a hidden `<audio>` element for simple audio playback.
|
|
8048
8034
|
*
|
|
8049
8035
|
* `createAudio()` returns a new
|
|
8050
8036
|
* <a href="#/p5.MediaElement">p5.MediaElement</a> object.
|
|
@@ -8067,22 +8053,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8067
8053
|
*/
|
|
8068
8054
|
createAudio(src?: string | string[], callback?: (video: P5.MediaElement<HTMLAudioElement>) => any): P5.MediaElement<HTMLAudioElement>;
|
|
8069
8055
|
|
|
8070
|
-
/**
|
|
8071
|
-
* Blends multiple colors to find a color between them.
|
|
8072
|
-
*
|
|
8073
|
-
* The `amt` parameter specifies the amount to interpolate between the color
|
|
8074
|
-
* stops which are colors at each `amt` value "location" with `amt` values
|
|
8075
|
-
* that are between 2 color stops interpolating between them based on its relative
|
|
8076
|
-
* distance to both.
|
|
8077
|
-
*
|
|
8078
|
-
* The way that colors are interpolated depends on the current
|
|
8079
|
-
* <a href="/reference/p5/colorMode/">colorMode()</a>.
|
|
8080
|
-
* @param colors_stops color stops to interpolate from
|
|
8081
|
-
* @param amt number to use to interpolate relative to color stops
|
|
8082
|
-
* @returns interpolated color.
|
|
8083
|
-
*/
|
|
8084
|
-
paletteLerp(colors_stops: [P5.Color | string | number | number[], number][], amt: number): P5.Color;
|
|
8085
|
-
|
|
8086
8056
|
/**
|
|
8087
8057
|
* Draws a torus.
|
|
8088
8058
|
*
|
|
@@ -8114,6 +8084,22 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8114
8084
|
*/
|
|
8115
8085
|
torus(radius?: number, tubeRadius?: number, detailX?: number, detailY?: number): void;
|
|
8116
8086
|
|
|
8087
|
+
/**
|
|
8088
|
+
* Blends multiple colors to find a color between them.
|
|
8089
|
+
*
|
|
8090
|
+
* The `amt` parameter specifies the amount to interpolate between the color
|
|
8091
|
+
* stops which are colors at each `amt` value "location" with `amt` values
|
|
8092
|
+
* that are between 2 color stops interpolating between them based on its relative
|
|
8093
|
+
* distance to both.
|
|
8094
|
+
*
|
|
8095
|
+
* The way that colors are interpolated depends on the current
|
|
8096
|
+
* <a href="/reference/p5/colorMode/">colorMode()</a>.
|
|
8097
|
+
* @param colors_stops color stops to interpolate from
|
|
8098
|
+
* @param amt number to use to interpolate relative to color stops
|
|
8099
|
+
* @returns interpolated color.
|
|
8100
|
+
*/
|
|
8101
|
+
paletteLerp(colors_stops: [P5.Color | string | number | number[], number][], amt: number): P5.Color;
|
|
8102
|
+
|
|
8117
8103
|
/**
|
|
8118
8104
|
* Saves the file and closes the print stream.
|
|
8119
8105
|
*/
|
|
@@ -8202,7 +8188,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8202
8188
|
* }
|
|
8203
8189
|
*
|
|
8204
8190
|
* function material() {
|
|
8205
|
-
* let time =
|
|
8191
|
+
* let time = millis();
|
|
8206
8192
|
* worldInputs.begin();
|
|
8207
8193
|
* worldInputs.position.y +=
|
|
8208
8194
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -8212,7 +8198,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8212
8198
|
* function draw() {
|
|
8213
8199
|
* background(255);
|
|
8214
8200
|
* shader(myShader);
|
|
8215
|
-
* myShader.setUniform('time', millis());
|
|
8216
8201
|
* lights();
|
|
8217
8202
|
* noStroke();
|
|
8218
8203
|
* fill('red');
|
|
@@ -8338,7 +8323,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8338
8323
|
buildMaterialShader(hooks: object, scope?: object): P5.Shader;
|
|
8339
8324
|
|
|
8340
8325
|
/**
|
|
8341
|
-
* Creates a
|
|
8326
|
+
* Creates a `<video>` element that "captures" the audio/video stream from
|
|
8342
8327
|
* the webcam and microphone.
|
|
8343
8328
|
*
|
|
8344
8329
|
* `createCapture()` returns a new
|
|
@@ -8430,42 +8415,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8430
8415
|
*/
|
|
8431
8416
|
createColorPicker(value?: string | P5.Color): P5.Element;
|
|
8432
8417
|
|
|
8433
|
-
/**
|
|
8434
|
-
* Saves a given element(image, text, json, csv, wav, or html) to the client's
|
|
8435
|
-
* computer. The first parameter can be a pointer to element we want to save.
|
|
8436
|
-
* The element can be one of <a href="#/p5.Element">p5.Element</a>,an Array of
|
|
8437
|
-
* Strings, an Array of JSON, a JSON object, a <a href="#/p5.Table">p5.Table
|
|
8438
|
-
* </a>, a <a href="#/p5.Image">p5.Image</a>, or a p5.SoundFile (requires
|
|
8439
|
-
* p5.sound). The second parameter is a filename (including extension).The
|
|
8440
|
-
* third parameter is for options specific to this type of object. This method
|
|
8441
|
-
* will save a file that fits the given parameters.
|
|
8442
|
-
* If it is called without specifying an element, by default it will save the
|
|
8443
|
-
* whole canvas as an image file. You can optionally specify a filename as
|
|
8444
|
-
* the first parameter in such a case.
|
|
8445
|
-
* Note that it is not recommended to
|
|
8446
|
-
* call this method within draw, as it will open a new save dialog on every
|
|
8447
|
-
* render.
|
|
8448
|
-
* @param objectOrFilename If filename is provided, will
|
|
8449
|
-
* save canvas as an image with
|
|
8450
|
-
* either png or jpg extension
|
|
8451
|
-
* depending on the filename.
|
|
8452
|
-
* If object is provided, will
|
|
8453
|
-
* save depending on the object
|
|
8454
|
-
* and filename (see examples
|
|
8455
|
-
* above).
|
|
8456
|
-
* @param filename If an object is provided as the first
|
|
8457
|
-
* parameter, then the second parameter
|
|
8458
|
-
* indicates the filename,
|
|
8459
|
-
* and should include an appropriate
|
|
8460
|
-
* file extension (see examples above).
|
|
8461
|
-
* @param options Additional options depend on
|
|
8462
|
-
* filetype. For example, when saving JSON,
|
|
8463
|
-
* <code>true</code> indicates that the
|
|
8464
|
-
* output will be optimized for filesize,
|
|
8465
|
-
* rather than readability.
|
|
8466
|
-
*/
|
|
8467
|
-
save(objectOrFilename?: object | string, filename?: string, options?: boolean | string): void;
|
|
8468
|
-
|
|
8469
8418
|
/**
|
|
8470
8419
|
* Loads a new shader from a file that can change how fills are drawn. Pass the resulting
|
|
8471
8420
|
* shader into the <a href="#/p5/shader">`shader()`</a> function to apply it
|
|
@@ -8483,7 +8432,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8483
8432
|
* function draw() {
|
|
8484
8433
|
* background(255);
|
|
8485
8434
|
* shader(myShader);
|
|
8486
|
-
* myShader.setUniform('time', millis());
|
|
8487
8435
|
* lights();
|
|
8488
8436
|
* noStroke();
|
|
8489
8437
|
* fill('red');
|
|
@@ -8493,7 +8441,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8493
8441
|
* might use the `pixelInputs` hook to change each pixel on the surface of a shape.
|
|
8494
8442
|
*
|
|
8495
8443
|
* `// myMaterial.js
|
|
8496
|
-
* let time =
|
|
8444
|
+
* let time = millis();
|
|
8497
8445
|
* worldInputs.begin();
|
|
8498
8446
|
* worldInputs.position.y +=
|
|
8499
8447
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -8511,7 +8459,43 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8511
8459
|
* @param onFailure A callback function to run when loading fails.
|
|
8512
8460
|
* @returns The material shader.
|
|
8513
8461
|
*/
|
|
8514
|
-
loadMaterialShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
|
|
8462
|
+
loadMaterialShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
|
|
8463
|
+
|
|
8464
|
+
/**
|
|
8465
|
+
* Saves a given element(image, text, json, csv, wav, or html) to the client's
|
|
8466
|
+
* computer. The first parameter can be a pointer to element we want to save.
|
|
8467
|
+
* The element can be one of <a href="#/p5.Element">p5.Element</a>,an Array of
|
|
8468
|
+
* Strings, an Array of JSON, a JSON object, a <a href="#/p5.Table">p5.Table
|
|
8469
|
+
* </a>, a <a href="#/p5.Image">p5.Image</a>, or a p5.SoundFile (requires
|
|
8470
|
+
* p5.sound). The second parameter is a filename (including extension).The
|
|
8471
|
+
* third parameter is for options specific to this type of object. This method
|
|
8472
|
+
* will save a file that fits the given parameters.
|
|
8473
|
+
* If it is called without specifying an element, by default it will save the
|
|
8474
|
+
* whole canvas as an image file. You can optionally specify a filename as
|
|
8475
|
+
* the first parameter in such a case.
|
|
8476
|
+
* Note that it is not recommended to
|
|
8477
|
+
* call this method within draw, as it will open a new save dialog on every
|
|
8478
|
+
* render.
|
|
8479
|
+
* @param objectOrFilename If filename is provided, will
|
|
8480
|
+
* save canvas as an image with
|
|
8481
|
+
* either png or jpg extension
|
|
8482
|
+
* depending on the filename.
|
|
8483
|
+
* If object is provided, will
|
|
8484
|
+
* save depending on the object
|
|
8485
|
+
* and filename (see examples
|
|
8486
|
+
* above).
|
|
8487
|
+
* @param filename If an object is provided as the first
|
|
8488
|
+
* parameter, then the second parameter
|
|
8489
|
+
* indicates the filename,
|
|
8490
|
+
* and should include an appropriate
|
|
8491
|
+
* file extension (see examples above).
|
|
8492
|
+
* @param options Additional options depend on
|
|
8493
|
+
* filetype. For example, when saving JSON,
|
|
8494
|
+
* <code>true</code> indicates that the
|
|
8495
|
+
* output will be optimized for filesize,
|
|
8496
|
+
* rather than readability.
|
|
8497
|
+
*/
|
|
8498
|
+
save(objectOrFilename?: object | string, filename?: string, options?: boolean | string): void;
|
|
8515
8499
|
|
|
8516
8500
|
/**
|
|
8517
8501
|
* Influences the shape of the Bézier curve segment in a custom shape.
|
|
@@ -8595,6 +8579,19 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8595
8579
|
*/
|
|
8596
8580
|
baseMaterialShader(): P5.Shader;
|
|
8597
8581
|
|
|
8582
|
+
/**
|
|
8583
|
+
* Returns the base shader used for filters.
|
|
8584
|
+
*
|
|
8585
|
+
* Calling <a href="#/p5/buildFilterShader">`buildFilterShader(shaderFunction)`</a>
|
|
8586
|
+
* is equivalent to calling `baseFilterShader().modify(shaderFunction)`.
|
|
8587
|
+
*
|
|
8588
|
+
* Read <a href="#/p5/buildFilterShader">the `buildFilterShader` reference</a> or
|
|
8589
|
+
* call `baseFilterShader().inspectHooks()` for more information on what you can do with
|
|
8590
|
+
* the base filter shader.
|
|
8591
|
+
* @returns The base filter shader.
|
|
8592
|
+
*/
|
|
8593
|
+
baseFilterShader(): P5.Shader;
|
|
8594
|
+
|
|
8598
8595
|
/**
|
|
8599
8596
|
* Starts using shapes to erase parts of the canvas.
|
|
8600
8597
|
*
|
|
@@ -8629,19 +8626,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8629
8626
|
*/
|
|
8630
8627
|
erase(strengthFill?: number, strengthStroke?: number): void;
|
|
8631
8628
|
|
|
8632
|
-
/**
|
|
8633
|
-
* Returns the base shader used for filters.
|
|
8634
|
-
*
|
|
8635
|
-
* Calling <a href="#/p5/buildFilterShader">`buildFilterShader(shaderFunction)`</a>
|
|
8636
|
-
* is equivalent to calling `baseFilterShader().modify(shaderFunction)`.
|
|
8637
|
-
*
|
|
8638
|
-
* Read <a href="#/p5/buildFilterShader">the `buildFilterShader` reference</a> or
|
|
8639
|
-
* call `baseFilterShader().inspectHooks()` for more information on what you can do with
|
|
8640
|
-
* the base filter shader.
|
|
8641
|
-
* @returns The base filter shader.
|
|
8642
|
-
*/
|
|
8643
|
-
baseFilterShader(): P5.Shader;
|
|
8644
|
-
|
|
8645
8629
|
/**
|
|
8646
8630
|
* Ends erasing that was started with <a href="#/p5/erase">erase()</a>.
|
|
8647
8631
|
*
|
|
@@ -8652,7 +8636,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8652
8636
|
noErase(): void;
|
|
8653
8637
|
|
|
8654
8638
|
/**
|
|
8655
|
-
* Creates a text
|
|
8639
|
+
* Creates a text `<input></input>` element.
|
|
8656
8640
|
*
|
|
8657
8641
|
* Call `myInput.size()` to set the length of the text box.
|
|
8658
8642
|
*
|
|
@@ -8702,7 +8686,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8702
8686
|
* }
|
|
8703
8687
|
*
|
|
8704
8688
|
* function material() {
|
|
8705
|
-
* let time =
|
|
8689
|
+
* let time = millis();
|
|
8706
8690
|
* worldInputs.begin();
|
|
8707
8691
|
* worldInputs.position.y +=
|
|
8708
8692
|
* 20. * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -8712,7 +8696,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
8712
8696
|
* function draw() {
|
|
8713
8697
|
* background(255);
|
|
8714
8698
|
* shader(myShader);
|
|
8715
|
-
* myShader.setUniform('time', millis());
|
|
8716
8699
|
* noStroke();
|
|
8717
8700
|
* sphere(50);
|
|
8718
8701
|
* }`You may also want to change the colors used. By default, the x, y, and z values of the orientation
|
|
@@ -9001,7 +8984,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9001
8984
|
pop(): void;
|
|
9002
8985
|
|
|
9003
8986
|
/**
|
|
9004
|
-
* Creates an
|
|
8987
|
+
* Creates an `<input></input>` element of type `'file'`.
|
|
9005
8988
|
*
|
|
9006
8989
|
* `createFileInput()` allows users to select local files for use in a sketch.
|
|
9007
8990
|
* It returns a <a href="#/p5.File">p5.File</a> object.
|
|
@@ -9037,7 +9020,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9037
9020
|
* function draw() {
|
|
9038
9021
|
* background(255);
|
|
9039
9022
|
* shader(myShader);
|
|
9040
|
-
* myShader.setUniform('time', millis());
|
|
9041
9023
|
* lights();
|
|
9042
9024
|
* noStroke();
|
|
9043
9025
|
* fill('red');
|
|
@@ -9047,7 +9029,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9047
9029
|
* might use the `finalColor` hook to change the color of each pixel on the surface of a shape.
|
|
9048
9030
|
*
|
|
9049
9031
|
* `// myMaterial.js
|
|
9050
|
-
* let time =
|
|
9032
|
+
* let time = millis();
|
|
9051
9033
|
* worldInputs.begin();
|
|
9052
9034
|
* worldInputs.position.y +=
|
|
9053
9035
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -9178,7 +9160,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9178
9160
|
* }
|
|
9179
9161
|
*
|
|
9180
9162
|
* function material() {
|
|
9181
|
-
* let time =
|
|
9163
|
+
* let time = millis();
|
|
9182
9164
|
* worldInputs.begin();
|
|
9183
9165
|
* worldInputs.position.y +=
|
|
9184
9166
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -9188,7 +9170,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9188
9170
|
* function draw() {
|
|
9189
9171
|
* background(255);
|
|
9190
9172
|
* shader(myShader);
|
|
9191
|
-
* myShader.setUniform('time', millis());
|
|
9192
9173
|
* noStroke();
|
|
9193
9174
|
* fill('red');
|
|
9194
9175
|
* circle(0, 0, 50);
|
|
@@ -9302,7 +9283,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9302
9283
|
* function draw() {
|
|
9303
9284
|
* background(255);
|
|
9304
9285
|
* shader(myShader);
|
|
9305
|
-
* myShader.setUniform('time', millis());
|
|
9306
9286
|
* lights();
|
|
9307
9287
|
* noStroke();
|
|
9308
9288
|
* fill('red');
|
|
@@ -9312,7 +9292,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9312
9292
|
* might use the `finalColor` hook to change the color of each pixel on the surface of a shape.
|
|
9313
9293
|
*
|
|
9314
9294
|
* `// myMaterial.js
|
|
9315
|
-
* let time =
|
|
9295
|
+
* let time = millis();
|
|
9316
9296
|
* worldInputs.begin();
|
|
9317
9297
|
* worldInputs.position.y +=
|
|
9318
9298
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -9597,7 +9577,7 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9597
9577
|
* }
|
|
9598
9578
|
*
|
|
9599
9579
|
* function material() {
|
|
9600
|
-
* let time =
|
|
9580
|
+
* let time = millis();
|
|
9601
9581
|
* worldInputs.begin();
|
|
9602
9582
|
* // Add a somewhat random offset to the weight
|
|
9603
9583
|
* // that varies based on position and time
|
|
@@ -9613,7 +9593,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9613
9593
|
* function draw() {
|
|
9614
9594
|
* background(255);
|
|
9615
9595
|
* strokeShader(myShader);
|
|
9616
|
-
* myShader.setUniform('time', millis());
|
|
9617
9596
|
* strokeWeight(10);
|
|
9618
9597
|
* beginShape();
|
|
9619
9598
|
* for (let i = 0; i <= 50; i++) {
|
|
@@ -9704,6 +9683,58 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9704
9683
|
splineProperty(property: string, value: any): void;
|
|
9705
9684
|
splineProperty(property: string): void;
|
|
9706
9685
|
|
|
9686
|
+
/**
|
|
9687
|
+
* Loads a new shader from a file that can change how strokes are drawn. Pass the resulting
|
|
9688
|
+
* shader into the <a href="#/p5/strokeShader">`strokeShader()`</a> function to apply it
|
|
9689
|
+
* to any strokes you draw.
|
|
9690
|
+
*
|
|
9691
|
+
* Since this function loads data from another file, it returns a `Promise`.
|
|
9692
|
+
* Use it in an `async function setup`, and `await` its result.
|
|
9693
|
+
*
|
|
9694
|
+
* `let myShader;
|
|
9695
|
+
* async function setup() {
|
|
9696
|
+
* createCanvas(200, 200, WEBGL);
|
|
9697
|
+
* myShader = await loadStrokeShader('myMaterial.js');
|
|
9698
|
+
* }
|
|
9699
|
+
*
|
|
9700
|
+
* function draw() {
|
|
9701
|
+
* background(255);
|
|
9702
|
+
* strokeShader(myShader);
|
|
9703
|
+
* strokeWeight(30);
|
|
9704
|
+
* line(
|
|
9705
|
+
* -width/3,
|
|
9706
|
+
* sin(millis()*0.001) * height/4,
|
|
9707
|
+
* width/3,
|
|
9708
|
+
* sin(millis()*0.001 + 1) * height/4
|
|
9709
|
+
* );
|
|
9710
|
+
* }`Inside your shader file, you can call p5.strands hooks to change parts of the shader. For
|
|
9711
|
+
* example, you might use the `worldInputs` hook to change each vertex, or you
|
|
9712
|
+
* might use the `pixelInputs` hook to change each pixel on the surface of a stroke.
|
|
9713
|
+
*
|
|
9714
|
+
* `// myMaterial.js
|
|
9715
|
+
* pixelInputs.begin();
|
|
9716
|
+
* let opacity = 1 - smoothstep(
|
|
9717
|
+
* 0,
|
|
9718
|
+
* 15,
|
|
9719
|
+
* length(pixelInputs.position - pixelInputs.center)
|
|
9720
|
+
* );
|
|
9721
|
+
* pixelInputs.color.a *= opacity;
|
|
9722
|
+
* pixelInputs.end();`Read the reference for <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a>,
|
|
9723
|
+
* the version of `loadStrokeShader` that takes in a function instead of a separate file,
|
|
9724
|
+
* for a full list of hooks you can use and examples for each.
|
|
9725
|
+
*
|
|
9726
|
+
* The second parameter, `successCallback`, is optional. If a function is passed, as in
|
|
9727
|
+
* `loadStrokeShader('myShader.js', onLoaded)`, then the `onLoaded()` function will be called
|
|
9728
|
+
* once the shader loads. The shader will be passed to `onLoaded()` as its only argument.
|
|
9729
|
+
* The return value of `handleData()`, if present, will be used as the final return value of
|
|
9730
|
+
* `loadStrokeShader('myShader.js', onLoaded)`.
|
|
9731
|
+
* @param url The URL of your p5.strands JavaScript file.
|
|
9732
|
+
* @param onSuccess A callback function to run when loading completes.
|
|
9733
|
+
* @param onFailure A callback function to run when loading fails.
|
|
9734
|
+
* @returns The stroke shader.
|
|
9735
|
+
*/
|
|
9736
|
+
loadStrokeShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
|
|
9737
|
+
|
|
9707
9738
|
/**
|
|
9708
9739
|
* Sets a perspective projection for the current camera in a 3D sketch.
|
|
9709
9740
|
*
|
|
@@ -9758,58 +9789,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9758
9789
|
*/
|
|
9759
9790
|
perspective(fovy?: number, aspect?: number, near?: number, far?: number): void;
|
|
9760
9791
|
|
|
9761
|
-
/**
|
|
9762
|
-
* Loads a new shader from a file that can change how strokes are drawn. Pass the resulting
|
|
9763
|
-
* shader into the <a href="#/p5/strokeShader">`strokeShader()`</a> function to apply it
|
|
9764
|
-
* to any strokes you draw.
|
|
9765
|
-
*
|
|
9766
|
-
* Since this function loads data from another file, it returns a `Promise`.
|
|
9767
|
-
* Use it in an `async function setup`, and `await` its result.
|
|
9768
|
-
*
|
|
9769
|
-
* `let myShader;
|
|
9770
|
-
* async function setup() {
|
|
9771
|
-
* createCanvas(200, 200, WEBGL);
|
|
9772
|
-
* myShader = await loadStrokeShader('myMaterial.js');
|
|
9773
|
-
* }
|
|
9774
|
-
*
|
|
9775
|
-
* function draw() {
|
|
9776
|
-
* background(255);
|
|
9777
|
-
* strokeShader(myShader);
|
|
9778
|
-
* strokeWeight(30);
|
|
9779
|
-
* line(
|
|
9780
|
-
* -width/3,
|
|
9781
|
-
* sin(millis()*0.001) * height/4,
|
|
9782
|
-
* width/3,
|
|
9783
|
-
* sin(millis()*0.001 + 1) * height/4
|
|
9784
|
-
* );
|
|
9785
|
-
* }`Inside your shader file, you can call p5.strands hooks to change parts of the shader. For
|
|
9786
|
-
* example, you might use the `worldInputs` hook to change each vertex, or you
|
|
9787
|
-
* might use the `pixelInputs` hook to change each pixel on the surface of a stroke.
|
|
9788
|
-
*
|
|
9789
|
-
* `// myMaterial.js
|
|
9790
|
-
* pixelInputs.begin();
|
|
9791
|
-
* let opacity = 1 - smoothstep(
|
|
9792
|
-
* 0,
|
|
9793
|
-
* 15,
|
|
9794
|
-
* length(pixelInputs.position - pixelInputs.center)
|
|
9795
|
-
* );
|
|
9796
|
-
* pixelInputs.color.a *= opacity;
|
|
9797
|
-
* pixelInputs.end();`Read the reference for <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a>,
|
|
9798
|
-
* the version of `loadStrokeShader` that takes in a function instead of a separate file,
|
|
9799
|
-
* for a full list of hooks you can use and examples for each.
|
|
9800
|
-
*
|
|
9801
|
-
* The second parameter, `successCallback`, is optional. If a function is passed, as in
|
|
9802
|
-
* `loadStrokeShader('myShader.js', onLoaded)`, then the `onLoaded()` function will be called
|
|
9803
|
-
* once the shader loads. The shader will be passed to `onLoaded()` as its only argument.
|
|
9804
|
-
* The return value of `handleData()`, if present, will be used as the final return value of
|
|
9805
|
-
* `loadStrokeShader('myShader.js', onLoaded)`.
|
|
9806
|
-
* @param url The URL of your p5.strands JavaScript file.
|
|
9807
|
-
* @param onSuccess A callback function to run when loading completes.
|
|
9808
|
-
* @param onFailure A callback function to run when loading fails.
|
|
9809
|
-
* @returns The stroke shader.
|
|
9810
|
-
*/
|
|
9811
|
-
loadStrokeShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
|
|
9812
|
-
|
|
9813
9792
|
/**
|
|
9814
9793
|
* Returns the default shader used for strokes.
|
|
9815
9794
|
*
|
|
@@ -9854,6 +9833,17 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9854
9833
|
*/
|
|
9855
9834
|
splineProperties(values: object): object;
|
|
9856
9835
|
|
|
9836
|
+
/**
|
|
9837
|
+
* Restores the default shaders.
|
|
9838
|
+
*
|
|
9839
|
+
* `resetShader()` deactivates any shaders previously applied by
|
|
9840
|
+
* <a href="#/p5/shader">shader()</a>, <a href="#/p5/strokeShader">strokeShader()</a>,
|
|
9841
|
+
* or <a href="#/p5/imageShader">imageShader()</a>.
|
|
9842
|
+
*
|
|
9843
|
+
* Note: Shaders can only be used in WebGL mode.
|
|
9844
|
+
*/
|
|
9845
|
+
resetShader(): void;
|
|
9846
|
+
|
|
9857
9847
|
/**
|
|
9858
9848
|
* Enables or disables perspective for lines in 3D sketches.
|
|
9859
9849
|
*
|
|
@@ -9891,17 +9881,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9891
9881
|
linePerspective(enable: boolean): boolean;
|
|
9892
9882
|
linePerspective(): boolean;
|
|
9893
9883
|
|
|
9894
|
-
/**
|
|
9895
|
-
* Restores the default shaders.
|
|
9896
|
-
*
|
|
9897
|
-
* `resetShader()` deactivates any shaders previously applied by
|
|
9898
|
-
* <a href="#/p5/shader">shader()</a>, <a href="#/p5/strokeShader">strokeShader()</a>,
|
|
9899
|
-
* or <a href="#/p5/imageShader">imageShader()</a>.
|
|
9900
|
-
*
|
|
9901
|
-
* Note: Shaders can only be used in WebGL mode.
|
|
9902
|
-
*/
|
|
9903
|
-
resetShader(): void;
|
|
9904
|
-
|
|
9905
9884
|
/**
|
|
9906
9885
|
* Sets an orthographic projection for the current camera in a 3D sketch.
|
|
9907
9886
|
*
|
|
@@ -9985,6 +9964,20 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
9985
9964
|
vertex(x: number, y: number, u?: number, v?: number): void;
|
|
9986
9965
|
vertex(x: number, y: number, z: number, u?: number, v?: number): void;
|
|
9987
9966
|
|
|
9967
|
+
/**
|
|
9968
|
+
* Sets the number of segments used to draw spline curves in WebGL mode.
|
|
9969
|
+
*
|
|
9970
|
+
* In WebGL mode, smooth shapes are drawn using many flat segments. Adding
|
|
9971
|
+
* more flat segments makes shapes appear smoother.
|
|
9972
|
+
*
|
|
9973
|
+
* The parameter, `detail`, is the density of segments to use while drawing a
|
|
9974
|
+
* spline curve.
|
|
9975
|
+
*
|
|
9976
|
+
* Note: `curveDetail()` has no effect in 2D mode.
|
|
9977
|
+
* @param resolution number of segments to use. Default is 1/4
|
|
9978
|
+
*/
|
|
9979
|
+
curveDetail(resolution: number): void;
|
|
9980
|
+
|
|
9988
9981
|
/**
|
|
9989
9982
|
* Sets the frustum of the current camera in a 3D sketch.
|
|
9990
9983
|
*
|
|
@@ -10024,20 +10017,6 @@ EXCLUDE: typeof P5.EXCLUDE;
|
|
|
10024
10017
|
*/
|
|
10025
10018
|
frustum(left?: number, right?: number, bottom?: number, top?: number, near?: number, far?: number): void;
|
|
10026
10019
|
|
|
10027
|
-
/**
|
|
10028
|
-
* Sets the number of segments used to draw spline curves in WebGL mode.
|
|
10029
|
-
*
|
|
10030
|
-
* In WebGL mode, smooth shapes are drawn using many flat segments. Adding
|
|
10031
|
-
* more flat segments makes shapes appear smoother.
|
|
10032
|
-
*
|
|
10033
|
-
* The parameter, `detail`, is the density of segments to use while drawing a
|
|
10034
|
-
* spline curve.
|
|
10035
|
-
*
|
|
10036
|
-
* Note: `curveDetail()` has no effect in 2D mode.
|
|
10037
|
-
* @param resolution number of segments to use. Default is 1/4
|
|
10038
|
-
*/
|
|
10039
|
-
curveDetail(resolution: number): void;
|
|
10040
|
-
|
|
10041
10020
|
/**
|
|
10042
10021
|
* Creates a new <a href="#/p5.Camera">p5.Camera</a> object.
|
|
10043
10022
|
*
|
|
@@ -12436,9 +12415,9 @@ const BOTTOM: typeof P5.BOTTOM;
|
|
|
12436
12415
|
|
|
12437
12416
|
/**
|
|
12438
12417
|
* A system variable that provides direct access to the sketch's
|
|
12439
|
-
*
|
|
12418
|
+
* `<canvas>` element.
|
|
12440
12419
|
*
|
|
12441
|
-
* The
|
|
12420
|
+
* The `<canvas>` element provides many specialized features that aren't
|
|
12442
12421
|
* included in the p5.js library. The `drawingContext` system variable
|
|
12443
12422
|
* provides access to these features by exposing the sketch's
|
|
12444
12423
|
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D">CanvasRenderingContext2D</a>
|
|
@@ -14368,6 +14347,26 @@ function str(n: string | boolean | number): string;
|
|
|
14368
14347
|
function byte(n: string | boolean | number): number;
|
|
14369
14348
|
function byte(ns: any[]): number[];
|
|
14370
14349
|
|
|
14350
|
+
/**
|
|
14351
|
+
* Creates a custom <a href="#/p5.Geometry">p5.Geometry</a> object from
|
|
14352
|
+
* simpler 3D shapes.
|
|
14353
|
+
*
|
|
14354
|
+
* `buildGeometry()` helps with creating complex 3D shapes from simpler ones
|
|
14355
|
+
* such as <a href="#/p5/sphere">sphere()</a>. It can help to make sketches
|
|
14356
|
+
* more performant. For example, if a complex 3D shape doesn’t change while a
|
|
14357
|
+
* sketch runs, then it can be created with `buildGeometry()`. Creating a
|
|
14358
|
+
* <a href="#/p5.Geometry">p5.Geometry</a> object once and then drawing it
|
|
14359
|
+
* will run faster than repeatedly drawing the individual pieces.
|
|
14360
|
+
*
|
|
14361
|
+
* The parameter, `callback`, is a function with the drawing instructions for
|
|
14362
|
+
* the new <a href="#/p5.Geometry">p5.Geometry</a> object. It will be called
|
|
14363
|
+
* once to create the new 3D shape.
|
|
14364
|
+
* Note: `buildGeometry()` can only be used in WebGL mode.
|
|
14365
|
+
* @param callback function that draws the shape.
|
|
14366
|
+
* @returns new 3D shape.
|
|
14367
|
+
*/
|
|
14368
|
+
function buildGeometry(callback: Function): P5.Geometry;
|
|
14369
|
+
|
|
14371
14370
|
/**
|
|
14372
14371
|
* Calculates coordinates along a Bézier curve using interpolation.
|
|
14373
14372
|
*
|
|
@@ -14398,31 +14397,6 @@ function byte(ns: any[]): number[];
|
|
|
14398
14397
|
*/
|
|
14399
14398
|
function bezierPoint(a: number, b: number, c: number, d: number, t: number): number;
|
|
14400
14399
|
|
|
14401
|
-
/**
|
|
14402
|
-
* Creates a custom <a href="#/p5.Geometry">p5.Geometry</a> object from
|
|
14403
|
-
* simpler 3D shapes.
|
|
14404
|
-
*
|
|
14405
|
-
* `buildGeometry()` helps with creating complex 3D shapes from simpler ones
|
|
14406
|
-
* such as <a href="#/p5/sphere">sphere()</a>. It can help to make sketches
|
|
14407
|
-
* more performant. For example, if a complex 3D shape doesn’t change while a
|
|
14408
|
-
* sketch runs, then it can be created with `buildGeometry()`. Creating a
|
|
14409
|
-
* <a href="#/p5.Geometry">p5.Geometry</a> object once and then drawing it
|
|
14410
|
-
* will run faster than repeatedly drawing the individual pieces.
|
|
14411
|
-
*
|
|
14412
|
-
* The parameter, `callback`, is a function with the drawing instructions for
|
|
14413
|
-
* the new <a href="#/p5.Geometry">p5.Geometry</a> object. It will be called
|
|
14414
|
-
* once to create the new 3D shape.
|
|
14415
|
-
*
|
|
14416
|
-
* See <a href="#/p5/beginGeometry">beginGeometry()</a> and
|
|
14417
|
-
* <a href="#/p5/endGeometry">endGeometry()</a> for another way to build 3D
|
|
14418
|
-
* shapes.
|
|
14419
|
-
*
|
|
14420
|
-
* Note: `buildGeometry()` can only be used in WebGL mode.
|
|
14421
|
-
* @param callback function that draws the shape.
|
|
14422
|
-
* @returns new 3D shape.
|
|
14423
|
-
*/
|
|
14424
|
-
function buildGeometry(callback: Function): P5.Geometry;
|
|
14425
|
-
|
|
14426
14400
|
/**
|
|
14427
14401
|
* Loads a 3D model to create a
|
|
14428
14402
|
* <a href="#/p5.Geometry">p5.Geometry</a> object.
|
|
@@ -14572,29 +14546,15 @@ function atan2(y: number, x: number): number;
|
|
|
14572
14546
|
/**
|
|
14573
14547
|
* Draws certain features with smooth (antialiased) edges.
|
|
14574
14548
|
*
|
|
14575
|
-
* `smooth()` is active by default. In 2D mode,
|
|
14576
|
-
* <a href="#/p5/noSmooth">noSmooth()</a> is helpful for scaling up images
|
|
14577
|
-
* without blurring. The functions don't affect shapes or fonts.
|
|
14578
|
-
*
|
|
14579
|
-
* In WebGL mode, <a href="#/p5/noSmooth">noSmooth()</a> causes all shapes to
|
|
14580
|
-
* be drawn with jagged (aliased) edges. The functions don't affect images or
|
|
14581
|
-
* fonts.
|
|
14582
|
-
*/
|
|
14583
|
-
function smooth(): void;
|
|
14584
|
-
|
|
14585
|
-
/**
|
|
14586
|
-
* Removes all items in the web browser's local storage.
|
|
14587
|
-
*
|
|
14588
|
-
* Web browsers can save small amounts of data using the built-in
|
|
14589
|
-
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
|
|
14590
|
-
* Data stored in `localStorage` can be retrieved at any point, even after
|
|
14591
|
-
* refreshing a page or restarting the browser. Data are stored as key-value
|
|
14592
|
-
* pairs. Calling `clearStorage()` removes all data from `localStorage`.
|
|
14593
|
-
*
|
|
14594
|
-
* Note: Sensitive data such as passwords or personal information shouldn't be
|
|
14595
|
-
* stored in `localStorage`.
|
|
14549
|
+
* `smooth()` is active by default. In 2D mode,
|
|
14550
|
+
* <a href="#/p5/noSmooth">noSmooth()</a> is helpful for scaling up images
|
|
14551
|
+
* without blurring. The functions don't affect shapes or fonts.
|
|
14552
|
+
*
|
|
14553
|
+
* In WebGL mode, <a href="#/p5/noSmooth">noSmooth()</a> causes all shapes to
|
|
14554
|
+
* be drawn with jagged (aliased) edges. The functions don't affect images or
|
|
14555
|
+
* fonts.
|
|
14596
14556
|
*/
|
|
14597
|
-
function
|
|
14557
|
+
function smooth(): void;
|
|
14598
14558
|
|
|
14599
14559
|
/**
|
|
14600
14560
|
* Converts a `Number` into a `String` with a plus or minus sign.
|
|
@@ -14631,6 +14591,20 @@ function clearStorage(): void;
|
|
|
14631
14591
|
function nfp(num: number, left?: number, right?: number): string;
|
|
14632
14592
|
function nfp(nums: number[], left?: number, right?: number): string[];
|
|
14633
14593
|
|
|
14594
|
+
/**
|
|
14595
|
+
* Removes all items in the web browser's local storage.
|
|
14596
|
+
*
|
|
14597
|
+
* Web browsers can save small amounts of data using the built-in
|
|
14598
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
|
|
14599
|
+
* Data stored in `localStorage` can be retrieved at any point, even after
|
|
14600
|
+
* refreshing a page or restarting the browser. Data are stored as key-value
|
|
14601
|
+
* pairs. Calling `clearStorage()` removes all data from `localStorage`.
|
|
14602
|
+
*
|
|
14603
|
+
* Note: Sensitive data such as passwords or personal information shouldn't be
|
|
14604
|
+
* stored in `localStorage`.
|
|
14605
|
+
*/
|
|
14606
|
+
function clearStorage(): void;
|
|
14607
|
+
|
|
14634
14608
|
/**
|
|
14635
14609
|
* Removes all elements created by p5.js, including any event handlers.
|
|
14636
14610
|
*
|
|
@@ -14873,6 +14847,29 @@ function lerp(start: number, stop: number, amt: number): number;
|
|
|
14873
14847
|
function frameRate(fps: number): number;
|
|
14874
14848
|
function frameRate(): number;
|
|
14875
14849
|
|
|
14850
|
+
/**
|
|
14851
|
+
* Clears a <a href="#/p5.Geometry">p5.Geometry</a> object from the graphics
|
|
14852
|
+
* processing unit (GPU) memory.
|
|
14853
|
+
*
|
|
14854
|
+
* <a href="#/p5.Geometry">p5.Geometry</a> objects can contain lots of data
|
|
14855
|
+
* about their vertices, surface normals, colors, and so on. Complex 3D shapes
|
|
14856
|
+
* can use lots of memory which is a limited resource in many GPUs. Calling
|
|
14857
|
+
* `freeGeometry()` works with <a href="#/p5.Geometry">p5.Geometry</a> objects
|
|
14858
|
+
* created with <a href="#/p5/buildGeometry">buildGeometry()</a> and
|
|
14859
|
+
* <a href="#/p5/loadModel">loadModel()</a>.
|
|
14860
|
+
*
|
|
14861
|
+
* The parameter, `geometry`, is the <a href="#/p5.Geometry">p5.Geometry</a>
|
|
14862
|
+
* object to be freed.
|
|
14863
|
+
*
|
|
14864
|
+
* Note: A <a href="#/p5.Geometry">p5.Geometry</a> object can still be drawn
|
|
14865
|
+
* after its resources are cleared from GPU memory. It may take longer to draw
|
|
14866
|
+
* the first time it’s redrawn.
|
|
14867
|
+
*
|
|
14868
|
+
* Note: `freeGeometry()` can only be used in WebGL mode.
|
|
14869
|
+
* @param geometry 3D shape whose resources should be freed.
|
|
14870
|
+
*/
|
|
14871
|
+
function freeGeometry(geometry: P5.Geometry): void;
|
|
14872
|
+
|
|
14876
14873
|
/**
|
|
14877
14874
|
* Calculates the cosine of an angle.
|
|
14878
14875
|
*
|
|
@@ -14935,14 +14932,14 @@ function specularColor(values: number[]): void;
|
|
|
14935
14932
|
function specularColor(color: P5.Color): void;
|
|
14936
14933
|
|
|
14937
14934
|
/**
|
|
14938
|
-
* Creates a
|
|
14935
|
+
* Creates a `<div></div>` element.
|
|
14939
14936
|
*
|
|
14940
|
-
*
|
|
14937
|
+
* `<div></div>` elements are commonly used as containers for
|
|
14941
14938
|
* other elements.
|
|
14942
14939
|
*
|
|
14943
14940
|
* The parameter `html` is optional. It accepts a string that sets the
|
|
14944
|
-
* inner HTML of the new
|
|
14945
|
-
* @param html inner HTML for the new
|
|
14941
|
+
* inner HTML of the new `<div></div>`.
|
|
14942
|
+
* @param html inner HTML for the new `<div></div>` element.
|
|
14946
14943
|
* @returns new <a href="#/p5.Element">p5.Element</a> object.
|
|
14947
14944
|
*/
|
|
14948
14945
|
function createDiv(html?: string): P5.Element;
|
|
@@ -15000,27 +14997,6 @@ function loadStrings(path: string | Request, successCallback?: Function, errorCa
|
|
|
15000
14997
|
function boolean(n: string | boolean | number): boolean;
|
|
15001
14998
|
function boolean(ns: any[]): boolean[];
|
|
15002
14999
|
|
|
15003
|
-
/**
|
|
15004
|
-
* Removes an item from the web browser's local storage.
|
|
15005
|
-
*
|
|
15006
|
-
* Web browsers can save small amounts of data using the built-in
|
|
15007
|
-
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
|
|
15008
|
-
* Data stored in `localStorage` can be retrieved at any point, even after
|
|
15009
|
-
* refreshing a page or restarting the browser. Data are stored as key-value
|
|
15010
|
-
* pairs.
|
|
15011
|
-
*
|
|
15012
|
-
* <a href="#/p5/storeItem">storeItem()</a> makes it easy to store values in
|
|
15013
|
-
* `localStorage` and `removeItem()` makes it easy to delete them.
|
|
15014
|
-
*
|
|
15015
|
-
* The parameter, `key`, is the name of the value to remove as a string. For
|
|
15016
|
-
* example, calling `removeItem('size')` removes the item with the key `size`.
|
|
15017
|
-
*
|
|
15018
|
-
* Note: Sensitive data such as passwords or personal information shouldn't be
|
|
15019
|
-
* stored in `localStorage`.
|
|
15020
|
-
* @param key name of the value to remove.
|
|
15021
|
-
*/
|
|
15022
|
-
function removeItem(key: string): void;
|
|
15023
|
-
|
|
15024
15000
|
/**
|
|
15025
15001
|
* Rotates the coordinate system.
|
|
15026
15002
|
*
|
|
@@ -15056,31 +15032,25 @@ function removeItem(key: string): void;
|
|
|
15056
15032
|
function rotate(angle: number, axis?: P5.Vector | number[]): void;
|
|
15057
15033
|
|
|
15058
15034
|
/**
|
|
15059
|
-
*
|
|
15060
|
-
* processing unit (GPU) memory.
|
|
15035
|
+
* Removes an item from the web browser's local storage.
|
|
15061
15036
|
*
|
|
15062
|
-
*
|
|
15063
|
-
*
|
|
15064
|
-
*
|
|
15065
|
-
*
|
|
15066
|
-
*
|
|
15067
|
-
* `freeGeometry()` works with <a href="#/p5.Geometry">p5.Geometry</a> objects
|
|
15068
|
-
* created with <a href="#/p5/beginGeometry">beginGeometry()</a> and
|
|
15069
|
-
* <a href="#/p5/endGeometry">endGeometry()</a>,
|
|
15070
|
-
* <a href="#/p5/buildGeometry">buildGeometry()</a>, and
|
|
15071
|
-
* <a href="#/p5/loadModel">loadModel()</a>.
|
|
15037
|
+
* Web browsers can save small amounts of data using the built-in
|
|
15038
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
|
|
15039
|
+
* Data stored in `localStorage` can be retrieved at any point, even after
|
|
15040
|
+
* refreshing a page or restarting the browser. Data are stored as key-value
|
|
15041
|
+
* pairs.
|
|
15072
15042
|
*
|
|
15073
|
-
*
|
|
15074
|
-
*
|
|
15043
|
+
* <a href="#/p5/storeItem">storeItem()</a> makes it easy to store values in
|
|
15044
|
+
* `localStorage` and `removeItem()` makes it easy to delete them.
|
|
15075
15045
|
*
|
|
15076
|
-
*
|
|
15077
|
-
*
|
|
15078
|
-
* the first time it’s redrawn.
|
|
15046
|
+
* The parameter, `key`, is the name of the value to remove as a string. For
|
|
15047
|
+
* example, calling `removeItem('size')` removes the item with the key `size`.
|
|
15079
15048
|
*
|
|
15080
|
-
* Note:
|
|
15081
|
-
*
|
|
15049
|
+
* Note: Sensitive data such as passwords or personal information shouldn't be
|
|
15050
|
+
* stored in `localStorage`.
|
|
15051
|
+
* @param key name of the value to remove.
|
|
15082
15052
|
*/
|
|
15083
|
-
function
|
|
15053
|
+
function removeItem(key: string): void;
|
|
15084
15054
|
|
|
15085
15055
|
/**
|
|
15086
15056
|
* The <a href="#/p5/setMoveThreshold">setMoveThreshold()</a> function is used to set the movement threshold for
|
|
@@ -15170,11 +15140,11 @@ function log(n: number): number;
|
|
|
15170
15140
|
/**
|
|
15171
15141
|
* Creates a paragraph element.
|
|
15172
15142
|
*
|
|
15173
|
-
*
|
|
15143
|
+
* `<p></p>` elements are commonly used for paragraph-length text.
|
|
15174
15144
|
*
|
|
15175
15145
|
* The parameter `html` is optional. It accepts a string that sets the
|
|
15176
|
-
* inner HTML of the new
|
|
15177
|
-
* @param html inner HTML for the new
|
|
15146
|
+
* inner HTML of the new `<p></p>`.
|
|
15147
|
+
* @param html inner HTML for the new `<p></p>` element.
|
|
15178
15148
|
* @returns new <a href="#/p5.Element">p5.Element</a> object.
|
|
15179
15149
|
*/
|
|
15180
15150
|
function createP(html?: string): P5.Element;
|
|
@@ -15418,7 +15388,7 @@ function createP(html?: string): P5.Element;
|
|
|
15418
15388
|
* // Make a version of the shader with a hook overridden
|
|
15419
15389
|
* modifiedShader = myShader.modify(() => {
|
|
15420
15390
|
* // Create new uniforms and override the getColor hook
|
|
15421
|
-
* let t =
|
|
15391
|
+
* let t = millis() / 1000;
|
|
15422
15392
|
* getColor(() => {
|
|
15423
15393
|
* return [0, 0.5 + 0.5 * sin(t), 1, 1];
|
|
15424
15394
|
* });
|
|
@@ -15608,6 +15578,38 @@ function mag(x: number, y: number): number;
|
|
|
15608
15578
|
*/
|
|
15609
15579
|
function loadTable(filename: string | Request, separator?: string, header?: string, callback?: Function, errorCallback?: Function): Promise<object>;
|
|
15610
15580
|
|
|
15581
|
+
/**
|
|
15582
|
+
* Draws a plane.
|
|
15583
|
+
*
|
|
15584
|
+
* A plane is a four-sided, flat shape with every angle measuring 90˚. It’s
|
|
15585
|
+
* similar to a rectangle and offers advanced drawing features in WebGL mode.
|
|
15586
|
+
*
|
|
15587
|
+
* The first parameter, `width`, is optional. If a `Number` is passed, as in
|
|
15588
|
+
* `plane(20)`, it sets the plane’s width and height. By default, `width` is
|
|
15589
|
+
* 50.
|
|
15590
|
+
*
|
|
15591
|
+
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
15592
|
+
* as in `plane(20, 30)`, it sets the plane’s height. By default, `height` is
|
|
15593
|
+
* set to the plane’s `width`.
|
|
15594
|
+
*
|
|
15595
|
+
* The third parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
15596
|
+
* as in `plane(20, 30, 5)` it sets the number of triangle subdivisions to use
|
|
15597
|
+
* along the x-axis. All 3D shapes are made by connecting triangles to form
|
|
15598
|
+
* their surfaces. By default, `detailX` is 1.
|
|
15599
|
+
*
|
|
15600
|
+
* The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
15601
|
+
* as in `plane(20, 30, 5, 7)` it sets the number of triangle subdivisions to
|
|
15602
|
+
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
15603
|
+
* form their surfaces. By default, `detailY` is 1.
|
|
15604
|
+
*
|
|
15605
|
+
* Note: `plane()` can only be used in WebGL mode.
|
|
15606
|
+
* @param width width of the plane.
|
|
15607
|
+
* @param height height of the plane.
|
|
15608
|
+
* @param detailX number of triangle subdivisions along the x-axis.
|
|
15609
|
+
* @param detailY number of triangle subdivisions along the y-axis.
|
|
15610
|
+
*/
|
|
15611
|
+
function plane(width?: number, height?: number, detailX?: number, detailY?: number): void;
|
|
15612
|
+
|
|
15611
15613
|
/**
|
|
15612
15614
|
* Gets the red value of a color.
|
|
15613
15615
|
*
|
|
@@ -15693,16 +15695,16 @@ function filter(shaderFilter: P5.Shader): void;
|
|
|
15693
15695
|
function tan(angle: number): number;
|
|
15694
15696
|
|
|
15695
15697
|
/**
|
|
15696
|
-
* Creates a
|
|
15698
|
+
* Creates a `<span></span>` element.
|
|
15697
15699
|
*
|
|
15698
|
-
*
|
|
15699
|
-
* for inline elements. For example, a
|
|
15700
|
+
* `<span></span>` elements are commonly used as containers
|
|
15701
|
+
* for inline elements. For example, a `<span></span>`
|
|
15700
15702
|
* can hold part of a sentence that's a
|
|
15701
15703
|
* <span style="color: deeppink;">different</span> style.
|
|
15702
15704
|
*
|
|
15703
15705
|
* The parameter `html` is optional. It accepts a string that sets the
|
|
15704
|
-
* inner HTML of the new
|
|
15705
|
-
* @param html inner HTML for the new
|
|
15706
|
+
* inner HTML of the new `<span></span>`.
|
|
15707
|
+
* @param html inner HTML for the new `<span></span>` element.
|
|
15706
15708
|
* @returns new <a href="#/p5.Element">p5.Element</a> object.
|
|
15707
15709
|
*/
|
|
15708
15710
|
function createSpan(html?: string): P5.Element;
|
|
@@ -15755,38 +15757,6 @@ function createSpan(html?: string): P5.Element;
|
|
|
15755
15757
|
*/
|
|
15756
15758
|
function loadFilterShader(filename: string, successCallback?: Function, failureCallback?: Function): Promise<P5.Shader>;
|
|
15757
15759
|
|
|
15758
|
-
/**
|
|
15759
|
-
* Draws a plane.
|
|
15760
|
-
*
|
|
15761
|
-
* A plane is a four-sided, flat shape with every angle measuring 90˚. It’s
|
|
15762
|
-
* similar to a rectangle and offers advanced drawing features in WebGL mode.
|
|
15763
|
-
*
|
|
15764
|
-
* The first parameter, `width`, is optional. If a `Number` is passed, as in
|
|
15765
|
-
* `plane(20)`, it sets the plane’s width and height. By default, `width` is
|
|
15766
|
-
* 50.
|
|
15767
|
-
*
|
|
15768
|
-
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
15769
|
-
* as in `plane(20, 30)`, it sets the plane’s height. By default, `height` is
|
|
15770
|
-
* set to the plane’s `width`.
|
|
15771
|
-
*
|
|
15772
|
-
* The third parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
15773
|
-
* as in `plane(20, 30, 5)` it sets the number of triangle subdivisions to use
|
|
15774
|
-
* along the x-axis. All 3D shapes are made by connecting triangles to form
|
|
15775
|
-
* their surfaces. By default, `detailX` is 1.
|
|
15776
|
-
*
|
|
15777
|
-
* The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
15778
|
-
* as in `plane(20, 30, 5, 7)` it sets the number of triangle subdivisions to
|
|
15779
|
-
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
15780
|
-
* form their surfaces. By default, `detailY` is 1.
|
|
15781
|
-
*
|
|
15782
|
-
* Note: `plane()` can only be used in WebGL mode.
|
|
15783
|
-
* @param width width of the plane.
|
|
15784
|
-
* @param height height of the plane.
|
|
15785
|
-
* @param detailX number of triangle subdivisions along the x-axis.
|
|
15786
|
-
* @param detailY number of triangle subdivisions along the y-axis.
|
|
15787
|
-
*/
|
|
15788
|
-
function plane(width?: number, height?: number, detailX?: number, detailY?: number): void;
|
|
15789
|
-
|
|
15790
15760
|
/**
|
|
15791
15761
|
* Creates and a new <a href="#/p5.Framebuffer">p5.Framebuffer</a> object.
|
|
15792
15762
|
*
|
|
@@ -15896,7 +15866,7 @@ function rotateX(angle: number): void;
|
|
|
15896
15866
|
function map(value: number, start1: number, stop1: number, start2: number, stop2: number, withinBounds?: boolean): number;
|
|
15897
15867
|
|
|
15898
15868
|
/**
|
|
15899
|
-
* Creates an
|
|
15869
|
+
* Creates an `<img>` element that can appear outside of the canvas.
|
|
15900
15870
|
*
|
|
15901
15871
|
* The first parameter, `src`, is a string with the path to the image file.
|
|
15902
15872
|
* `src` should be a relative path, as in `'assets/image.png'`, or a URL, as
|
|
@@ -16154,6 +16124,42 @@ function keyPressed(event?: KeyboardEvent): void;
|
|
|
16154
16124
|
*/
|
|
16155
16125
|
function green(color: P5.Color | number[] | string): number;
|
|
16156
16126
|
|
|
16127
|
+
/**
|
|
16128
|
+
* Draws a box (rectangular prism).
|
|
16129
|
+
*
|
|
16130
|
+
* A box is a 3D shape with six faces. Each face makes a 90˚ with four
|
|
16131
|
+
* neighboring faces.
|
|
16132
|
+
*
|
|
16133
|
+
* The first parameter, `width`, is optional. If a `Number` is passed, as in
|
|
16134
|
+
* `box(20)`, it sets the box’s width and height. By default, `width` is 50.
|
|
16135
|
+
*
|
|
16136
|
+
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
16137
|
+
* as in `box(20, 30)`, it sets the box’s height. By default, `height` is set
|
|
16138
|
+
* to the box’s `width`.
|
|
16139
|
+
*
|
|
16140
|
+
* The third parameter, `depth`, is also optional. If a `Number` is passed, as
|
|
16141
|
+
* in `box(20, 30, 40)`, it sets the box’s depth. By default, `depth` is set
|
|
16142
|
+
* to the box’s `height`.
|
|
16143
|
+
*
|
|
16144
|
+
* The fourth parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
16145
|
+
* as in `box(20, 30, 40, 5)`, it sets the number of triangle subdivisions to
|
|
16146
|
+
* use along the x-axis. All 3D shapes are made by connecting triangles to
|
|
16147
|
+
* form their surfaces. By default, `detailX` is 1.
|
|
16148
|
+
*
|
|
16149
|
+
* The fifth parameter, `detailY`, is also optional. If a number is passed, as
|
|
16150
|
+
* in `box(20, 30, 40, 5, 7)`, it sets the number of triangle subdivisions to
|
|
16151
|
+
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
16152
|
+
* form their surfaces. By default, `detailY` is 1.
|
|
16153
|
+
*
|
|
16154
|
+
* Note: `box()` can only be used in WebGL mode.
|
|
16155
|
+
* @param width width of the box.
|
|
16156
|
+
* @param height height of the box.
|
|
16157
|
+
* @param depth depth of the box.
|
|
16158
|
+
* @param detailX number of triangle subdivisions along the x-axis.
|
|
16159
|
+
* @param detailY number of triangle subdivisions along the y-axis.
|
|
16160
|
+
*/
|
|
16161
|
+
function box(width?: number, height?: number, depth?: number, detailX?: number, detailY?: number): void;
|
|
16162
|
+
|
|
16157
16163
|
/**
|
|
16158
16164
|
* Returns the largest value in a sequence of numbers.
|
|
16159
16165
|
*
|
|
@@ -16204,7 +16210,7 @@ function bezierVertex(x: number, y: number, u?: number, v?: number): void;
|
|
|
16204
16210
|
function bezierVertex(x: number, y: number, z: number, u?: number, v?: number): void;
|
|
16205
16211
|
|
|
16206
16212
|
/**
|
|
16207
|
-
* Creates an
|
|
16213
|
+
* Creates an `<a></a>` element that links to another web page.
|
|
16208
16214
|
*
|
|
16209
16215
|
* The first parmeter, `href`, is a string that sets the URL of the linked
|
|
16210
16216
|
* page.
|
|
@@ -16361,42 +16367,6 @@ function draw(): void;
|
|
|
16361
16367
|
function clear(r?: number, g?: number, b?: number, a?: number): void;
|
|
16362
16368
|
function clear(): void;
|
|
16363
16369
|
|
|
16364
|
-
/**
|
|
16365
|
-
* Draws a box (rectangular prism).
|
|
16366
|
-
*
|
|
16367
|
-
* A box is a 3D shape with six faces. Each face makes a 90˚ with four
|
|
16368
|
-
* neighboring faces.
|
|
16369
|
-
*
|
|
16370
|
-
* The first parameter, `width`, is optional. If a `Number` is passed, as in
|
|
16371
|
-
* `box(20)`, it sets the box’s width and height. By default, `width` is 50.
|
|
16372
|
-
*
|
|
16373
|
-
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
16374
|
-
* as in `box(20, 30)`, it sets the box’s height. By default, `height` is set
|
|
16375
|
-
* to the box’s `width`.
|
|
16376
|
-
*
|
|
16377
|
-
* The third parameter, `depth`, is also optional. If a `Number` is passed, as
|
|
16378
|
-
* in `box(20, 30, 40)`, it sets the box’s depth. By default, `depth` is set
|
|
16379
|
-
* to the box’s `height`.
|
|
16380
|
-
*
|
|
16381
|
-
* The fourth parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
16382
|
-
* as in `box(20, 30, 40, 5)`, it sets the number of triangle subdivisions to
|
|
16383
|
-
* use along the x-axis. All 3D shapes are made by connecting triangles to
|
|
16384
|
-
* form their surfaces. By default, `detailX` is 1.
|
|
16385
|
-
*
|
|
16386
|
-
* The fifth parameter, `detailY`, is also optional. If a number is passed, as
|
|
16387
|
-
* in `box(20, 30, 40, 5, 7)`, it sets the number of triangle subdivisions to
|
|
16388
|
-
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
16389
|
-
* form their surfaces. By default, `detailY` is 1.
|
|
16390
|
-
*
|
|
16391
|
-
* Note: `box()` can only be used in WebGL mode.
|
|
16392
|
-
* @param width width of the box.
|
|
16393
|
-
* @param height height of the box.
|
|
16394
|
-
* @param depth depth of the box.
|
|
16395
|
-
* @param detailX number of triangle subdivisions along the x-axis.
|
|
16396
|
-
* @param detailY number of triangle subdivisions along the y-axis.
|
|
16397
|
-
*/
|
|
16398
|
-
function box(width?: number, height?: number, depth?: number, detailX?: number, detailY?: number): void;
|
|
16399
|
-
|
|
16400
16370
|
/**
|
|
16401
16371
|
* Converts a `Number` or `String` to a single-character `String`.
|
|
16402
16372
|
*
|
|
@@ -16541,7 +16511,7 @@ function spline(x1: number, y1: number, z1: number, x2: number, y2: number, z2:
|
|
|
16541
16511
|
* (<a href="https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction" target="_blank">XML</a>)
|
|
16542
16512
|
* is a standard format for sending data between applications. Like HTML, the
|
|
16543
16513
|
* XML format is based on tags and attributes, as in
|
|
16544
|
-
*
|
|
16514
|
+
* `<time units="s">1234</time>`.
|
|
16545
16515
|
*
|
|
16546
16516
|
* The first parameter, `path`, is always a string with the path to the file.
|
|
16547
16517
|
* Paths to local files should be relative, as in
|
|
@@ -16702,13 +16672,40 @@ function unchar(ns: string[]): number[];
|
|
|
16702
16672
|
* Calling `angleMode(DEGREES)` switches to degrees. Calling
|
|
16703
16673
|
* `angleMode(RADIANS)` switches back to radians.
|
|
16704
16674
|
*
|
|
16705
|
-
* Calling `angleMode()` with no arguments returns current angle mode, which
|
|
16706
|
-
* is either `RADIANS` or `DEGREES`.
|
|
16707
|
-
* @param mode either RADIANS or DEGREES.
|
|
16708
|
-
* @returns mode either RADIANS or DEGREES
|
|
16675
|
+
* Calling `angleMode()` with no arguments returns current angle mode, which
|
|
16676
|
+
* is either `RADIANS` or `DEGREES`.
|
|
16677
|
+
* @param mode either RADIANS or DEGREES.
|
|
16678
|
+
* @returns mode either RADIANS or DEGREES
|
|
16679
|
+
*/
|
|
16680
|
+
function angleMode(mode: typeof P5.RADIANS | typeof P5.DEGREES): typeof P5.RADIANS | typeof P5.DEGREES;
|
|
16681
|
+
function angleMode(): typeof P5.RADIANS | typeof P5.DEGREES;
|
|
16682
|
+
|
|
16683
|
+
/**
|
|
16684
|
+
* Draws a sphere.
|
|
16685
|
+
*
|
|
16686
|
+
* A sphere is a 3D shape with triangular faces that connect to form a round
|
|
16687
|
+
* surface. Spheres with few faces look like crystals. Spheres with many faces
|
|
16688
|
+
* have smooth surfaces and look like balls.
|
|
16689
|
+
*
|
|
16690
|
+
* The first parameter, `radius`, is optional. If a `Number` is passed, as in
|
|
16691
|
+
* `sphere(20)`, it sets the radius of the sphere. By default, `radius` is 50.
|
|
16692
|
+
*
|
|
16693
|
+
* The second parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
16694
|
+
* as in `sphere(20, 5)`, it sets the number of triangle subdivisions to use
|
|
16695
|
+
* along the x-axis. All 3D shapes are made by connecting triangles to form
|
|
16696
|
+
* their surfaces. By default, `detailX` is 24.
|
|
16697
|
+
*
|
|
16698
|
+
* The third parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
16699
|
+
* as in `sphere(20, 5, 2)`, it sets the number of triangle subdivisions to
|
|
16700
|
+
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
16701
|
+
* form their surfaces. By default, `detailY` is 16.
|
|
16702
|
+
*
|
|
16703
|
+
* Note: `sphere()` can only be used in WebGL mode.
|
|
16704
|
+
* @param radius radius of the sphere. Defaults to 50.
|
|
16705
|
+
* @param detailX number of triangle subdivisions along the x-axis. Defaults to 24.
|
|
16706
|
+
* @param detailY number of triangle subdivisions along the y-axis. Defaults to 16.
|
|
16709
16707
|
*/
|
|
16710
|
-
function
|
|
16711
|
-
function angleMode(): typeof P5.RADIANS | typeof P5.DEGREES;
|
|
16708
|
+
function sphere(radius?: number, detailX?: number, detailY?: number): void;
|
|
16712
16709
|
|
|
16713
16710
|
/**
|
|
16714
16711
|
* Loads the current value of each pixel on the canvas into the
|
|
@@ -16719,17 +16716,6 @@ function angleMode(): typeof P5.RADIANS | typeof P5.DEGREES;
|
|
|
16719
16716
|
*/
|
|
16720
16717
|
function loadPixels(): void;
|
|
16721
16718
|
|
|
16722
|
-
/**
|
|
16723
|
-
* This method is suitable for fetching files up to size of 64MB.
|
|
16724
|
-
* @param file name of the file or URL to load
|
|
16725
|
-
* @param callback function to be executed after <a href="#/p5/loadBytes">loadBytes()</a>
|
|
16726
|
-
* completes
|
|
16727
|
-
* @param errorCallback function to be executed if there
|
|
16728
|
-
* is an error
|
|
16729
|
-
* @returns a Uint8Array containing the loaded buffer
|
|
16730
|
-
*/
|
|
16731
|
-
function loadBytes(file: string | Request, callback?: Function, errorCallback?: Function): Promise<Uint8Array>;
|
|
16732
|
-
|
|
16733
16719
|
/**
|
|
16734
16720
|
* Creates a <a href="#/p5.Shader">p5.Shader</a> object to be used with the
|
|
16735
16721
|
* <a href="#/p5/filter">filter()</a> function.
|
|
@@ -16826,7 +16812,7 @@ function loadBytes(file: string | Request, callback?: Function, errorCallback?:
|
|
|
16826
16812
|
* filterColor.texCoord.x // x coordinate, from 0 to 1
|
|
16827
16813
|
* ));
|
|
16828
16814
|
* filterColor.end();
|
|
16829
|
-
* }`You can also animate your filters over time
|
|
16815
|
+
* }`You can also animate your filters over time using the `millis()` function.
|
|
16830
16816
|
*
|
|
16831
16817
|
* `let myFilter;
|
|
16832
16818
|
* function setup() {
|
|
@@ -16836,7 +16822,7 @@ function loadBytes(file: string | Request, callback?: Function, errorCallback?:
|
|
|
16836
16822
|
* }
|
|
16837
16823
|
*
|
|
16838
16824
|
* function gradient() {
|
|
16839
|
-
* let time =
|
|
16825
|
+
* let time = millis();
|
|
16840
16826
|
* filterColor.begin();
|
|
16841
16827
|
* filterColor.set(mix(
|
|
16842
16828
|
* [1, 0, 0, 1], // Red
|
|
@@ -16847,9 +16833,8 @@ function loadBytes(file: string | Request, callback?: Function, errorCallback?:
|
|
|
16847
16833
|
* }
|
|
16848
16834
|
*
|
|
16849
16835
|
* function draw() {
|
|
16850
|
-
* myFilter.setUniform('time', millis());
|
|
16851
16836
|
* filter(myFilter);
|
|
16852
|
-
* }`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
|
|
16837
|
+
* }`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.
|
|
16853
16838
|
*
|
|
16854
16839
|
* `let myFilter;
|
|
16855
16840
|
*
|
|
@@ -16860,7 +16845,7 @@ function loadBytes(file: string | Request, callback?: Function, errorCallback?:
|
|
|
16860
16845
|
* }
|
|
16861
16846
|
*
|
|
16862
16847
|
* function noiseShaderCallback() {
|
|
16863
|
-
* let time =
|
|
16848
|
+
* let time = millis();
|
|
16864
16849
|
* filterColor.begin();
|
|
16865
16850
|
* let coord = filterColor.texCoord;
|
|
16866
16851
|
*
|
|
@@ -16877,7 +16862,6 @@ function loadBytes(file: string | Request, callback?: Function, errorCallback?:
|
|
|
16877
16862
|
* }
|
|
16878
16863
|
*
|
|
16879
16864
|
* function draw() {
|
|
16880
|
-
* myFilter.setUniform("time", millis());
|
|
16881
16865
|
* filter(myFilter);
|
|
16882
16866
|
* }`Like the `modify()` method on shaders,
|
|
16883
16867
|
* advanced users can also fill in `filterColor` using <a href="https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders" target="_blank">GLSL</a>
|
|
@@ -16896,7 +16880,18 @@ function buildFilterShader(callback: Function, scope?: object): P5.Shader;
|
|
|
16896
16880
|
function buildFilterShader(hooks: object, scope?: object): P5.Shader;
|
|
16897
16881
|
|
|
16898
16882
|
/**
|
|
16899
|
-
*
|
|
16883
|
+
* This method is suitable for fetching files up to size of 64MB.
|
|
16884
|
+
* @param file name of the file or URL to load
|
|
16885
|
+
* @param callback function to be executed after <a href="#/p5/loadBytes">loadBytes()</a>
|
|
16886
|
+
* completes
|
|
16887
|
+
* @param errorCallback function to be executed if there
|
|
16888
|
+
* is an error
|
|
16889
|
+
* @returns a Uint8Array containing the loaded buffer
|
|
16890
|
+
*/
|
|
16891
|
+
function loadBytes(file: string | Request, callback?: Function, errorCallback?: Function): Promise<Uint8Array>;
|
|
16892
|
+
|
|
16893
|
+
/**
|
|
16894
|
+
* Creates a slider `<input></input>` element.
|
|
16900
16895
|
*
|
|
16901
16896
|
* Range sliders are useful for quickly selecting numbers from a given range.
|
|
16902
16897
|
*
|
|
@@ -16933,33 +16928,6 @@ function createSlider(min: number, max: number, value?: number, step?: number):
|
|
|
16933
16928
|
*/
|
|
16934
16929
|
function norm(value: number, start: number, stop: number): number;
|
|
16935
16930
|
|
|
16936
|
-
/**
|
|
16937
|
-
* Draws a sphere.
|
|
16938
|
-
*
|
|
16939
|
-
* A sphere is a 3D shape with triangular faces that connect to form a round
|
|
16940
|
-
* surface. Spheres with few faces look like crystals. Spheres with many faces
|
|
16941
|
-
* have smooth surfaces and look like balls.
|
|
16942
|
-
*
|
|
16943
|
-
* The first parameter, `radius`, is optional. If a `Number` is passed, as in
|
|
16944
|
-
* `sphere(20)`, it sets the radius of the sphere. By default, `radius` is 50.
|
|
16945
|
-
*
|
|
16946
|
-
* The second parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
16947
|
-
* as in `sphere(20, 5)`, it sets the number of triangle subdivisions to use
|
|
16948
|
-
* along the x-axis. All 3D shapes are made by connecting triangles to form
|
|
16949
|
-
* their surfaces. By default, `detailX` is 24.
|
|
16950
|
-
*
|
|
16951
|
-
* The third parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
16952
|
-
* as in `sphere(20, 5, 2)`, it sets the number of triangle subdivisions to
|
|
16953
|
-
* use along the y-axis. All 3D shapes are made by connecting triangles to
|
|
16954
|
-
* form their surfaces. By default, `detailY` is 16.
|
|
16955
|
-
*
|
|
16956
|
-
* Note: `sphere()` can only be used in WebGL mode.
|
|
16957
|
-
* @param radius radius of the sphere. Defaults to 50.
|
|
16958
|
-
* @param detailX number of triangle subdivisions along the x-axis. Defaults to 24.
|
|
16959
|
-
* @param detailY number of triangle subdivisions along the y-axis. Defaults to 16.
|
|
16960
|
-
*/
|
|
16961
|
-
function sphere(radius?: number, detailX?: number, detailY?: number): void;
|
|
16962
|
-
|
|
16963
16931
|
/**
|
|
16964
16932
|
* A function that's called once when any key is released.
|
|
16965
16933
|
*
|
|
@@ -17150,7 +17118,7 @@ function point(coordinateVector: P5.Vector): void;
|
|
|
17150
17118
|
function alpha(color: P5.Color | number[] | string): number;
|
|
17151
17119
|
|
|
17152
17120
|
/**
|
|
17153
|
-
* Creates a
|
|
17121
|
+
* Creates a `<button></button>` element.
|
|
17154
17122
|
*
|
|
17155
17123
|
* The first parameter, `label`, is a string that sets the label displayed on
|
|
17156
17124
|
* the button.
|
|
@@ -17441,7 +17409,7 @@ function displayDensity(): number;
|
|
|
17441
17409
|
function panorama(img: P5.Image): void;
|
|
17442
17410
|
|
|
17443
17411
|
/**
|
|
17444
|
-
* Creates a checkbox
|
|
17412
|
+
* Creates a checkbox `<input></input>` element.
|
|
17445
17413
|
*
|
|
17446
17414
|
* Checkboxes extend the <a href="#/p5.Element">p5.Element</a> class with a
|
|
17447
17415
|
* `checked()` method. Calling `myBox.checked()` returns `true` if it the box
|
|
@@ -17517,6 +17485,50 @@ function keyTyped(event?: KeyboardEvent): void;
|
|
|
17517
17485
|
*/
|
|
17518
17486
|
function hue(color: P5.Color | number[] | string): number;
|
|
17519
17487
|
|
|
17488
|
+
/**
|
|
17489
|
+
* Draws a cylinder.
|
|
17490
|
+
*
|
|
17491
|
+
* A cylinder is a 3D shape with triangular faces that connect a flat bottom
|
|
17492
|
+
* to a flat top. Cylinders with few faces look like boxes. Cylinders with
|
|
17493
|
+
* many faces have smooth surfaces.
|
|
17494
|
+
*
|
|
17495
|
+
* The first parameter, `radius`, is optional. If a `Number` is passed, as in
|
|
17496
|
+
* `cylinder(20)`, it sets the radius of the cylinder’s base. By default,
|
|
17497
|
+
* `radius` is 50.
|
|
17498
|
+
*
|
|
17499
|
+
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
17500
|
+
* as in `cylinder(20, 30)`, it sets the cylinder’s height. By default,
|
|
17501
|
+
* `height` is set to the cylinder’s `radius`.
|
|
17502
|
+
*
|
|
17503
|
+
* The third parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
17504
|
+
* as in `cylinder(20, 30, 5)`, it sets the number of edges used to form the
|
|
17505
|
+
* cylinder's top and bottom. Using more edges makes the top and bottom look
|
|
17506
|
+
* more like circles. By default, `detailX` is 24.
|
|
17507
|
+
*
|
|
17508
|
+
* The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
17509
|
+
* as in `cylinder(20, 30, 5, 2)`, it sets the number of triangle subdivisions
|
|
17510
|
+
* to use along the y-axis, between cylinder's the top and bottom. All 3D
|
|
17511
|
+
* shapes are made by connecting triangles to form their surfaces. By default,
|
|
17512
|
+
* `detailY` is 1.
|
|
17513
|
+
*
|
|
17514
|
+
* The fifth parameter, `bottomCap`, is also optional. If a `false` is passed,
|
|
17515
|
+
* as in `cylinder(20, 30, 5, 2, false)` the cylinder’s bottom won’t be drawn.
|
|
17516
|
+
* By default, `bottomCap` is `true`.
|
|
17517
|
+
*
|
|
17518
|
+
* The sixth parameter, `topCap`, is also optional. If a `false` is passed, as
|
|
17519
|
+
* in `cylinder(20, 30, 5, 2, false, false)` the cylinder’s top won’t be
|
|
17520
|
+
* drawn. By default, `topCap` is `true`.
|
|
17521
|
+
*
|
|
17522
|
+
* Note: `cylinder()` can only be used in WebGL mode.
|
|
17523
|
+
* @param radius radius of the cylinder. Defaults to 50.
|
|
17524
|
+
* @param height height of the cylinder. Defaults to the value of `radius`.
|
|
17525
|
+
* @param detailX number of edges along the top and bottom. Defaults to 24.
|
|
17526
|
+
* @param detailY number of triangle subdivisions along the y-axis. Defaults to 1.
|
|
17527
|
+
* @param bottomCap whether to draw the cylinder's bottom. Defaults to `true`.
|
|
17528
|
+
* @param topCap whether to draw the cylinder's top. Defaults to `true`.
|
|
17529
|
+
*/
|
|
17530
|
+
function cylinder(radius?: number, height?: number, detailX?: number, detailY?: number, bottomCap?: boolean, topCap?: boolean): void;
|
|
17531
|
+
|
|
17520
17532
|
/**
|
|
17521
17533
|
* Scales the coordinate system.
|
|
17522
17534
|
*
|
|
@@ -17636,50 +17648,6 @@ function httpPost(path: string | Request, data?: object | boolean, datatype?: st
|
|
|
17636
17648
|
function httpPost(path: string | Request, data: object | boolean, callback?: Function, errorCallback?: Function): Promise<any>;
|
|
17637
17649
|
function httpPost(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
|
|
17638
17650
|
|
|
17639
|
-
/**
|
|
17640
|
-
* Draws a cylinder.
|
|
17641
|
-
*
|
|
17642
|
-
* A cylinder is a 3D shape with triangular faces that connect a flat bottom
|
|
17643
|
-
* to a flat top. Cylinders with few faces look like boxes. Cylinders with
|
|
17644
|
-
* many faces have smooth surfaces.
|
|
17645
|
-
*
|
|
17646
|
-
* The first parameter, `radius`, is optional. If a `Number` is passed, as in
|
|
17647
|
-
* `cylinder(20)`, it sets the radius of the cylinder’s base. By default,
|
|
17648
|
-
* `radius` is 50.
|
|
17649
|
-
*
|
|
17650
|
-
* The second parameter, `height`, is also optional. If a `Number` is passed,
|
|
17651
|
-
* as in `cylinder(20, 30)`, it sets the cylinder’s height. By default,
|
|
17652
|
-
* `height` is set to the cylinder’s `radius`.
|
|
17653
|
-
*
|
|
17654
|
-
* The third parameter, `detailX`, is also optional. If a `Number` is passed,
|
|
17655
|
-
* as in `cylinder(20, 30, 5)`, it sets the number of edges used to form the
|
|
17656
|
-
* cylinder's top and bottom. Using more edges makes the top and bottom look
|
|
17657
|
-
* more like circles. By default, `detailX` is 24.
|
|
17658
|
-
*
|
|
17659
|
-
* The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
|
|
17660
|
-
* as in `cylinder(20, 30, 5, 2)`, it sets the number of triangle subdivisions
|
|
17661
|
-
* to use along the y-axis, between cylinder's the top and bottom. All 3D
|
|
17662
|
-
* shapes are made by connecting triangles to form their surfaces. By default,
|
|
17663
|
-
* `detailY` is 1.
|
|
17664
|
-
*
|
|
17665
|
-
* The fifth parameter, `bottomCap`, is also optional. If a `false` is passed,
|
|
17666
|
-
* as in `cylinder(20, 30, 5, 2, false)` the cylinder’s bottom won’t be drawn.
|
|
17667
|
-
* By default, `bottomCap` is `true`.
|
|
17668
|
-
*
|
|
17669
|
-
* The sixth parameter, `topCap`, is also optional. If a `false` is passed, as
|
|
17670
|
-
* in `cylinder(20, 30, 5, 2, false, false)` the cylinder’s top won’t be
|
|
17671
|
-
* drawn. By default, `topCap` is `true`.
|
|
17672
|
-
*
|
|
17673
|
-
* Note: `cylinder()` can only be used in WebGL mode.
|
|
17674
|
-
* @param radius radius of the cylinder. Defaults to 50.
|
|
17675
|
-
* @param height height of the cylinder. Defaults to the value of `radius`.
|
|
17676
|
-
* @param detailX number of edges along the top and bottom. Defaults to 24.
|
|
17677
|
-
* @param detailY number of triangle subdivisions along the y-axis. Defaults to 1.
|
|
17678
|
-
* @param bottomCap whether to draw the cylinder's bottom. Defaults to `true`.
|
|
17679
|
-
* @param topCap whether to draw the cylinder's top. Defaults to `true`.
|
|
17680
|
-
*/
|
|
17681
|
-
function cylinder(radius?: number, height?: number, detailX?: number, detailY?: number, bottomCap?: boolean, topCap?: boolean): void;
|
|
17682
|
-
|
|
17683
17651
|
/**
|
|
17684
17652
|
* Returns the sketch's current
|
|
17685
17653
|
* <a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL" target="_blank">URL</a>
|
|
@@ -17969,147 +17937,49 @@ function getURLParams(): object;
|
|
|
17969
17937
|
/**
|
|
17970
17938
|
* Shears the x-axis so that shapes appear skewed.
|
|
17971
17939
|
*
|
|
17972
|
-
* By default, the x- and y-axes are perpendicular. The `shearX()` function
|
|
17973
|
-
* transforms the coordinate system so that x-coordinates are translated while
|
|
17974
|
-
* y-coordinates are fixed.
|
|
17975
|
-
*
|
|
17976
|
-
* The first parameter, `angle`, is the amount to shear. For example, calling
|
|
17977
|
-
* `shearX(1)` transforms all x-coordinates using the formula
|
|
17978
|
-
* `x = x + y * tan(angle)`. `shearX()` interprets angle values using the
|
|
17979
|
-
* current <a href="#/p5/angleMode">angleMode()</a>.
|
|
17980
|
-
*
|
|
17981
|
-
* By default, transformations accumulate. For example, calling
|
|
17982
|
-
* `shearX(1)` twice has the same effect as calling `shearX(2)` once. The
|
|
17983
|
-
* <a href="#/p5/push">push()</a> and
|
|
17984
|
-
* <a href="#/p5/pop">pop()</a> functions can be used to isolate
|
|
17985
|
-
* transformations within distinct drawing groups.
|
|
17986
|
-
*
|
|
17987
|
-
* Note: Transformations are reset at the beginning of the draw loop. Calling
|
|
17988
|
-
* `shearX(1)` inside the <a href="#/p5/draw">draw()</a> function won't
|
|
17989
|
-
* cause shapes to shear continuously.
|
|
17990
|
-
* @param angle angle to shear by in the current <a href="#/p5/angleMode">angleMode()</a>.
|
|
17991
|
-
*/
|
|
17992
|
-
function shearX(angle: number): void;
|
|
17993
|
-
|
|
17994
|
-
/**
|
|
17995
|
-
* Sets the falloff rate for <a href="#/p5/pointLight">pointLight()</a>
|
|
17996
|
-
* and <a href="#/p5/spotLight">spotLight()</a>.
|
|
17997
|
-
*
|
|
17998
|
-
* A light’s falloff describes the intensity of its beam at a distance. For
|
|
17999
|
-
* example, a lantern has a slow falloff, a flashlight has a medium falloff,
|
|
18000
|
-
* and a laser pointer has a sharp falloff.
|
|
18001
|
-
*
|
|
18002
|
-
* `lightFalloff()` has three parameters, `constant`, `linear`, and
|
|
18003
|
-
* `quadratic`. They’re numbers used to calculate falloff at a distance, `d`,
|
|
18004
|
-
* as follows:
|
|
18005
|
-
*
|
|
18006
|
-
* `falloff = 1 / (constant + d * linear + (d * d) * quadratic)`
|
|
18007
|
-
*
|
|
18008
|
-
* Note: `constant`, `linear`, and `quadratic` should always be set to values
|
|
18009
|
-
* greater than 0.
|
|
18010
|
-
* @param constant constant value for calculating falloff.
|
|
18011
|
-
* @param linear linear value for calculating falloff.
|
|
18012
|
-
* @param quadratic quadratic value for calculating falloff.
|
|
18013
|
-
*/
|
|
18014
|
-
function lightFalloff(constant: number, linear: number, quadratic: number): void;
|
|
18015
|
-
|
|
18016
|
-
/**
|
|
18017
|
-
* A function that's called when the mouse moves.
|
|
18018
|
-
*
|
|
18019
|
-
* Declaring the function `mouseMoved()` sets a code block to run
|
|
18020
|
-
* automatically when the user moves the mouse without clicking any mouse
|
|
18021
|
-
* buttons:
|
|
18022
|
-
*
|
|
18023
|
-
* `function mouseMoved() {
|
|
18024
|
-
* // Code to run.
|
|
18025
|
-
* }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
|
|
18026
|
-
* <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
|
|
18027
|
-
* value when `mouseMoved()` is called by p5.js:
|
|
18028
|
-
*
|
|
18029
|
-
* `function mouseMoved() {
|
|
18030
|
-
* if (mouseX < 50) {
|
|
18031
|
-
* // Code to run if the mouse is on the left.
|
|
18032
|
-
* }
|
|
18033
|
-
*
|
|
18034
|
-
* if (mouseY > 50) {
|
|
18035
|
-
* // Code to run if the mouse is near the bottom.
|
|
18036
|
-
* }
|
|
18037
|
-
* }`The parameter, `event`, is optional. `mouseMoved()` is always passed a
|
|
18038
|
-
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
|
|
18039
|
-
* object with properties that describe the mouse move event:
|
|
18040
|
-
*
|
|
18041
|
-
* `function mouseMoved(event) {
|
|
18042
|
-
* // Code to run that uses the event.
|
|
18043
|
-
* console.log(event);
|
|
18044
|
-
* }`Browsers may have default behaviors attached to various mouse events. For
|
|
18045
|
-
* example, some browsers highlight text when the user moves the mouse while
|
|
18046
|
-
* pressing a mouse button. To prevent any default behavior for this event,
|
|
18047
|
-
* add `return false;` to the end of the function.
|
|
18048
|
-
* @param event optional `MouseEvent` argument.
|
|
18049
|
-
*/
|
|
18050
|
-
function mouseMoved(event?: MouseEvent): void;
|
|
18051
|
-
|
|
18052
|
-
/**
|
|
18053
|
-
* A function that's called when the mouse moves while a button is pressed.
|
|
18054
|
-
*
|
|
18055
|
-
* Declaring the function `mouseDragged()` sets a code block to run
|
|
18056
|
-
* automatically when the user clicks and drags the mouse:
|
|
18057
|
-
*
|
|
18058
|
-
* `function mouseDragged() {
|
|
18059
|
-
* // Code to run.
|
|
18060
|
-
* }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
|
|
18061
|
-
* <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
|
|
18062
|
-
* value when `mouseDragged()` is called by p5.js:
|
|
18063
|
-
*
|
|
18064
|
-
* `function mouseDragged() {
|
|
18065
|
-
* if (mouseX < 50) {
|
|
18066
|
-
* // Code to run if the mouse is on the left.
|
|
18067
|
-
* }
|
|
18068
|
-
*
|
|
18069
|
-
* if (mouseY > 50) {
|
|
18070
|
-
* // Code to run if the mouse is near the bottom.
|
|
18071
|
-
* }
|
|
18072
|
-
* }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
|
|
18073
|
-
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
|
|
18074
|
-
* object with properties that describe the mouse drag event:
|
|
17940
|
+
* By default, the x- and y-axes are perpendicular. The `shearX()` function
|
|
17941
|
+
* transforms the coordinate system so that x-coordinates are translated while
|
|
17942
|
+
* y-coordinates are fixed.
|
|
18075
17943
|
*
|
|
18076
|
-
* `
|
|
18077
|
-
*
|
|
18078
|
-
*
|
|
18079
|
-
*
|
|
18080
|
-
* point.
|
|
17944
|
+
* The first parameter, `angle`, is the amount to shear. For example, calling
|
|
17945
|
+
* `shearX(1)` transforms all x-coordinates using the formula
|
|
17946
|
+
* `x = x + y * tan(angle)`. `shearX()` interprets angle values using the
|
|
17947
|
+
* current <a href="#/p5/angleMode">angleMode()</a>.
|
|
18081
17948
|
*
|
|
18082
|
-
*
|
|
18083
|
-
*
|
|
18084
|
-
*
|
|
18085
|
-
*
|
|
18086
|
-
*
|
|
17949
|
+
* By default, transformations accumulate. For example, calling
|
|
17950
|
+
* `shearX(1)` twice has the same effect as calling `shearX(2)` once. The
|
|
17951
|
+
* <a href="#/p5/push">push()</a> and
|
|
17952
|
+
* <a href="#/p5/pop">pop()</a> functions can be used to isolate
|
|
17953
|
+
* transformations within distinct drawing groups.
|
|
17954
|
+
*
|
|
17955
|
+
* Note: Transformations are reset at the beginning of the draw loop. Calling
|
|
17956
|
+
* `shearX(1)` inside the <a href="#/p5/draw">draw()</a> function won't
|
|
17957
|
+
* cause shapes to shear continuously.
|
|
17958
|
+
* @param angle angle to shear by in the current <a href="#/p5/angleMode">angleMode()</a>.
|
|
18087
17959
|
*/
|
|
18088
|
-
function
|
|
17960
|
+
function shearX(angle: number): void;
|
|
18089
17961
|
|
|
18090
17962
|
/**
|
|
18091
|
-
*
|
|
17963
|
+
* Sets the falloff rate for <a href="#/p5/pointLight">pointLight()</a>
|
|
17964
|
+
* and <a href="#/p5/spotLight">spotLight()</a>.
|
|
18092
17965
|
*
|
|
18093
|
-
*
|
|
18094
|
-
*
|
|
18095
|
-
*
|
|
17966
|
+
* A light’s falloff describes the intensity of its beam at a distance. For
|
|
17967
|
+
* example, a lantern has a slow falloff, a flashlight has a medium falloff,
|
|
17968
|
+
* and a laser pointer has a sharp falloff.
|
|
18096
17969
|
*
|
|
18097
|
-
* `
|
|
18098
|
-
*
|
|
18099
|
-
*
|
|
18100
|
-
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
|
|
18101
|
-
* or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
|
|
18102
|
-
* such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
|
|
17970
|
+
* `lightFalloff()` has three parameters, `constant`, `linear`, and
|
|
17971
|
+
* `quadratic`. They’re numbers used to calculate falloff at a distance, `d`,
|
|
17972
|
+
* as follows:
|
|
18103
17973
|
*
|
|
18104
|
-
*
|
|
18105
|
-
* This is a breaking change from previous versions.
|
|
17974
|
+
* `falloff = 1 / (constant + d * linear + (d * d) * quadratic)`
|
|
18106
17975
|
*
|
|
18107
|
-
*
|
|
18108
|
-
*
|
|
18109
|
-
* @param
|
|
18110
|
-
* @
|
|
17976
|
+
* Note: `constant`, `linear`, and `quadratic` should always be set to values
|
|
17977
|
+
* greater than 0.
|
|
17978
|
+
* @param constant constant value for calculating falloff.
|
|
17979
|
+
* @param linear linear value for calculating falloff.
|
|
17980
|
+
* @param quadratic quadratic value for calculating falloff.
|
|
18111
17981
|
*/
|
|
18112
|
-
function
|
|
17982
|
+
function lightFalloff(constant: number, linear: number, quadratic: number): void;
|
|
18113
17983
|
|
|
18114
17984
|
/**
|
|
18115
17985
|
* Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply while drawing.
|
|
@@ -18150,7 +18020,7 @@ function keyIsDown(code: number | string): boolean;
|
|
|
18150
18020
|
* }
|
|
18151
18021
|
*
|
|
18152
18022
|
* function material() {
|
|
18153
|
-
* let time =
|
|
18023
|
+
* let time = millis() / 1000;
|
|
18154
18024
|
* finalColor.begin();
|
|
18155
18025
|
* let r = 0.2 + 0.5 * abs(sin(time + 0));
|
|
18156
18026
|
* let g = 0.2 + 0.5 * abs(sin(time + 1));
|
|
@@ -18161,7 +18031,6 @@ function keyIsDown(code: number | string): boolean;
|
|
|
18161
18031
|
*
|
|
18162
18032
|
* function draw() {
|
|
18163
18033
|
* background(245, 245, 220);
|
|
18164
|
-
* myShader.setUniform('time', millis() / 1000);
|
|
18165
18034
|
* shader(myShader);
|
|
18166
18035
|
*
|
|
18167
18036
|
* rectMode(CENTER);
|
|
@@ -18274,11 +18143,109 @@ function keyIsDown(code: number | string): boolean;
|
|
|
18274
18143
|
*/
|
|
18275
18144
|
function shader(s: P5.Shader): void;
|
|
18276
18145
|
|
|
18146
|
+
/**
|
|
18147
|
+
* A function that's called when the mouse moves.
|
|
18148
|
+
*
|
|
18149
|
+
* Declaring the function `mouseMoved()` sets a code block to run
|
|
18150
|
+
* automatically when the user moves the mouse without clicking any mouse
|
|
18151
|
+
* buttons:
|
|
18152
|
+
*
|
|
18153
|
+
* `function mouseMoved() {
|
|
18154
|
+
* // Code to run.
|
|
18155
|
+
* }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
|
|
18156
|
+
* <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
|
|
18157
|
+
* value when `mouseMoved()` is called by p5.js:
|
|
18158
|
+
*
|
|
18159
|
+
* `function mouseMoved() {
|
|
18160
|
+
* if (mouseX < 50) {
|
|
18161
|
+
* // Code to run if the mouse is on the left.
|
|
18162
|
+
* }
|
|
18163
|
+
*
|
|
18164
|
+
* if (mouseY > 50) {
|
|
18165
|
+
* // Code to run if the mouse is near the bottom.
|
|
18166
|
+
* }
|
|
18167
|
+
* }`The parameter, `event`, is optional. `mouseMoved()` is always passed a
|
|
18168
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
|
|
18169
|
+
* object with properties that describe the mouse move event:
|
|
18170
|
+
*
|
|
18171
|
+
* `function mouseMoved(event) {
|
|
18172
|
+
* // Code to run that uses the event.
|
|
18173
|
+
* console.log(event);
|
|
18174
|
+
* }`Browsers may have default behaviors attached to various mouse events. For
|
|
18175
|
+
* example, some browsers highlight text when the user moves the mouse while
|
|
18176
|
+
* pressing a mouse button. To prevent any default behavior for this event,
|
|
18177
|
+
* add `return false;` to the end of the function.
|
|
18178
|
+
* @param event optional `MouseEvent` argument.
|
|
18179
|
+
*/
|
|
18180
|
+
function mouseMoved(event?: MouseEvent): void;
|
|
18181
|
+
|
|
18182
|
+
/**
|
|
18183
|
+
* A function that's called when the mouse moves while a button is pressed.
|
|
18184
|
+
*
|
|
18185
|
+
* Declaring the function `mouseDragged()` sets a code block to run
|
|
18186
|
+
* automatically when the user clicks and drags the mouse:
|
|
18187
|
+
*
|
|
18188
|
+
* `function mouseDragged() {
|
|
18189
|
+
* // Code to run.
|
|
18190
|
+
* }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
|
|
18191
|
+
* <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
|
|
18192
|
+
* value when `mouseDragged()` is called by p5.js:
|
|
18193
|
+
*
|
|
18194
|
+
* `function mouseDragged() {
|
|
18195
|
+
* if (mouseX < 50) {
|
|
18196
|
+
* // Code to run if the mouse is on the left.
|
|
18197
|
+
* }
|
|
18198
|
+
*
|
|
18199
|
+
* if (mouseY > 50) {
|
|
18200
|
+
* // Code to run if the mouse is near the bottom.
|
|
18201
|
+
* }
|
|
18202
|
+
* }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
|
|
18203
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
|
|
18204
|
+
* object with properties that describe the mouse drag event:
|
|
18205
|
+
*
|
|
18206
|
+
* `function mouseDragged(event) {
|
|
18207
|
+
* // Code to run that uses the event.
|
|
18208
|
+
* console.log(event);
|
|
18209
|
+
* }`On touchscreen devices, `mouseDragged()` will run when a user moves a touch
|
|
18210
|
+
* point.
|
|
18211
|
+
*
|
|
18212
|
+
* Browsers may have default behaviors attached to various mouse events. For
|
|
18213
|
+
* example, some browsers highlight text when the user moves the mouse while
|
|
18214
|
+
* pressing a mouse button. To prevent any default behavior for this event,
|
|
18215
|
+
* add `return false;` to the end of the function.
|
|
18216
|
+
* @param event optional `MouseEvent` argument.
|
|
18217
|
+
*/
|
|
18218
|
+
function mouseDragged(event?: MouseEvent): void;
|
|
18219
|
+
|
|
18220
|
+
/**
|
|
18221
|
+
* Returns `true` if the key it’s checking is pressed and `false` if not.
|
|
18222
|
+
*
|
|
18223
|
+
* `keyIsDown()` is helpful when checking for multiple different key presses.
|
|
18224
|
+
* For example, `keyIsDown()` can be used to check if both `LEFT_ARROW` and
|
|
18225
|
+
* `UP_ARROW` are pressed:
|
|
18226
|
+
*
|
|
18227
|
+
* `if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
|
|
18228
|
+
* // Move diagonally.
|
|
18229
|
+
* }``keyIsDown()` can check for key presses using strings based on
|
|
18230
|
+
* <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
|
|
18231
|
+
* or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
|
|
18232
|
+
* such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
|
|
18233
|
+
*
|
|
18234
|
+
* Note: In p5.js 2.0 and newer, numeric keycodes (such as 88 for 'X') are no longer supported.
|
|
18235
|
+
* This is a breaking change from previous versions.
|
|
18236
|
+
*
|
|
18237
|
+
* You can still use the p5 constants like `LEFT_ARROW` which now map to string values
|
|
18238
|
+
* internally rather than numeric codes.
|
|
18239
|
+
* @param code key to check.
|
|
18240
|
+
* @returns whether the key is down or not.
|
|
18241
|
+
*/
|
|
18242
|
+
function keyIsDown(code: number | string): boolean;
|
|
18243
|
+
|
|
18277
18244
|
/**
|
|
18278
18245
|
* Sets the element's content.
|
|
18279
18246
|
*
|
|
18280
18247
|
* An element's content is the text between its tags. For example, the element
|
|
18281
|
-
*
|
|
18248
|
+
* `<language>JavaScript</language>` has the content `JavaScript`.
|
|
18282
18249
|
*
|
|
18283
18250
|
* The parameter, `content`, is a string with the element's new content.
|
|
18284
18251
|
* @param content new content for the element.
|
|
@@ -18291,9 +18258,7 @@ function setContent(content: string): void;
|
|
|
18291
18258
|
* The parameter, `model`, is the
|
|
18292
18259
|
* <a href="#/p5.Geometry">p5.Geometry</a> object to draw.
|
|
18293
18260
|
* <a href="#/p5.Geometry">p5.Geometry</a> objects can be built with
|
|
18294
|
-
* <a href="#/p5/buildGeometry">buildGeometry()</a
|
|
18295
|
-
* <a href="#/p5/beginGeometry">beginGeometry()</a> and
|
|
18296
|
-
* <a href="#/p5/endGeometry">endGeometry()</a>. They can also be loaded from
|
|
18261
|
+
* <a href="#/p5/buildGeometry">buildGeometry()</a>. They can also be loaded from
|
|
18297
18262
|
* a file with <a href="#/p5/loadGeometry">loadGeometry()</a>.
|
|
18298
18263
|
*
|
|
18299
18264
|
* Note: `model()` can only be used in WebGL mode.
|
|
@@ -18401,11 +18366,11 @@ function shearY(angle: number): void;
|
|
|
18401
18366
|
function saturation(color: P5.Color | number[] | string): number;
|
|
18402
18367
|
|
|
18403
18368
|
/**
|
|
18404
|
-
* Creates a dropdown menu
|
|
18369
|
+
* Creates a dropdown menu `<select></select>` element.
|
|
18405
18370
|
*
|
|
18406
18371
|
* The parameter is optional. If `true` is passed, as in
|
|
18407
18372
|
* `let mySelect = createSelect(true)`, then the dropdown will support
|
|
18408
|
-
* multiple selections. If an existing
|
|
18373
|
+
* multiple selections. If an existing `<select></select>` element
|
|
18409
18374
|
* is passed, as in `let mySelect = createSelect(otherSelect)`, the existing
|
|
18410
18375
|
* element will be wrapped in a new <a href="#/p5.Element">p5.Element</a>
|
|
18411
18376
|
* object.
|
|
@@ -18434,20 +18399,6 @@ function saturation(color: P5.Color | number[] | string): number;
|
|
|
18434
18399
|
function createSelect(multiple?: boolean): P5.Element;
|
|
18435
18400
|
function createSelect(existing: object): P5.Element;
|
|
18436
18401
|
|
|
18437
|
-
/**
|
|
18438
|
-
* Converts 3D world coordinates to 2D screen coordinates.
|
|
18439
|
-
*
|
|
18440
|
-
* This function takes a 3D vector and converts its coordinates
|
|
18441
|
-
* from the world space to screen space. This can be useful for placing
|
|
18442
|
-
* 2D elements in a 3D scene or for determining the screen position
|
|
18443
|
-
* of 3D objects.
|
|
18444
|
-
* @param x The x coordinate in world space. (Or a vector for all three coordinates.)
|
|
18445
|
-
* @param y The y coordinate in world space.
|
|
18446
|
-
* @param z The z coordinate in world space.
|
|
18447
|
-
* @returns A vector containing the 2D screen coordinates.
|
|
18448
|
-
*/
|
|
18449
|
-
function worldToScreen(x: number | P5.Vector, y: number, z?: number): P5.Vector;
|
|
18450
|
-
|
|
18451
18402
|
/**
|
|
18452
18403
|
* Draws a cone.
|
|
18453
18404
|
*
|
|
@@ -18486,6 +18437,20 @@ function worldToScreen(x: number | P5.Vector, y: number, z?: number): P5.Vector;
|
|
|
18486
18437
|
*/
|
|
18487
18438
|
function cone(radius?: number, height?: number, detailX?: number, detailY?: number, cap?: boolean): void;
|
|
18488
18439
|
|
|
18440
|
+
/**
|
|
18441
|
+
* Converts 3D world coordinates to 2D screen coordinates.
|
|
18442
|
+
*
|
|
18443
|
+
* This function takes a 3D vector and converts its coordinates
|
|
18444
|
+
* from the world space to screen space. This can be useful for placing
|
|
18445
|
+
* 2D elements in a 3D scene or for determining the screen position
|
|
18446
|
+
* of 3D objects.
|
|
18447
|
+
* @param x The x coordinate in world space. (Or a vector for all three coordinates.)
|
|
18448
|
+
* @param y The y coordinate in world space.
|
|
18449
|
+
* @param z The z coordinate in world space.
|
|
18450
|
+
* @returns A vector containing the 2D screen coordinates.
|
|
18451
|
+
*/
|
|
18452
|
+
function worldToScreen(x: number | P5.Vector, y: number, z?: number): P5.Vector;
|
|
18453
|
+
|
|
18489
18454
|
/**
|
|
18490
18455
|
* Load a 3d model from an OBJ or STL string.
|
|
18491
18456
|
*
|
|
@@ -19287,6 +19252,25 @@ function noLights(): void;
|
|
|
19287
19252
|
*/
|
|
19288
19253
|
function lightness(color: P5.Color | number[] | string): number;
|
|
19289
19254
|
|
|
19255
|
+
/**
|
|
19256
|
+
* Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply for images.
|
|
19257
|
+
*
|
|
19258
|
+
* This method allows the user to apply a custom shader to images, enabling
|
|
19259
|
+
* advanced visual effects such as pixel manipulation, color adjustments,
|
|
19260
|
+
* or dynamic behavior. The shader will be applied to the image drawn using
|
|
19261
|
+
* the <a href="#/p5/image">image()</a> function.
|
|
19262
|
+
*
|
|
19263
|
+
* The shader will be used exclusively for:
|
|
19264
|
+
*
|
|
19265
|
+
* - `image()` calls, applying only when drawing 2D images.
|
|
19266
|
+
*
|
|
19267
|
+
* - This shader will NOT apply to images used in <a href="#/p5/texture">texture()</a> or other 3D contexts.
|
|
19268
|
+
* Any attempts to use the imageShader in these cases will be ignored.
|
|
19269
|
+
* @param s <a href="#/p5.Shader">p5.Shader</a> object
|
|
19270
|
+
* to apply for images.
|
|
19271
|
+
*/
|
|
19272
|
+
function imageShader(s: P5.Shader): void;
|
|
19273
|
+
|
|
19290
19274
|
/**
|
|
19291
19275
|
* Changes the location from which images are drawn when
|
|
19292
19276
|
* <a href="#/p5/image">image()</a> is called.
|
|
@@ -19308,25 +19292,6 @@ function lightness(color: P5.Color | number[] | string): number;
|
|
|
19308
19292
|
*/
|
|
19309
19293
|
function imageMode(mode: typeof P5.CORNER | typeof P5.CORNERS | typeof P5.CENTER): void;
|
|
19310
19294
|
|
|
19311
|
-
/**
|
|
19312
|
-
* Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply for images.
|
|
19313
|
-
*
|
|
19314
|
-
* This method allows the user to apply a custom shader to images, enabling
|
|
19315
|
-
* advanced visual effects such as pixel manipulation, color adjustments,
|
|
19316
|
-
* or dynamic behavior. The shader will be applied to the image drawn using
|
|
19317
|
-
* the <a href="#/p5/image">image()</a> function.
|
|
19318
|
-
*
|
|
19319
|
-
* The shader will be used exclusively for:
|
|
19320
|
-
*
|
|
19321
|
-
* - `image()` calls, applying only when drawing 2D images.
|
|
19322
|
-
*
|
|
19323
|
-
* - This shader will NOT apply to images used in <a href="#/p5/texture">texture()</a> or other 3D contexts.
|
|
19324
|
-
* Any attempts to use the imageShader in these cases will be ignored.
|
|
19325
|
-
* @param s <a href="#/p5.Shader">p5.Shader</a> object
|
|
19326
|
-
* to apply for images.
|
|
19327
|
-
*/
|
|
19328
|
-
function imageShader(s: P5.Shader): void;
|
|
19329
|
-
|
|
19330
19295
|
/**
|
|
19331
19296
|
* A function that's called once when a mouse button is released.
|
|
19332
19297
|
*
|
|
@@ -19400,8 +19365,8 @@ function noStroke(): void;
|
|
|
19400
19365
|
*
|
|
19401
19366
|
* The parameter is optional. If a string is passed, as in
|
|
19402
19367
|
* `let myRadio = createSelect('food')`, then each radio option will
|
|
19403
|
-
* have `"food"` as its `name` parameter:
|
|
19404
|
-
* If an existing
|
|
19368
|
+
* have `"food"` as its `name` parameter: `<input name="food"></input>`.
|
|
19369
|
+
* If an existing `<div></div>` or `<span></span>`
|
|
19405
19370
|
* element is passed, as in `let myRadio = createSelect(container)`, it will
|
|
19406
19371
|
* become the radio button's parent element.
|
|
19407
19372
|
*
|
|
@@ -19417,8 +19382,8 @@ function noStroke(): void;
|
|
|
19417
19382
|
* - `myRadio.selected(value)` selects the given option and returns it as an <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement" target="_blank">`HTMLInputElement`</a>.
|
|
19418
19383
|
*
|
|
19419
19384
|
* - `myRadio.disable(shouldDisable)` enables the entire radio button if `true` is passed and disables it if `false` is passed.
|
|
19420
|
-
* @param containerElement container HTML Element, either a
|
|
19421
|
-
* or
|
|
19385
|
+
* @param containerElement container HTML Element, either a `<div></div>`
|
|
19386
|
+
* or `<span></span>`.
|
|
19422
19387
|
* @returns new <a href="#/p5.Element">p5.Element</a> object.
|
|
19423
19388
|
*/
|
|
19424
19389
|
function createRadio(containerElement?: object): P5.Element;
|
|
@@ -19426,7 +19391,7 @@ function createRadio(name?: string): P5.Element;
|
|
|
19426
19391
|
function createRadio(): P5.Element;
|
|
19427
19392
|
|
|
19428
19393
|
/**
|
|
19429
|
-
* Creates a
|
|
19394
|
+
* Creates a `<video>` element for simple audio/video playback.
|
|
19430
19395
|
*
|
|
19431
19396
|
* `createVideo()` returns a new
|
|
19432
19397
|
* <a href="#/p5.MediaElement">p5.MediaElement</a> object. Videos are shown by
|
|
@@ -19515,7 +19480,7 @@ function loadFont(path: string, successCallback?: (font: P5.Font) => any, failur
|
|
|
19515
19480
|
function lerpColor(c1: P5.Color, c2: P5.Color, amt: number): P5.Color;
|
|
19516
19481
|
|
|
19517
19482
|
/**
|
|
19518
|
-
* Creates a hidden
|
|
19483
|
+
* Creates a hidden `<audio>` element for simple audio playback.
|
|
19519
19484
|
*
|
|
19520
19485
|
* `createAudio()` returns a new
|
|
19521
19486
|
* <a href="#/p5.MediaElement">p5.MediaElement</a> object.
|
|
@@ -19538,22 +19503,6 @@ function lerpColor(c1: P5.Color, c2: P5.Color, amt: number): P5.Color;
|
|
|
19538
19503
|
*/
|
|
19539
19504
|
function createAudio(src?: string | string[], callback?: (video: P5.MediaElement<HTMLAudioElement>) => any): P5.MediaElement<HTMLAudioElement>;
|
|
19540
19505
|
|
|
19541
|
-
/**
|
|
19542
|
-
* Blends multiple colors to find a color between them.
|
|
19543
|
-
*
|
|
19544
|
-
* The `amt` parameter specifies the amount to interpolate between the color
|
|
19545
|
-
* stops which are colors at each `amt` value "location" with `amt` values
|
|
19546
|
-
* that are between 2 color stops interpolating between them based on its relative
|
|
19547
|
-
* distance to both.
|
|
19548
|
-
*
|
|
19549
|
-
* The way that colors are interpolated depends on the current
|
|
19550
|
-
* <a href="/reference/p5/colorMode/">colorMode()</a>.
|
|
19551
|
-
* @param colors_stops color stops to interpolate from
|
|
19552
|
-
* @param amt number to use to interpolate relative to color stops
|
|
19553
|
-
* @returns interpolated color.
|
|
19554
|
-
*/
|
|
19555
|
-
function paletteLerp(colors_stops: [P5.Color | string | number | number[], number][], amt: number): P5.Color;
|
|
19556
|
-
|
|
19557
19506
|
/**
|
|
19558
19507
|
* Draws a torus.
|
|
19559
19508
|
*
|
|
@@ -19583,7 +19532,23 @@ function paletteLerp(colors_stops: [P5.Color | string | number | number[], numbe
|
|
|
19583
19532
|
* @param detailX number of edges that form the hole. Defaults to 24.
|
|
19584
19533
|
* @param detailY number of triangle subdivisions along the y-axis. Defaults to 16.
|
|
19585
19534
|
*/
|
|
19586
|
-
function torus(radius?: number, tubeRadius?: number, detailX?: number, detailY?: number): void;
|
|
19535
|
+
function torus(radius?: number, tubeRadius?: number, detailX?: number, detailY?: number): void;
|
|
19536
|
+
|
|
19537
|
+
/**
|
|
19538
|
+
* Blends multiple colors to find a color between them.
|
|
19539
|
+
*
|
|
19540
|
+
* The `amt` parameter specifies the amount to interpolate between the color
|
|
19541
|
+
* stops which are colors at each `amt` value "location" with `amt` values
|
|
19542
|
+
* that are between 2 color stops interpolating between them based on its relative
|
|
19543
|
+
* distance to both.
|
|
19544
|
+
*
|
|
19545
|
+
* The way that colors are interpolated depends on the current
|
|
19546
|
+
* <a href="/reference/p5/colorMode/">colorMode()</a>.
|
|
19547
|
+
* @param colors_stops color stops to interpolate from
|
|
19548
|
+
* @param amt number to use to interpolate relative to color stops
|
|
19549
|
+
* @returns interpolated color.
|
|
19550
|
+
*/
|
|
19551
|
+
function paletteLerp(colors_stops: [P5.Color | string | number | number[], number][], amt: number): P5.Color;
|
|
19587
19552
|
|
|
19588
19553
|
/**
|
|
19589
19554
|
* Saves the file and closes the print stream.
|
|
@@ -19673,7 +19638,7 @@ function mouseClicked(event?: MouseEvent): void;
|
|
|
19673
19638
|
* }
|
|
19674
19639
|
*
|
|
19675
19640
|
* function material() {
|
|
19676
|
-
* let time =
|
|
19641
|
+
* let time = millis();
|
|
19677
19642
|
* worldInputs.begin();
|
|
19678
19643
|
* worldInputs.position.y +=
|
|
19679
19644
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -19683,7 +19648,6 @@ function mouseClicked(event?: MouseEvent): void;
|
|
|
19683
19648
|
* function draw() {
|
|
19684
19649
|
* background(255);
|
|
19685
19650
|
* shader(myShader);
|
|
19686
|
-
* myShader.setUniform('time', millis());
|
|
19687
19651
|
* lights();
|
|
19688
19652
|
* noStroke();
|
|
19689
19653
|
* fill('red');
|
|
@@ -19809,7 +19773,7 @@ function buildMaterialShader(callback: Function, scope?: object): P5.Shader;
|
|
|
19809
19773
|
function buildMaterialShader(hooks: object, scope?: object): P5.Shader;
|
|
19810
19774
|
|
|
19811
19775
|
/**
|
|
19812
|
-
* Creates a
|
|
19776
|
+
* Creates a `<video>` element that "captures" the audio/video stream from
|
|
19813
19777
|
* the webcam and microphone.
|
|
19814
19778
|
*
|
|
19815
19779
|
* `createCapture()` returns a new
|
|
@@ -19901,42 +19865,6 @@ function stroke(color: P5.Color): void;
|
|
|
19901
19865
|
*/
|
|
19902
19866
|
function createColorPicker(value?: string | P5.Color): P5.Element;
|
|
19903
19867
|
|
|
19904
|
-
/**
|
|
19905
|
-
* Saves a given element(image, text, json, csv, wav, or html) to the client's
|
|
19906
|
-
* computer. The first parameter can be a pointer to element we want to save.
|
|
19907
|
-
* The element can be one of <a href="#/p5.Element">p5.Element</a>,an Array of
|
|
19908
|
-
* Strings, an Array of JSON, a JSON object, a <a href="#/p5.Table">p5.Table
|
|
19909
|
-
* </a>, a <a href="#/p5.Image">p5.Image</a>, or a p5.SoundFile (requires
|
|
19910
|
-
* p5.sound). The second parameter is a filename (including extension).The
|
|
19911
|
-
* third parameter is for options specific to this type of object. This method
|
|
19912
|
-
* will save a file that fits the given parameters.
|
|
19913
|
-
* If it is called without specifying an element, by default it will save the
|
|
19914
|
-
* whole canvas as an image file. You can optionally specify a filename as
|
|
19915
|
-
* the first parameter in such a case.
|
|
19916
|
-
* Note that it is not recommended to
|
|
19917
|
-
* call this method within draw, as it will open a new save dialog on every
|
|
19918
|
-
* render.
|
|
19919
|
-
* @param objectOrFilename If filename is provided, will
|
|
19920
|
-
* save canvas as an image with
|
|
19921
|
-
* either png or jpg extension
|
|
19922
|
-
* depending on the filename.
|
|
19923
|
-
* If object is provided, will
|
|
19924
|
-
* save depending on the object
|
|
19925
|
-
* and filename (see examples
|
|
19926
|
-
* above).
|
|
19927
|
-
* @param filename If an object is provided as the first
|
|
19928
|
-
* parameter, then the second parameter
|
|
19929
|
-
* indicates the filename,
|
|
19930
|
-
* and should include an appropriate
|
|
19931
|
-
* file extension (see examples above).
|
|
19932
|
-
* @param options Additional options depend on
|
|
19933
|
-
* filetype. For example, when saving JSON,
|
|
19934
|
-
* <code>true</code> indicates that the
|
|
19935
|
-
* output will be optimized for filesize,
|
|
19936
|
-
* rather than readability.
|
|
19937
|
-
*/
|
|
19938
|
-
function save(objectOrFilename?: object | string, filename?: string, options?: boolean | string): void;
|
|
19939
|
-
|
|
19940
19868
|
/**
|
|
19941
19869
|
* Loads a new shader from a file that can change how fills are drawn. Pass the resulting
|
|
19942
19870
|
* shader into the <a href="#/p5/shader">`shader()`</a> function to apply it
|
|
@@ -19954,7 +19882,6 @@ function save(objectOrFilename?: object | string, filename?: string, options?: b
|
|
|
19954
19882
|
* function draw() {
|
|
19955
19883
|
* background(255);
|
|
19956
19884
|
* shader(myShader);
|
|
19957
|
-
* myShader.setUniform('time', millis());
|
|
19958
19885
|
* lights();
|
|
19959
19886
|
* noStroke();
|
|
19960
19887
|
* fill('red');
|
|
@@ -19964,7 +19891,7 @@ function save(objectOrFilename?: object | string, filename?: string, options?: b
|
|
|
19964
19891
|
* might use the `pixelInputs` hook to change each pixel on the surface of a shape.
|
|
19965
19892
|
*
|
|
19966
19893
|
* `// myMaterial.js
|
|
19967
|
-
* let time =
|
|
19894
|
+
* let time = millis();
|
|
19968
19895
|
* worldInputs.begin();
|
|
19969
19896
|
* worldInputs.position.y +=
|
|
19970
19897
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -19984,6 +19911,42 @@ function save(objectOrFilename?: object | string, filename?: string, options?: b
|
|
|
19984
19911
|
*/
|
|
19985
19912
|
function loadMaterialShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
|
|
19986
19913
|
|
|
19914
|
+
/**
|
|
19915
|
+
* Saves a given element(image, text, json, csv, wav, or html) to the client's
|
|
19916
|
+
* computer. The first parameter can be a pointer to element we want to save.
|
|
19917
|
+
* The element can be one of <a href="#/p5.Element">p5.Element</a>,an Array of
|
|
19918
|
+
* Strings, an Array of JSON, a JSON object, a <a href="#/p5.Table">p5.Table
|
|
19919
|
+
* </a>, a <a href="#/p5.Image">p5.Image</a>, or a p5.SoundFile (requires
|
|
19920
|
+
* p5.sound). The second parameter is a filename (including extension).The
|
|
19921
|
+
* third parameter is for options specific to this type of object. This method
|
|
19922
|
+
* will save a file that fits the given parameters.
|
|
19923
|
+
* If it is called without specifying an element, by default it will save the
|
|
19924
|
+
* whole canvas as an image file. You can optionally specify a filename as
|
|
19925
|
+
* the first parameter in such a case.
|
|
19926
|
+
* Note that it is not recommended to
|
|
19927
|
+
* call this method within draw, as it will open a new save dialog on every
|
|
19928
|
+
* render.
|
|
19929
|
+
* @param objectOrFilename If filename is provided, will
|
|
19930
|
+
* save canvas as an image with
|
|
19931
|
+
* either png or jpg extension
|
|
19932
|
+
* depending on the filename.
|
|
19933
|
+
* If object is provided, will
|
|
19934
|
+
* save depending on the object
|
|
19935
|
+
* and filename (see examples
|
|
19936
|
+
* above).
|
|
19937
|
+
* @param filename If an object is provided as the first
|
|
19938
|
+
* parameter, then the second parameter
|
|
19939
|
+
* indicates the filename,
|
|
19940
|
+
* and should include an appropriate
|
|
19941
|
+
* file extension (see examples above).
|
|
19942
|
+
* @param options Additional options depend on
|
|
19943
|
+
* filetype. For example, when saving JSON,
|
|
19944
|
+
* <code>true</code> indicates that the
|
|
19945
|
+
* output will be optimized for filesize,
|
|
19946
|
+
* rather than readability.
|
|
19947
|
+
*/
|
|
19948
|
+
function save(objectOrFilename?: object | string, filename?: string, options?: boolean | string): void;
|
|
19949
|
+
|
|
19987
19950
|
/**
|
|
19988
19951
|
* Influences the shape of the Bézier curve segment in a custom shape.
|
|
19989
19952
|
* By default, this is 3; the other possible parameter is 2. This
|
|
@@ -20066,6 +20029,19 @@ function doubleClicked(event?: MouseEvent): void;
|
|
|
20066
20029
|
*/
|
|
20067
20030
|
function baseMaterialShader(): P5.Shader;
|
|
20068
20031
|
|
|
20032
|
+
/**
|
|
20033
|
+
* Returns the base shader used for filters.
|
|
20034
|
+
*
|
|
20035
|
+
* Calling <a href="#/p5/buildFilterShader">`buildFilterShader(shaderFunction)`</a>
|
|
20036
|
+
* is equivalent to calling `baseFilterShader().modify(shaderFunction)`.
|
|
20037
|
+
*
|
|
20038
|
+
* Read <a href="#/p5/buildFilterShader">the `buildFilterShader` reference</a> or
|
|
20039
|
+
* call `baseFilterShader().inspectHooks()` for more information on what you can do with
|
|
20040
|
+
* the base filter shader.
|
|
20041
|
+
* @returns The base filter shader.
|
|
20042
|
+
*/
|
|
20043
|
+
function baseFilterShader(): P5.Shader;
|
|
20044
|
+
|
|
20069
20045
|
/**
|
|
20070
20046
|
* Starts using shapes to erase parts of the canvas.
|
|
20071
20047
|
*
|
|
@@ -20100,19 +20076,6 @@ function baseMaterialShader(): P5.Shader;
|
|
|
20100
20076
|
*/
|
|
20101
20077
|
function erase(strengthFill?: number, strengthStroke?: number): void;
|
|
20102
20078
|
|
|
20103
|
-
/**
|
|
20104
|
-
* Returns the base shader used for filters.
|
|
20105
|
-
*
|
|
20106
|
-
* Calling <a href="#/p5/buildFilterShader">`buildFilterShader(shaderFunction)`</a>
|
|
20107
|
-
* is equivalent to calling `baseFilterShader().modify(shaderFunction)`.
|
|
20108
|
-
*
|
|
20109
|
-
* Read <a href="#/p5/buildFilterShader">the `buildFilterShader` reference</a> or
|
|
20110
|
-
* call `baseFilterShader().inspectHooks()` for more information on what you can do with
|
|
20111
|
-
* the base filter shader.
|
|
20112
|
-
* @returns The base filter shader.
|
|
20113
|
-
*/
|
|
20114
|
-
function baseFilterShader(): P5.Shader;
|
|
20115
|
-
|
|
20116
20079
|
/**
|
|
20117
20080
|
* Ends erasing that was started with <a href="#/p5/erase">erase()</a>.
|
|
20118
20081
|
*
|
|
@@ -20123,7 +20086,7 @@ function baseFilterShader(): P5.Shader;
|
|
|
20123
20086
|
function noErase(): void;
|
|
20124
20087
|
|
|
20125
20088
|
/**
|
|
20126
|
-
* Creates a text
|
|
20089
|
+
* Creates a text `<input></input>` element.
|
|
20127
20090
|
*
|
|
20128
20091
|
* Call `myInput.size()` to set the length of the text box.
|
|
20129
20092
|
*
|
|
@@ -20173,7 +20136,7 @@ function createInput(value?: string): P5.Element;
|
|
|
20173
20136
|
* }
|
|
20174
20137
|
*
|
|
20175
20138
|
* function material() {
|
|
20176
|
-
* let time =
|
|
20139
|
+
* let time = millis();
|
|
20177
20140
|
* worldInputs.begin();
|
|
20178
20141
|
* worldInputs.position.y +=
|
|
20179
20142
|
* 20. * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -20183,7 +20146,6 @@ function createInput(value?: string): P5.Element;
|
|
|
20183
20146
|
* function draw() {
|
|
20184
20147
|
* background(255);
|
|
20185
20148
|
* shader(myShader);
|
|
20186
|
-
* myShader.setUniform('time', millis());
|
|
20187
20149
|
* noStroke();
|
|
20188
20150
|
* sphere(50);
|
|
20189
20151
|
* }`You may also want to change the colors used. By default, the x, y, and z values of the orientation
|
|
@@ -20472,7 +20434,7 @@ function saveJSON(json: any[] | object, filename: string, optimize?: boolean): v
|
|
|
20472
20434
|
function pop(): void;
|
|
20473
20435
|
|
|
20474
20436
|
/**
|
|
20475
|
-
* Creates an
|
|
20437
|
+
* Creates an `<input></input>` element of type `'file'`.
|
|
20476
20438
|
*
|
|
20477
20439
|
* `createFileInput()` allows users to select local files for use in a sketch.
|
|
20478
20440
|
* It returns a <a href="#/p5.File">p5.File</a> object.
|
|
@@ -20508,7 +20470,6 @@ function createFileInput(callback: (input: P5.File) => any, multiple?: boolean):
|
|
|
20508
20470
|
* function draw() {
|
|
20509
20471
|
* background(255);
|
|
20510
20472
|
* shader(myShader);
|
|
20511
|
-
* myShader.setUniform('time', millis());
|
|
20512
20473
|
* lights();
|
|
20513
20474
|
* noStroke();
|
|
20514
20475
|
* fill('red');
|
|
@@ -20518,7 +20479,7 @@ function createFileInput(callback: (input: P5.File) => any, multiple?: boolean):
|
|
|
20518
20479
|
* might use the `finalColor` hook to change the color of each pixel on the surface of a shape.
|
|
20519
20480
|
*
|
|
20520
20481
|
* `// myMaterial.js
|
|
20521
|
-
* let time =
|
|
20482
|
+
* let time = millis();
|
|
20522
20483
|
* worldInputs.begin();
|
|
20523
20484
|
* worldInputs.position.y +=
|
|
20524
20485
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -20649,7 +20610,7 @@ function saveStrings(list: string[], filename: string, extension?: string, isCRL
|
|
|
20649
20610
|
* }
|
|
20650
20611
|
*
|
|
20651
20612
|
* function material() {
|
|
20652
|
-
* let time =
|
|
20613
|
+
* let time = millis();
|
|
20653
20614
|
* worldInputs.begin();
|
|
20654
20615
|
* worldInputs.position.y +=
|
|
20655
20616
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -20659,7 +20620,6 @@ function saveStrings(list: string[], filename: string, extension?: string, isCRL
|
|
|
20659
20620
|
* function draw() {
|
|
20660
20621
|
* background(255);
|
|
20661
20622
|
* shader(myShader);
|
|
20662
|
-
* myShader.setUniform('time', millis());
|
|
20663
20623
|
* noStroke();
|
|
20664
20624
|
* fill('red');
|
|
20665
20625
|
* circle(0, 0, 50);
|
|
@@ -20773,7 +20733,6 @@ function saveTable(Table: P5.Table, filename: string, options?: string): void;
|
|
|
20773
20733
|
* function draw() {
|
|
20774
20734
|
* background(255);
|
|
20775
20735
|
* shader(myShader);
|
|
20776
|
-
* myShader.setUniform('time', millis());
|
|
20777
20736
|
* lights();
|
|
20778
20737
|
* noStroke();
|
|
20779
20738
|
* fill('red');
|
|
@@ -20783,7 +20742,7 @@ function saveTable(Table: P5.Table, filename: string, options?: string): void;
|
|
|
20783
20742
|
* might use the `finalColor` hook to change the color of each pixel on the surface of a shape.
|
|
20784
20743
|
*
|
|
20785
20744
|
* `// myMaterial.js
|
|
20786
|
-
* let time =
|
|
20745
|
+
* let time = millis();
|
|
20787
20746
|
* worldInputs.begin();
|
|
20788
20747
|
* worldInputs.position.y +=
|
|
20789
20748
|
* 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
|
|
@@ -21068,7 +21027,7 @@ function camera(x?: number, y?: number, z?: number, centerX?: number, centerY?:
|
|
|
21068
21027
|
* }
|
|
21069
21028
|
*
|
|
21070
21029
|
* function material() {
|
|
21071
|
-
* let time =
|
|
21030
|
+
* let time = millis();
|
|
21072
21031
|
* worldInputs.begin();
|
|
21073
21032
|
* // Add a somewhat random offset to the weight
|
|
21074
21033
|
* // that varies based on position and time
|
|
@@ -21084,7 +21043,6 @@ function camera(x?: number, y?: number, z?: number, centerX?: number, centerY?:
|
|
|
21084
21043
|
* function draw() {
|
|
21085
21044
|
* background(255);
|
|
21086
21045
|
* strokeShader(myShader);
|
|
21087
|
-
* myShader.setUniform('time', millis());
|
|
21088
21046
|
* strokeWeight(10);
|
|
21089
21047
|
* beginShape();
|
|
21090
21048
|
* for (let i = 0; i <= 50; i++) {
|
|
@@ -21175,6 +21133,58 @@ function buildStrokeShader(hooks: object, scope?: object): P5.Shader;
|
|
|
21175
21133
|
function splineProperty(property: string, value: any): void;
|
|
21176
21134
|
function splineProperty(property: string): void;
|
|
21177
21135
|
|
|
21136
|
+
/**
|
|
21137
|
+
* Loads a new shader from a file that can change how strokes are drawn. Pass the resulting
|
|
21138
|
+
* shader into the <a href="#/p5/strokeShader">`strokeShader()`</a> function to apply it
|
|
21139
|
+
* to any strokes you draw.
|
|
21140
|
+
*
|
|
21141
|
+
* Since this function loads data from another file, it returns a `Promise`.
|
|
21142
|
+
* Use it in an `async function setup`, and `await` its result.
|
|
21143
|
+
*
|
|
21144
|
+
* `let myShader;
|
|
21145
|
+
* async function setup() {
|
|
21146
|
+
* createCanvas(200, 200, WEBGL);
|
|
21147
|
+
* myShader = await loadStrokeShader('myMaterial.js');
|
|
21148
|
+
* }
|
|
21149
|
+
*
|
|
21150
|
+
* function draw() {
|
|
21151
|
+
* background(255);
|
|
21152
|
+
* strokeShader(myShader);
|
|
21153
|
+
* strokeWeight(30);
|
|
21154
|
+
* line(
|
|
21155
|
+
* -width/3,
|
|
21156
|
+
* sin(millis()*0.001) * height/4,
|
|
21157
|
+
* width/3,
|
|
21158
|
+
* sin(millis()*0.001 + 1) * height/4
|
|
21159
|
+
* );
|
|
21160
|
+
* }`Inside your shader file, you can call p5.strands hooks to change parts of the shader. For
|
|
21161
|
+
* example, you might use the `worldInputs` hook to change each vertex, or you
|
|
21162
|
+
* might use the `pixelInputs` hook to change each pixel on the surface of a stroke.
|
|
21163
|
+
*
|
|
21164
|
+
* `// myMaterial.js
|
|
21165
|
+
* pixelInputs.begin();
|
|
21166
|
+
* let opacity = 1 - smoothstep(
|
|
21167
|
+
* 0,
|
|
21168
|
+
* 15,
|
|
21169
|
+
* length(pixelInputs.position - pixelInputs.center)
|
|
21170
|
+
* );
|
|
21171
|
+
* pixelInputs.color.a *= opacity;
|
|
21172
|
+
* pixelInputs.end();`Read the reference for <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a>,
|
|
21173
|
+
* the version of `loadStrokeShader` that takes in a function instead of a separate file,
|
|
21174
|
+
* for a full list of hooks you can use and examples for each.
|
|
21175
|
+
*
|
|
21176
|
+
* The second parameter, `successCallback`, is optional. If a function is passed, as in
|
|
21177
|
+
* `loadStrokeShader('myShader.js', onLoaded)`, then the `onLoaded()` function will be called
|
|
21178
|
+
* once the shader loads. The shader will be passed to `onLoaded()` as its only argument.
|
|
21179
|
+
* The return value of `handleData()`, if present, will be used as the final return value of
|
|
21180
|
+
* `loadStrokeShader('myShader.js', onLoaded)`.
|
|
21181
|
+
* @param url The URL of your p5.strands JavaScript file.
|
|
21182
|
+
* @param onSuccess A callback function to run when loading completes.
|
|
21183
|
+
* @param onFailure A callback function to run when loading fails.
|
|
21184
|
+
* @returns The stroke shader.
|
|
21185
|
+
*/
|
|
21186
|
+
function loadStrokeShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
|
|
21187
|
+
|
|
21178
21188
|
/**
|
|
21179
21189
|
* Sets a perspective projection for the current camera in a 3D sketch.
|
|
21180
21190
|
*
|
|
@@ -21229,58 +21239,6 @@ function splineProperty(property: string): void;
|
|
|
21229
21239
|
*/
|
|
21230
21240
|
function perspective(fovy?: number, aspect?: number, near?: number, far?: number): void;
|
|
21231
21241
|
|
|
21232
|
-
/**
|
|
21233
|
-
* Loads a new shader from a file that can change how strokes are drawn. Pass the resulting
|
|
21234
|
-
* shader into the <a href="#/p5/strokeShader">`strokeShader()`</a> function to apply it
|
|
21235
|
-
* to any strokes you draw.
|
|
21236
|
-
*
|
|
21237
|
-
* Since this function loads data from another file, it returns a `Promise`.
|
|
21238
|
-
* Use it in an `async function setup`, and `await` its result.
|
|
21239
|
-
*
|
|
21240
|
-
* `let myShader;
|
|
21241
|
-
* async function setup() {
|
|
21242
|
-
* createCanvas(200, 200, WEBGL);
|
|
21243
|
-
* myShader = await loadStrokeShader('myMaterial.js');
|
|
21244
|
-
* }
|
|
21245
|
-
*
|
|
21246
|
-
* function draw() {
|
|
21247
|
-
* background(255);
|
|
21248
|
-
* strokeShader(myShader);
|
|
21249
|
-
* strokeWeight(30);
|
|
21250
|
-
* line(
|
|
21251
|
-
* -width/3,
|
|
21252
|
-
* sin(millis()*0.001) * height/4,
|
|
21253
|
-
* width/3,
|
|
21254
|
-
* sin(millis()*0.001 + 1) * height/4
|
|
21255
|
-
* );
|
|
21256
|
-
* }`Inside your shader file, you can call p5.strands hooks to change parts of the shader. For
|
|
21257
|
-
* example, you might use the `worldInputs` hook to change each vertex, or you
|
|
21258
|
-
* might use the `pixelInputs` hook to change each pixel on the surface of a stroke.
|
|
21259
|
-
*
|
|
21260
|
-
* `// myMaterial.js
|
|
21261
|
-
* pixelInputs.begin();
|
|
21262
|
-
* let opacity = 1 - smoothstep(
|
|
21263
|
-
* 0,
|
|
21264
|
-
* 15,
|
|
21265
|
-
* length(pixelInputs.position - pixelInputs.center)
|
|
21266
|
-
* );
|
|
21267
|
-
* pixelInputs.color.a *= opacity;
|
|
21268
|
-
* pixelInputs.end();`Read the reference for <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a>,
|
|
21269
|
-
* the version of `loadStrokeShader` that takes in a function instead of a separate file,
|
|
21270
|
-
* for a full list of hooks you can use and examples for each.
|
|
21271
|
-
*
|
|
21272
|
-
* The second parameter, `successCallback`, is optional. If a function is passed, as in
|
|
21273
|
-
* `loadStrokeShader('myShader.js', onLoaded)`, then the `onLoaded()` function will be called
|
|
21274
|
-
* once the shader loads. The shader will be passed to `onLoaded()` as its only argument.
|
|
21275
|
-
* The return value of `handleData()`, if present, will be used as the final return value of
|
|
21276
|
-
* `loadStrokeShader('myShader.js', onLoaded)`.
|
|
21277
|
-
* @param url The URL of your p5.strands JavaScript file.
|
|
21278
|
-
* @param onSuccess A callback function to run when loading completes.
|
|
21279
|
-
* @param onFailure A callback function to run when loading fails.
|
|
21280
|
-
* @returns The stroke shader.
|
|
21281
|
-
*/
|
|
21282
|
-
function loadStrokeShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
|
|
21283
|
-
|
|
21284
21242
|
/**
|
|
21285
21243
|
* Returns the default shader used for strokes.
|
|
21286
21244
|
*
|
|
@@ -21325,6 +21283,17 @@ function baseStrokeShader(): P5.Shader;
|
|
|
21325
21283
|
*/
|
|
21326
21284
|
function splineProperties(values: object): object;
|
|
21327
21285
|
|
|
21286
|
+
/**
|
|
21287
|
+
* Restores the default shaders.
|
|
21288
|
+
*
|
|
21289
|
+
* `resetShader()` deactivates any shaders previously applied by
|
|
21290
|
+
* <a href="#/p5/shader">shader()</a>, <a href="#/p5/strokeShader">strokeShader()</a>,
|
|
21291
|
+
* or <a href="#/p5/imageShader">imageShader()</a>.
|
|
21292
|
+
*
|
|
21293
|
+
* Note: Shaders can only be used in WebGL mode.
|
|
21294
|
+
*/
|
|
21295
|
+
function resetShader(): void;
|
|
21296
|
+
|
|
21328
21297
|
/**
|
|
21329
21298
|
* Enables or disables perspective for lines in 3D sketches.
|
|
21330
21299
|
*
|
|
@@ -21362,17 +21331,6 @@ function splineProperties(values: object): object;
|
|
|
21362
21331
|
function linePerspective(enable: boolean): boolean;
|
|
21363
21332
|
function linePerspective(): boolean;
|
|
21364
21333
|
|
|
21365
|
-
/**
|
|
21366
|
-
* Restores the default shaders.
|
|
21367
|
-
*
|
|
21368
|
-
* `resetShader()` deactivates any shaders previously applied by
|
|
21369
|
-
* <a href="#/p5/shader">shader()</a>, <a href="#/p5/strokeShader">strokeShader()</a>,
|
|
21370
|
-
* or <a href="#/p5/imageShader">imageShader()</a>.
|
|
21371
|
-
*
|
|
21372
|
-
* Note: Shaders can only be used in WebGL mode.
|
|
21373
|
-
*/
|
|
21374
|
-
function resetShader(): void;
|
|
21375
|
-
|
|
21376
21334
|
/**
|
|
21377
21335
|
* Sets an orthographic projection for the current camera in a 3D sketch.
|
|
21378
21336
|
*
|
|
@@ -21456,6 +21414,20 @@ function vertex(x: number, y: number): void;
|
|
|
21456
21414
|
function vertex(x: number, y: number, u?: number, v?: number): void;
|
|
21457
21415
|
function vertex(x: number, y: number, z: number, u?: number, v?: number): void;
|
|
21458
21416
|
|
|
21417
|
+
/**
|
|
21418
|
+
* Sets the number of segments used to draw spline curves in WebGL mode.
|
|
21419
|
+
*
|
|
21420
|
+
* In WebGL mode, smooth shapes are drawn using many flat segments. Adding
|
|
21421
|
+
* more flat segments makes shapes appear smoother.
|
|
21422
|
+
*
|
|
21423
|
+
* The parameter, `detail`, is the density of segments to use while drawing a
|
|
21424
|
+
* spline curve.
|
|
21425
|
+
*
|
|
21426
|
+
* Note: `curveDetail()` has no effect in 2D mode.
|
|
21427
|
+
* @param resolution number of segments to use. Default is 1/4
|
|
21428
|
+
*/
|
|
21429
|
+
function curveDetail(resolution: number): void;
|
|
21430
|
+
|
|
21459
21431
|
/**
|
|
21460
21432
|
* Sets the frustum of the current camera in a 3D sketch.
|
|
21461
21433
|
*
|
|
@@ -21495,20 +21467,6 @@ function vertex(x: number, y: number, z: number, u?: number, v?: number): void;
|
|
|
21495
21467
|
*/
|
|
21496
21468
|
function frustum(left?: number, right?: number, bottom?: number, top?: number, near?: number, far?: number): void;
|
|
21497
21469
|
|
|
21498
|
-
/**
|
|
21499
|
-
* Sets the number of segments used to draw spline curves in WebGL mode.
|
|
21500
|
-
*
|
|
21501
|
-
* In WebGL mode, smooth shapes are drawn using many flat segments. Adding
|
|
21502
|
-
* more flat segments makes shapes appear smoother.
|
|
21503
|
-
*
|
|
21504
|
-
* The parameter, `detail`, is the density of segments to use while drawing a
|
|
21505
|
-
* spline curve.
|
|
21506
|
-
*
|
|
21507
|
-
* Note: `curveDetail()` has no effect in 2D mode.
|
|
21508
|
-
* @param resolution number of segments to use. Default is 1/4
|
|
21509
|
-
*/
|
|
21510
|
-
function curveDetail(resolution: number): void;
|
|
21511
|
-
|
|
21512
21470
|
/**
|
|
21513
21471
|
* Creates a new <a href="#/p5.Camera">p5.Camera</a> object.
|
|
21514
21472
|
*
|
|
@@ -22710,3 +22668,5 @@ function sampler(value: any): any;
|
|
|
22710
22668
|
|
|
22711
22669
|
}
|
|
22712
22670
|
|
|
22671
|
+
export default p5;
|
|
22672
|
+
|