Modified the overloads of sf::Shape::Rectangle according to the last modification

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1506 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-04-10 09:35:15 +00:00
parent 136af3d1fe
commit a00a9c1cc2
5 changed files with 32 additions and 35 deletions

View File

@ -58,14 +58,14 @@ CSFML_API sfShape* sfShape_CreateLine(float p1x, float p1y, float p2x, float p2y
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create a new shape made of a single rectangle /// Create a new shape made of a single rectangle
/// ///
/// \param p1x, p1y : Position of the first point /// \param left, top : Top-left corner of the rectangle
/// \param p2x, p2y : Position second point /// \param width, height : Size of the rectangle
/// \param color : Color used to fill the rectangle /// \param color : Color used to fill the rectangle
/// \param outline : Outline width /// \param outline : Outline width
/// \param outlineColor : Color used to draw the outline /// \param outlineColor : Color used to draw the outline
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_CreateRectangle(float p1x, float p1y, float p2x, float p2y, sfColor color, float outline, sfColor outlineColor); CSFML_API sfShape* sfShape_CreateRectangle(float left, float top, float width, float height, sfColor color, float outline, sfColor outlineColor);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create a new shape made of a single circle /// Create a new shape made of a single circle

View File

@ -57,13 +57,13 @@ sfShape* sfShape_CreateLine(float p1x, float p1y, float p2x, float p2y, float th
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create a new shape made of a single rectangle /// Create a new shape made of a single rectangle
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfShape* sfShape_CreateRectangle(float p1x, float p1y, float p2x, float p2y, sfColor color, float outline, sfColor outlineColor) sfShape* sfShape_CreateRectangle(float left, float top, float width, float height, sfColor color, float outline, sfColor outlineColor)
{ {
sf::Color SFMLColor(color.r, color.g, color.b, color.a); sf::Color SFMLColor(color.r, color.g, color.b, color.a);
sf::Color SFMLOutlineColor(outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a); sf::Color SFMLOutlineColor(outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a);
sfShape* shape = new sfShape; sfShape* shape = new sfShape;
shape->This = sf::Shape::Rectangle(p1x, p1y, p2x, p2y, SFMLColor, outline, SFMLOutlineColor); shape->This = sf::Shape::Rectangle(left, top, width, height, SFMLColor, outline, SFMLOutlineColor);
return shape; return shape;
} }

View File

@ -316,30 +316,28 @@ namespace SFML
/// <summary> /// <summary>
/// Create a shape made of a single rectangle /// Create a shape made of a single rectangle
/// </summary> /// </summary>
/// <param name="p1">Position of the top-left corner</param> /// <param name="rectangle">Rectangle to create</param>
/// <param name="p2">Position of the bottom-right corner</param>
/// <param name="color">Color used to fill the rectangle</param> /// <param name="color">Color used to fill the rectangle</param>
/// <returns>New rectangle shape built with the given parameters</returns> /// <returns>New rectangle shape built with the given parameters</returns>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
public static Shape Rectangle(Vector2 p1, Vector2 p2, Color color) public static Shape Rectangle(FloatRect rectangle, Color color)
{ {
return Rectangle(p1, p2, color, 0, Color.White); return Rectangle(rectangle, color, 0, Color.White);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// <summary> /// <summary>
/// Create a shape made of a single rectangle /// Create a shape made of a single rectangle
/// </summary> /// </summary>
/// <param name="p1">Position of the top-left corner</param> /// <param name="rectangle">Rectangle to create</param>
/// <param name="p2">Position of the bottom-right corner</param>
/// <param name="color">Color used to fill the rectangle</param> /// <param name="color">Color used to fill the rectangle</param>
/// <param name="outline">Outline width</param> /// <param name="outline">Outline width</param>
/// <param name="outlineColor">Color used to draw the outline</param> /// <param name="outlineColor">Color used to draw the outline</param>
/// <returns>New rectangle shape built with the given parameters</returns> /// <returns>New rectangle shape built with the given parameters</returns>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
public static Shape Rectangle(Vector2 p1, Vector2 p2, Color color, float outline, Color outlineColor) public static Shape Rectangle(FloatRect rectangle, Color color, float outline, Color outlineColor)
{ {
return new Shape(sfShape_CreateRectangle(p1.X, p1.Y, p2.X, p2.Y, color, outline, outlineColor)); return new Shape(sfShape_CreateRectangle(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, color, outline, outlineColor));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -206,28 +206,27 @@ public :
static Shape Line(const Vector2f& p1, const Vector2f& p2, float thickness, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0)); static Shape Line(const Vector2f& p1, const Vector2f& p2, float thickness, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0));
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create a shape made of a single rectangle (use floats) /// Create a shape made of a single rectangle
/// ///
/// \param p1x, p1y : Position of the first point /// \param left, top : Position of the top-left corner
/// \param p2x, p2y : Position second point /// \param width, height : Size of the rectangle
/// \param color : Color used to fill the rectangle /// \param color : Color used to fill the rectangle
/// \param outline : Outline width /// \param outline : Outline width
/// \param outlineColor : Color used to draw the outline /// \param outlineColor : Color used to draw the outline
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Shape Rectangle(float p1x, float p1y, float p2x, float p2y, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0)); 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));
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create a shape made of a single rectangle (use vectors) /// Create a shape made of a single rectangle
/// ///
/// \param p1 : Position of the first point /// \param rectangle : Rectangle
/// \param p2 : Position second point
/// \param color : Color used to fill the rectangle /// \param color : Color used to fill the rectangle
/// \param outline : Outline width /// \param outline : Outline width
/// \param outlineColor : Color used to draw the outline /// \param outlineColor : Color used to draw the outline
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Shape Rectangle(const Vector2f& p1, const Vector2f& p2, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0)); static Shape Rectangle(const FloatRect& rectangle, const Color& color, float outline = 0.f, const Color& outlineColor = Color(0, 0, 0));
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create a shape made of a single circle (use floats) /// Create a shape made of a single circle (use floats)

