p5 2.3.0 → 2.3.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -11
- package/dist/accessibility/color_namer.js +7 -7
- package/dist/accessibility/index.js +7 -7
- package/dist/app.js +7 -7
- package/dist/app.node.js +7 -7
- package/dist/color/color_conversion.js +7 -7
- package/dist/color/creating_reading.js +1 -1
- package/dist/color/index.js +2 -2
- package/dist/color/p5.Color.js +1 -1
- package/dist/color/setting.js +10 -10
- package/dist/{constants-Dv6ZqA6s.js → constants-DkQDfqzw.js} +8 -8
- package/dist/core/constants.js +1 -1
- package/dist/core/environment.js +3 -3
- 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 +489 -466
- package/dist/core/friendly_errors/sketch_verifier.js +1 -1
- package/dist/core/helpers.js +1 -1
- package/dist/core/init.js +7 -7
- package/dist/core/internationalization.js +1 -1
- package/dist/core/legacy.js +7 -7
- package/dist/core/main.js +7 -7
- package/dist/core/p5.Graphics.js +4 -4
- package/dist/core/p5.Renderer.js +3 -3
- package/dist/core/p5.Renderer2D.js +7 -7
- package/dist/core/p5.Renderer3D.js +4 -4
- package/dist/core/rendering.js +4 -4
- package/dist/{creating_reading-DLkHH80h.js → creating_reading-Dyt2y-6S.js} +25 -17
- package/dist/dom/dom.js +2 -2
- package/dist/dom/index.js +2 -2
- package/dist/dom/p5.Element.js +2 -2
- package/dist/dom/p5.MediaElement.js +2 -2
- package/dist/events/pointer.js +15 -0
- package/dist/image/const.js +1 -1
- package/dist/image/filterRenderer2D.js +6 -6
- package/dist/image/image.js +4 -4
- package/dist/image/index.js +4 -4
- package/dist/image/loading_displaying.js +4 -4
- package/dist/image/p5.Image.js +3 -3
- package/dist/io/files.js +4 -4
- package/dist/io/index.js +4 -4
- package/dist/{ir_builders-C8mrXj5z.js → ir_builders-CMXkjMoV.js} +34 -24
- package/dist/{main-BR2ALC_6.js → main-CAqj0AHr.js} +41 -210
- package/dist/math/Matrices/Matrix.js +1 -1
- package/dist/math/Matrices/MatrixNumjs.js +1 -1
- package/dist/math/calculation.js +669 -84
- package/dist/math/index.js +1 -1
- package/dist/math/p5.Matrix.js +1 -1
- package/dist/math/p5.Vector.js +9 -1
- package/dist/math/patch-vector.js +3 -1
- package/dist/math/trigonometry.js +399 -48
- package/dist/{p5.Renderer-XOvhEbJn.js → p5.Renderer-Bf-YLpi6.js} +2 -2
- package/dist/{rendering-C5lX6zKm.js → rendering-BowMW0pZ.js} +32 -13
- package/dist/shape/2d_primitives.js +1 -1
- package/dist/shape/attributes.js +4 -3
- package/dist/shape/custom_shapes.js +205 -3
- package/dist/shape/index.js +2 -2
- package/dist/strands/ir_builders.js +1 -1
- package/dist/strands/p5.strands.js +26 -9
- package/dist/strands/strands_FES.js +8 -1
- package/dist/strands/strands_api.js +316 -21
- package/dist/strands/strands_conditionals.js +1 -1
- package/dist/strands/strands_for.js +1 -1
- package/dist/strands/strands_node.js +1 -1
- package/dist/strands/strands_ternary.js +1 -1
- package/dist/{strands_glslBackend-D6G3UyCs.js → strands_glslBackend-DMhOnoGl.js} +2 -2
- package/dist/type/index.js +3 -3
- package/dist/type/p5.Font.js +13 -4
- package/dist/type/textCore.js +3 -3
- package/dist/webgl/3d_primitives.js +4 -4
- package/dist/webgl/GeometryBuilder.js +1 -1
- package/dist/webgl/ShapeBuilder.js +50 -1
- package/dist/webgl/enums.js +1 -1
- package/dist/webgl/index.js +6 -6
- package/dist/webgl/interaction.js +1 -1
- package/dist/webgl/light.js +4 -4
- package/dist/webgl/loading.js +4 -4
- package/dist/webgl/material.js +4 -4
- package/dist/webgl/p5.Camera.js +4 -4
- package/dist/webgl/p5.Framebuffer.js +4 -4
- package/dist/webgl/p5.Geometry.js +1 -1
- package/dist/webgl/p5.Quat.js +1 -1
- package/dist/webgl/p5.RendererGL.js +20 -9
- package/dist/webgl/p5.Shader.js +5 -1
- package/dist/webgl/p5.Texture.js +4 -4
- package/dist/webgl/strands_glslBackend.js +2 -2
- package/dist/webgl/text.js +4 -4
- package/dist/webgl/utils.js +4 -4
- package/dist/webgpu/index.js +2 -2
- package/dist/webgpu/p5.RendererWebGPU.js +6 -2
- package/dist/webgpu/strands_wgslBackend.js +2 -2
- package/lib/p5.esm.js +2358 -911
- package/lib/p5.esm.min.js +1 -1
- package/lib/p5.js +2358 -911
- package/lib/p5.min.js +1 -1
- package/lib/p5.webgpu.esm.js +44 -9
- package/lib/p5.webgpu.js +44 -9
- package/lib/p5.webgpu.min.js +1 -1
- package/package.json +1 -1
- package/types/global.d.ts +5785 -2850
- package/types/p5.d.ts +3016 -1531
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getNodeDataFromID, createNodeData, getOrCreateNode, extractNodeTypeInfo, propagateTypeToAssignOnUse } from './strands/ir_dag.js';
|
|
2
2
|
import { recordInBasicBlock } from './strands/ir_cfg.js';
|
|
3
|
-
import { userError, internalError } from './strands/strands_FES.js';
|
|
3
|
+
import { dimensionMismatchError, userError, internalError } from './strands/strands_FES.js';
|
|
4
4
|
import { BaseType, NodeType, OpCode, typeEquals, BasePriority, DataType, OpCodeToSymbol, booleanOpCode } from './strands/ir_types.js';
|
|
5
5
|
import { strandsBuiltinFunctions } from './strands/strands_builtins.js';
|
|
6
6
|
|
|
@@ -58,6 +58,16 @@ class StrandsNode {
|
|
|
58
58
|
|
|
59
59
|
// For varying variables, we need both assignment generation AND a way to reference by identifier
|
|
60
60
|
if (this._originalIdentifier) {
|
|
61
|
+
const valueDim = value?.isStrandsNode
|
|
62
|
+
? value.dimension
|
|
63
|
+
: (Array.isArray(value) ? value.length : 1);
|
|
64
|
+
if (valueDim !== this._originalDimension && valueDim !== 1){
|
|
65
|
+
dimensionMismatchError(
|
|
66
|
+
this._originalDimension,
|
|
67
|
+
valueDim,
|
|
68
|
+
this._originalIdentifier
|
|
69
|
+
);
|
|
70
|
+
}
|
|
61
71
|
// Create a variable node for the target (the varying variable)
|
|
62
72
|
const { id: targetVarID } = variableNode(
|
|
63
73
|
this.strandsContext,
|
|
@@ -110,6 +120,16 @@ class StrandsNode {
|
|
|
110
120
|
|
|
111
121
|
// For varying variables, create swizzle assignment
|
|
112
122
|
if (this._originalIdentifier) {
|
|
123
|
+
const valueDim = value?.isStrandsNode
|
|
124
|
+
? value.dimension
|
|
125
|
+
: (Array.isArray(value) ? value.length : 1);
|
|
126
|
+
if (valueDim !== swizzlePattern.length && valueDim !== 1){
|
|
127
|
+
dimensionMismatchError(
|
|
128
|
+
swizzlePattern.length,
|
|
129
|
+
valueDim,
|
|
130
|
+
`${this._originalIdentifier}.${swizzlePattern}`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
113
133
|
// Create a variable node for the target with swizzle
|
|
114
134
|
const { id: targetVarID } = variableNode(
|
|
115
135
|
this.strandsContext,
|
|
@@ -560,38 +580,24 @@ function castToFloat(strandsContext, dep) {
|
|
|
560
580
|
return createStrandsNode(id, dimension, strandsContext);
|
|
561
581
|
}
|
|
562
582
|
|
|
563
|
-
function structConstructorNode(strandsContext, structTypeInfo,
|
|
583
|
+
function structConstructorNode(strandsContext, structTypeInfo, dependsOn) {
|
|
564
584
|
const { cfg, dag } = strandsContext;
|
|
565
|
-
const {
|
|
585
|
+
const { properties } = structTypeInfo;
|
|
566
586
|
|
|
567
|
-
if (
|
|
587
|
+
if (dependsOn.length !== properties.length) {
|
|
568
588
|
userError('type error',
|
|
569
|
-
`You've tried to construct a ${structTypeInfo.typeName} struct with ${
|
|
589
|
+
`You've tried to construct a ${structTypeInfo.typeName} struct with ${dependsOn.length} properties, but it expects ${properties.length} properties.\n` +
|
|
570
590
|
`The properties it expects are:\n` +
|
|
571
|
-
`${properties.map(prop => prop.name
|
|
591
|
+
`${properties.map(prop => `${prop.name}: ${prop.dataType.baseType}${prop.dataType.dimension}`).join(', ')}`
|
|
572
592
|
);
|
|
573
593
|
}
|
|
574
594
|
|
|
575
|
-
const dependsOn = [];
|
|
576
|
-
for (let i = 0; i < properties.length; i++) {
|
|
577
|
-
const expectedProperty = properties[i];
|
|
578
|
-
const { originalNodeID, mappedDependencies } = mapPrimitiveDepsToIDs(strandsContext, expectedProperty.dataType, rawUserArgs[i]);
|
|
579
|
-
if (originalNodeID) {
|
|
580
|
-
dependsOn.push(originalNodeID);
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
dependsOn.push(
|
|
584
|
-
constructTypeFromIDs(strandsContext, expectedProperty.dataType, mappedDependencies)
|
|
585
|
-
);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
595
|
const nodeData = createNodeData({
|
|
590
596
|
nodeType: NodeType.OPERATION,
|
|
591
597
|
opCode: OpCode.Nary.CONSTRUCTOR,
|
|
592
598
|
dimension: properties.length,
|
|
593
|
-
baseType: structTypeInfo.typeName
|
|
594
|
-
dependsOn
|
|
599
|
+
baseType: structTypeInfo.typeName,
|
|
600
|
+
dependsOn,
|
|
595
601
|
});
|
|
596
602
|
const id = getOrCreateNode(dag, nodeData);
|
|
597
603
|
recordInBasicBlock(cfg, cfg.currentBlock, id);
|
|
@@ -788,7 +794,11 @@ function swizzleTrap(id, dimension, strandsContext, onRebind) {
|
|
|
788
794
|
scalars.push(createStrandsNode(id, dimension, strandsContext));
|
|
789
795
|
}
|
|
790
796
|
} else {
|
|
791
|
-
|
|
797
|
+
dimensionMismatchError(
|
|
798
|
+
chars.length,
|
|
799
|
+
value.dimension,
|
|
800
|
+
`${target._originalIdentifier || 'value'}.${property}`
|
|
801
|
+
);
|
|
792
802
|
}
|
|
793
803
|
} else if (Array.isArray(value)) {
|
|
794
804
|
const flat = value.flat(Infinity);
|
|
@@ -1018,4 +1028,4 @@ function arrayAssignmentNode(strandsContext, bufferNode, indexNode, valueNode) {
|
|
|
1018
1028
|
return { id: assignmentID };
|
|
1019
1029
|
}
|
|
1020
1030
|
|
|
1021
|
-
export { StrandsNode as S,
|
|
1031
|
+
export { StrandsNode as S, structInstanceNode as a, structConstructorNode as b, createStrandsNode as c, binaryOpNode as d, statementNode as e, functionCallNode as f, constructTypeFromIDs as g, castToFloat as h, swizzleNode as i, swizzleTrap as j, arrayAccessNode as k, createStructArrayElementProxy as l, memberAccessNode as m, arrayAssignmentNode as n, primitiveConstructorNode as p, scalarLiteralNode as s, unaryOpNode as u, variableNode as v };
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { P as P2D, ad as WEBGL, B as BLEND, an as _DEFAULT_FILL, ao as _DEFAULT_STROKE, u as ROUND, b as REMOVE, S as SUBTRACT, D as DARKEST, L as LIGHTEST, ap as DIFFERENCE, M as MULTIPLY, E as EXCLUSION, a as SCREEN, R as REPLACE, aq as OVERLAY, ar as HARD_LIGHT, as as SOFT_LIGHT, at as DODGE, au as BURN, A as ADD,
|
|
1
|
+
import { P as P2D, ad as WEBGL, B as BLEND, an as _DEFAULT_FILL, ao as _DEFAULT_STROKE, u as ROUND, b as REMOVE, S as SUBTRACT, D as DARKEST, L as LIGHTEST, ap as DIFFERENCE, M as MULTIPLY, E as EXCLUSION, a as SCREEN, R as REPLACE, aq as OVERLAY, ar as HARD_LIGHT, as as SOFT_LIGHT, at as DODGE, au as BURN, A as ADD, v as SQUARE, w as PROJECT, x as BEVEL, y as MITER, aa as RIGHT, t as CENTER, av as LEFT, aw as BOTTOM, ax as BASELINE, ay as TOP, az as VERSION, am as constants } from './constants-DkQDfqzw.js';
|
|
2
2
|
import transform from './core/transform.js';
|
|
3
3
|
import structure from './core/structure.js';
|
|
4
4
|
import environment from './core/environment.js';
|
|
5
|
-
import { G as Graphics, k as rendering, n as graphics } from './rendering-
|
|
6
|
-
import { R as Renderer, I as Image, r as renderer } from './p5.Renderer-
|
|
5
|
+
import { G as Graphics, k as rendering, n as graphics } from './rendering-BowMW0pZ.js';
|
|
6
|
+
import { R as Renderer, I as Image, r as renderer } from './p5.Renderer-Bf-YLpi6.js';
|
|
7
7
|
import { Element } from './dom/p5.Element.js';
|
|
8
8
|
import { MediaElement } from './dom/p5.MediaElement.js';
|
|
9
|
-
import { b as
|
|
9
|
+
import { b as RGBP3 } from './creating_reading-Dyt2y-6S.js';
|
|
10
10
|
import FilterRenderer2D from './image/filterRenderer2D.js';
|
|
11
11
|
import './math/p5.Matrix.js';
|
|
12
12
|
import { PrimitiveToPath2DConverter } from './shape/custom_shapes.js';
|
|
13
13
|
import { DefaultFill, textCoreConstants } from './type/textCore.js';
|
|
14
14
|
import { Matrix } from './math/Matrices/Matrix.js';
|
|
15
15
|
|
|
16
|
-
const styleEmpty = 'rgba(0,0,0,0)';
|
|
17
|
-
|
|
18
16
|
class Renderer2D extends Renderer {
|
|
19
17
|
constructor(pInst, w, h, isMainCanvas, elt, attributes = {}) {
|
|
20
18
|
super(pInst, w, h, isMainCanvas);
|
|
@@ -69,7 +67,7 @@ class Renderer2D extends Renderer {
|
|
|
69
67
|
// Get and store drawing context
|
|
70
68
|
this.drawingContext = this.canvas.getContext('2d', attributes);
|
|
71
69
|
if(attributes.colorSpace === 'display-p3'){
|
|
72
|
-
this.states.colorMode =
|
|
70
|
+
this.states.colorMode = RGBP3;
|
|
73
71
|
}
|
|
74
72
|
this.scale(this._pixelDensity, this._pixelDensity);
|
|
75
73
|
|
|
@@ -446,10 +444,12 @@ class Renderer2D extends Renderer {
|
|
|
446
444
|
ctx.save();
|
|
447
445
|
ctx.clearRect(0, 0, img.canvas.width, img.canvas.height);
|
|
448
446
|
|
|
447
|
+
const tint = this.states.tint._getRGBA([255, 255, 255, 255]);
|
|
448
|
+
|
|
449
449
|
if (
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
450
|
+
tint[0] < 255 ||
|
|
451
|
+
tint[1] < 255 ||
|
|
452
|
+
tint[2] < 255
|
|
453
453
|
) {
|
|
454
454
|
// Color tint: we need to use the multiply blend mode to change the colors.
|
|
455
455
|
// However, the canvas implementation of this destroys the alpha channel of
|
|
@@ -472,16 +472,16 @@ class Renderer2D extends Renderer {
|
|
|
472
472
|
|
|
473
473
|
// Apply color tint
|
|
474
474
|
ctx.globalCompositeOperation = 'multiply';
|
|
475
|
-
ctx.fillStyle = `rgb(${
|
|
475
|
+
ctx.fillStyle = `rgb(${tint.slice(0, 3).join(', ')})`;
|
|
476
476
|
ctx.fillRect(0, 0, img.canvas.width, img.canvas.height);
|
|
477
477
|
|
|
478
478
|
// Replace the alpha channel with the original alpha * the alpha tint
|
|
479
479
|
ctx.globalCompositeOperation = 'destination-in';
|
|
480
|
-
ctx.globalAlpha =
|
|
480
|
+
ctx.globalAlpha = tint[3] / 255;
|
|
481
481
|
ctx.drawImage(img.canvas, 0, 0);
|
|
482
482
|
} else {
|
|
483
483
|
// If we only need to change the alpha, we can skip all the extra work!
|
|
484
|
-
ctx.globalAlpha =
|
|
484
|
+
ctx.globalAlpha = tint[3] / 255;
|
|
485
485
|
ctx.drawImage(img.canvas, 0, 0);
|
|
486
486
|
}
|
|
487
487
|
|
|
@@ -707,96 +707,32 @@ class Renderer2D extends Renderer {
|
|
|
707
707
|
}
|
|
708
708
|
|
|
709
709
|
line(x1, y1, x2, y2) {
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
}
|
|
716
|
-
if (this._clipping) {
|
|
717
|
-
const tempPath = new Path2D();
|
|
718
|
-
tempPath.moveTo(x1, y1);
|
|
719
|
-
tempPath.lineTo(x2, y2);
|
|
720
|
-
const currentTransform = this.drawingContext.getTransform();
|
|
721
|
-
const clipBaseTransform = this._clipBaseTransform.inverse();
|
|
722
|
-
const relativeTransform = clipBaseTransform.multiply(currentTransform);
|
|
723
|
-
this.clipPath.addPath(tempPath, relativeTransform);
|
|
724
|
-
return this;
|
|
725
|
-
}
|
|
726
|
-
ctx.beginPath();
|
|
727
|
-
ctx.moveTo(x1, y1);
|
|
728
|
-
ctx.lineTo(x2, y2);
|
|
729
|
-
ctx.stroke();
|
|
710
|
+
const shape = new p5.Shape({ position: new p5.Vector(0, 0) });
|
|
711
|
+
shape.beginShape();
|
|
712
|
+
shape.line(x1, y1, x2, y2);
|
|
713
|
+
shape.endShape();
|
|
714
|
+
this.drawShape(shape);
|
|
730
715
|
|
|
731
716
|
return this;
|
|
732
717
|
}
|
|
733
718
|
|
|
734
719
|
point(x, y) {
|
|
735
|
-
const
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
const s = this._getStroke();
|
|
742
|
-
const f = this._getFill();
|
|
743
|
-
if (this._clipping) {
|
|
744
|
-
const tempPath = new Path2D();
|
|
745
|
-
const drawingContextWidth = this.drawingContext.lineWidth;
|
|
746
|
-
tempPath.arc(x, y, drawingContextWidth / 2, 0, TWO_PI);
|
|
747
|
-
const currentTransform = this.drawingContext.getTransform();
|
|
748
|
-
const clipBaseTransform = this._clipBaseTransform.inverse();
|
|
749
|
-
const relativeTransform = clipBaseTransform.multiply(currentTransform);
|
|
750
|
-
this.clipPath.addPath(tempPath, relativeTransform);
|
|
751
|
-
return this;
|
|
752
|
-
}
|
|
753
|
-
this._setFill(s);
|
|
754
|
-
ctx.beginPath();
|
|
755
|
-
ctx.arc(x, y, ctx.lineWidth / 2, 0, TWO_PI, false);
|
|
756
|
-
ctx.fill();
|
|
757
|
-
this._setFill(f);
|
|
720
|
+
const shape = new p5.Shape({ position: new p5.Vector(0, 0) });
|
|
721
|
+
shape.beginShape();
|
|
722
|
+
shape.point(x, y);
|
|
723
|
+
shape.endShape();
|
|
724
|
+
this.drawShape(shape);
|
|
758
725
|
|
|
759
726
|
return this;
|
|
760
727
|
}
|
|
761
728
|
|
|
762
729
|
quad(x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
763
|
-
const
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
}
|
|
770
|
-
} else if (!doFill && doStroke) {
|
|
771
|
-
if (this._getStroke() === styleEmpty) {
|
|
772
|
-
return this;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
if (this._clipping) {
|
|
776
|
-
const tempPath = new Path2D();
|
|
777
|
-
tempPath.moveTo(x1, y1);
|
|
778
|
-
tempPath.lineTo(x2, y2);
|
|
779
|
-
tempPath.lineTo(x3, y3);
|
|
780
|
-
tempPath.lineTo(x4, y4);
|
|
781
|
-
tempPath.closePath();
|
|
782
|
-
const currentTransform = this.drawingContext.getTransform();
|
|
783
|
-
const clipBaseTransform = this._clipBaseTransform.inverse();
|
|
784
|
-
const relativeTransform = clipBaseTransform.multiply(currentTransform);
|
|
785
|
-
this.clipPath.addPath(tempPath, relativeTransform);
|
|
786
|
-
return this;
|
|
787
|
-
}
|
|
788
|
-
ctx.beginPath();
|
|
789
|
-
ctx.moveTo(x1, y1);
|
|
790
|
-
ctx.lineTo(x2, y2);
|
|
791
|
-
ctx.lineTo(x3, y3);
|
|
792
|
-
ctx.lineTo(x4, y4);
|
|
793
|
-
ctx.closePath();
|
|
794
|
-
if (doFill) {
|
|
795
|
-
ctx.fill();
|
|
796
|
-
}
|
|
797
|
-
if (doStroke) {
|
|
798
|
-
ctx.stroke();
|
|
799
|
-
}
|
|
730
|
+
const shape = new p5.Shape({ position: new p5.Vector(0, 0) });
|
|
731
|
+
shape.beginShape();
|
|
732
|
+
shape.quad(x1, y1, x2, y2, x3, y3, x4, y4);
|
|
733
|
+
shape.endShape();
|
|
734
|
+
this.drawShape(shape);
|
|
735
|
+
|
|
800
736
|
return this;
|
|
801
737
|
}
|
|
802
738
|
|
|
@@ -809,134 +745,29 @@ class Renderer2D extends Renderer {
|
|
|
809
745
|
let tr = args[5];
|
|
810
746
|
let br = args[6];
|
|
811
747
|
let bl = args[7];
|
|
812
|
-
const ctx = this.drawingContext;
|
|
813
|
-
const doFill = !!this.states.fillColor,
|
|
814
|
-
doStroke = this.states.strokeColor;
|
|
815
|
-
if (doFill && !doStroke) {
|
|
816
|
-
if (this._getFill() === styleEmpty) {
|
|
817
|
-
return this;
|
|
818
|
-
}
|
|
819
|
-
} else if (!doFill && doStroke) {
|
|
820
|
-
if (this._getStroke() === styleEmpty) {
|
|
821
|
-
return this;
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
if (this._clipping) {
|
|
825
|
-
const tempPath = new Path2D();
|
|
826
|
-
if (typeof tl === 'undefined') {
|
|
827
|
-
tempPath.rect(x, y, w, h);
|
|
828
|
-
} else {
|
|
829
|
-
tempPath.roundRect(x, y, w, h, [tl, tr, br, bl]);
|
|
830
|
-
}
|
|
831
|
-
const currentTransform = this.drawingContext.getTransform();
|
|
832
|
-
const clipBaseTransform = this._clipBaseTransform.inverse();
|
|
833
|
-
const relativeTransform = clipBaseTransform.multiply(currentTransform);
|
|
834
|
-
this.clipPath.addPath(tempPath, relativeTransform);
|
|
835
|
-
return this;
|
|
836
|
-
}
|
|
837
|
-
ctx.beginPath();
|
|
838
|
-
if (typeof tl === 'undefined') {
|
|
839
|
-
// No rounded corners
|
|
840
|
-
ctx.rect(x, y, w, h);
|
|
841
|
-
} else {
|
|
842
|
-
// At least one rounded corner
|
|
843
|
-
// Set defaults when not specified
|
|
844
|
-
if (typeof tr === 'undefined') {
|
|
845
|
-
tr = tl;
|
|
846
|
-
}
|
|
847
|
-
if (typeof br === 'undefined') {
|
|
848
|
-
br = tr;
|
|
849
|
-
}
|
|
850
|
-
if (typeof bl === 'undefined') {
|
|
851
|
-
bl = br;
|
|
852
|
-
}
|
|
853
748
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
// Clip radii
|
|
861
|
-
if (absW < 2 * tl) {
|
|
862
|
-
tl = hw;
|
|
863
|
-
}
|
|
864
|
-
if (absH < 2 * tl) {
|
|
865
|
-
tl = hh;
|
|
866
|
-
}
|
|
867
|
-
if (absW < 2 * tr) {
|
|
868
|
-
tr = hw;
|
|
869
|
-
}
|
|
870
|
-
if (absH < 2 * tr) {
|
|
871
|
-
tr = hh;
|
|
872
|
-
}
|
|
873
|
-
if (absW < 2 * br) {
|
|
874
|
-
br = hw;
|
|
875
|
-
}
|
|
876
|
-
if (absH < 2 * br) {
|
|
877
|
-
br = hh;
|
|
878
|
-
}
|
|
879
|
-
if (absW < 2 * bl) {
|
|
880
|
-
bl = hw;
|
|
881
|
-
}
|
|
882
|
-
if (absH < 2 * bl) {
|
|
883
|
-
bl = hh;
|
|
884
|
-
}
|
|
749
|
+
const shape = new p5.Shape({ position: new p5.Vector(0, 0) });
|
|
750
|
+
shape.beginShape();
|
|
751
|
+
shape.rectPrimitive(x, y, w, h, tl, tr, br, bl);
|
|
752
|
+
shape.endShape();
|
|
753
|
+
this.drawShape(shape);
|
|
885
754
|
|
|
886
|
-
ctx.roundRect(x, y, w, h, [tl, tr, br, bl]);
|
|
887
|
-
}
|
|
888
|
-
if (doFill) {
|
|
889
|
-
ctx.fill();
|
|
890
|
-
}
|
|
891
|
-
if (doStroke) {
|
|
892
|
-
ctx.stroke();
|
|
893
|
-
}
|
|
894
755
|
return this;
|
|
895
756
|
}
|
|
896
757
|
|
|
897
|
-
|
|
898
758
|
triangle(args) {
|
|
899
|
-
const ctx = this.drawingContext;
|
|
900
|
-
const doFill = !!this.states.fillColor,
|
|
901
|
-
doStroke = this.states.strokeColor;
|
|
902
759
|
const x1 = args[0],
|
|
903
760
|
y1 = args[1];
|
|
904
761
|
const x2 = args[2],
|
|
905
762
|
y2 = args[3];
|
|
906
763
|
const x3 = args[4],
|
|
907
764
|
y3 = args[5];
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
return this;
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
if (this._clipping) {
|
|
918
|
-
const tempPath = new Path2D();
|
|
919
|
-
tempPath.moveTo(x1, y1);
|
|
920
|
-
tempPath.lineTo(x2, y2);
|
|
921
|
-
tempPath.lineTo(x3, y3);
|
|
922
|
-
tempPath.closePath();
|
|
923
|
-
const currentTransform = this.drawingContext.getTransform();
|
|
924
|
-
const clipBaseTransform = this._clipBaseTransform.inverse();
|
|
925
|
-
const relativeTransform = clipBaseTransform.multiply(currentTransform);
|
|
926
|
-
this.clipPath.addPath(tempPath, relativeTransform);
|
|
927
|
-
return this;
|
|
928
|
-
}
|
|
929
|
-
ctx.beginPath();
|
|
930
|
-
ctx.moveTo(x1, y1);
|
|
931
|
-
ctx.lineTo(x2, y2);
|
|
932
|
-
ctx.lineTo(x3, y3);
|
|
933
|
-
ctx.closePath();
|
|
934
|
-
if (doFill) {
|
|
935
|
-
ctx.fill();
|
|
936
|
-
}
|
|
937
|
-
if (doStroke) {
|
|
938
|
-
ctx.stroke();
|
|
939
|
-
}
|
|
765
|
+
|
|
766
|
+
const shape = new p5.Shape({ position: new p5.Vector(0, 0) });
|
|
767
|
+
shape.beginShape();
|
|
768
|
+
shape.triangle(x1, y1, x2, y2, x3, y3);
|
|
769
|
+
shape.endShape();
|
|
770
|
+
this.drawShape(shape);
|
|
940
771
|
|
|
941
772
|
return this;
|
|
942
773
|
}
|
|
@@ -1207,7 +1038,7 @@ function renderer2D(p5, fn){
|
|
|
1207
1038
|
*/
|
|
1208
1039
|
p5.Renderer2D = Renderer2D;
|
|
1209
1040
|
p5.renderers[P2D] = Renderer2D;
|
|
1210
|
-
p5.renderers['p2d-
|
|
1041
|
+
p5.renderers['p2d-p3'] = new Proxy(Renderer2D, {
|
|
1211
1042
|
construct(target, [pInst, w, h, isMainCanvas, elt]){
|
|
1212
1043
|
return new target(pInst, w, h, isMainCanvas, elt, { colorSpace: 'display-p3' });
|
|
1213
1044
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import nj from '@d4c/numjs/build/module/numjs.min.js';
|
|
2
2
|
import { Vector } from '../p5.Vector.js';
|
|
3
3
|
import { MatrixInterface } from './MatrixInterface.js';
|
|
4
|
-
import '../../constants-
|
|
4
|
+
import '../../constants-DkQDfqzw.js';
|
|
5
5
|
|
|
6
6
|
let isMatrixArray = x => Array.isArray(x);
|
|
7
7
|
if (typeof Float32Array !== 'undefined') {
|