00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025 #ifndef SFML_DRAWABLE_HPP
00026 #define SFML_DRAWABLE_HPP
00027
00029
00031 #include <SFML/System/Vector2.hpp>
00032 #include <SFML/Graphics/Color.hpp>
00033 #include <SFML/Graphics/Matrix3.hpp>
00034
00035
00036 namespace sf
00037 {
00038 class RenderWindow;
00039
00043 namespace Blend
00044 {
00045 enum Mode
00046 {
00047 Alpha,
00048 Add,
00049 Multiply,
00050 None
00051 };
00052 }
00053
00058 class SFML_API Drawable
00059 {
00060 public :
00061
00071 Drawable(const Vector2f& Position = Vector2f(0, 0), const Vector2f& Scale = Vector2f(1, 1), float Rotation = 0.f, const Color& Col = Color(255, 255, 255, 255));
00072
00077 virtual ~Drawable();
00078
00086 void SetPosition(float X, float Y);
00087
00094 void SetPosition(const Vector2f& Position);
00095
00102 void SetX(float X);
00103
00110 void SetY(float Y);
00111
00119 void SetScale(float ScaleX, float ScaleY);
00120
00127 void SetScale(const Vector2f& Scale);
00128
00135 void SetScaleX(float FactorX);
00136
00143 void SetScaleY(float FactorY);
00144
00154 void SetCenter(float CenterX, float CenterY);
00155
00164 void SetCenter(const Vector2f& Center);
00165
00172 void SetRotation(float Rotation);
00173
00181 void SetColor(const Color& Col);
00182
00190 void SetBlendMode(Blend::Mode Mode);
00191
00198 const Vector2f& GetPosition() const;
00199
00206 const Vector2f& GetScale() const;
00207
00214 const Vector2f& GetCenter() const;
00215
00223 float GetRotation() const;
00224
00231 const Color& GetColor() const;
00232
00239 Blend::Mode GetBlendMode() const;
00240
00248 void Move(float OffsetX, float OffsetY);
00249
00256 void Move(const Vector2f& Offset);
00257
00265 void Scale(float FactorX, float FactorY);
00266
00273 void Scale(const Vector2f& Factor);
00274
00281 void Rotate(float Angle);
00282
00283 protected :
00284
00291 const Matrix3& GetMatrix() const;
00292
00293 private :
00294
00295 friend class RenderWindow;
00296
00303 void Draw(const RenderWindow& Window) const;
00304
00311 virtual void Render(const RenderWindow& Window) const = 0;
00312
00314
00316 Vector2f myPosition;
00317 Vector2f myScale;
00318 Vector2f myCenter;
00319 float myRotation;
00320 Color myColor;
00321 Blend::Mode myBlendMode;
00322 mutable bool myNeedUpdate;
00323 mutable Matrix3 myMatrix;
00324 };
00325
00326 }
00327
00328
00329 #endif // SFML_DRAWABLE_HPP