View File

@ -218,14 +218,14 @@ Shape Shape::Line(const Vector2f& p1, const Vector2f& p2, float thickness, const
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create a shape made of a single rectangle /// Create a shape made of a single rectangle
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Shape Shape::Rectangle(float p1x, float p1y, float p2x, float p2y, const Color& color, float outline, const Color& outlineColor) Shape Shape::Rectangle(float left, float top, float width, float height, const Color& color, float outline, const Color& outlineColor)
{ {
// Create the shape's points // Create the shape's points
Shape shape; Shape shape;
shape.AddPoint(Vector2f(p1x, p1y), color, outlineColor); shape.AddPoint(Vector2f(left, top), color, outlineColor);
shape.AddPoint(Vector2f(p2x, p1y), color, outlineColor); shape.AddPoint(Vector2f(left + width, top), color, outlineColor);
shape.AddPoint(Vector2f(p2x, p2y), color, outlineColor); shape.AddPoint(Vector2f(left + width, top + height), color, outlineColor);
shape.AddPoint(Vector2f(p1x, p2y), color, outlineColor); shape.AddPoint(Vector2f(left, top + height), color, outlineColor);
shape.SetOutlineWidth(outline); shape.SetOutlineWidth(outline);
// Compile it // Compile it
@ -236,11 +236,11 @@ Shape Shape::Rectangle(float p1x, float p1y, float p2x, float p2y, const Color&
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create a shape made of a single rectangle (use vectors) /// Create a shape made of a single rectangle
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Shape Shape::Rectangle(const Vector2f& p1, const Vector2f& p2, const Color& color, float outline, const Color& outlineColor) Shape Shape::Rectangle(const FloatRect& rectangle, const Color& color, float outline, const Color& outlineColor)
{ {
return Shape::Rectangle(p1.x, p1.y, p2.x, p2.y, color, outline, outlineColor); return Shape::Rectangle(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, color, outline, outlineColor);
} }