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_SHAPE_HPP 00026 #define SFML_SHAPE_HPP 00027 00029 // Headers 00031 #include <SFML/Graphics/Drawable.hpp> 00032 #include <SFML/System/Vector2.hpp> 00033 #include <vector> 00034 00035 00036 namespace sf 00037 { 00042 class SFML_API Shape : public Drawable 00043 { 00044 public : 00045 00052 Shape(); 00053 00065 void AddPoint(float x, float y, const Color& color = Color(255, 255, 255), const Color& outlineColor = Color(0, 0, 0)); 00066 00077 void AddPoint(const Vector2f& position, const Color& color = Color(255, 255, 255), const Color& outlineColor = Color(0, 0, 0)); 00078 00085 unsigned int GetPointsCount() const; 00086 00097 void EnableFill(bool enable); 00098 00109 void EnableOutline(bool enable); 00110 00124 void SetPointPosition(unsigned int index, const Vector2f& position); 00125 00140 void SetPointPosition(unsigned int index, float x, float y); 00141 00155 void SetPointColor(unsigned int index, const Color& color); 00156 00170 void SetPointOutlineColor(unsigned int index, const Color& color); 00171 00180 void SetOutlineThickness(float thickness); 00181 00196 const Vector2f& GetPointPosition(unsigned int index) const; 00197 00212 const Color& GetPointColor(unsigned int index) const; 00213 00228 const Color& GetPointOutlineColor(unsigned int index) const; 00229 00238 float GetOutlineThickness() const; 00239 00266 static Shape Line(float p1x, float p1y, float p2x, float p2y, float thickness, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0)); 00267 00294 static Shape Line(const Vector2f& start, const Vector2f& end, float thickness, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0)); 00295 00321 static Shape Rectangle(float left, float top, float width, float height, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0)); 00322 00346 static Shape Rectangle(const FloatRect& rectangle, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0)); 00347 00372 static Shape Circle(float x, float y, float radius, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0)); 00373 00398 static Shape Circle(const Vector2f& center, float radius, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0)); 00399 00400 protected : 00401 00409 virtual void Render(RenderTarget& target, Renderer& renderer) const; 00410 00411 private : 00412 00420 void Compile(); 00421 00432 static bool ComputeNormal(const Vector2f& p1, const Vector2f& p2, Vector2f& normal); 00433 00438 struct Point 00439 { 00440 Point(const Vector2f& position = Vector2f(0, 0), const Color& color = Color(255, 255, 255), const Color& outlineColor = Color(255, 255, 255)); 00441 00442 Vector2f Position; 00443 Vector2f Normal; 00444 Color Col; 00445 Color OutlineCol; 00446 }; 00447 00449 // Member data 00451 std::vector<Point> myPoints; 00452 float myOutline; 00453 bool myIsFillEnabled; 00454 bool myIsOutlineEnabled; 00455 bool myIsCompiled; 00456 }; 00457 00458 } // namespace sf 00459 00460 00461 #endif // SFML_SHAPE_HPP 00462 00463
:: Copyright © 2007-2008 Laurent Gomila, all rights reserved :: Documentation generated by doxygen 1.5.2 ::