p5 2.0.4 → 2.0.5

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 (79) hide show
  1. package/README.md +1 -1
  2. package/dist/accessibility/color_namer.js +4 -4
  3. package/dist/accessibility/index.js +4 -4
  4. package/dist/accessibility/outputs.js +1 -1
  5. package/dist/app.js +4 -4
  6. package/dist/color/color_conversion.js +4 -4
  7. package/dist/color/index.js +1 -1
  8. package/dist/color/setting.js +1 -1
  9. package/dist/{constants-C2DVjshm.js → constants-8IpwyBct.js} +1 -1
  10. package/dist/core/constants.js +1 -1
  11. package/dist/core/environment.js +1 -1
  12. package/dist/core/friendly_errors/fes_core.js +1 -1
  13. package/dist/core/friendly_errors/index.js +1 -1
  14. package/dist/core/friendly_errors/param_validator.js +1 -1
  15. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  16. package/dist/core/helpers.js +1 -1
  17. package/dist/core/init.js +4 -4
  18. package/dist/core/legacy.js +4 -4
  19. package/dist/core/main.js +4 -4
  20. package/dist/core/p5.Graphics.js +3 -3
  21. package/dist/core/p5.Renderer.js +2 -2
  22. package/dist/core/p5.Renderer2D.js +4 -4
  23. package/dist/core/rendering.js +3 -3
  24. package/dist/dom/dom.js +1 -1
  25. package/dist/dom/index.js +1 -1
  26. package/dist/dom/p5.Element.js +1 -1
  27. package/dist/dom/p5.MediaElement.js +1 -1
  28. package/dist/image/const.js +1 -1
  29. package/dist/image/filterRenderer2D.js +3 -3
  30. package/dist/image/image.js +3 -3
  31. package/dist/image/index.js +3 -3
  32. package/dist/image/loading_displaying.js +3 -3
  33. package/dist/image/p5.Image.js +2 -2
  34. package/dist/io/files.js +3 -3
  35. package/dist/io/index.js +3 -3
  36. package/dist/{main-rEhlsQtb.js → main-B3Z63C6j.js} +3 -3
  37. package/dist/math/Matrices/Matrix.js +1 -1
  38. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  39. package/dist/math/index.js +1 -1
  40. package/dist/math/p5.Matrix.js +1 -1
  41. package/dist/math/p5.Vector.js +1 -1
  42. package/dist/math/trigonometry.js +1 -1
  43. package/dist/{p5.Renderer-DO9wIL55.js → p5.Renderer-DoDzbpcT.js} +1 -1
  44. package/dist/{rendering-CpHn8PfG.js → rendering-BELwvfI6.js} +3 -3
  45. package/dist/shape/2d_primitives.js +1 -1
  46. package/dist/shape/attributes.js +1 -1
  47. package/dist/shape/curves.js +143 -74
  48. package/dist/shape/custom_shapes.js +261 -277
  49. package/dist/shape/index.js +1 -1
  50. package/dist/type/index.js +2 -2
  51. package/dist/type/p5.Font.js +2 -2
  52. package/dist/type/textCore.js +2 -2
  53. package/dist/webgl/3d_primitives.js +3 -3
  54. package/dist/webgl/GeometryBuilder.js +1 -1
  55. package/dist/webgl/ShaderGenerator.js +10 -7
  56. package/dist/webgl/ShapeBuilder.js +1 -1
  57. package/dist/webgl/index.js +3 -3
  58. package/dist/webgl/interaction.js +1 -1
  59. package/dist/webgl/light.js +3 -3
  60. package/dist/webgl/loading.js +3 -3
  61. package/dist/webgl/material.js +3 -3
  62. package/dist/webgl/p5.Camera.js +3 -3
  63. package/dist/webgl/p5.Framebuffer.js +3 -3
  64. package/dist/webgl/p5.Geometry.js +1 -1
  65. package/dist/webgl/p5.Quat.js +1 -1
  66. package/dist/webgl/p5.RendererGL.js +3 -3
  67. package/dist/webgl/p5.Shader.js +3 -3
  68. package/dist/webgl/p5.Texture.js +3 -3
  69. package/dist/webgl/text.js +3 -3
  70. package/lib/p5.esm.js +414 -358
  71. package/lib/p5.esm.min.js +1 -1
  72. package/lib/p5.js +414 -358
  73. package/lib/p5.min.js +1 -1
  74. package/package.json +1 -1
  75. package/types/core/main.d.ts +87 -71
  76. package/types/global.d.ts +87 -71
  77. package/types/p5.d.ts +87 -71
  78. package/types/shape/curves.d.ts +130 -56
  79. package/types/shape/custom_shapes.d.ts +188 -252
