00001 00002 // 00003 // SFML - Simple and Fast Multimedia Library 00004 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) 00005 // 00006 // This software is provided 'as-is', without any express or implied warranty. 00007 // In no event will the authors be held liable for any damages arising from the use of this software. 00008 // 00009 // Permission is granted to anyone to use this software for any purpose, 00010 // including commercial applications, and to alter it and redistribute it freely, 00011 // subject to the following restrictions: 00012 // 00013 // 1. The origin of this software must not be misrepresented; 00014 // you must not claim that you wrote the original software. 00015 // If you use this software in a product, an acknowledgment 00016 // in the product documentation would be appreciated but is not required. 00017 // 00018 // 2. Altered source versions must be plainly marked as such, 00019 // and must not be misrepresented as being the original software. 00020 // 00021 // 3. This notice may not be removed or altered from any source distribution. 00022 // 00024 00025 #ifndef SFML_DRAWABLE_HPP 00026 #define SFML_DRAWABLE_HPP 00027 00029 // Headers 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 Renderer; 00039 class RenderTarget; 00040 00044 namespace Blend 00045 { 00046 enum Mode 00047 { 00048 Alpha, 00049 Add, 00050 Multiply, 00051 None 00052 }; 00053 } 00054 00059 class SFML_API Drawable 00060 { 00061 public : 00062 00072 Drawable(const Vector2f& position = Vector2f(0, 0), const Vector2f& scale = Vector2f(1, 1), float rotation = 0.f, const Color& color = Color(255, 255, 255)); 00073 00078 virtual ~Drawable(); 00079 00087 void SetPosition(float x, float y); 00088 00095 void SetPosition(const Vector2f& position); 00096 00103 void SetX(float x); 00104 00111 void SetY(float y); 00112 00120 void SetScale(float factorX, float factorY); 00121 00128 void SetScale(const Vector2f& scale); 00129 00136 void SetScaleX(float factor); 00137 00144 void SetScaleY(float factor); 00145 00155 void SetOrigin(float x, float y); 00156 00165 void SetOrigin(const Vector2f& origin); 00166 00173 void SetRotation(float angle); 00174 00182 void SetColor(const Color& color); 00183 00191 void SetBlendMode(Blend::Mode mode); 00192 00199 const Vector2f& GetPosition() const; 00200 00207 const Vector2f& GetScale() const; 00208 00215 const Vector2f& GetOrigin() const; 00216 00224 float GetRotation() const; 00225 00232 const Color& GetColor() const; 00233 00240 Blend::Mode GetBlendMode() const; 00241 00249 void Move(float offsetX, float offsetY); 00250 00257 void Move(const Vector2f& offset); 00258 00266 void Scale(float factorX, float factorY); 00267 00274 void Scale(const Vector2f& factor); 00275 00282 void Rotate(float Angle); 00283 00293 Vector2f TransformToLocal(const Vector2f& point) const; 00294 00304 Vector2f TransformToGlobal(const Vector2f& point) const; 00305 00306 protected : 00307 00314 const Matrix3& GetMatrix() const; 00315 00322 const Matrix3& GetInverseMatrix() const; 00323 00324 private : 00325 00326 friend class RenderTarget; 00327 00335 void Draw(RenderTarget& target, Renderer& renderer) const; 00336 00344 virtual void Render(RenderTarget& target, Renderer& renderer) const = 0; 00345 00347 // Member data 00349 Vector2f myPosition; 00350 Vector2f myScale; 00351 Vector2f myOrigin; 00352 float myRotation; 00353 Color myColor; 00354 Blend::Mode myBlendMode; 00355 mutable Matrix3 myMatrix; 00356 mutable Matrix3 myInvMatrix; 00357 mutable bool myMatrixUpdated; 00358 mutable bool myInvMatrixUpdated; 00359 }; 00360 00361 } // namespace sf 00362 00363 00364 #endif // SFML_DRAWABLE_HPP
:: Copyright © 2007-2008 Laurent Gomila, all rights reserved :: Documentation generated by doxygen 1.5.2 ::