diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index 9a9e8079b..c56c195d4 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -7,6 +7,7 @@ #include "interface/Point.h" #include "Brush.h" #include "EllipseBrush.h" +#include "TriangleBrush.h" #include "client/Client.h" #include "game/DecorationTool.h" #include "GameModelException.h" @@ -222,6 +223,7 @@ void GameModel::BuildMenus() //Set default brush palette brushList.push_back(new EllipseBrush(ui::Point(4, 4))); brushList.push_back(new Brush(ui::Point(4, 4))); + brushList.push_back(new TriangleBrush(ui::Point(4, 4))); //Set default tools activeTools[0] = menuList[SC_POWDERS]->GetToolList()[0]; @@ -801,4 +803,4 @@ void GameModel::notifyQuickOptionsChanged() { observers[i]->NotifyQuickOptionsChanged(this); } -} \ No newline at end of file +} diff --git a/src/game/TriangleBrush.h b/src/game/TriangleBrush.h new file mode 100644 index 000000000..7d537bde4 --- /dev/null +++ b/src/game/TriangleBrush.h @@ -0,0 +1,46 @@ +/* + * TriangleBrush.h + * + * Created on: Jan 26, 2012 + * Author: Savely Skresanov + */ + +#ifndef TRIANGLEBRUSH_H_ +#define TRIANGLEBRUSH_H_ + +#include +#include "Brush.h" + +class TriangleBrush: public Brush +{ +public: + TriangleBrush(ui::Point size_): + Brush(size_) + { + SetRadius(size_); + }; + virtual void GenerateBitmap() + { + if(bitmap) + delete[] bitmap; + bitmap = new unsigned char[size.X*size.Y]; + int rx = radius.X; + int ry = radius.Y; + for(int x = -rx; x <= rx; x++) + { + for(int y = -ry; y <= ry; y++) + { + if ((abs((rx+2*x)*ry+rx*y) + abs(2*rx*(y-ry)) + abs((rx-2*x)*ry+rx*y))<=(4*rx*ry)) + { + bitmap[(y+ry)*(size.X)+x+rx] = 255; + } + else + { + bitmap[(y+ry)*(size.X)+x+rx] = 0; + } + } + } + } +}; + +#endif /* TRIANGLEBRUSH_H_ */