p5 2.3.0 → 2.3.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +3 -11
  2. package/dist/accessibility/color_namer.js +7 -7
  3. package/dist/accessibility/index.js +7 -7
  4. package/dist/app.js +7 -7
  5. package/dist/app.node.js +7 -7
  6. package/dist/color/color_conversion.js +7 -7
  7. package/dist/color/creating_reading.js +1 -1
  8. package/dist/color/index.js +2 -2
  9. package/dist/color/p5.Color.js +1 -1
  10. package/dist/color/setting.js +2 -2
  11. package/dist/{constants-Dv6ZqA6s.js → constants-Bx3_xAam.js} +1 -1
  12. package/dist/core/constants.js +1 -1
  13. package/dist/core/environment.js +1 -1
  14. package/dist/core/filterShaders.js +1 -1
  15. package/dist/core/friendly_errors/fes_core.js +1 -1
  16. package/dist/core/friendly_errors/file_errors.js +1 -1
  17. package/dist/core/friendly_errors/index.js +1 -1
  18. package/dist/core/friendly_errors/param_validator.js +1 -1
  19. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  20. package/dist/core/helpers.js +1 -1
  21. package/dist/core/init.js +7 -7
  22. package/dist/core/internationalization.js +1 -1
  23. package/dist/core/legacy.js +7 -7
  24. package/dist/core/main.js +7 -7
  25. package/dist/core/p5.Graphics.js +4 -4
  26. package/dist/core/p5.Renderer.js +3 -3
  27. package/dist/core/p5.Renderer2D.js +7 -7
  28. package/dist/core/p5.Renderer3D.js +4 -4
  29. package/dist/core/rendering.js +4 -4
  30. package/dist/{creating_reading-DLkHH80h.js → creating_reading-YUSK33h8.js} +8 -0
  31. package/dist/dom/dom.js +2 -2
  32. package/dist/dom/index.js +2 -2
  33. package/dist/dom/p5.Element.js +2 -2
  34. package/dist/dom/p5.MediaElement.js +2 -2
  35. package/dist/events/pointer.js +15 -0
  36. package/dist/image/const.js +1 -1
  37. package/dist/image/filterRenderer2D.js +6 -6
  38. package/dist/image/image.js +4 -4
  39. package/dist/image/index.js +4 -4
  40. package/dist/image/loading_displaying.js +4 -4
  41. package/dist/image/p5.Image.js +3 -3
  42. package/dist/io/files.js +4 -4
  43. package/dist/io/index.js +4 -4
  44. package/dist/{ir_builders-C8mrXj5z.js → ir_builders-CMXkjMoV.js} +34 -24
  45. package/dist/{main-BR2ALC_6.js → main-BpW7VbDr.js} +39 -208
  46. package/dist/math/Matrices/Matrix.js +1 -1
  47. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  48. package/dist/math/calculation.js +669 -84
  49. package/dist/math/index.js +1 -1
  50. package/dist/math/p5.Matrix.js +1 -1
  51. package/dist/math/p5.Vector.js +9 -1
  52. package/dist/math/patch-vector.js +3 -1
  53. package/dist/math/trigonometry.js +399 -48
  54. package/dist/{p5.Renderer-XOvhEbJn.js → p5.Renderer-op0Y1WO6.js} +2 -2
  55. package/dist/{rendering-C5lX6zKm.js → rendering-SZ71KIDM.js} +24 -9
  56. package/dist/shape/2d_primitives.js +1 -1
  57. package/dist/shape/attributes.js +4 -3
  58. package/dist/shape/custom_shapes.js +205 -3
  59. package/dist/shape/index.js +2 -2
  60. package/dist/strands/ir_builders.js +1 -1
  61. package/dist/strands/p5.strands.js +26 -9
  62. package/dist/strands/strands_FES.js +8 -1
  63. package/dist/strands/strands_api.js +316 -21
  64. package/dist/strands/strands_conditionals.js +1 -1
  65. package/dist/strands/strands_for.js +1 -1
  66. package/dist/strands/strands_node.js +1 -1
  67. package/dist/strands/strands_ternary.js +1 -1
  68. package/dist/{strands_glslBackend-D6G3UyCs.js → strands_glslBackend-DMhOnoGl.js} +2 -2
  69. package/dist/type/index.js +3 -3
  70. package/dist/type/p5.Font.js +13 -4
  71. package/dist/type/textCore.js +3 -3
  72. package/dist/webgl/3d_primitives.js +4 -4
  73. package/dist/webgl/GeometryBuilder.js +1 -1
  74. package/dist/webgl/ShapeBuilder.js +1 -1
  75. package/dist/webgl/enums.js +1 -1
  76. package/dist/webgl/index.js +6 -6
  77. package/dist/webgl/interaction.js +1 -1
  78. package/dist/webgl/light.js +4 -4
  79. package/dist/webgl/loading.js +4 -4
  80. package/dist/webgl/material.js +4 -4
  81. package/dist/webgl/p5.Camera.js +4 -4
  82. package/dist/webgl/p5.Framebuffer.js +4 -4
  83. package/dist/webgl/p5.Geometry.js +1 -1
  84. package/dist/webgl/p5.Quat.js +1 -1
  85. package/dist/webgl/p5.RendererGL.js +6 -6
  86. package/dist/webgl/p5.Shader.js +5 -1
  87. package/dist/webgl/p5.Texture.js +4 -4
  88. package/dist/webgl/strands_glslBackend.js +2 -2
  89. package/dist/webgl/text.js +4 -4
  90. package/dist/webgl/utils.js +4 -4
  91. package/dist/webgpu/index.js +2 -2
  92. package/dist/webgpu/p5.RendererWebGPU.js +2 -2
  93. package/dist/webgpu/strands_wgslBackend.js +2 -2
  94. package/lib/p5.esm.js +1765 -405
  95. package/lib/p5.esm.min.js +1 -1
  96. package/lib/p5.js +1765 -405
  97. package/lib/p5.min.js +1 -1
  98. package/lib/p5.webgpu.esm.js +34 -3
  99. package/lib/p5.webgpu.js +34 -3
  100. package/lib/p5.webgpu.min.js +1 -1
  101. package/package.json +1 -1
  102. package/types/global.d.ts +5539 -2604
  103. package/types/p5.d.ts +2917 -1432
