diff options
author | Christopher Baines <cbaines8@gmail.com> | 2011-09-12 09:55:01 +0100 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2011-09-12 09:55:01 +0100 |
commit | c7a7e4634b79a7b5da8d7b53306897347d57374d (patch) | |
tree | 7900a3fa8fcf356d49b2bb3278ec290a95f75185 | |
parent | 852306221f4adcaf2ea9edb68153ea6090b68803 (diff) | |
parent | 86abb5088585c6b88016362ffde7b5f3dfd568fe (diff) | |
download | punchingbag-c7a7e4634b79a7b5da8d7b53306897347d57374d.tar punchingbag-c7a7e4634b79a7b5da8d7b53306897347d57374d.tar.gz |
Merge branch 'master' of gitorious.org:punchingbag/punchingbag
-rw-r--r-- | PunchingBag/src/PunchingBag.java | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/PunchingBag/src/PunchingBag.java b/PunchingBag/src/PunchingBag.java index 85553a5..e046842 100644 --- a/PunchingBag/src/PunchingBag.java +++ b/PunchingBag/src/PunchingBag.java @@ -217,6 +217,91 @@ 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 { + 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, + 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); |