Skip to content

Commit 7da91e3

Browse files
authored
Removing control/anchor point usage.
1 parent cd19498 commit 7da91e3

1 file changed

Lines changed: 38 additions & 35 deletions

File tree

src/shape/custom_shapes.js

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,48 +1657,51 @@ function customShapes(p5, fn) {
16571657
* <a href="#/p5/endShape">endShape()</a> functions.
16581658
*
16591659
* Spline curves can form shapes and curves that slope gently. They’re like
1660-
* cables that are attached to a set of points. Splines are defined by two
1661-
* anchor points and two control points. `splineVertex()` must be called at
1662-
* least four times between
1660+
* cables that are attached to a set of points. `splineVertex()` draws a smooth
1661+
* curve through the points you give it.
16631662
* <a href="#/p5/beginShape">beginShape()</a> and
16641663
* <a href="#/p5/endShape">endShape()</a> in order to draw a curve:
16651664
*
1665+
*
16661666
* ```js
16671667
* beginShape();
16681668
*
1669-
* // Add the first control point.
1669+
* // Add the first point.
16701670
* splineVertex(84, 91);
16711671
*
1672-
* // Add the anchor points to draw between.
1672+
* // Add the next points in order.
16731673
* splineVertex(68, 19);
16741674
* splineVertex(21, 17);
16751675
*
1676-
* // Add the second control point.
1676+
* // Add the last point.
16771677
* splineVertex(32, 91);
16781678
*
16791679
* endShape();
16801680
* ```
16811681
*
1682-
* The code snippet above would only draw the curve between the anchor points,
1683-
* similar to the <a href="#/p5/spline">spline()</a> function. The segments
1684-
* between the control and anchor points can be drawn by calling
1685-
* `splineVertex()` with the coordinates of the control points:
1686-
*
1682+
*
1683+
* By default (`ends: INCLUDE`), the curve passes through
1684+
* all the points you add with `splineVertex()`, similar to
1685+
* the <a href="#/p5/spline">spline()</a> function. To draw only
1686+
* the middle span p1->p2 (skipping p0->p1 and p2->p3), set
1687+
* `splineProperty('ends', EXCLUDE)`. You don’t need to duplicate
1688+
* vertices to draw those spans.
1689+
16871690
* ```js
16881691
* beginShape();
16891692
*
1690-
* // Add the first control point and draw a segment to it.
1693+
* // Add the first point and draw a segment to it.
16911694
* splineVertex(84, 91);
16921695
* splineVertex(84, 91);
16931696
*
16941697
* // Add the anchor points to draw between.
16951698
* splineVertex(68, 19);
16961699
* splineVertex(21, 17);
16971700
*
1698-
* // Add the second control point.
1701+
* // Add the second point.
16991702
* splineVertex(32, 91);
17001703
*
1701-
* // Uncomment the next line to draw the segment to the second control point.
1704+
* // Uncomment the next line to draw the segment to the second point.
17021705
* // splineVertex(32, 91);
17031706
*
17041707
* endShape();
@@ -1735,28 +1738,28 @@ function customShapes(p5, fn) {
17351738
* // Start drawing the shape.
17361739
* beginShape();
17371740
*
1738-
* // Add the first control point.
1741+
* // Add the first point.
17391742
* splineVertex(32, 91);
17401743
*
17411744
* // Add the anchor points.
17421745
* splineVertex(21, 17);
17431746
* splineVertex(68, 19);
17441747
*
1745-
* // Add the second control point.
1748+
* // Add the second point.
17461749
* splineVertex(84, 91);
17471750
*
17481751
* // Stop drawing the shape.
17491752
* endShape();
17501753
*
1751-
* // Style the anchor and control points.
1754+
* // Style the points.
17521755
* strokeWeight(5);
17531756
*
17541757
* // Draw the anchor points in black.
17551758
* stroke(0);
17561759
* point(21, 17);
17571760
* point(68, 19);
17581761
*
1759-
* // Draw the control points in red.
1762+
* // Draw the points in red.
17601763
* stroke(255, 0, 0);
17611764
* point(32, 91);
17621765
* point(84, 91);
@@ -1782,29 +1785,29 @@ function customShapes(p5, fn) {
17821785
* // Start drawing the shape.
17831786
* beginShape();
17841787
*
1785-
* // Add the first control point and draw a segment to it.
1788+
* // Add the first point and draw a segment to it.
17861789
* splineVertex(32, 91);
17871790
* splineVertex(32, 91);
17881791
*
17891792
* // Add the anchor points.
17901793
* splineVertex(21, 17);
17911794
* splineVertex(68, 19);
17921795
*
1793-
* // Add the second control point.
1796+
* // Add the second point.
17941797
* splineVertex(84, 91);
17951798
*
17961799
* // Stop drawing the shape.
17971800
* endShape();
17981801
*
1799-
* // Style the anchor and control points.
1802+
* // Style the points.
18001803
* strokeWeight(5);
18011804
*
18021805
* // Draw the anchor points in black.
18031806
* stroke(0);
18041807
* point(21, 17);
18051808
* point(68, 19);
18061809
*
1807-
* // Draw the control points in red.
1810+
* // Draw the points in red.
18081811
* stroke(255, 0, 0);
18091812
* point(32, 91);
18101813
* point(84, 91);
@@ -1830,30 +1833,30 @@ function customShapes(p5, fn) {
18301833
* // Start drawing the shape.
18311834
* beginShape();
18321835
*
1833-
* // Add the first control point and draw a segment to it.
1836+
* // Add the first point and draw a segment to it.
18341837
* splineVertex(32, 91);
18351838
* splineVertex(32, 91);
18361839
*
18371840
* // Add the anchor points.
18381841
* splineVertex(21, 17);
18391842
* splineVertex(68, 19);
18401843
*
1841-
* // Add the second control point and draw a segment to it.
1844+
* // Add the second point and draw a segment to it.
18421845
* splineVertex(84, 91);
18431846
* splineVertex(84, 91);
18441847
*
18451848
* // Stop drawing the shape.
18461849
* endShape();
18471850
*
1848-
* // Style the anchor and control points.
1851+
* // Style the points.
18491852
* strokeWeight(5);
18501853
*
18511854
* // Draw the anchor points in black.
18521855
* stroke(0);
18531856
* point(21, 17);
18541857
* point(68, 19);
18551858
*
1856-
* // Draw the control points in red.
1859+
* // Draw the points in red.
18571860
* stroke(255, 0, 0);
18581861
* point(32, 91);
18591862
* point(84, 91);
@@ -1893,48 +1896,48 @@ function customShapes(p5, fn) {
18931896
* // Start drawing the shape.
18941897
* beginShape();
18951898
*
1896-
* // Add the first control point and draw a segment to it.
1899+
* // Add the first point and draw a segment to it.
18971900
* splineVertex(x1, y1);
18981901
* splineVertex(x1, y1);
18991902
*
19001903
* // Add the anchor points.
19011904
* splineVertex(21, 17);
19021905
* splineVertex(68, 19);
19031906
*
1904-
* // Add the second control point and draw a segment to it.
1907+
* // Add the second point and draw a segment to it.
19051908
* splineVertex(84, 91);
19061909
* splineVertex(84, 91);
19071910
*
19081911
* // Stop drawing the shape.
19091912
* endShape();
19101913
*
1911-
* // Style the anchor and control points.
1914+
* // Style the anchor and points.
19121915
* strokeWeight(5);
19131916
*
19141917
* // Draw the anchor points in black.
19151918
* stroke(0);
19161919
* point(21, 17);
19171920
* point(68, 19);
19181921
*
1919-
* // Draw the control points in red.
1922+
* // Draw the points in red.
19201923
* stroke(255, 0, 0);
19211924
* point(x1, y1);
19221925
* point(84, 91);
19231926
* }
19241927
*
1925-
* // Start changing the first control point if the user clicks near it.
1928+
* // Start changing the first point if the user clicks near it.
19261929
* function mousePressed() {
19271930
* if (dist(mouseX, mouseY, x1, y1) < 20) {
19281931
* isChanging = true;
19291932
* }
19301933
* }
19311934
*
1932-
* // Stop changing the first control point when the user releases the mouse.
1935+
* // Stop changing the first point when the user releases the mouse.
19331936
* function mouseReleased() {
19341937
* isChanging = false;
19351938
* }
19361939
*
1937-
* // Update the first control point while the user drags the mouse.
1940+
* // Update the first point while the user drags the mouse.
19381941
* function mouseDragged() {
19391942
* if (isChanging === true) {
19401943
* x1 = mouseX;
@@ -1954,15 +1957,15 @@ function customShapes(p5, fn) {
19541957
* // Start drawing the shape.
19551958
* beginShape();
19561959
*
1957-
* // Add the first control point and draw a segment to it.
1960+
* // Add the first point and draw a segment to it.
19581961
* splineVertex(32, 91);
19591962
* splineVertex(32, 91);
19601963
*
19611964
* // Add the anchor points.
19621965
* splineVertex(21, 17);
19631966
* splineVertex(68, 19);
19641967
*
1965-
* // Add the second control point.
1968+
* // Add the second point.
19661969
* splineVertex(84, 91);
19671970
* splineVertex(84, 91);
19681971
*

0 commit comments

Comments
 (0)