Skip to content

Commit e2cd6d5

Browse files
committed
Added bezierVertex docs
1 parent dbdb30a commit e2cd6d5

File tree

1 file changed

+52
-32
lines changed

1 file changed

+52
-32
lines changed

src/shape/vertex.js

+52-32
Original file line numberDiff line numberDiff line change
@@ -410,20 +410,17 @@ function vertex(p5, fn){
410410
* <a href="#/p5/bezier">bezier()</a> function. `bezierVertex()` must be
411411
* called between the
412412
* <a href="#/p5/beginShape">beginShape()</a> and
413-
* <a href="#/p5/endShape">endShape()</a> functions. The curved segment uses
414-
* the previous vertex as the first anchor point, so there must be at least
415-
* one call to <a href="#/p5/vertex">vertex()</a> before `bezierVertex()` can
416-
* be used.
417-
*
418-
* The first four parameters, `x2`, `y2`, `x3`, and `y3`, set the curve’s two
419-
* control points. The control points "pull" the curve towards them.
420-
*
421-
* The fifth and sixth parameters, `x4`, and `y4`, set the last anchor point.
422-
* The last anchor point is where the curve ends.
423-
*
424-
* Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of
425-
* `bezierVertex()` has eight arguments because each point has x-, y-, and
426-
* z-coordinates.
413+
* <a href="#/p5/endShape">endShape()</a> functions. There must be at least
414+
* one call to <a href="#/p5/vertex">bezierVertex()</a>, before
415+
* a number of `bezierVertex()` calls that is a multiple of the parameter
416+
* set by <a href="#/p5/bezierOrder">bezierOrder(...)</a> (default 3).
417+
*
418+
* Each curve of order 3 requires three calls to `bezierVertext`, so
419+
* 2 curves would need 7 calls to `bezierVertex()`:
420+
* (1 one initial anchor point, two sets of 3 curves describing the curves)
421+
* With `bezierOrder(2)`, two curves would need 5 calls: 1 + 2 + 2.
422+
*
423+
* Bézier curves can also be drawn in 3D using WebGL mode.
427424
*
428425
* Note: `bezierVertex()` won’t work when an argument is passed to
429426
* <a href="#/p5/beginShape">beginShape()</a>.
@@ -449,10 +446,12 @@ function vertex(p5, fn){
449446
* beginShape();
450447
*
451448
* // Add the first anchor point.
452-
* vertex(30, 20);
449+
* bezierVertex(30, 20);
453450
*
454451
* // Add the Bézier vertex.
455-
* bezierVertex(80, 0, 80, 75, 30, 75);
452+
* bezierVertex(80, 0);
453+
* bezierVertex(80, 75);
454+
* bezierVertex(30, 75);
456455
*
457456
* // Stop drawing the shape.
458457
* endShape();
@@ -489,10 +488,12 @@ function vertex(p5, fn){
489488
* beginShape();
490489
*
491490
* // Add the first anchor point.
492-
* vertex(30, 20);
491+
* bezierVertex(30, 20);
493492
*
494493
* // Add the Bézier vertex.
495-
* bezierVertex(80, 0, 80, 75, 30, 75);
494+
* bezierVertex(80, 0);
495+
* bezierVertex(80, 75);
496+
* bezierVertex(30, 75);
496497
*
497498
* // Stop drawing the shape.
498499
* endShape();
@@ -549,10 +550,12 @@ function vertex(p5, fn){
549550
* beginShape();
550551
*
551552
* // Add the first anchor point.
552-
* vertex(30, 20);
553+
* bezierVertex(30, 20);
553554
*
554555
* // Add the Bézier vertex.
555-
* bezierVertex(x2, y2, 80, 75, 30, 75);
556+
* bezierVertex(x2, y2);
557+
* bezierVertex(80, 75);
558+
* bezierVertex(30, 75);
556559
*
557560
* // Stop drawing the shape.
558561
* endShape();
@@ -596,11 +599,16 @@ function vertex(p5, fn){
596599
* beginShape();
597600
*
598601
* // Add the first anchor point.
599-
* vertex(30, 20);
602+
* bezierVertex(30, 20);
600603
*
601604
* // Add the Bézier vertices.
602-
* bezierVertex(80, 0, 80, 75, 30, 75);
603-
* bezierVertex(50, 80, 60, 25, 30, 20);
605+
* bezierVertex(80, 0);
606+
* bezierVertex(80, 75);
607+
* bezierVertex(30, 75);
608+
*
609+
* bezierVertex(50, 80);
610+
* bezierVertex(60, 25);
611+
* bezierVertex(30, 20);
604612
*
605613
* // Stop drawing the shape.
606614
* endShape();
@@ -632,16 +640,30 @@ function vertex(p5, fn){
632640
*
633641
* // Draw the first moon.
634642
* beginShape();
635-
* vertex(-20, -30, 0);
636-
* bezierVertex(30, -50, 0, 30, 25, 0, -20, 25, 0);
637-
* bezierVertex(0, 30, 0, 10, -25, 0, -20, -30, 0);
643+
* bezierVertex(-20, -30, 0);
644+
*
645+
* bezierVertex(30, -50, 0);
646+
* bezierVertex(30, 25, 0);
647+
* bezierVertex(-20, 25, 0);
648+
*
649+
* bezierVertex(0, 30, 0);
650+
* bezierVertex(10, -25, 0);
651+
* bezierVertex(-20, -30, 0);
638652
* endShape();
639653
*
640654
* // Draw the second moon.
641655
* beginShape();
642-
* vertex(-20, -30, -20);
643-
* bezierVertex(30, -50, -20, 30, 25, -20, -20, 25, -20);
644-
* bezierVertex(0, 30, -20, 10, -25, -20, -20, -30, -20);
656+
*
657+
* bezierVertex(-20, -30, -20);
658+
*
659+
* bezierVertex(30, -50, -20);
660+
* bezierVertex(30, 25, -20);
661+
* bezierVertex(-20, 25, -20);
662+
*
663+
* bezierVertex(0, 30, -20);
664+
* bezierVertex(10, -25, -20);
665+
* bezierVertex(-20, -30, -20);
666+
*
645667
* endShape();
646668
* }
647669
* </code>
@@ -1068,9 +1090,7 @@ function vertex(p5, fn){
10681090
* <a href="https://p5js.org/tutorials/intro-to-shaders/" target="_blank">writing a custom shader</a>.
10691091
*
10701092
* After calling <a href="#/p5/beginShape">beginShape()</a>, shapes can be
1071-
* built by calling <a href="#/p5/vertex">vertex()</a>,
1072-
* <a href="#/p5/bezierVertex">bezierVertex()</a>,
1073-
* <a href="#/p5/quadraticVertex">quadraticVertex()</a>, and/or
1093+
* <a href="#/p5/bezierVertex">bezierVertex()</a> and/or
10741094
* <a href="#/p5/splineVertex">splineVertex()</a>. Calling
10751095
* `endShape()` will stop adding vertices to the
10761096
* shape. Each shape will be outlined with the current stroke color and filled

0 commit comments

Comments
 (0)