summaryrefslogtreecommitdiff
path: root/src/SFML/Graphics/Shape.cpp
diff options
context:
space:
mode:
authorChristoph Egger <Christoph.Egger@gmx.de>2008-11-01 17:37:58 +0100
committerChristoph Egger <Christoph.Egger@gmx.de>2008-11-01 17:37:58 +0100
commit9035708f4c5f7a78d8fb810e87e183fd61fd3350 (patch)
tree030e13b45c9882b799f793aa27007c74862fe934 /src/SFML/Graphics/Shape.cpp
parenta96b4da2ed67a3e8dcc8e2a0d9af9463a23bb021 (diff)
Imported Upstream version 1.4~svn915
Diffstat (limited to 'src/SFML/Graphics/Shape.cpp')
-rw-r--r--[-rwxr-xr-x]src/SFML/Graphics/Shape.cpp100
1 files changed, 92 insertions, 8 deletions
diff --git a/src/SFML/Graphics/Shape.cpp b/src/SFML/Graphics/Shape.cpp
index 551f562..a5c9524 100755..100644
--- a/src/SFML/Graphics/Shape.cpp
+++ b/src/SFML/Graphics/Shape.cpp
@@ -26,7 +26,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Shape.hpp>
-#include <SFML/Graphics/Renderer.hpp>
+#include <SFML/Graphics/GraphicsContext.hpp>
#include <math.h>
@@ -66,6 +66,15 @@ void Shape::AddPoint(const Vector2f& Position, const Color& Col, const Color& Ou
////////////////////////////////////////////////////////////
+/// Get the number of points composing the shape
+////////////////////////////////////////////////////////////
+unsigned int Shape::GetNbPoints() const
+{
+ return static_cast<unsigned int>(myPoints.size() - 1);
+}
+
+
+////////////////////////////////////////////////////////////
/// Enable or disable filling the shape.
/// Fill is enabled by default
////////////////////////////////////////////////////////////
@@ -86,6 +95,45 @@ void Shape::EnableOutline(bool Enable)
////////////////////////////////////////////////////////////
+/// Set the position of a point
+////////////////////////////////////////////////////////////
+void Shape::SetPointPosition(unsigned int Index, const Vector2f& Position)
+{
+ myPoints[Index + 1].Position = Position;
+ myIsCompiled = false;
+}
+
+
+////////////////////////////////////////////////////////////
+/// Set the position of a point
+////////////////////////////////////////////////////////////
+void Shape::SetPointPosition(unsigned int Index, float X, float Y)
+{
+ SetPointPosition(Index, Vector2f(X, Y));
+}
+
+
+////////////////////////////////////////////////////////////
+/// Set the color of a point
+////////////////////////////////////////////////////////////
+void Shape::SetPointColor(unsigned int Index, const Color& Col)
+{
+ myPoints[Index + 1].Col = Col;
+ myIsCompiled = false;
+}
+
+
+////////////////////////////////////////////////////////////
+/// Set the outline color of a point
+////////////////////////////////////////////////////////////
+void Shape::SetPointOutlineColor(unsigned int Index, const Color& OutlineCol)
+{
+ myPoints[Index + 1].OutlineCol = OutlineCol;
+ myIsCompiled = false;
+}
+
+
+////////////////////////////////////////////////////////////
/// Change the width of the shape outline
////////////////////////////////////////////////////////////
void Shape::SetOutlineWidth(float Width)
@@ -95,20 +143,29 @@ void Shape::SetOutlineWidth(float Width)
////////////////////////////////////////////////////////////
-/// Get the number of points composing the shape
+/// Get the position of a point
////////////////////////////////////////////////////////////
-unsigned int Shape::GetNbPoints() const
+const Vector2f& Shape::GetPointPosition(unsigned int Index) const
{
- return static_cast<unsigned int>(myPoints.size() - 1);
+ return myPoints[Index + 1].Position;
}
////////////////////////////////////////////////////////////
-/// Get a point of the shape
+/// Get the color of a point
////////////////////////////////////////////////////////////
-const Vector2f& Shape::GetPoint(unsigned int Index) const
+const Color& Shape::GetPointColor(unsigned int Index) const
{
- return myPoints[Index + 1].Position;
+ return myPoints[Index + 1].Col;
+}
+
+
+////////////////////////////////////////////////////////////
+/// Get the outline color of a point
+////////////////////////////////////////////////////////////
+const Color& Shape::GetPointOutlineColor(unsigned int Index) const
+{
+ return myPoints[Index + 1].OutlineCol;
}
@@ -150,6 +207,15 @@ Shape Shape::Line(float P1X, float P1Y, float P2X, float P2Y, float Thickness, c
////////////////////////////////////////////////////////////
+/// Create a shape made of a single line (use vectors)
+////////////////////////////////////////////////////////////
+Shape Shape::Line(const Vector2f& P1, const Vector2f& P2, float Thickness, const Color& Col, float Outline, const Color& OutlineCol)
+{
+ return Shape::Line(P1.x, P1.y, P2.x, P2.y, Thickness, Col, Outline, OutlineCol);
+}
+
+
+////////////////////////////////////////////////////////////
/// Create a shape made of a single rectangle
////////////////////////////////////////////////////////////
Shape Shape::Rectangle(float P1X, float P1Y, float P2X, float P2Y, const Color& Col, float Outline, const Color& OutlineCol)
@@ -170,6 +236,15 @@ Shape Shape::Rectangle(float P1X, float P1Y, float P2X, float P2Y, const Color&
////////////////////////////////////////////////////////////
+/// Create a shape made of a single rectangle (use vectors)
+////////////////////////////////////////////////////////////
+Shape Shape::Rectangle(const Vector2f& P1, const Vector2f& P2, const Color& Col, float Outline, const Color& OutlineCol)
+{
+ return Shape::Rectangle(P1.x, P1.y, P2.x, P2.y, Col, Outline, OutlineCol);
+}
+
+
+////////////////////////////////////////////////////////////
/// Create a shape made of a single circle
////////////////////////////////////////////////////////////
Shape Shape::Circle(float X, float Y, float Radius, const Color& Col, float Outline, const Color& OutlineCol)
@@ -196,9 +271,18 @@ Shape Shape::Circle(float X, float Y, float Radius, const Color& Col, float Outl
////////////////////////////////////////////////////////////
+/// Create a shape made of a single circle (use vectors)
+////////////////////////////////////////////////////////////
+Shape Shape::Circle(const Vector2f& Center, float Radius, const Color& Col, float Outline, const Color& OutlineCol)
+{
+ return Shape::Circle(Center.x, Center.y, Radius, Col, Outline, OutlineCol);
+}
+
+
+////////////////////////////////////////////////////////////
/// /see Drawable::Render
////////////////////////////////////////////////////////////
-void Shape::Render(const RenderWindow&) const
+void Shape::Render(RenderTarget&) const
{
// Make sure the shape has at least 3 points (4 if we count the center)
if (myPoints.size() < 4)