summaryrefslogtreecommitdiff
path: root/src/gui/game/Brush.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2013-03-24 12:24:17 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2013-03-24 12:24:17 (GMT)
commit9b5b85f9b01cbda7ef9a7ec2a15b2a35630a5b9d (patch)
treeac7d040253b459ce102e476cb19ab59e3cfa90d7 /src/gui/game/Brush.cpp
parent6bf98ccdca39936a3c51367862eed7c49f8786ec (diff)
parentbdc69f31c0be94191015838886bdcc2bc67f1acb (diff)
downloadpowder-9b5b85f9b01cbda7ef9a7ec2a15b2a35630a5b9d.zip
powder-9b5b85f9b01cbda7ef9a7ec2a15b2a35630a5b9d.tar.gz
Merge branch 'reorganisation' of github.com:FacialTurd/The-Powder-Toy
Diffstat (limited to 'src/gui/game/Brush.cpp')
-rw-r--r--src/gui/game/Brush.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/gui/game/Brush.cpp b/src/gui/game/Brush.cpp
new file mode 100644
index 0000000..9f2f2a8
--- /dev/null
+++ b/src/gui/game/Brush.cpp
@@ -0,0 +1,51 @@
+#include "Brush.h"
+#include "graphics/Renderer.h"
+
+void Brush::RenderRect(Renderer * ren, ui::Point position1, ui::Point position2)
+{
+ int width, height, t;
+ width = position2.X-position1.X;
+ height = position2.Y-position1.Y;
+ if(height<0)
+ {
+ position1.Y += height;
+ height *= -1;
+ }
+ if(width<0)
+ {
+ position1.X += width;
+ width *= -1;
+ }
+
+ ren->xor_line(position1.X, position1.Y, position1.X+width, position1.Y);
+ if(height>0){
+ ren->xor_line(position1.X, position1.Y+height, position1.X+width, position1.Y+height);
+ if(height>1){
+ ren->xor_line(position1.X+width, position1.Y+1, position1.X+width, position1.Y+height-1);
+ if(width>0)
+ ren->xor_line(position1.X, position1.Y+1, position1.X, position1.Y+height-1);
+ }
+ }
+}
+
+void Brush::RenderLine(Renderer * ren, ui::Point position1, ui::Point position2)
+{
+ ren->xor_line(position1.X, position1.Y, position2.X, position2.Y);
+}
+
+void Brush::RenderPoint(Renderer * ren, ui::Point position)
+{
+ if(!outline)
+ updateOutline();
+ if(!outline)
+ return;
+ ren->xor_bitmap(outline, position.X-radius.X, position.Y-radius.Y, size.X, size.Y);
+}
+
+void Brush::RenderFill(Renderer * ren, ui::Point position)
+{
+ ren->xor_line(position.X-5, position.Y, position.X-1, position.Y);
+ ren->xor_line(position.X+5, position.Y, position.X+1, position.Y);
+ ren->xor_line(position.X, position.Y-5, position.X, position.Y-1);
+ ren->xor_line(position.X, position.Y+5, position.X, position.Y+1);
+}