@@ -894,6 +894,10 @@ class Shape {
894
894
this . _splineProperties [ key ] = value ;
895
895
}
896
896
897
+ /**
898
+ * @method splineProperties
899
+ * @param {Number } value
900
+ */
897
901
splineProperties ( values ) {
898
902
if ( values ) {
899
903
for ( const key in values ) {
@@ -1680,24 +1684,63 @@ function customShapes(p5, fn) {
1680
1684
} ;
1681
1685
1682
1686
/**
1683
- * @method splineProperty
1684
- * @param {String } property
1685
- * @returns value The current value for the given property.
1686
- */
1687
- /**
1687
+ * Sets the property of a curve. For example, set tightness,
1688
+ * use `splineProperty('tightness', t)`, with `t` between 0 and 1,
1689
+ * at 0 as default.
1690
+ *
1691
+ * Spline curves are like cables that are attached to a set of points.
1692
+ * Adjusting tightness adjusts how tightly the cable is
1693
+ * attached to the points. The parameter, tightness, determines
1694
+ * how the curve fits to the vertex points. By default,
1695
+ * tightness is set to 0. Setting tightness to 1, as in
1696
+ * `splineProperty('tightness', 1)`, connects the curve's points
1697
+ * using straight lines. Values in the range from –5 to 5
1698
+ * deform curves while leaving them recognizable.
1699
+ *
1688
1700
* @method splineProperty
1689
1701
* @param {String } property
1690
1702
* @param value Value to set the given property to.
1703
+ *
1704
+ * @example
1705
+ * <div>
1706
+ * <code>
1707
+ * // Move the mouse left and right to see the curve change.
1708
+ *
1709
+ * function setup() {
1710
+ * createCanvas(100, 100);
1711
+ * describe('A black curve forms a sideways U shape. The curve deforms as the user moves the mouse from left to right');
1712
+ * }
1713
+ *
1714
+ * function draw() {
1715
+ * background(200);
1716
+ *
1717
+ * // Set the curve's tightness using the mouse.
1718
+ * let t = map(mouseX, 0, 100, -5, 5, true);
1719
+ * splineProperty('tightness', t);
1720
+ *
1721
+ * // Draw the curve.
1722
+ * noFill();
1723
+ * beginShape();
1724
+ * curveVertex(10, 26);
1725
+ * curveVertex(10, 26);
1726
+ * curveVertex(83, 24);
1727
+ * curveVertex(83, 61);
1728
+ * curveVertex(25, 65);
1729
+ * curveVertex(25, 65);
1730
+ * endShape();
1731
+ * }
1732
+ * </code>
1733
+ * </div>
1691
1734
*/
1692
1735
fn . splineProperty = function ( property , value ) {
1693
1736
return this . _renderer . splineProperty ( property , value ) ;
1694
1737
} ;
1695
1738
1696
1739
/**
1697
- * @method splineProperties
1698
- * @returns { Object } The current spline properties.
1699
- */
1700
- /**
1740
+ * Similar to <a href="#/p5/splineProperty">splineProperty()</a>:
1741
+ * `splineProperty('tightness', t)` is the same as
1742
+ * `splineProperties({'tightness': t})``
1743
+ *
1701
1744
* @method splineProperties
1702
1745
* @param {Object } An object containing key-value pairs to set.
1703
1746
*/
0 commit comments