diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-26 18:06:23 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-26 18:06:23 (GMT) |
| commit | e84f0fc6e5301265708a99b13ab898ce45422611 (patch) | |
| tree | 2bbcf8aeb7e0b4177ccaa22a0bde2add3c696765 /src/game/EllipseBrush.h | |
| parent | 824d3c069bc409d268a2a15352e96868a7731a56 (diff) | |
| download | powder-e84f0fc6e5301265708a99b13ab898ce45422611.zip powder-e84f0fc6e5301265708a99b13ab898ce45422611.tar.gz | |
Ellipse cursor
Diffstat (limited to 'src/game/EllipseBrush.h')
| -rw-r--r-- | src/game/EllipseBrush.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/game/EllipseBrush.h b/src/game/EllipseBrush.h new file mode 100644 index 0000000..7e5825b --- /dev/null +++ b/src/game/EllipseBrush.h @@ -0,0 +1,60 @@ +/* + * ElipseBrush.h + * + * Created on: Jan 26, 2012 + * Author: Simon + */ + +#ifndef ELIPSEBRUSH_H_ +#define ELIPSEBRUSH_H_ + +#include "Brush.h" + +class EllipseBrush: public Brush +{ +public: + EllipseBrush(ui::Point size_): + Brush(size_) + { + + }; + //Draw the brush outline onto the screen + virtual void Render(Graphics * g, ui::Point position) + { + if(!bitmap) + GenerateBitmap(); + //g->fillrect(position.X-size.X-1, position.Y-size.Y-1, (size.X*2)+2, (size.Y*2)+2, 255, 0, 255, 70); + for(int x = 0; x <= size.X*2; x++) + { + for(int y = 0; y <= size.Y*2; y++) + { + if(bitmap[y*(size.X*2)+x]) + g->blendpixel(position.X-size.X+x, position.Y-size.Y+y, 255, 0, 255, 70); + } + } + } + virtual void GenerateBitmap() + { + if(bitmap) + free(bitmap); + bitmap = (bool *)malloc(sizeof(bool)*(((size.X*2)+1)*((size.Y*2)+1))); + int rx = size.X; + int ry = size.Y; + for(int x = 0; x <= size.X*2; x++) + { + for(int y = 0; y <= size.Y*2; y++) + { + if((pow(x-size.X,2)*pow(ry,2)+pow(y-size.Y,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2))) + { + bitmap[y*(size.X*2)+x] = true; + } + else + { + bitmap[y*(size.X*2)+x] = false; + } + } + } + } +}; + +#endif /* ELIPSEBRUSH_H_ */ |