@@ -1,8 +1,8 @@
1
- import { n as CORNER, r as CORNERS, t as CENTER, aB as COVER, aC as CONTAIN, aa as RIGHT, aw as BOTTOM, B as BLEND, aD as FILL, ae as IMAGE, C as CLAMP, u as ROUND, Q as LINES, K as POINTS, c as TRIANGLES, ac as BLUR, D as DARKEST, L as LIGHTEST, A as ADD, S as SUBTRACT, a as SCREEN, E as EXCLUSION, R as REPLACE, M as MULTIPLY, b as REMOVE, au as BURN, aq as OVERLAY, ar as HARD_LIGHT, as as SOFT_LIGHT, at as DODGE, d as UNSIGNED_INT, U as UNSIGNED_BYTE, av as LEFT, ax as BASELINE, ay as TOP, aE as SIMPLE, aF as FULL, o as TWO_PI, O as OPEN, a1 as NORMAL, J as CLOSE, a0 as PIE, $ as CHORD, a7 as TEXTURE, P as P2D, g as LINEAR, ab as WEBGL2, N as NEAREST, aG as LINEAR_MIPMAP, f as REPEAT, e as MIRROR, F as FLOAT, ad as WEBGL, H as HALF_FLOAT, W as WEBGPU } from './constants-Dv6ZqA6s.js';
2
- import { C as Color, c as creatingReading, h as RGBA, R as RGB } from './creating_reading-DLkHH80h.js';
1
+ import { n as CORNER, r as CORNERS, t as CENTER, aB as COVER, aC as CONTAIN, aa as RIGHT, aw as BOTTOM, B as BLEND, aD as FILL, ae as IMAGE, C as CLAMP, u as ROUND, Q as LINES, K as POINTS, c as TRIANGLES, ac as BLUR, D as DARKEST, L as LIGHTEST, A as ADD, S as SUBTRACT, a as SCREEN, E as EXCLUSION, R as REPLACE, M as MULTIPLY, b as REMOVE, au as BURN, aq as OVERLAY, ar as HARD_LIGHT, as as SOFT_LIGHT, at as DODGE, d as UNSIGNED_INT, U as UNSIGNED_BYTE, av as LEFT, ax as BASELINE, ay as TOP, aE as SIMPLE, aF as FULL, o as TWO_PI, O as OPEN, a1 as NORMAL, J as CLOSE, a0 as PIE, $ as CHORD, a7 as TEXTURE, P as P2D, g as LINEAR, ab as WEBGL2, N as NEAREST, aG as LINEAR_MIPMAP, f as REPEAT, e as MIRROR, F as FLOAT, ad as WEBGL, H as HALF_FLOAT, W as WEBGPU } from './constants-Bx3_xAam.js';
2
+ import { C as Color, c as creatingReading, h as RGBA, R as RGB } from './creating_reading-YUSK33h8.js';
3
3
  import './strands/ir_types.js';
