From d68f057b995fc42a611f8f015cda6cd7ad80ddd1 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Thu, 13 Aug 2015 20:59:03 -0400 Subject: [PATCH] implement add(x, y) and sub(x, y) in PVector (fixes #3593) --- core/src/processing/core/PVector.java | 23 +++++++++++++++++++++++ core/todo.txt | 2 ++ todo.txt | 4 ++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/core/src/processing/core/PVector.java b/core/src/processing/core/PVector.java index e0d5eb72d..72c26a093 100644 --- a/core/src/processing/core/PVector.java +++ b/core/src/processing/core/PVector.java @@ -460,6 +460,17 @@ public class PVector implements Serializable { } + /** + * @param x x component of the vector + * @param y y component of the vector + */ + public PVector add(float x, float y) { + this.x += x; + this.y += y; + return this; + } + + /** * @param x x component of the vector * @param y y component of the vector @@ -521,6 +532,17 @@ public class PVector implements Serializable { } + /** + * @param x the x component of the vector + * @param y the y component of the vector + */ + public PVector sub(float x, float y) { + this.x -= x; + this.y -= y; + return this; + } + + /** * @param x the x component of the vector * @param y the y component of the vector @@ -543,6 +565,7 @@ public class PVector implements Serializable { return sub(v1, v2, null); } + /** * Subtract one vector from another and store in another vector * @param v1 the x, y, and z components of a PVector object diff --git a/core/todo.txt b/core/todo.txt index f3b443d7c..6ba6475db 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -5,6 +5,8 @@ X Zero length string passed to TextLayout constructor X https://github.com/processing/processing/issues/3487 X improve speed of text(x, y, w, h) when using large strings with no spaces X https://github.com/processing/processing/issues/211 +X implement add(x, y) and sub(x, y) in PVector +X https://github.com/processing/processing/issues/3593 earlier X are we clear on sketchPath() for OS X? diff --git a/todo.txt b/todo.txt index dfafafe28..f13fb05a9 100644 --- a/todo.txt +++ b/todo.txt @@ -7,6 +7,8 @@ X canceling "create folder, move sketch, and continue?" will cause crash X throws an NPE and then forces a quit X https://github.com/processing/processing/issues/3586 X also showError() there shouldn't die if other Java windows open +_ move Platform into its own class? +_ https://github.com/processing/processing/issues/2765 api changes X Make fields and functions in PdeKeywords protected @@ -45,8 +47,6 @@ _ mouse events (i.e. toggle breakpoint) seem to be firing twice 3.0 final -_ move Platform into its own class? -_ https://github.com/processing/processing/issues/2765 _ Contributions Manager UI design _ https://github.com/processing/processing/issues/3482 _ Ready to add contributed example packages?