Added GetLocalBounds and GetGlobalBounds functions to drawable classes

This commit is contained in:
Laurent Gomila committed 2012-02-10 17:13:31 +01:00
1 parent 441703a997
commit cc8d8ed07b
10 files changed
+320

No files matched your search

+32
View File
@@ -398,5 +398,37 @@ CSFML_GRAPHICS_API float sfCircleShape_GetRadius(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfCircleShape_SetPointCount(sfCircleShape* shape, unsigned int count);
////////////////////////////////////////////////////////////
/// \brief Get the local bounding rectangle of a circle shape
///
/// The returned rectangle is in local coordinates, which means
/// that it ignores the transformations (translation, rotation,
/// scale, ...) that are applied to the entity.
/// In other words, this function returns the bounds of the
/// entity in the entity's coordinate system.
///
/// \param shape Shape object
///
/// \return Local bounding rectangle of the entity
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfCircleShape_GetLocalBounds(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the global bounding rectangle of a circle shape
///
/// The returned rectangle is in global coordinates, which means
/// that it takes in account the transformations (translation,
/// rotation, scale, ...) that are applied to the entity.
/// In other words, this function returns the bounds of the
/// sprite in the global 2D world's coordinate system.
///
/// \param shape Shape object
///
/// \return Global bounding rectangle of the entity
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfCircleShape_GetGlobalBounds(const sfCircleShape* shape);
#endif // SFML_CIRCLESHAPE_H
+32
View File
@@ -398,5 +398,37 @@ CSFML_GRAPHICS_API void sfConvexShape_SetPointCount(sfConvexShape* shape, unsign
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfConvexShape_SetPoint(sfConvexShape* shape, unsigned int index, float x, float y);
////////////////////////////////////////////////////////////
/// \brief Get the local bounding rectangle of a convex shape
///
/// The returned rectangle is in local coordinates, which means
/// that it ignores the transformations (translation, rotation,
/// scale, ...) that are applied to the entity.
/// In other words, this function returns the bounds of the
/// entity in the entity's coordinate system.
///
/// \param shape Shape object
///
/// \return Local bounding rectangle of the entity
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfConvexShape_GetLocalBounds(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the global bounding rectangle of a convex shape
///
/// The returned rectangle is in global coordinates, which means
/// that it takes in account the transformations (translation,
/// rotation, scale, ...) that are applied to the entity.
/// In other words, this function returns the bounds of the
/// sprite in the global 2D world's coordinate system.
///
/// \param shape Shape object
///
/// \return Global bounding rectangle of the entity
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfConvexShape_GetGlobalBounds(const sfConvexShape* shape);
#endif // SFML_CONVEXSHAPE_H
+32
View File
@@ -390,5 +390,37 @@ CSFML_GRAPHICS_API void sfRectangleShape_SetSize(sfRectangleShape* shape, float
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRectangleShape_GetSize(const sfRectangleShape* shape, float* width, float* height);
////////////////////////////////////////////////////////////
/// \brief Get the local bounding rectangle of a rectangle shape
///
/// The returned rectangle is in local coordinates, which means
/// that it ignores the transformations (translation, rotation,
/// scale, ...) that are applied to the entity.
/// In other words, this function returns the bounds of the
/// entity in the entity's coordinate system.
///
/// \param shape Shape object
///
/// \return Local bounding rectangle of the entity
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfRectangleShape_GetLocalBounds(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the global bounding rectangle of a rectangle shape
///
/// The returned rectangle is in global coordinates, which means
/// that it takes in account the transformations (translation,
/// rotation, scale, ...) that are applied to the entity.
/// In other words, this function returns the bounds of the
/// sprite in the global 2D world's coordinate system.
///
/// \param shape Shape object
///
/// \return Global bounding rectangle of the entity
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfRectangleShape_GetGlobalBounds(const sfRectangleShape* shape);
#endif // SFML_RECTANGLESHAPE_H
+32
View File
@@ -300,5 +300,37 @@ CSFML_GRAPHICS_API sfIntRect sfSprite_GetTextureRect(const sfSprite* sprite);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfSprite_GetColor(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// \brief Get the local bounding rectangle of a sprite
///
/// The returned rectangle is in local coordinates, which means
/// that it ignores the transformations (translation, rotation,
/// scale, ...) that are applied to the entity.
/// In other words, this function returns the bounds of the
/// entity in the entity's coordinate system.
///
/// \param sprite Sprite object
///
/// \return Local bounding rectangle of the entity
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfSprite_GetLocalBounds(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// \brief Get the global bounding rectangle of a sprite
///
/// The returned rectangle is in global coordinates, which means
/// that it takes in account the transformations (translation,
/// rotation, scale, ...) that are applied to the entity.
/// In other words, this function returns the bounds of the
/// sprite in the global 2D world's coordinate system.
///
/// \param sprite Sprite object
///
/// \return Global bounding rectangle of the entity
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfSprite_GetGlobalBounds(const sfSprite* sprite);
#endif // SFML_SPRITE_H
+32
View File
@@ -382,5 +382,37 @@ CSFML_GRAPHICS_API sfColor sfText_GetColor(const sfText* text);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_FindCharacterPos(const sfText* text, size_t index, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Get the local bounding rectangle of a text
///
/// The returned rectangle is in local coordinates, which means
/// that it ignores the transformations (translation, rotation,
/// scale, ...) that are applied to the entity.
/// In other words, this function returns the bounds of the
/// entity in the entity's coordinate system.
///
/// \param text Text object
///
/// \return Local bounding rectangle of the entity
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfText_GetLocalBounds(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Get the global bounding rectangle of a text
///
/// The returned rectangle is in global coordinates, which means
/// that it takes in account the transformations (translation,
/// rotation, scale, ...) that are applied to the entity.
/// In other words, this function returns the bounds of the
/// sprite in the global 2D world's coordinate system.
///
/// \param text Text object
///
/// \return Global bounding rectangle of the entity
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfFloatRect sfText_GetGlobalBounds(const sfText* text);
#endif // SFML_TEXT_H
+32
View File
@@ -314,3 +314,35 @@ void sfCircleShape_SetPointCount(sfCircleShape* shape, unsigned int count)
{
CSFML_CALL(shape, SetPointCount(count));
}
////////////////////////////////////////////////////////////
sfFloatRect sfCircleShape_GetLocalBounds(const sfCircleShape* shape)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, rect);
sf::FloatRect sfmlRect = shape->This.GetLocalBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
////////////////////////////////////////////////////////////
sfFloatRect sfCircleShape_GetGlobalBounds(const sfCircleShape* shape)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, rect);
sf::FloatRect sfmlRect = shape->This.GetGlobalBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
+32
View File
@@ -304,3 +304,35 @@ void sfConvexShape_SetPoint(sfConvexShape* shape, unsigned int index, float x, f
{
CSFML_CALL(shape, SetPoint(index, sf::Vector2f(x, y)));
}
////////////////////////////////////////////////////////////
sfFloatRect sfConvexShape_GetLocalBounds(const sfConvexShape* shape)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, rect);
sf::FloatRect sfmlRect = shape->This.GetLocalBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
////////////////////////////////////////////////////////////
sfFloatRect sfConvexShape_GetGlobalBounds(const sfConvexShape* shape)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, rect);
sf::FloatRect sfmlRect = shape->This.GetGlobalBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
+32
View File
@@ -310,3 +310,35 @@ void sfRectangleShape_GetSize(const sfRectangleShape* shape, float* width, float
if (height)
*height = size.y;
}
////////////////////////////////////////////////////////////
sfFloatRect sfRectangleShape_GetLocalBounds(const sfRectangleShape* shape)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, rect);
sf::FloatRect sfmlRect = shape->This.GetLocalBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
////////////////////////////////////////////////////////////
sfFloatRect sfRectangleShape_GetGlobalBounds(const sfRectangleShape* shape)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, rect);
sf::FloatRect sfmlRect = shape->This.GetGlobalBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
+32
View File
@@ -240,3 +240,35 @@ sfColor sfSprite_GetColor(const sfSprite* sprite)
return color;
}
////////////////////////////////////////////////////////////
sfFloatRect sfSprite_GetLocalBounds(const sfSprite* sprite)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(sprite, rect);
sf::FloatRect sfmlRect = sprite->This.GetLocalBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
////////////////////////////////////////////////////////////
sfFloatRect sfSprite_GetGlobalBounds(const sfSprite* sprite)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(sprite, rect);
sf::FloatRect sfmlRect = sprite->This.GetGlobalBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
+32
View File
@@ -269,3 +269,35 @@ void sfText_FindCharacterPos(const sfText* text, size_t index, float* x, float*
if (y)
*y = pos.y;
}
////////////////////////////////////////////////////////////
sfFloatRect sfText_GetLocalBounds(const sfText* text)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(text, rect);
sf::FloatRect sfmlRect = text->This.GetLocalBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
////////////////////////////////////////////////////////////
sfFloatRect sfText_GetGlobalBounds(const sfText* text)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(text, rect);
sf::FloatRect sfmlRect = text->This.GetGlobalBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}