4
4
  import { Element } from './dom/p5.Element.js';
5
- import { R as Renderer, I as Image } from './p5.Renderer-XOvhEbJn.js';
5
+ import { R as Renderer, I as Image$1 } from './p5.Renderer-op0Y1WO6.js';
6
6
  import { MediaElement } from './dom/p5.MediaElement.js';
7
7
  import primitives from './shape/2d_primitives.js';
8
8
  import attributes from './shape/attributes.js';
@@ -2973,8 +2973,19 @@ function loadingDisplaying(p5, fn){
2973
2973
 
2974
2974
  } else {
2975
2975
  // Non-GIF Section
2976
- const blob = new Blob([data]);
2977
- const img = await createImageBitmap(blob);
2976
+ const img = await new Promise((resolve, reject) => {
2977
+ const img = new Image();
2978
+ const blob = new Blob([data], { type: contentType });
2979
+ const url = URL.createObjectURL(blob);
2980
+
2981
+ img.onerror = e => reject(e);
2982
+ img.onload = () => {
2983
+ URL.revokeObjectURL(url);
2984
+ resolve(img);
2985
+ };
2986
+
2987
+ img.src = url;
2988
+ });
2978
2989
 
2979
2990
  pImg.width = pImg.canvas.width = img.width;
2980
2991
  pImg.height = pImg.canvas.height = img.height;
@@ -9594,7 +9605,11 @@ class Renderer3D extends Renderer {
9594
9605
  // the next time a shader is used. However, the texture() function
9595
9606
  // works differently and is global p5 state. If the p5 state has
9596
9607
  // been cleared, we also need to clear the value in uSampler to match.
9597
- fillShader.setUniform("uSampler", this.states._tex || empty);
9608
+ this._settingFillUniforms = true;
9609
+ if (this.states._tex || !fillShader._userSetSampler) {
9610
+ fillShader.setUniform("uSampler", this.states._tex || empty);
9611
+ }
9612
+ this._settingFillUniforms = false;
9598
9613
  fillShader.setUniform(
9599
9614
  "uTint",
9600
9615
  this.states.tint?._getRGBA([255, 255, 255, 255]) ?? [255, 255, 255, 255]
@@ -9717,7 +9732,7 @@ class Renderer3D extends Renderer {
9717
9732
  _getEmptyTexture() {
9718
9733
  if (!this._emptyTexture) {
9719
9734
  // a plain white texture RGBA, full alpha, single pixel.
9720
- const im = new Image(1, 1);
9735
+ const im = new Image$1(1, 1);
9721
9736
  im.set(0, 0, 255);
9722
9737
  this._emptyTexture = new Texture(this, im);
9723
9738
  }
@@ -17172,7 +17187,7 @@ function material(p5, fn) {
17172
17187
  * // Replace alpha in the color with dithering by
17173
17188
  * // randomly setting pixel colors to 0 based on opacity
17174
17189
  * let a = 1;
17175
- * if (noise(pixelInputs.position.xy) > pixelInputs.color.a) {
17190
+ * if (random() > pixelInputs.color.a) {
17176
17191
  * a = 0;
17177
17192
  * }
17178
17193
  * pixelInputs.color.a = a;
@@ -19621,7 +19636,7 @@ class Texture {
19621
19636
  _detectSourceType() {
19622
19637
  const obj = this.src;
19623
19638
  this.isFramebufferTexture = obj instanceof FramebufferTexture;
19624
- this.isSrcP5Image = obj instanceof Image;
19639
+ this.isSrcP5Image = obj instanceof Image$1;
19625
19640
  this.isSrcP5Graphics = obj instanceof Graphics;
19626
19641
  this.isSrcP5Renderer = obj instanceof Renderer;
19627
19642
  this.isImageData = typeof ImageData !== 'undefined' && obj instanceof ImageData;
@@ -1,4 +1,4 @@
1
- import { n as CORNER, o as TWO_PI, p as HALF_PI, q as PI } from '../constants-Dv6ZqA6s.js';
1
+ import { n as CORNER, o as TWO_PI, p as HALF_PI, q as PI } from '../constants-Bx3_xAam.js';
2
2
  import canvas from '../core/helpers.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { n as CORNER, r as CORNERS, s as RADIUS, t as CENTER, u as ROUND, v as SQUARE, w as PROJECT, x as BEVEL, y as MITER } from '../constants-Dv6ZqA6s.js';
1
+ import { n as CORNER, r as CORNERS, s as RADIUS, t as CENTER, u as ROUND, v as SQUARE, w as PROJECT, x as BEVEL, y as MITER } from '../constants-Bx3_xAam.js';
2
2
 
3
3
  /**
4
4
  * @module Shape
@@ -514,8 +514,9 @@ function attributes(p5, fn){
514
514
  * Sets the width of the stroke used for points, lines, and the outlines of
515
515
  * shapes.
516
516
  *
517
- * Note: `strokeWeight()` is affected by transformations, especially calls to
518
- * <a href="#/p5/scale">scale()</a>.
517
+ * Note: In 2D mode, `strokeWeight()` is affected by transformations,
518
+ * especially calls to <a href="#/p5/scale">scale()</a>. It isn't affected by
519
+ * transformations in WebGL and WebGPU modes.
519
520
  *
520
521
  * Calling `strokeWeight()` without an argument returns the current stroke weight as a number.
521
522
  *
@@ -1,6 +1,6 @@
1
- import { C as Color } from '../creating_reading-DLkHH80h.js';
1
+ import { C as Color } from '../creating_reading-YUSK33h8.js';
2
2
  import { Vector } from '../math/p5.Vector.js';
3
- import { I as INCLUDE, z as PATH, G as EMPTY_PATH, O as OPEN, J as CLOSE, K as POINTS, Q as LINES, c as TRIANGLES, V as QUADS, X as TRIANGLE_FAN, T as TRIANGLE_STRIP, Y as QUAD_STRIP, Z as EXCLUDE, _ as JOIN, $ as CHORD, a0 as PIE } from '../constants-Dv6ZqA6s.js';
3
+ import { I as INCLUDE, z as PATH, G as EMPTY_PATH, O as OPEN, J as CLOSE, K as POINTS, Q as LINES, c as TRIANGLES, V as QUADS, X as TRIANGLE_FAN, T as TRIANGLE_STRIP, Y as QUAD_STRIP, Z as EXCLUDE, _ as JOIN, $ as CHORD, a0 as PIE } from '../constants-Bx3_xAam.js';
4
4
  import 'colorjs.io/fn';
5
5
  import '../color/color_spaces/hsb.js';
6
6
 
@@ -545,6 +545,47 @@ class EllipsePrimitive extends ShapePrimitive {
545
545
  }
546
546
  }
547
547
 
548
+ class RectPrimitive extends ShapePrimitive {
549
+ #x;
550
+ #y;
551
+ #w;
552
+ #h;
553
+ #tl;
554
+ #tr;
555
+ #br;
556
+ #bl;
557
+ #vertexCapacity = 1;
558
+
559
+ constructor(startVertex, x, y, w, h, tl, tr, br, bl) {
560
+ super(startVertex);
561
+ this.#x = x;
562
+ this.#y = y;
563
+ this.#w = w;
564
+ this.#h = h;
565
+ this.#tl = tl;
566
+ this.#tr = tr;
567
+ this.#br = br;
568
+ this.#bl = bl;
569
+ }
570
+
571
+ get x() { return this.#x; }
572
+ get y() { return this.#y; }
573
+ get w() { return this.#w; }
574
+ get h() { return this.#h; }
575
+ get tl() { return this.#tl; }
576
+ get tr() { return this.#tr; }
577
+ get br() { return this.#br; }
578
+ get bl() { return this.#bl; }
579
+
580
+ get vertexCapacity() {
581
+ return this.#vertexCapacity;
582
+ }
583
+
584
+ accept(visitor) {
585
+ visitor.visitRectPrimitive(this);
586
+ }
587
+ }
588
+
548
589
  // ---- TESSELLATION PRIMITIVES ----
549
590
 
550
591
  class TriangleFan extends ShapePrimitive {
@@ -1027,6 +1068,42 @@ class Shape {
1027
1068
  return primitive.addToShape(this);
1028
1069
  }
1029
1070
 
1071
+ rectPrimitive(x, y, w, h, tl, tr, br, bl) {
1072
+ const startVertex = this.#createVertex(new Vector(x, y));
1073
+ const primitive = new RectPrimitive(startVertex, x, y, w, h, tl, tr, br, bl);
1074
+ return primitive.addToShape(this);
1075
+ }
1076
+
1077
+ point(x, y) {
1078
+ const v0 = this.#createVertex(new Vector(x, y));
1079
+ const primitive = new Point(v0);
1080
+ return primitive.addToShape(this);
1081
+ }
1082
+
1083
+ line(x1, y1, x2, y2) {
1084
+ const v0 = this.#createVertex(new Vector(x1, y1));
1085
+ const v1 = this.#createVertex(new Vector(x2, y2));
1086
+ const primitive = new Line(v0, v1);
1087
+ return primitive.addToShape(this);
1088
+ }
1089
+
1090
+ triangle(x1, y1, x2, y2, x3, y3) {
1091
+ const v0 = this.#createVertex(new Vector(x1, y1));
1092
+ const v1 = this.#createVertex(new Vector(x2, y2));
1093
+ const v2 = this.#createVertex(new Vector(x3, y3));
1094
+ const primitive = new Triangle(v0, v1, v2);
1095
+ return primitive.addToShape(this);
1096
+ }
1097
+
1098
+ quad(x1, y1, x2, y2, x3, y3, x4, y4) {
1099
+ const v0 = this.#createVertex(new Vector(x1, y1));
1100
+ const v1 = this.#createVertex(new Vector(x2, y2));
1101
+ const v2 = this.#createVertex(new Vector(x3, y3));
1102
+ const v3 = this.#createVertex(new Vector(x4, y4));
1103
+ const primitive = new Quad(v0, v1, v2, v3);
1104
+ return primitive.addToShape(this);
1105
+ }
1106
+
1030
1107
  beginContour(shapeKind = PATH) {
1031
1108
  if (this.at(-1)?.kind === EMPTY_PATH) {
1032
1109
  this.contours.pop();
@@ -1131,6 +1208,9 @@ class PrimitiveVisitor {
1131
1208
  visitEllipsePrimitive(ellipse) {
1132
1209
  throw new Error('Method visitEllipsePrimitive() has not been implemented.');
1133
1210
  }
1211
+ visitRectPrimitive(rect) {
1212
+ throw new Error('Method visitRectPrimitive() has not been implemented.');
1213
+ }
1134
1214
 
1135
1215
  // isolated primitives
1136
1216
  visitPoint(point) {
@@ -1334,6 +1414,62 @@ class PrimitiveToPath2DConverter extends PrimitiveVisitor {
1334
1414
  this.path.moveTo(centerX + radiusX, centerY);
1335
1415
  this.path.ellipse(centerX, centerY, radiusX, radiusY, 0, 0, 2 * Math.PI);
1336
1416
  }
1417
+ visitRectPrimitive(rect) {
1418
+ const x = rect.x;
1419
+ const y = rect.y;
1420
+ const w = rect.w;
1421
+ const h = rect.h;
1422
+ let tl = rect.tl;
1423
+ let tr = rect.tr;
1424
+ let br = rect.br;
1425
+ let bl = rect.bl;
1426
+
1427
+ if (typeof tl === 'undefined') {
1428
+ this.path.rect(x, y, w, h);
1429
+ } else {
1430
+ if (typeof tr === 'undefined') {
1431
+ tr = tl;
1432
+ }
1433
+ if (typeof br === 'undefined') {
1434
+ br = tr;
1435
+ }
1436
+ if (typeof bl === 'undefined') {
1437
+ bl = br;
1438
+ }
1439
+
1440
+ const absW = Math.abs(w);
1441
+ const absH = Math.abs(h);
1442
+ const hw = absW / 2;
1443
+ const hh = absH / 2;
1444
+
1445
+ if (absW < 2 * tl) {
1446
+ tl = hw;
1447
+ }
1448
+ if (absH < 2 * tl) {
1449
+ tl = hh;
1450
+ }
1451
+ if (absW < 2 * tr) {
1452
+ tr = hw;
1453
+ }
1454
+ if (absH < 2 * tr) {
1455
+ tr = hh;
1456
+ }
1457
+ if (absW < 2 * br) {
1458
+ br = hw;
1459
+ }
1460
+ if (absH < 2 * br) {
1461
+ br = hh;
1462
+ }
1463
+ if (absW < 2 * bl) {
1464
+ bl = hw;
1465
+ }
1466
+ if (absH < 2 * bl) {
1467
+ bl = hh;
1468
+ }
1469
+
1470
+ this.path.roundRect(x, y, w, h, [tl, tr, br, bl]);
1471
+ }
1472
+ }
1337
1473
  visitQuadStrip(quadStrip) {
1338
1474
  for (let i = 0; i < quadStrip.vertices.length - 3; i += 2) {
1339
1475
  const v0 = quadStrip.vertices[i];
@@ -1530,6 +1666,72 @@ class PrimitiveToVerticesConverter extends PrimitiveVisitor {
1530
1666
  verts.push(new Vertex(vertexProps));
1531
1667
  }
1532
1668
 
1669
+ this.contours.push(verts);
1670
+ }
1671
+ visitRectPrimitive(rect) {
1672
+ const x = rect.x;
1673
+ const y = rect.y;
1674
+ const w = rect.w;
1675
+ const h = rect.h;
1676
+ let tl = rect.tl;
1677
+ let tr = rect.tr;
1678
+ let br = rect.br;
1679
+ let bl = rect.bl;
1680
+
1681
+ const startVertex = rect.vertices[0];
1682
+ const getVertexProps = (px, py) => {
1683
+ const props = {};
1684
+ for (const [key, value] of Object.entries(startVertex)) {
1685
+ if (key === 'position') continue;
1686
+ props[key] = value;
1687
+ }
1688
+ props.position = new Vector(px, py);
1689
+ return new Vertex(props);
1690
+ };
1691
+
1692
+ const verts = [];
1693
+ if (typeof tl === 'undefined') {
1694
+ verts.push(getVertexProps(x, y));
1695
+ verts.push(getVertexProps(x + w, y));
1696
+ verts.push(getVertexProps(x + w, y + h));
1697
+ verts.push(getVertexProps(x, y + h));
1698
+ verts.push(getVertexProps(x, y));
1699
+ } else {
1700
+ if (typeof tr === 'undefined') tr = tl;
1701
+ if (typeof br === 'undefined') br = tr;
1702
+ if (typeof bl === 'undefined') bl = br;
1703
+
1704
+ const absW = Math.abs(w);
1705
+ const absH = Math.abs(h);
1706
+ const hw = absW / 2;
1707
+ const hh = absH / 2;
1708
+
1709
+ if (absW < 2 * tl) tl = hw;
1710
+ if (absH < 2 * tl) tl = hh;
1711
+ if (absW < 2 * tr) tr = hw;
1712
+ if (absH < 2 * tr) tr = hh;
1713
+ if (absW < 2 * br) br = hw;
1714
+ if (absH < 2 * br) br = hh;
1715
+ if (absW < 2 * bl) bl = hw;
1716
+ if (absH < 2 * bl) bl = hh;
1717
+
1718
+ const addCornerArc = (cx, cy, rx, ry, startAngle, endAngle) => {
1719
+ const perimeter = Math.PI / 2 * (rx + ry) / 2;
1720
+ const numPoints = Math.max(1, Math.ceil(this.curveDetail * perimeter));
1721
+ for (let i = 0; i <= numPoints; i++) {
1722
+ const angle = startAngle + (endAngle - startAngle) * (i / numPoints);
1723
+ verts.push(getVertexProps(cx + rx * Math.cos(angle), cy + ry * Math.sin(angle)));
1724
+ }
1725
+ };
1726
+
1727
+ addCornerArc(x + tl, y + tl, tl, tl, Math.PI, 1.5 * Math.PI);
1728
+ addCornerArc(x + w - tr, y + tr, tr, tr, 1.5 * Math.PI, 2 * Math.PI);
1729
+ addCornerArc(x + w - br, y + h - br, br, br, 0, 0.5 * Math.PI);
1730
+ addCornerArc(x + bl, y + h - bl, bl, bl, 0.5 * Math.PI, Math.PI);
1731
+
1732
+ verts.push(verts[0]);
1733
+ }
1734
+
1533
1735
  this.contours.push(verts);
1534
1736
  }
1535
1737
  }
@@ -3039,4 +3241,4 @@ if (typeof p5 !== 'undefined') {
3039
3241
  customShapes(p5, p5.prototype);
3040
3242
  }
3041
3243
 
3042
- export { Anchor, ArcPrimitive, BezierSegment, Contour, EllipsePrimitive, Line, LineSegment, Point, PointAtLengthGetter, PrimitiveToPath2DConverter, PrimitiveToVerticesConverter, PrimitiveVisitor, Quad, QuadStrip, Segment, Shape, ShapePrimitive, SplineSegment, Triangle, TriangleFan, TriangleStrip, Vertex, customShapes as default };
3244
+ export { Anchor, ArcPrimitive, BezierSegment, Contour, EllipsePrimitive, Line, LineSegment, Point, PointAtLengthGetter, PrimitiveToPath2DConverter, PrimitiveToVerticesConverter, PrimitiveVisitor, Quad, QuadStrip, RectPrimitive, Segment, Shape, ShapePrimitive, SplineSegment, Triangle, TriangleFan, TriangleStrip, Vertex, customShapes as default };
@@ -3,9 +3,9 @@ import attributes from './attributes.js';
3
3
  import curves from './curves.js';
4
4
  import vertex from './vertex.js';
5
5
  import customShapes from './custom_shapes.js';
6
- import '../constants-Dv6ZqA6s.js';
6
+ import '../constants-Bx3_xAam.js';
7
7
  import '../core/helpers.js';
8
- import '../creating_reading-DLkHH80h.js';
8
+ import '../creating_reading-YUSK33h8.js';
9
9
  import 'colorjs.io/fn';
10
10
  import '../color/color_spaces/hsb.js';
11
11
  import '../math/p5.Vector.js';
@@ -2,5 +2,5 @@ import './ir_dag.js';
2
2
  import './ir_cfg.js';
3
3
  import './strands_FES.js';
4
4
  import './ir_types.js';
5
- export { k as arrayAccessNode, n as arrayAssignmentNode, b as binaryOpNode, h as castToFloat, g as constructTypeFromIDs, l as createStructArrayElementProxy, f as functionCallNode, m as memberAccessNode, p as primitiveConstructorNode, s as scalarLiteralNode, a as statementNode, e as structConstructorNode, d as structInstanceNode, i as swizzleNode, j as swizzleTrap, u as unaryOpNode, v as variableNode } from '../ir_builders-C8mrXj5z.js';
5
+ export { k as arrayAccessNode, n as arrayAssignmentNode, d as binaryOpNode, h as castToFloat, g as constructTypeFromIDs, l as createStructArrayElementProxy, f as functionCallNode, m as memberAccessNode, p as primitiveConstructorNode, s as scalarLiteralNode, e as statementNode, b as structConstructorNode, a as structInstanceNode, i as swizzleNode, j as swizzleTrap, u as unaryOpNode, v as variableNode } from '../ir_builders-CMXkjMoV.js';
6
6
  import './strands_builtins.js';
@@ -8,7 +8,7 @@ import 'acorn';
8
8
  import 'acorn-walk';
9
9
  import 'escodegen';
10
10
  import './strands_FES.js';
11
- import '../ir_builders-C8mrXj5z.js';
11
+ import '../ir_builders-CMXkjMoV.js';
12
12
  import './strands_builtins.js';
13
13
  import './strands_conditionals.js';
14
14
  import './strands_phi_utils.js';
@@ -338,18 +338,20 @@ if (typeof p5 !== "undefined") {
338
338
  */
339
339
 
340
340
  /**
341
- * @method instanceID
341
+ * @property instanceIndex
342
342
  * @beta
343
343
  * @description
344
344
  * Returns the index of the current instance when drawing multiple copies of a
345
345
  * shape with <a href="#/p5/model">`model(count)`</a>. The first instance has an
346
- * ID of `0`, the second has `1`, and so on.
346
+ * index of `0`, the second has `1`, and so on.
347
347
  *
348
348
  * This lets each copy of a shape behave differently. For example, you can use
349
- * the ID to place instances at different positions, give them different colors,
349
+ * the index to place instances at different positions, give them different colors,
350
350
  * or animate them at different speeds.
351
351
  *
352
- * `instanceID()` can only be used inside a p5.strands shader callback.
352
+ * `instanceIndex` can only be used inside a p5.strands shader callback.
353
+ *
354
+ * (Note: `instanceID()` is also available as a function for compatibility.)
353
355
  *
354
356
  * ```js example
355
357
  * let instancesShader;
@@ -372,7 +374,7 @@ if (typeof p5 !== "undefined") {
372
374
  * // Spread spheres evenly across the canvas based on their index
373
375
  * let spacing = width / count;
374
376
  * worldInputs.position.x +=
375
- * (instanceID() - (count - 1) / 2) * spacing;
377
+ * (instanceIndex - (count - 1) / 2) * spacing;
376
378
  * worldInputs.end();
377
379
  * }
378
380
  *
@@ -386,7 +388,7 @@ if (typeof p5 !== "undefined") {
386
388
  * }
387
389
  * ```
388
390
  *
389
- * If you are using WebGPU mode, a common pattern is to use `instanceID()` to look up data made with
391
+ * If you are using WebGPU mode, a common pattern is to use `instanceIndex` to look up data made with
390
392
  * <a href="#/p5/createStorage">`createStorage()`</a>.
391
393
  * This lets you give each instance different properties.
392
394
  *
@@ -429,7 +431,7 @@ if (typeof p5 !== "undefined") {
429
431
  * let itemColor = sharedVec4();
430
432
  *
431
433
  * worldInputs.begin();
432
- * let item = data[instanceID()];
434
+ * let item = data[instanceIndex];
433
435
  * itemColor = item.color;
434
436
  * worldInputs.position += item.position;
435
437
  * worldInputs.end();
@@ -451,7 +453,22 @@ if (typeof p5 !== "undefined") {
451
453
  * This can be paired with <a href="#/p5/buildComputeShader">`buildComputeShader`</a>
452
454
  * to update the data being read.
453
455
  *
454
- * @webgpu
456
+ * @type {*}
457
+ */
458
+
459
+ /**
460
+ * @method instanceID
461
+ * @beta
462
+ * @deprecated Use <a href="#/p5/instanceIndex">`instanceIndex`</a> instead.
463
+ * @description
464
+ * A function alias for <a href="#/p5/instanceIndex">`instanceIndex`</a>, kept for compatibility.
465
+ * Prefer using <a href="#/p5/instanceIndex">`instanceIndex`</a> directly as a value instead.
466
+ *
467
+ * Returns the index of the current instance when drawing multiple copies of a
468
+ * shape with <a href="#/p5/model">`model(count)`</a>.
469
+ *
470
+ * `instanceID()` can only be used inside a p5.strands shader callback.
471
+ *
455
472
  * @returns {*} The index of the current instance.
456
473
  */
457
474
 
@@ -8,4 +8,11 @@ function userError(errorType, errorMessage) {
8
8
  throw new Error(prefixedMessage);
9
9
  }
10
10
 
11
- export { internalError, userError };
11
+ function dimensionMismatchError(declaredDim,actualDim,varName){
12
+ userError(
13
+ 'dimension mismatch',
14
+ `Cannot assign a value of dimension ${actualDim} to \`${varName}\`, which expects dimension ${declaredDim}.`
15
+ );
16
+ }
17
+
18
+ export { dimensionMismatchError, internalError, userError };