Skip to content

Commit 63ad988

Browse files
committed
implement add(x, y) and sub(x, y) in PVector (fixes #3593)
1 parent 6f42502 commit 63ad988

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

core/src/processing/core/PVector.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,17 @@ public PVector add(PVector v) {
460460
}
461461

462462

463+
/**
464+
* @param x x component of the vector
465+
* @param y y component of the vector
466+
*/
467+
public PVector add(float x, float y) {
468+
this.x += x;
469+
this.y += y;
470+
return this;
471+
}
472+
473+
463474
/**
464475
* @param x x component of the vector
465476
* @param y y component of the vector
@@ -521,6 +532,17 @@ public PVector sub(PVector v) {
521532
}
522533

523534

535+
/**
536+
* @param x the x component of the vector
537+
* @param y the y component of the vector
538+
*/
539+
public PVector sub(float x, float y) {
540+
this.x -= x;
541+
this.y -= y;
542+
return this;
543+
}
544+
545+
524546
/**
525547
* @param x the x component of the vector
526548
* @param y the y component of the vector
@@ -543,6 +565,7 @@ static public PVector sub(PVector v1, PVector v2) {
543565
return sub(v1, v2, null);
544566
}
545567

568+
546569
/**
547570
* Subtract one vector from another and store in another vector
548571
* @param v1 the x, y, and z components of a PVector object

core/todo.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ X Zero length string passed to TextLayout constructor
55
X https://github.com/processing/processing/issues/3487
66
X improve speed of text(x, y, w, h) when using large strings with no spaces
77
X https://github.com/processing/processing/issues/211
8+
X implement add(x, y) and sub(x, y) in PVector
9+
X https://github.com/processing/processing/issues/3593
810

911
earlier
1012
X are we clear on sketchPath() for OS X?

todo.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ X canceling "create folder, move sketch, and continue?" will cause crash
77
X throws an NPE and then forces a quit
88
X https://github.com/processing/processing/issues/3586
99
X also showError() there shouldn't die if other Java windows open
10+
_ move Platform into its own class?
11+
_ https://github.com/processing/processing/issues/2765
1012

1113
api changes
1214
X Make fields and functions in PdeKeywords protected
@@ -45,8 +47,6 @@ _ mouse events (i.e. toggle breakpoint) seem to be firing twice
4547

4648

4749
3.0 final
48-
_ move Platform into its own class?
49-
_ https://github.com/processing/processing/issues/2765
5050
_ Contributions Manager UI design
5151
_ https://github.com/processing/processing/issues/3482
5252
_ Ready to add contributed example packages?

0 commit comments

Comments
 (0)