Skip to content

Commit

Permalink
Implement getGeometricCenter
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed Sep 20, 2024
1 parent 77b3035 commit fbe6e61
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/CSFML/Graphics/CircleShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ CSFML_GRAPHICS_API size_t sfCircleShape_getPointCount(const sfCircleShape* shape
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfCircleShape_getPoint(const sfCircleShape* shape, size_t index);

////////////////////////////////////////////////////////////
/// \brief Get the geometric center of the circle
///
/// The returned point is in local coordinates, that is,
/// the shape's transforms (position, rotation, scale) are
/// not taken into account.
///
/// \param shape Shape object
///
/// \return The geometric center of the shape
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfCircleShape_getGeometricCenter(const sfCircleShape* shape);

////////////////////////////////////////////////////////////
/// \brief Set the radius of a circle
///
Expand Down
14 changes: 14 additions & 0 deletions include/CSFML/Graphics/ConvexShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ CSFML_GRAPHICS_API size_t sfConvexShape_getPointCount(const sfConvexShape* shape
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfConvexShape_getPoint(const sfConvexShape* shape, size_t index);

////////////////////////////////////////////////////////////
/// \brief Get the geometric center of a convex shape
///
/// The returned point is in local coordinates, that is,
/// the shape's transforms (position, rotation, scale) are
/// not taken into account.
///
/// \param shape Shape object
///
/// \return The geometric center of the shape
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfConvexShape_getGeometricCenter(const sfConvexShape* shape);

////////////////////////////////////////////////////////////
/// \brief Set the number of points of a convex shap
///
Expand Down
14 changes: 14 additions & 0 deletions include/CSFML/Graphics/RectangleShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ CSFML_GRAPHICS_API size_t sfRectangleShape_getPointCount(const sfRectangleShape*
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfRectangleShape_getPoint(const sfRectangleShape* shape, size_t index);

////////////////////////////////////////////////////////////
/// \brief Get the geometric center of the rectangle
///
/// The returned point is in local coordinates, that is,
/// the shape's transforms (position, rotation, scale) are
/// not taken into account.
///
/// \param shape Shape object
///
/// \return The geometric center of the shape
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfRectangleShape_getGeometricCenter(const sfRectangleShape* shape);

////////////////////////////////////////////////////////////
/// \brief Set the size of a rectangle shape
///
Expand Down
14 changes: 14 additions & 0 deletions include/CSFML/Graphics/Shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,20 @@ CSFML_GRAPHICS_API size_t sfShape_getPointCount(const sfShape* shape);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfShape_getPoint(const sfShape* shape, size_t index);

////////////////////////////////////////////////////////////
/// \brief Get the geometric center of the shape
///
/// The returned point is in local coordinates, that is,
/// the shape's transforms (position, rotation, scale) are
/// not taken into account.
///
/// \param shape Shape object
///
/// \return The geometric center of the shape
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfVector2f sfShape_getGeometricCenter(const sfShape* shape);

////////////////////////////////////////////////////////////
/// \brief Get the local bounding rectangle of a shape
///
Expand Down
8 changes: 8 additions & 0 deletions src/CSFML/Graphics/CircleShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@ sfVector2f sfCircleShape_getPoint(const sfCircleShape* shape, size_t index)
}


////////////////////////////////////////////////////////////
sfVector2f sfCircleShape_getGeometricCenter(const sfCircleShape* shape)
{
assert(shape);
return convertVector2(shape->This.getGeometricCenter());
}


////////////////////////////////////////////////////////////
void sfCircleShape_setRadius(sfCircleShape* shape, float radius)
{
Expand Down
8 changes: 8 additions & 0 deletions src/CSFML/Graphics/ConvexShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ sfVector2f sfConvexShape_getPoint(const sfConvexShape* shape, size_t index)
}


////////////////////////////////////////////////////////////
sfVector2f sfConvexShape_getGeometricCenter(const sfConvexShape* shape)
{
assert(shape);
return convertVector2(shape->This.getGeometricCenter());
}


////////////////////////////////////////////////////////////
void sfConvexShape_setPointCount(sfConvexShape* shape, size_t count)
{
Expand Down
8 changes: 8 additions & 0 deletions src/CSFML/Graphics/RectangleShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ sfVector2f sfRectangleShape_getPoint(const sfRectangleShape* shape, size_t index
}


////////////////////////////////////////////////////////////
sfVector2f sfRectangleShape_getGeometricCenter(const sfRectangleShape* shape)
{
assert(shape);
return convertVector2(shape->This.getGeometricCenter());
}


////////////////////////////////////////////////////////////
void sfRectangleShape_setSize(sfRectangleShape* shape, sfVector2f size)
{
Expand Down
8 changes: 8 additions & 0 deletions src/CSFML/Graphics/Shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ sfVector2f sfShape_getPoint(const sfShape* shape, size_t index)
}


////////////////////////////////////////////////////////////
sfVector2f sfShape_getGeometricCenter(const sfShape* shape)
{
assert(shape);
return convertVector2(shape->getGeometricCenter());
}


////////////////////////////////////////////////////////////
sfFloatRect sfShape_getLocalBounds(const sfShape* shape)
{
Expand Down

0 comments on commit fbe6e61

Please sign in to comment.