You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The static version of <code>add()</code>, as in <code>p5.Vector.add(v2,
28
+
v1)</code>, returns a new
29
+
30
+
<a href="/reference/p5/p5.Vector">p5.Vector</a> object and doesn't change the
31
+
32
+
originals.</p>
33
+
line: 517
8
34
isConstructor: false
9
35
itemtype: method
10
-
example: []
36
+
example:
37
+
- |-
38
+
<div>
39
+
<code>
40
+
function setup() {
41
+
createCanvas(100, 100);
42
+
43
+
background(200);
44
+
45
+
// Style the points.
46
+
strokeWeight(5);
47
+
48
+
// Top left.
49
+
let pos = createVector(25, 25);
50
+
point(pos);
51
+
52
+
// Top right.
53
+
// Add numbers.
54
+
pos.add(50, 0);
55
+
point(pos);
56
+
57
+
// Bottom right.
58
+
// Add a p5.Vector.
59
+
let p2 = createVector(0, 50);
60
+
pos.add(p2);
61
+
point(pos);
62
+
63
+
// Bottom left.
64
+
// Add an array.
65
+
let arr = [-50, 0];
66
+
pos.add(arr);
67
+
point(pos);
68
+
69
+
describe('Four black dots arranged in a square on a gray background.');
70
+
}
71
+
</code>
72
+
</div>
73
+
74
+
<div>
75
+
<code>
76
+
function setup() {
77
+
createCanvas(100, 100);
78
+
79
+
background(200);
80
+
81
+
// Top left.
82
+
let p1 = createVector(25, 25);
83
+
84
+
// Center.
85
+
let p2 = createVector(50, 50);
86
+
87
+
// Bottom right.
88
+
// Add p1 and p2.
89
+
let p3 = p5.Vector.add(p1, p2);
90
+
91
+
// Draw the points.
92
+
strokeWeight(5);
93
+
point(p1);
94
+
point(p2);
95
+
point(p3);
96
+
97
+
describe('Three black dots in a diagonal line from top left to bottom right.');
98
+
}
99
+
</code>
100
+
</div>
101
+
102
+
<div>
103
+
<code>
104
+
function setup() {
105
+
createCanvas(100, 100);
106
+
107
+
describe('Three arrows drawn on a gray square. A red arrow extends from the top left corner to the center. A blue arrow extends from the tip of the red arrow. A purple arrow extends from the origin to the tip of the blue arrow.');
0 commit comments