@@ -3,24 +3,98 @@ title: bezierOrder
3
3
module : Shape
4
4
submodule : Custom Shapes
5
5
file : src/shape/custom_shapes.js
6
- description : ' '
7
- line : 1594
6
+ description : >
7
+ <p>Influences the shape of the Bézier curve segment in a custom shape.
8
+
9
+ By default, this is 3; the other possible parameter is 2. This
10
+
11
+ results in quadratic Bézier curves.</p>
12
+
13
+ <p><code>bezierVertex()</code> adds a curved segment to custom shapes. The
14
+ Bézier curves
15
+
16
+ it creates are defined like those made by the
17
+
18
+ <a href="/reference/p5/bezier/">bezier()</a> function.
19
+ <code>bezierVertex()</code> must be
20
+
21
+ called between the
22
+
23
+ <a href="/reference/p5/beginShape/">beginShape()</a> and
24
+
25
+ <a href="/reference/p5/endShape/">endShape()</a> functions. There must be at
26
+ least
27
+
28
+ one call to <a href="/reference/p5/vertex/">bezierVertex()</a>, before
29
+
30
+ a number of <code>bezierVertex()</code> calls that is a multiple of the
31
+ parameter
32
+
33
+ set by <a href="/reference/p5/bezierOrder/">bezierOrder(...)</a> (default
34
+ 3).</p>
35
+
36
+ <p>Each curve of order 3 requires three calls to <code>bezierVertex</code>, so
37
+
38
+ 2 curves would need 7 calls to <code>bezierVertex()</code>:
39
+
40
+ (1 one initial anchor point, two sets of 3 curves describing the curves)
41
+
42
+ With <code>bezierOrder(2)</code>, two curves would need 5 calls: 1 + 2 +
43
+ 2.</p>
44
+
45
+ <p>Bézier curves can also be drawn in 3D using WebGL mode.</p>
46
+
47
+ <p>Note: <code>bezierVertex()</code> won’t work when an argument is passed to
48
+
49
+ <a href="/reference/p5/beginShape/">beginShape()</a>.</p>
50
+ line : 1645
8
51
isConstructor : false
9
52
itemtype : method
10
- example : []
53
+ example :
54
+ - |-
55
+ <div>
56
+ <code>
57
+ function setup() {
58
+ createCanvas(100, 100);
59
+
60
+ background(200);
61
+
62
+ // Style the shape.
63
+ noFill();
64
+
65
+ // Start drawing the shape.
66
+ beginShape();
67
+
68
+ // set the order to 2 for a quadratic Bézier curve
69
+ bezierOrder(2);
70
+
71
+ // Add the first anchor point.
72
+ bezierVertex(30, 20);
73
+
74
+ // Add the Bézier vertex.
75
+ bezierVertex(80, 20);
76
+ bezierVertex(50, 50);
77
+
78
+ // Stop drawing the shape.
79
+ endShape();
80
+
81
+ describe('A black curve drawn on a gray square. The curve starts at the top-left corner and ends at the center.');
82
+ }
83
+ </code>
84
+ </div>
11
85
class : p5
12
86
return :
13
- description : The current bezier order.
87
+ description : The current Bézier order.
14
88
type : Number
15
89
overloads :
16
- - params : []
17
- return :
18
- description : The current bezier order.
19
- type : Number
20
90
- params :
21
91
- name : order
22
- description : The new order to set.
92
+ description : ' The new order to set. Can be either 2 or 3, by default 3 '
23
93
type : Number
94
+ - params : []
95
+ return :
96
+ description : The current Bézier order.
97
+ type : Number
24
98
chainable : false
25
99
---
26
100
0 commit comments