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.
- package/README.md +1 -1
- package/dist/accessibility/color_namer.js +4 -4
- package/dist/accessibility/index.js +4 -4
- package/dist/accessibility/outputs.js +1 -1
- package/dist/app.js +4 -4
- package/dist/color/color_conversion.js +4 -4
- package/dist/color/index.js +1 -1
- package/dist/color/setting.js +1 -1
- package/dist/{constants-C2DVjshm.js → constants-8IpwyBct.js} +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/environment.js +1 -1
- package/dist/core/friendly_errors/fes_core.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 +4 -4
- package/dist/core/legacy.js +4 -4
- package/dist/core/main.js +4 -4
- package/dist/core/p5.Graphics.js +3 -3
- package/dist/core/p5.Renderer.js +2 -2
- package/dist/core/p5.Renderer2D.js +4 -4
- package/dist/core/rendering.js +3 -3
- package/dist/dom/dom.js +1 -1
- package/dist/dom/index.js +1 -1
- package/dist/dom/p5.Element.js +1 -1
- package/dist/dom/p5.MediaElement.js +1 -1
- package/dist/image/const.js +1 -1
- package/dist/image/filterRenderer2D.js +3 -3
- 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/{main-rEhlsQtb.js → main-B3Z63C6j.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-DO9wIL55.js → p5.Renderer-DoDzbpcT.js} +1 -1
- package/dist/{rendering-CpHn8PfG.js → rendering-BELwvfI6.js} +3 -3
- package/dist/shape/2d_primitives.js +1 -1
- package/dist/shape/attributes.js +1 -1
- package/dist/shape/curves.js +143 -74
- package/dist/shape/custom_shapes.js +261 -277
- package/dist/shape/index.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/ShaderGenerator.js +10 -7
- package/dist/webgl/ShapeBuilder.js +1 -1
- package/dist/webgl/index.js +3 -3
- package/dist/webgl/interaction.js +1 -1
- package/dist/webgl/light.js +3 -3
- package/dist/webgl/loading.js +3 -3
- 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 +3 -3
- package/dist/webgl/p5.Shader.js +3 -3
- package/dist/webgl/p5.Texture.js +3 -3
- package/dist/webgl/text.js +3 -3
- package/lib/p5.esm.js +414 -358
- package/lib/p5.esm.min.js +1 -1
- package/lib/p5.js +414 -358
- package/lib/p5.min.js +1 -1
- package/package.json +1 -1
- package/types/core/main.d.ts +87 -71
- package/types/global.d.ts +87 -71
- package/types/p5.d.ts +87 -71
- package/types/shape/curves.d.ts +130 -56
- 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-
|
|
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
|
-
*
|
|
1654
|
+
* Connects points with a smooth curve (a spline).
|
|
1654
1655
|
*
|
|
1655
|
-
* `splineVertex()` adds a curved segment to custom shapes.
|
|
1656
|
-
* it creates
|
|
1657
|
-
* <a href="#/p5/
|
|
1658
|
-
* between the
|
|
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.
|
|
1663
|
-
*
|
|
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
|
|
1672
|
-
* splineVertex(
|
|
1678
|
+
* // Add the first point.
|
|
1679
|
+
* splineVertex(25, 80);
|
|
1673
1680
|
*
|
|
1674
|
-
* // Add the
|
|
1675
|
-
* splineVertex(
|
|
1676
|
-
* splineVertex(21, 17);
|
|
1681
|
+
* // Add the second point.
|
|
1682
|
+
* splineVertex(20, 30);
|
|
1677
1683
|
*
|
|
1678
|
-
* // Add the
|
|
1679
|
-
* splineVertex(
|
|
1684
|
+
* // Add the last point.
|
|
1685
|
+
* splineVertex(85, 60);
|
|
1680
1686
|
*
|
|
1681
1687
|
* endShape();
|
|
1682
1688
|
* ```
|
|
1683
|
-
*
|
|
1684
|
-
*
|
|
1685
|
-
*
|
|
1686
|
-
*
|
|
1687
|
-
* `
|
|
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
|
|
1693
|
-
* splineVertex(
|
|
1694
|
-
*
|
|
1695
|
-
*
|
|
1696
|
-
*
|
|
1697
|
-
*
|
|
1698
|
-
*
|
|
1699
|
-
*
|
|
1700
|
-
*
|
|
1701
|
-
*
|
|
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
|
-
*
|
|
1710
|
-
*
|
|
1711
|
-
*
|
|
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(
|
|
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
|
-
*
|
|
1741
|
-
* splineVertex(
|
|
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
|
-
*
|
|
1759
|
-
* point(
|
|
1760
|
-
*
|
|
1761
|
-
*
|
|
1762
|
-
*
|
|
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
|
-
* '
|
|
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
|
-
*
|
|
1788
|
-
* splineVertex(
|
|
1789
|
-
*
|
|
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
|
-
* '
|
|
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
|
-
*
|
|
1824
|
-
*
|
|
1825
|
-
*
|
|
1826
|
-
*
|
|
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
|
-
*
|
|
1851
|
-
*
|
|
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
|
-
*
|
|
1871
|
-
*
|
|
1872
|
-
*
|
|
1873
|
-
*
|
|
1793
|
+
* vertexCount = 15;
|
|
1794
|
+
* unit = createVector(1, 0);
|
|
1795
|
+
* dTheta = TAU / vertexCount;
|
|
1796
|
+
* dTime = 0.004;
|
|
1874
1797
|
*
|
|
1875
|
-
*
|
|
1876
|
-
*
|
|
1877
|
-
* let isChanging = false;
|
|
1798
|
+
* ringInnerRadius = 25;
|
|
1799
|
+
* ringWidth = 5 * ringInnerRadius;
|
|
1878
1800
|
*
|
|
1879
|
-
*
|
|
1880
|
-
* createCanvas(100, 100);
|
|
1801
|
+
* offset = width;
|
|
1881
1802
|
*
|
|
1882
1803
|
* describe(
|
|
1883
|
-
* 'A
|
|
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(
|
|
1809
|
+
* background(220);
|
|
1810
|
+
* strokeWeight(2);
|
|
1811
|
+
* translate(width / 2, height / 2);
|
|
1889
1812
|
*
|
|
1890
|
-
*
|
|
1891
|
-
* noFill();
|
|
1892
|
-
* stroke(0);
|
|
1893
|
-
* strokeWeight(1);
|
|
1813
|
+
* time = dTime * frameCount;
|
|
1894
1814
|
*
|
|
1895
|
-
* // Start drawing the shape.
|
|
1896
1815
|
* beginShape();
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
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
|
-
*
|
|
2064
|
-
*
|
|
2065
|
-
*
|
|
2066
|
-
*
|
|
2067
|
-
*
|
|
2068
|
-
*
|
|
2069
|
-
*
|
|
2070
|
-
*
|
|
2071
|
-
*
|
|
2072
|
-
*
|
|
2073
|
-
*
|
|
2074
|
-
*
|
|
2075
|
-
*
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2078
|
-
*
|
|
2079
|
-
* (
|
|
2080
|
-
*
|
|
2081
|
-
*
|
|
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
|
-
*
|
|
2002
|
+
*
|
|
2095
2003
|
* }
|
|
2096
|
-
*
|
|
2004
|
+
*
|
|
2097
2005
|
* function draw() {
|
|
2098
|
-
* background(
|
|
2099
|
-
*
|
|
2100
|
-
*
|
|
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
|
package/dist/shape/index.js
CHANGED
|
@@ -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-
|
|
6
|
+
import '../constants-8IpwyBct.js';
|
|
7
7
|
import '../core/helpers.js';
|
|
8
8
|
import '../creating_reading-BdolPjuO.js';
|
|
9
9
|
import 'colorjs.io/fn';
|
package/dist/type/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import textCore from './textCore.js';
|
|
2
2
|
import font from './p5.Font.js';
|
|
3
|
-
import '../p5.Renderer-
|
|
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-
|
|
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';
|
package/dist/type/p5.Font.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { textCoreConstants } from './textCore.js';
|
|
2
|
-
import { C as CENTER, R as RIGHT, a as RADIUS } from '../constants-
|
|
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-
|
|
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';
|