Rectangle.cpp
Go to the documentation of this file.00001 //*** Rectangle.cpp ** 00002 00003 #include "Rectangle.h" 00004 00005 00006 //*** Constructor *** 00007 00008 Rectangle::Rectangle(): 00009 width_(10), 00010 height_(10) 00011 { 00012 } 00013 00014 00015 //*** Constructor *** 00016 00017 Rectangle::Rectangle(SpriteManager* spriteManager): 00018 Sprite(spriteManager), 00019 width_(10), 00020 height_(10) 00021 { 00022 } 00023 00024 00025 //*** Destructor *** 00026 00027 Rectangle::~Rectangle() 00028 { 00029 } 00030 00031 00032 00033 //*** SetSize *** 00034 00035 void Rectangle::SetSize(float width, float height) 00036 { 00037 width_=width; 00038 height_=height; 00039 } 00040 00041 00042 //*** SetWidth *** 00043 00044 void Rectangle::SetWidth(float width) 00045 { 00046 width_=width; 00047 } 00048 00049 00050 //*** SetHeight *** 00051 00052 void Rectangle::SetHeight(float height) 00053 { 00054 height_=height; 00055 } 00056 00057 00058 //*** GetWidth *** 00059 00060 float Rectangle::GetWidth() const 00061 { 00062 return width_; 00063 } 00064 00065 00066 //*** GetHeight *** 00067 00068 float Rectangle::GetHeight() const 00069 { 00070 return height_; 00071 } 00072 00073 00074 //*** Render *** 00075 00076 void Rectangle::Render(Bitmap& bitmap) 00077 { 00078 if (IsVisible() && width_>0 && height_>0) 00079 { 00080 int x1=(int)(GetX()-GetOriginX()); 00081 int y1=(int)(GetY()-GetOriginY()); 00082 int x2=x1+(int)GetWidth()-1; 00083 int y2=y1+(int)GetHeight()-1; 00084 00085 if (x1==0 && y1==0 && x2==bitmap.GetWidth()-1 && y2==bitmap.GetHeight()-1 && GetColor()==0 && GetAlpha()==255) 00086 { 00087 bitmap.Clear(); 00088 } 00089 else 00090 { 00091 bitmap.Fill(x1,y1,x2,y2,GetColor(),GetAlpha()); 00092 } 00093 } 00094 00095 }
Reproduction/republishing of any material on this site without permission is strictly prohibited.
