diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-22 14:45:37 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-22 14:45:37 (GMT) |
| commit | 19c1fa5dcb4c4a2ba9d692e136b17da316a2631b (patch) | |
| tree | 8436e6674dc4375f0392a9142be1a06ddf888337 /src/game/Brush.h | |
| parent | 91bb5a8b781fba33901c0a2804b86055ed588aa4 (diff) | |
| download | powder-19c1fa5dcb4c4a2ba9d692e136b17da316a2631b.zip powder-19c1fa5dcb4c4a2ba9d692e136b17da316a2631b.tar.gz | |
Brush class for drawing on simulation, more interface for game
Diffstat (limited to 'src/game/Brush.h')
| -rw-r--r-- | src/game/Brush.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/game/Brush.h b/src/game/Brush.h new file mode 100644 index 0000000..cc5e819 --- /dev/null +++ b/src/game/Brush.h @@ -0,0 +1,65 @@ +/* + * Brush.h + * + * Created on: Jan 22, 2012 + * Author: Simon + */ + +#ifndef BRUSH_H_ +#define BRUSH_H_ + +#include "interface/Point.h" + +class Brush +{ + bool * bitmap; + ui::Point size; +public: + Brush(ui::Point size_): + bitmap(NULL), + size(size_) + { + + }; + ui::Point GetRadius() + { + return size; + } + void SetRadius(ui::Point size) + { + this->size = size; + GenerateBitmap(); + } + virtual ~Brush() { + if(bitmap) + delete bitmap; + } + //Draw the brush outline onto the screen + virtual void Render(Graphics * g, ui::Point position) + { + g->fillrect(position.X-size.X-1, position.Y-size.Y-1, (size.X*2)+2, (size.Y*2)+2, 255, 0, 255, 70); + } + virtual void GenerateBitmap() + { + if(bitmap) + free(bitmap); + bitmap = (bool *)malloc(sizeof(bool)*(((size.X*2)+1)*((size.Y*2)+1))); + for(int x = 0; x <= size.X*2; x++) + { + for(int y = 0; y <= size.Y*2; y++) + { + bitmap[y*(size.X*2)+x] = true; + } + } + } + //Get a bitmap for drawing particles + bool * GetBitmap() + { + if(!bitmap) + GenerateBitmap(); + return bitmap; + } +}; + + +#endif /* BRUSH_H_ */ |
