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_SHAPE_HPP
00026 #define SFML_SHAPE_HPP
00027
00029
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
00451 std::vector<Point> myPoints;
00452 float myOutline;
00453 bool myIsFillEnabled;
00454 bool myIsOutlineEnabled;
00455 bool myIsCompiled;
00456 };
00457
00458 }
00459
00460
00461 #endif // SFML_SHAPE_HPP
00462
00463