@@ -1,6 +1,6 @@
1
1
  import { C as Color } from '../creating_reading-BdolPjuO.js';
2
2
  import { Vector } from '../math/p5.Vector.js';
3
- import { I as INCLUDE, m as PATH, E as EMPTY_PATH, O as OPEN, n as CLOSE, o as POINTS, L as LINES, p as TRIANGLES, Q as QUADS, q as TRIANGLE_FAN, r as TRIANGLE_STRIP, s as QUAD_STRIP, t as EXCLUDE, J as JOIN } from '../constants-C2DVjshm.js';
3
+ import { I as INCLUDE, m as PATH, E as EMPTY_PATH, O as OPEN, n as CLOSE, o as POINTS, L as LINES, p as TRIANGLES, Q as QUADS, q as TRIANGLE_FAN, r as TRIANGLE_STRIP, s as QUAD_STRIP, t as EXCLUDE, J as JOIN } from '../constants-8IpwyBct.js';
4
4
  import 'colorjs.io/fn';
5
5
  import '../color/color_spaces/hsb.js';
6
6
 
@@ -1649,67 +1649,73 @@ function customShapes(p5, fn) {
1649
1649
  };
1650
1650
 
1651
1651
 
1652
+
1652
1653
  /**
1653
- * Adds a spline curve segment to a custom shape.
1654
+ * Connects points with a smooth curve (a spline).
1654
1655
  *
1655
- * `splineVertex()` adds a curved segment to custom shapes. The spline curves
1656
- * it creates are defined like those made by the
1657
- * <a href="#/p5/curve">curve()</a> function. `splineVertex()` must be called
1658
- * between the <a href="#/p5/beginShape">beginShape()</a> and
1656
+ * `splineVertex()` adds a curved segment to custom shapes.
1657
+ * The curve it creates follows the same rules as the ones
1658
+ * made with the <a href="#/p5/spline">spline()</a> function.
1659
+ * `splineVertex()` must be called between the
1660
+ * <a href="#/p5/beginShape">beginShape()</a> and
1659
1661
  * <a href="#/p5/endShape">endShape()</a> functions.
1660
1662
  *
1661
1663
  * Spline curves can form shapes and curves that slope gently. They’re like
1662
- * cables that are attached to a set of points. Splines are defined by two
1663
- * anchor points and two control points. `splineVertex()` must be called at
1664
- * least four times between
1664
+ * cables that are attached to a set of points. `splineVertex()` draws a smooth
1665
+ * curve through the points you give it.
1665
1666
  * <a href="#/p5/beginShape">beginShape()</a> and
1666
1667
  * <a href="#/p5/endShape">endShape()</a> in order to draw a curve:
1667
1668
  *
1669
+ *
1670
+ * If you provide three points, the spline will pass through them.
1671
+ * It works the same way with any number of points.
1672
+ *
1673
+ *
1674
+ *
1668
1675
  * ```js
1669
1676
  * beginShape();
1670
1677
  *
1671
- * // Add the first control point.
1672
- * splineVertex(84, 91);
1678
+ * // Add the first point.
1679
+ * splineVertex(25, 80);
1673
1680
  *
1674
- * // Add the anchor points to draw between.
1675
- * splineVertex(68, 19);
1676
- * splineVertex(21, 17);
1681
+ * // Add the second point.
1682
+ * splineVertex(20, 30);
1677
1683
  *
1678
- * // Add the second control point.
1679
- * splineVertex(32, 91);
1684
+ * // Add the last point.
1685
+ * splineVertex(85, 60);
1680
1686
  *
1681
1687
  * endShape();
1682
1688
  * ```
1683
- *
1684
- * The code snippet above would only draw the curve between the anchor points,
1685
- * similar to the <a href="#/p5/curve">curve()</a> function. The segments
1686
- * between the control and anchor points can be drawn by calling
1687
- * `splineVertex()` with the coordinates of the control points:
1688
- *
1689
+ *
1690
+ * <img src="assets/openCurveSpline.png"></img>
1691
+ *
1692
+ *
1693
+ * Passing in `CLOSE` to `endShape()` closes the spline smoothly.
1689
1694
  * ```js
1690
1695
  * beginShape();
1691
- *
1692
- * // Add the first control point and draw a segment to it.
1693
- * splineVertex(84, 91);
1694
- * splineVertex(84, 91);
1695
- *
1696
- * // Add the anchor points to draw between.
1697
- * splineVertex(68, 19);
1698
- * splineVertex(21, 17);
1699
- *
1700
- * // Add the second control point.
1701
- * splineVertex(32, 91);
1702
- *
1703
- * // Uncomment the next line to draw the segment to the second control point.
1704
- * // splineVertex(32, 91);
1705
- *
1706
- * endShape();
1696
+ *
1697
+ * // Add the first point.
1698
+ * splineVertex(25, 80);
1699
+ *
1700
+ * // Add the second point.
1701
+ * splineVertex(20, 30);
1702
+ *
1703
+ * // Add the second point.
1704
+ * splineVertex(85, 60);
1705
+ *
1706
+ * endShape(CLOSE);
1707
1707
  * ```
1708
- *
1709
- * The first two parameters, `x` and `y`, set the vertex’s location. For
1710
- * example, calling `splineVertex(10, 10)` adds a point to the curve at
1711
- * `(10, 10)`.
1712
- *
1708
+ *
1709
+ * <img src="assets/closeCurveSpline.png"></img>
1710
+ *
1711
+ *
1712
+ * By default (`ends: INCLUDE`), the curve passes through
1713
+ * all the points you add with `splineVertex()`, similar to
1714
+ * the <a href="#/p5/spline">spline()</a> function. To draw only
1715
+ * the middle span p1->p2 (skipping p0->p1 and p2->p3), set
1716
+ * `splineProperty('ends', EXCLUDE)`. You don’t need to duplicate
1717
+ * vertices to draw those spans.
1718
+ *
1713
1719
  * Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
1714
1720
  * `splineVertex()` has three arguments because each point has x-, y-, and
1715
1721
  * z-coordinates. By default, the vertex’s z-coordinate is set to 0.
@@ -1727,46 +1733,29 @@ function customShapes(p5, fn) {
1727
1733
  * <code>
1728
1734
  * function setup() {
1729
1735
  * createCanvas(100, 100);
1730
- *
1731
- * background(200);
1732
- *
1733
- * // Style the shape.
1736
+ *
1737
+ * background(220);
1734
1738
  * noFill();
1735
1739
  * strokeWeight(1);
1736
- *
1737
- * // Start drawing the shape.
1740
+ *
1738
1741
  * beginShape();
1739
- *
1740
- * // Add the first control point.
1741
- * splineVertex(32, 91);
1742
- *
1743
- * // Add the anchor points.
1744
- * splineVertex(21, 17);
1745
- * splineVertex(68, 19);
1746
- *
1747
- * // Add the second control point.
1748
- * splineVertex(84, 91);
1749
- *
1750
- * // Stop drawing the shape.
1742
+ * splineVertex(25, 80);
1743
+ * splineVertex(20, 30);
1744
+ * splineVertex(85, 60);
1751
1745
  * endShape();
1752
- *
1753
- * // Style the anchor and control points.
1746
+ *
1754
1747
  * strokeWeight(5);
1755
- *
1756
- * // Draw the anchor points in black.
1757
1748
  * stroke(0);
1758
- * point(21, 17);
1759
- * point(68, 19);
1760
- *
1761
- * // Draw the control points in red.
1762
- * stroke(255, 0, 0);
1763
- * point(32, 91);
1764
- * point(84, 91);
1765
- *
1749
+ *
1750
+ * point(25, 80);
1751
+ * point(20, 30);
1752
+ * point(85, 60);
1753
+ *
1766
1754
  * describe(
1767
- * 'A black curve drawn on a gray background. The curve has black dots at its ends. Two red dots appear near the bottom of the canvas.'
1755
+ * 'On a gray background, a black spline passes through three marked points.'
1768
1756
  * );
1769
1757
  * }
1758
+ *
1770
1759
  * </code>
1771
1760
  * </div>
1772
1761
  *
@@ -1774,204 +1763,63 @@ function customShapes(p5, fn) {
1774
1763
  * <code>
1775
1764
  * function setup() {
1776
1765
  * createCanvas(100, 100);
1766
+ * background(220);
1777
1767
  *
1778
- * background(200);
1779
- *
1780
- * // Style the shape.
1781
- * noFill();
1782
- * strokeWeight(1);
1783
- *
1784
- * // Start drawing the shape.
1785
1768
  * beginShape();
1786
- *
1787
- * // Add the first control point and draw a segment to it.
1788
- * splineVertex(32, 91);
1789
- * splineVertex(32, 91);
1790
- *
1791
- * // Add the anchor points.
1792
- * splineVertex(21, 17);
1793
- * splineVertex(68, 19);
1794
- *
1795
- * // Add the second control point.
1796
- * splineVertex(84, 91);
1797
- *
1798
- * // Stop drawing the shape.
1799
- * endShape();
1800
- *
1801
- * // Style the anchor and control points.
1802
- * strokeWeight(5);
1803
- *
1804
- * // Draw the anchor points in black.
1805
- * stroke(0);
1806
- * point(21, 17);
1807
- * point(68, 19);
1808
- *
1809
- * // Draw the control points in red.
1810
- * stroke(255, 0, 0);
1811
- * point(32, 91);
1812
- * point(84, 91);
1769
+ * splineVertex(25, 80);
1770
+ * splineVertex(20, 30);
1771
+ * splineVertex(85, 60);
1772
+ * endShape(CLOSE);
1813
1773
  *
1814
1774
  * describe(
1815
- * 'A black curve drawn on a gray background. The curve passes through one red dot and two black dots. Another red dot appears near the bottom of the canvas.'
1775
+ * 'On a gray background, a closed black spline with a white interior forms a triangular shape with smooth corners.'
1816
1776
  * );
1817
1777
  * }
1778
+ *
1818
1779
  * </code>
1819
1780
  * </div>
1820
1781
  *
1821
1782
  * <div>
1822
1783
  * <code>
1823
- * function setup() {
1824
- * createCanvas(100, 100);
1825
- *
1826
- * background(200);
1827
- *
1828
- * // Style the shape.
1829
- * noFill();
1830
- * strokeWeight(1);
1831
- *
1832
- * // Start drawing the shape.
1833
- * beginShape();
1834
- *
1835
- * // Add the first control point and draw a segment to it.
1836
- * splineVertex(32, 91);
1837
- * splineVertex(32, 91);
1838
- *
1839
- * // Add the anchor points.
1840
- * splineVertex(21, 17);
1841
- * splineVertex(68, 19);
1842
- *
1843
- * // Add the second control point and draw a segment to it.
1844
- * splineVertex(84, 91);
1845
- * splineVertex(84, 91);
1846
- *
1847
- * // Stop drawing the shape.
1848
- * endShape();
1784
+ * let ringInnerRadius, ringWidth;
1785
+ * let radius, dRadius;
1786
+ * let theta, dTheta;
1787
+ * let time, dTime;
1788
+ * let vertexCount, unit, offset;
1849
1789
  *
1850
- * // Style the anchor and control points.
1851
- * strokeWeight(5);
1852
- *
1853
- * // Draw the anchor points in black.
1854
- * stroke(0);
1855
- * point(21, 17);
1856
- * point(68, 19);
1857
- *
1858
- * // Draw the control points in red.
1859
- * stroke(255, 0, 0);
1860
- * point(32, 91);
1861
- * point(84, 91);
1862
- *
1863
- * describe(
1864
- * 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.'
1865
- * );
1866
- * }
1867
- * </code>
1868
- * </div>
1790
+ * function setup() {
1791
+ * createCanvas(400, 400);
1869
1792
  *
1870
- * <div>
1871
- * <code>
1872
- * // Click the mouse near the red dot in the bottom-left corner
1873
- * // and drag to change the curve's shape.
1793
+ * vertexCount = 15;
1794
+ * unit = createVector(1, 0);
1795
+ * dTheta = TAU / vertexCount;
1796
+ * dTime = 0.004;
1874
1797
  *
1875
- * let x1 = 32;
1876
- * let y1 = 91;
1877
- * let isChanging = false;
1798
+ * ringInnerRadius = 25;
1799
+ * ringWidth = 5 * ringInnerRadius;
1878
1800
  *
1879
- * function setup() {
1880
- * createCanvas(100, 100);
1801
+ * offset = width;
1881
1802
  *
1882
1803
  * describe(
1883
- * 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.'
1804
+ * 'A white blob with a black outline changes its shape over time.'
1884
1805
  * );
1885
1806
  * }
1886
1807
  *
1887
1808
  * function draw() {
1888
- * background(200);
1809
+ * background(220);
1810
+ * strokeWeight(2);
1811
+ * translate(width / 2, height / 2);
1889
1812
  *
1890
- * // Style the shape.
1891
- * noFill();
1892
- * stroke(0);
1893
- * strokeWeight(1);
1813
+ * time = dTime * frameCount;
1894
1814
  *
1895
- * // Start drawing the shape.
1896
1815
  * beginShape();
1897
- *
1898
- * // Add the first control point and draw a segment to it.
1899
- * splineVertex(x1, y1);
1900
- * splineVertex(x1, y1);
1901
- *
1902
- * // Add the anchor points.
1903
- * splineVertex(21, 17);
1904
- * splineVertex(68, 19);
1905
- *
1906
- * // Add the second control point and draw a segment to it.
1907
- * splineVertex(84, 91);
1908
- * splineVertex(84, 91);
1909
- *
1910
- * // Stop drawing the shape.
1911
- * endShape();
1912
- *
1913
- * // Style the anchor and control points.
1914
- * strokeWeight(5);
1915
- *
1916
- * // Draw the anchor points in black.
1917
- * stroke(0);
1918
- * point(21, 17);
1919
- * point(68, 19);
1920
- *
1921
- * // Draw the control points in red.
1922
- * stroke(255, 0, 0);
1923
- * point(x1, y1);
1924
- * point(84, 91);
1925
- * }
1926
- *
1927
- * // Start changing the first control point if the user clicks near it.
1928
- * function mousePressed() {
1929
- * if (dist(mouseX, mouseY, x1, y1) < 20) {
1930
- * isChanging = true;
1931
- * }
1932
- * }
1933
- *
1934
- * // Stop changing the first control point when the user releases the mouse.
1935
- * function mouseReleased() {
1936
- * isChanging = false;
1937
- * }
1938
- *
1939
- * // Update the first control point while the user drags the mouse.
1940
- * function mouseDragged() {
1941
- * if (isChanging === true) {
1942
- * x1 = mouseX;
1943
- * y1 = mouseY;
1816
+ * for (let i = 0; i < vertexCount; i++) {
1817
+ * unit.rotate(dTheta);
1818
+ * dRadius = noise(offset + unit.x, offset + unit.y, time) * ringWidth;
1819
+ * radius = ringInnerRadius + dRadius;
1820
+ * splineVertex(radius * unit.x, radius * unit.y);
1944
1821
  * }
1945
- * }
1946
- * </code>
1947
- * </div>
1948
- *
1949
- * <div>
1950
- * <code>
1951
- * function setup() {
1952
- * createCanvas(100, 100);
1953
- *
1954
- * background(200);
1955
- *
1956
- * // Start drawing the shape.
1957
- * beginShape();
1958
- *
1959
- * // Add the first control point and draw a segment to it.
1960
- * splineVertex(32, 91);
1961
- * splineVertex(32, 91);
1962
- *
1963
- * // Add the anchor points.
1964
- * splineVertex(21, 17);
1965
- * splineVertex(68, 19);
1966
- *
1967
- * // Add the second control point.
1968
- * splineVertex(84, 91);
1969
- * splineVertex(84, 91);
1970
- *
1971
- * // Stop drawing the shape.
1972
- * endShape();
1973
- *
1974
- * describe('A ghost shape drawn in white on a gray background.');
1822
+ * endShape(CLOSE);
1975
1823
  * }
1976
1824
  * </code>
1977
1825
  * </div>
@@ -2060,25 +1908,83 @@ function customShapes(p5, fn) {
2060
1908
  };
2061
1909
 
2062
1910
  /**
2063
- * Sets the property of a curve.
2064
- *
2065
- * For example, set tightness,
2066
- * use `splineProperty('tightness', t)`, with `t` between 0 and 1,
2067
- * at 0 as default.
2068
- *
2069
- * Spline curves are like cables that are attached to a set of points.
2070
- * Adjusting tightness adjusts how tightly the cable is
2071
- * attached to the points. The parameter, tightness, determines
2072
- * how the curve fits to the vertex points. By default,
2073
- * tightness is set to 0. Setting tightness to 1, as in
2074
- * `splineProperty('tightness', 1)`, connects the curve's points
2075
- * using straight lines. Values in the range from –5 to 5
2076
- * deform curves while leaving them recognizable.
2077
- *
2078
- * This function can also be used to set 'ends' property
2079
- * (see also: the <a href="#/p5/curveDetail">curveDetail()</a> example),
2080
- * such as: `splineProperty('ends', EXCLUDE)` to exclude
2081
- * vertices, or `splineProperty('ends', INCLUDE)` to include them.
1911
+ * Gets or sets a given spline property.
1912
+ *
1913
+ * Use `splineProperty()` to adjust the behavior of splines
1914
+ * created with `splineVertex()` or `spline()`. You can control
1915
+ * two key aspects of a spline: its end behavior (`ends`) and
1916
+ * its curvature (`tightness`).
1917
+ *
1918
+ * By default, the ends property is set to `INCLUDE`, which means
1919
+ * the spline passes through every point, including the endpoints.
1920
+ * You can also set it to `EXCLUDE` i.e. `splineProperty('ends', EXCLUDE)`,
1921
+ * which makes the spline pass through all points except the endpoints.
1922
+ *
1923
+ * `INCLUDE` case will have the spline passing through
1924
+ * all points, like this:
1925
+ *
1926
+ * ```js
1927
+ * splineProperty('ends', INCLUDE); // no need to set this, as it is the default
1928
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
1929
+ *
1930
+ * point(25, 46);
1931
+ * point(93, 44);
1932
+ * point(93, 81);
1933
+ * point(35, 85);
1934
+ * ```
1935
+ *
1936
+ * <img src="assets/includeSpline.png"></img>
1937
+ *
1938
+ *
1939
+ * EXCLUDE case will have the spline passing through
1940
+ * the middle points, like this:
1941
+ *
1942
+ *
1943
+ * ```js
1944
+ * splineProperty('ends', INCLUDE);
1945
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
1946
+ *
1947
+ * point(25, 46);
1948
+ * point(93, 44);
1949
+ * point(93, 81);
1950
+ * point(35, 85);
1951
+ * ```
1952
+ *
1953
+ * <img src="assets/excludeSpline.png"></img>
1954
+ *
1955
+ * By default, the tightness property is set to `0`,
1956
+ * producing a smooth curve that passes evenly through
1957
+ * the vertices. Negative values make the curve looser,
1958
+ * while positive values make it tighter. Common values
1959
+ * range between -1 and 1, though values outside this
1960
+ * range can also be used for different effects.
1961
+ *
1962
+ * For example, To set tightness, use `splineProperty('tightness', t)`,
1963
+ * (default: t = 0).
1964
+ *
1965
+ * Here's the example showing negetive value of tightness,
1966
+ * which creates a rounder bulge:
1967
+ *
1968
+ * ```js
1969
+ * splineProperty('tightness', -5)
1970
+ * stroke(0);
1971
+ * strokeWeight(2);
1972
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
1973
+ * ```
1974
+ *
1975
+ * Here's the example showing positive value of tightness,
1976
+ * which makes the curve tighter and more angular:
1977
+ *
1978
+ * ```js
1979
+ * splineProperty('tightness', 5)
1980
+ * stroke(0);
1981
+ * strokeWeight(2);
1982
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
1983
+ * ```
1984
+ *
1985
+ * In all cases, the splines in p5.js are <a href = "https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline">cardinal splines</a>.
1986
+ * When tightness is 0, these splines are often known as
1987
+ * <a href="https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull%E2%80%93Rom_spline">Catmull-Rom splines</a>
2082
1988
  *
2083
1989
  * @method splineProperty
2084
1990
  * @param {String} property
@@ -2088,33 +1994,111 @@ function customShapes(p5, fn) {
2088
1994
  * <div>
2089
1995
  * <code>
2090
1996
  * // Move the mouse left and right to see the curve change.
2091
- *
1997
+ *
1998
+ * let t;
1999
+ *
2092
2000
  * function setup() {
2093
2001
  * createCanvas(100, 100);
2094
- * describe('A black curve forms a sideways U shape. The curve deforms as the user moves the mouse from left to right');
2002
+ *
2095
2003
  * }
2096
- *
2004
+ *
2097
2005
  * function draw() {
2098
- * background(200);
2099
- *
2100
- * // Set the curve's tightness using the mouse.
2101
- * let t = map(mouseX, 0, 100, -5, 5, true);
2006
+ * background(240);
2007
+ *
2008
+ * t = map(mouseX, 0, width, -5, 5, true);
2102
2009
  * splineProperty('tightness', t);
2103
- *
2104
- * // Draw the curve.
2010
+ *
2105
2011
  * noFill();
2012
+ * stroke(0);
2013
+ * strokeWeight(2);
2014
+ *
2106
2015
  * beginShape();
2107
2016
  * splineVertex(10, 26);
2108
- * splineVertex(10, 26);
2109
2017
  * splineVertex(83, 24);
2018
+ *
2110
2019
  * splineVertex(83, 61);
2111
2020
  * splineVertex(25, 65);
2112
- * splineVertex(25, 65);
2113
2021
  * endShape();
2022
+ *
2023
+ * push();
2024
+ * strokeWeight(5);
2025
+ * point(10, 26);
2026
+ * point(83, 24);
2027
+ * point(83, 61);
2028
+ * point(25, 65);
2029
+ * pop();
2030
+ *
2031
+ * fill(0);
2032
+ * noStroke();
2033
+ * textSize(10);
2034
+ * text(`tightness: ${round(t, 1)}`, 15, 90);
2035
+ * describe('A black spline forms a sideways U shape through four points. The spline passes through the points more loosely as the mouse moves left of center (negative tightness), and more tightly as it moves right of center (positive tightness). The tightness is displayed at the bottom.');
2036
+ * }
2037
+ * </code>
2038
+ * </div>
2039
+ *
2040
+ * @example
2041
+ * <div>
2042
+ * <code>
2043
+ * function setup() {
2044
+ * createCanvas(360, 140);
2045
+ * background(240);
2046
+ * noFill();
2047
+ *
2048
+ * // Right panel: ends = INCLUDE (all spans).
2049
+ * push();
2050
+ * translate(10, 10);
2051
+ * stroke(220);
2052
+ * rect(0, 0, 160, 120);
2053
+ * fill(30);
2054
+ * textSize(11);
2055
+ * text('ends: INCLUDE (all spans)', 8, 16);
2056
+ * noFill();
2057
+ *
2058
+ * splineProperty('ends', INCLUDE);
2059
+ * stroke(0);
2060
+ * strokeWeight(2);
2061
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
2062
+ *
2063
+ * // vertices
2064
+ * strokeWeight(5);
2065
+ * stroke(0);
2066
+ * point(25, 46);
2067
+ * point(93, 44);
2068
+ * point(93, 81);
2069
+ * point(35, 85);
2070
+ * pop();
2071
+ *
2072
+ * // Right panel: ends = EXCLUDE (middle only).
2073
+ * push();
2074
+ * translate(190, 10);
2075
+ * stroke(220);
2076
+ * rect(0, 0, 160, 120);
2077
+ * noStroke();
2078
+ * fill(30);
2079
+ * text('ends: EXCLUDE ', 18, 16);
2080
+ * noFill();
2081
+ *
2082
+ * splineProperty('ends', EXCLUDE);
2083
+ * stroke(0);
2084
+ * strokeWeight(2);
2085
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
2086
+ *
2087
+ * // vertices
2088
+ * strokeWeight(5);
2089
+ * stroke(0);
2090
+ * point(25, 46);
2091
+ * point(93, 44);
2092
+ * point(93, 81);
2093
+ * point(35, 85);
2094
+ * pop();
2095
+ *
2096
+ * describe('Left panel shows spline with ends INCLUDE (three spans). Right panel shows EXCLUDE (only the middle span). Four black points mark the vertices.');
2114
2097
  * }
2115
2098
  * </code>
2116
2099
  * </div>
2117
2100
  */
