Skip to content

Commit 9ffb4ae

Browse files
committed
Merge pull request processing-js#197 from jjwon/master
adding and subtracting for 2D vectors
2 parents f72e3c3 + b6cb09d commit 9ffb4ae

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Objects/PVector.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ module.exports = function(options, undef) {
106106
this.x += v.x;
107107
this.y += v.y;
108108
this.z += v.z;
109+
} else if (arguments.length === 2) {
110+
// 2D Vector
111+
this.x += v;
112+
this.y += y;
109113
} else {
110114
this.x += v;
111115
this.y += y;
@@ -117,6 +121,10 @@ module.exports = function(options, undef) {
117121
this.x -= v.x;
118122
this.y -= v.y;
119123
this.z -= v.z;
124+
} else if (arguments.length === 2) {
125+
// 2D Vector
126+
this.x -= v;
127+
this.y -= y;
120128
} else {
121129
this.x -= v;
122130
this.y -= y;
@@ -234,4 +242,3 @@ module.exports = function(options, undef) {
234242

235243
return PVector;
236244
};
237-

0 commit comments

Comments
 (0)