summaryrefslogtreecommitdiff
path: root/src/game/BitmapBrush.h
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-11-18 18:03:36 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-11-18 18:03:36 (GMT)
commit045f5e14c287a2b44e963268365f48f862f0e23f (patch)
tree3cad89614aac064363e10cef22c4b7fd30a4c841 /src/game/BitmapBrush.h
parent483e9077023bf75e4e2aaa0630f62e5d3893395e (diff)
downloadpowder-045f5e14c287a2b44e963268365f48f862f0e23f.zip
powder-045f5e14c287a2b44e963268365f48f862f0e23f.tar.gz
Custom brushes loaded from "Brushes" folder, format is a simple RAW 8bit greyscale square format
Diffstat (limited to 'src/game/BitmapBrush.h')
-rw-r--r--src/game/BitmapBrush.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/game/BitmapBrush.h b/src/game/BitmapBrush.h
new file mode 100644
index 0000000..dd8dd92
--- /dev/null
+++ b/src/game/BitmapBrush.h
@@ -0,0 +1,56 @@
+/*
+ * BitmapBrush.h
+ *
+ * Created on: Nov 18, 2012
+ * Author: Simon Robertshaw
+ */
+
+#ifndef BTIMAPBRUSH_H_
+#define BTIMAPBRUSH_H_
+
+#include <vector>
+#include <cmath>
+#include "Brush.h"
+
+class BitmapBrush: public Brush
+{
+public:
+ BitmapBrush(std::vector<unsigned char> newBitmap, ui::Point rectSize_):
+ Brush(ui::Point(0, 0))
+ {
+ ui::Point newSize = rectSize_;
+
+ //Ensure the rect has odd dimentions so we can pull an integer radius with a 1x1 centre
+ if(!(newSize.X % 2))
+ newSize.X += 1;
+ if(!(newSize.Y % 2))
+ newSize.Y += 1;
+
+ radius = (newSize-ui::Point(1, 1))/2;
+ size = newSize;
+
+ if(bitmap)
+ delete[] bitmap;
+ bitmap = new unsigned char[size.X*size.Y];
+ std::fill(bitmap, bitmap+(size.X*size.Y), 0);
+ for(int y = 0; y < rectSize_.Y; y++)
+ {
+ for(int x = 0; x < rectSize_.X; x++)
+ {
+ bitmap[(y*size.X)+x] = newBitmap[(y*rectSize_.X)+x];
+ }
+ }
+
+ updateOutline();
+ };
+ virtual void SetRadius(ui::Point radius)
+ {
+ //Do nothing... this brush is a fixed size
+ }
+ virtual void GenerateBitmap()
+ {
+ //Do nothing
+ }
+};
+
+#endif /* BTIMAPBRUSH_H_ */