From 056a5920ed894e7340a0dc4cfcebad4b8ff2c50b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Sep 2011 15:32:48 +0100 Subject: Added drawRectCorner, half way through drawRectCentre --- PunchingBag/src/PunchingBag.java | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'PunchingBag') diff --git a/PunchingBag/src/PunchingBag.java b/PunchingBag/src/PunchingBag.java index 198e709..0128120 100644 --- a/PunchingBag/src/PunchingBag.java +++ b/PunchingBag/src/PunchingBag.java @@ -217,6 +217,70 @@ public class PunchingBag implements Runnable { } } + public boolean drawRectCenter(int x, int y, int height, int width, + Colour colour) { + if (height < 0) { + height = 0; + } + if (width < 0) { + width = 0; + } + if (height == 0 && width == 0) { + return setLEDInternal(x, y, colour); + } + + boolean doneSomething = false; + int widthEx = 0; + int heightEx = 0; + + do { + + } while (height && width >= 0); + + + } + + public boolean drawRectCorner(int x, int y, int height, int width, + Colour colour) { + if (height < 0) { + height = 0; + } + if (width < 0) { + width = 0; + } + if (height == 0 && width == 0) { + return setLEDInternal(x, y, colour); + } + + boolean doneSomething = false; + int heightEx = 0; + int widthEx = 0; + + do { + if (setLEDInternal(x + widthEx, y, colour)) { + doneSomething = true; + } + + if (setLEDInternal(x, y + heightEx, colour)) { + doneSomething = true; + } + if (setLEDInternal(x + widthEx, y + height, colour)) { + doneSomething = true; + } + if (setLEDInternal(x + width, y + heightEx, colour)) { + doneSomething = true; + } + if (heightEx < height) { + heightEx++; + } + if (widthEx < width) { + heightEx++; + } + } while (height >= 0 && width >= 0); + + return doneSomething; + } + public boolean drawEllipse(int x, int y, int radx, int rady, Colour colour) { if (radx == 0 && rady == 0) { return setLEDInternal(x, y, colour); -- cgit v1.2.3 From 86abb5088585c6b88016362ffde7b5f3dfd568fe Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Sep 2011 15:52:37 +0100 Subject: Finished drawRectCentre --- PunchingBag/src/PunchingBag.java | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'PunchingBag') diff --git a/PunchingBag/src/PunchingBag.java b/PunchingBag/src/PunchingBag.java index 0128120..5af23cf 100644 --- a/PunchingBag/src/PunchingBag.java +++ b/PunchingBag/src/PunchingBag.java @@ -232,12 +232,33 @@ public class PunchingBag implements Runnable { boolean doneSomething = false; int widthEx = 0; int heightEx = 0; - + do { - + if (setLEDInternal((x - (height / 2)) + widthEx, y - (height / 2), + colour)) { + doneSomething = true; + } + if (setLEDInternal(x - (height / 2), (y - (height / 2)) + heightEx, + colour)) { + doneSomething = true; + } + if (setLEDInternal((x - (height / 2)) + widthEx, y + (height / 2), + colour)) { + doneSomething = true; + } + if (setLEDInternal(x + (height / 2), (y - (height / 2)) + heightEx)) { + doneSomething = true; + } + if (heightEx < height) { + heightEx++; + } + if (widthEx < width) { + widthEx++; + } + } while (height && width >= 0); - + return doneSomething; } public boolean drawRectCorner(int x, int y, int height, int width, @@ -274,10 +295,10 @@ public class PunchingBag implements Runnable { heightEx++; } if (widthEx < width) { - heightEx++; + heightEx++; } } while (height >= 0 && width >= 0); - + return doneSomething; } -- cgit v1.2.3