2101
+
2118
2102
  /**
2119
2103
  * @method splineProperty
2120
2104
  * @param {String} property
@@ -3,7 +3,7 @@ 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-C2DVjshm.js';
6
+ import '../constants-8IpwyBct.js';
7
7
  import '../core/helpers.js';
8
8
  import '../creating_reading-BdolPjuO.js';
9
9
  import 'colorjs.io/fn';
@@ -1,10 +1,10 @@
1
1
  import textCore from './textCore.js';
2
2
  import font from './p5.Font.js';
3
- import '../p5.Renderer-DO9wIL55.js';
3
+ import '../p5.Renderer-DoDzbpcT.js';
4
4
  import '../creating_reading-BdolPjuO.js';
5
5
  import 'colorjs.io/fn';
6
6
  import '../color/color_spaces/hsb.js';
7
- import '../constants-C2DVjshm.js';
7
+ import '../constants-8IpwyBct.js';
8
8
  import '../image/filters.js';
9
9
  import '../math/p5.Vector.js';
10
10
  import '../shape/custom_shapes.js';
@@ -1,10 +1,10 @@
1
1
  import { textCoreConstants } from './textCore.js';
2
- import { C as CENTER, R as RIGHT, a as RADIUS } from '../constants-C2DVjshm.js';
2
+ import { C as CENTER, R as RIGHT, a as RADIUS } from '../constants-8IpwyBct.js';
3
3
  import { UnicodeRange } from '@japont/unicode-range';
4
4
  import { unicodeRanges } from './unicodeRanges.js';
5
5
  import Typr from './lib/Typr.js';
6
6
  import { createFromCommands } from '@davepagurek/bezier-path';
7
- import '../p5.Renderer-DO9wIL55.js';
7
+ import '../p5.Renderer-DoDzbpcT.js';
8
8
  import '../creating_reading-BdolPjuO.js';
9
9
  import 'colorjs.io/fn';
10
10
  import '../color/color_spaces/hsb.js';