mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-27 21:36:13 +01:00
Add miter limit functions to all shapes
This commit is contained in:
9 files changed
+233
No files matched your search
@@ -292,6 +292,36 @@ CSFML_GRAPHICS_API void sfCircleShape_setOutlineColor(sfCircleShape* shape, sfCo
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API void sfCircleShape_setOutlineThickness(sfCircleShape* shape, float thickness);
|
CSFML_GRAPHICS_API void sfCircleShape_setOutlineThickness(sfCircleShape* shape, float thickness);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Set the limit on the ratio between miter length and outline thickness of a circle shape
|
||||||
|
///
|
||||||
|
/// Outline segments around each corner are joined either
|
||||||
|
/// with a miter or a bevel join.
|
||||||
|
/// - A miter join is formed by extending outline segments until
|
||||||
|
/// they intersect. The distance between the point of
|
||||||
|
/// intersection and the shape's corner is the miter length.
|
||||||
|
/// - A bevel join is formed by connecting outline segments with
|
||||||
|
/// a straight line perpendicular to the corner's bisector.
|
||||||
|
///
|
||||||
|
/// The miter limit is used to determine whether outline segments
|
||||||
|
/// around a corner are joined with a bevel or a miter.
|
||||||
|
/// When the ratio between the miter length and outline thickness
|
||||||
|
/// exceeds the miter limit, a bevel is used instead of a miter.
|
||||||
|
///
|
||||||
|
/// The miter limit is linked to the maximum inner angle of a
|
||||||
|
/// corner below which a bevel is used by the following formula:
|
||||||
|
///
|
||||||
|
/// miterLimit = 1 / sin(angle / 2)
|
||||||
|
///
|
||||||
|
/// The miter limit must be greater than or equal to 1.
|
||||||
|
/// By default, the miter limit is 10.
|
||||||
|
///
|
||||||
|
/// \param shape Shape object
|
||||||
|
/// \param miterLimit New miter limit
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_GRAPHICS_API void sfCircleShape_setMiterLimit(sfCircleShape* shape, float miterLimit);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the source texture of a circle shape
|
/// \brief Get the source texture of a circle shape
|
||||||
///
|
///
|
||||||
@@ -346,6 +376,16 @@ CSFML_GRAPHICS_API sfColor sfCircleShape_getOutlineColor(const sfCircleShape* sh
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API float sfCircleShape_getOutlineThickness(const sfCircleShape* shape);
|
CSFML_GRAPHICS_API float sfCircleShape_getOutlineThickness(const sfCircleShape* shape);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get the limit on the ratio between miter length and outline thickness of a circle shape
|
||||||
|
///
|
||||||
|
/// \param shape Shape object
|
||||||
|
///
|
||||||
|
/// \return Limit on the ratio between miter length and outline thickness
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_GRAPHICS_API float sfCircleShape_getMiterLimit(const sfCircleShape* shape);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the total number of points of a circle shape
|
/// \brief Get the total number of points of a circle shape
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -292,6 +292,36 @@ CSFML_GRAPHICS_API void sfConvexShape_setOutlineColor(sfConvexShape* shape, sfCo
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API void sfConvexShape_setOutlineThickness(sfConvexShape* shape, float thickness);
|
CSFML_GRAPHICS_API void sfConvexShape_setOutlineThickness(sfConvexShape* shape, float thickness);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Set the limit on the ratio between miter length and outline thickness of a convex shape
|
||||||
|
///
|
||||||
|
/// Outline segments around each corner are joined either
|
||||||
|
/// with a miter or a bevel join.
|
||||||
|
/// - A miter join is formed by extending outline segments until
|
||||||
|
/// they intersect. The distance between the point of
|
||||||
|
/// intersection and the shape's corner is the miter length.
|
||||||
|
/// - A bevel join is formed by connecting outline segments with
|
||||||
|
/// a straight line perpendicular to the corner's bisector.
|
||||||
|
///
|
||||||
|
/// The miter limit is used to determine whether outline segments
|
||||||
|
/// around a corner are joined with a bevel or a miter.
|
||||||
|
/// When the ratio between the miter length and outline thickness
|
||||||
|
/// exceeds the miter limit, a bevel is used instead of a miter.
|
||||||
|
///
|
||||||
|
/// The miter limit is linked to the maximum inner angle of a
|
||||||
|
/// corner below which a bevel is used by the following formula:
|
||||||
|
///
|
||||||
|
/// miterLimit = 1 / sin(angle / 2)
|
||||||
|
///
|
||||||
|
/// The miter limit must be greater than or equal to 1.
|
||||||
|
/// By default, the miter limit is 10.
|
||||||
|
///
|
||||||
|
/// \param shape Shape object
|
||||||
|
/// \param miterLimit New miter limit
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_GRAPHICS_API void sfConvexShape_setMiterLimit(sfConvexShape* shape, float miterLimit);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the source texture of a convex shape
|
/// \brief Get the source texture of a convex shape
|
||||||
///
|
///
|
||||||
@@ -346,6 +376,16 @@ CSFML_GRAPHICS_API sfColor sfConvexShape_getOutlineColor(const sfConvexShape* sh
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API float sfConvexShape_getOutlineThickness(const sfConvexShape* shape);
|
CSFML_GRAPHICS_API float sfConvexShape_getOutlineThickness(const sfConvexShape* shape);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get the limit on the ratio between miter length and outline thickness of a convex shape
|
||||||
|
///
|
||||||
|
/// \param shape Shape object
|
||||||
|
///
|
||||||
|
/// \return Limit on the ratio between miter length and outline thickness
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_GRAPHICS_API float sfConvexShape_getMiterLimit(const sfConvexShape* shape);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the total number of points of a convex shape
|
/// \brief Get the total number of points of a convex shape
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -292,6 +292,36 @@ CSFML_GRAPHICS_API void sfRectangleShape_setOutlineColor(sfRectangleShape* shape
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API void sfRectangleShape_setOutlineThickness(sfRectangleShape* shape, float thickness);
|
CSFML_GRAPHICS_API void sfRectangleShape_setOutlineThickness(sfRectangleShape* shape, float thickness);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Set the limit on the ratio between miter length and outline thickness of a rectangle shape
|
||||||
|
///
|
||||||
|
/// Outline segments around each corner are joined either
|
||||||
|
/// with a miter or a bevel join.
|
||||||
|
/// - A miter join is formed by extending outline segments until
|
||||||
|
/// they intersect. The distance between the point of
|
||||||
|
/// intersection and the shape's corner is the miter length.
|
||||||
|
/// - A bevel join is formed by connecting outline segments with
|
||||||
|
/// a straight line perpendicular to the corner's bisector.
|
||||||
|
///
|
||||||
|
/// The miter limit is used to determine whether outline segments
|
||||||
|
/// around a corner are joined with a bevel or a miter.
|
||||||
|
/// When the ratio between the miter length and outline thickness
|
||||||
|
/// exceeds the miter limit, a bevel is used instead of a miter.
|
||||||
|
///
|
||||||
|
/// The miter limit is linked to the maximum inner angle of a
|
||||||
|
/// corner below which a bevel is used by the following formula:
|
||||||
|
///
|
||||||
|
/// miterLimit = 1 / sin(angle / 2)
|
||||||
|
///
|
||||||
|
/// The miter limit must be greater than or equal to 1.
|
||||||
|
/// By default, the miter limit is 10.
|
||||||
|
///
|
||||||
|
/// \param shape Shape object
|
||||||
|
/// \param miterLimit New miter limit
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_GRAPHICS_API void sfRectangleShape_setMiterLimit(sfRectangleShape* shape, float miterLimit);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the source texture of a rectangle shape
|
/// \brief Get the source texture of a rectangle shape
|
||||||
///
|
///
|
||||||
@@ -346,6 +376,16 @@ CSFML_GRAPHICS_API sfColor sfRectangleShape_getOutlineColor(const sfRectangleSha
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API float sfRectangleShape_getOutlineThickness(const sfRectangleShape* shape);
|
CSFML_GRAPHICS_API float sfRectangleShape_getOutlineThickness(const sfRectangleShape* shape);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get the limit on the ratio between miter length and outline thickness of a rectangle shape
|
||||||
|
///
|
||||||
|
/// \param shape Shape object
|
||||||
|
///
|
||||||
|
/// \return Limit on the ratio between miter length and outline thickness
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_GRAPHICS_API float sfRectangleShape_getMiterLimit(const sfRectangleShape* shape);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the total number of points of a rectangle shape
|
/// \brief Get the total number of points of a rectangle shape
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -291,6 +291,36 @@ CSFML_GRAPHICS_API void sfShape_setOutlineColor(sfShape* shape, sfColor color);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API void sfShape_setOutlineThickness(sfShape* shape, float thickness);
|
CSFML_GRAPHICS_API void sfShape_setOutlineThickness(sfShape* shape, float thickness);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Set the limit on the ratio between miter length and outline thickness of a shape
|
||||||
|
///
|
||||||
|
/// Outline segments around each corner are joined either
|
||||||
|
/// with a miter or a bevel join.
|
||||||
|
/// - A miter join is formed by extending outline segments until
|
||||||
|
/// they intersect. The distance between the point of
|
||||||
|
/// intersection and the shape's corner is the miter length.
|
||||||
|
/// - A bevel join is formed by connecting outline segments with
|
||||||
|
/// a straight line perpendicular to the corner's bisector.
|
||||||
|
///
|
||||||
|
/// The miter limit is used to determine whether outline segments
|
||||||
|
/// around a corner are joined with a bevel or a miter.
|
||||||
|
/// When the ratio between the miter length and outline thickness
|
||||||
|
/// exceeds the miter limit, a bevel is used instead of a miter.
|
||||||
|
///
|
||||||
|
/// The miter limit is linked to the maximum inner angle of a
|
||||||
|
/// corner below which a bevel is used by the following formula:
|
||||||
|
///
|
||||||
|
/// miterLimit = 1 / sin(angle / 2)
|
||||||
|
///
|
||||||
|
/// The miter limit must be greater than or equal to 1.
|
||||||
|
/// By default, the miter limit is 10.
|
||||||
|
///
|
||||||
|
/// \param shape Shape object
|
||||||
|
/// \param miterLimit New miter limit
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_GRAPHICS_API void sfShape_setMiterLimit(sfShape* shape, float miterLimit);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the source texture of a shape
|
/// \brief Get the source texture of a shape
|
||||||
///
|
///
|
||||||
@@ -345,6 +375,16 @@ CSFML_GRAPHICS_API sfColor sfShape_getOutlineColor(const sfShape* shape);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API float sfShape_getOutlineThickness(const sfShape* shape);
|
CSFML_GRAPHICS_API float sfShape_getOutlineThickness(const sfShape* shape);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get the limit on the ratio between miter length and outline thickness of a shape
|
||||||
|
///
|
||||||
|
/// \param shape Shape object
|
||||||
|
///
|
||||||
|
/// \return Limit on the ratio between miter length and outline thickness
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_GRAPHICS_API float sfShape_getMiterLimit(const sfShape* shape);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the total number of points of a shape
|
/// \brief Get the total number of points of a shape
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -207,6 +207,14 @@ void sfCircleShape_setOutlineThickness(sfCircleShape* shape, float thickness)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void sfCircleShape_setMiterLimit(sfCircleShape* shape, float miterLimit)
|
||||||
|
{
|
||||||
|
assert(shape);
|
||||||
|
shape->setMiterLimit(miterLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const sfTexture* sfCircleShape_getTexture(const sfCircleShape* shape)
|
const sfTexture* sfCircleShape_getTexture(const sfCircleShape* shape)
|
||||||
{
|
{
|
||||||
@@ -247,6 +255,14 @@ float sfCircleShape_getOutlineThickness(const sfCircleShape* shape)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
float sfCircleShape_getMiterLimit(const sfCircleShape* shape)
|
||||||
|
{
|
||||||
|
assert(shape);
|
||||||
|
return shape->getMiterLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
size_t sfCircleShape_getPointCount(const sfCircleShape* shape)
|
size_t sfCircleShape_getPointCount(const sfCircleShape* shape)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -204,6 +204,14 @@ void sfConvexShape_setOutlineThickness(sfConvexShape* shape, float thickness)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void sfConvexShape_setMiterLimit(sfConvexShape* shape, float miterLimit)
|
||||||
|
{
|
||||||
|
assert(shape);
|
||||||
|
shape->setMiterLimit(miterLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const sfTexture* sfConvexShape_getTexture(const sfConvexShape* shape)
|
const sfTexture* sfConvexShape_getTexture(const sfConvexShape* shape)
|
||||||
{
|
{
|
||||||
@@ -244,6 +252,14 @@ float sfConvexShape_getOutlineThickness(const sfConvexShape* shape)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
float sfConvexShape_getMiterLimit(const sfConvexShape* shape)
|
||||||
|
{
|
||||||
|
assert(shape);
|
||||||
|
return shape->getMiterLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
size_t sfConvexShape_getPointCount(const sfConvexShape* shape)
|
size_t sfConvexShape_getPointCount(const sfConvexShape* shape)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -204,6 +204,14 @@ void sfRectangleShape_setOutlineThickness(sfRectangleShape* shape, float thickne
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void sfRectangleShape_setMiterLimit(sfRectangleShape* shape, float miterLimit)
|
||||||
|
{
|
||||||
|
assert(shape);
|
||||||
|
shape->setMiterLimit(miterLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const sfTexture* sfRectangleShape_getTexture(const sfRectangleShape* shape)
|
const sfTexture* sfRectangleShape_getTexture(const sfRectangleShape* shape)
|
||||||
{
|
{
|
||||||
@@ -244,6 +252,14 @@ float sfRectangleShape_getOutlineThickness(const sfRectangleShape* shape)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
float sfRectangleShape_getMiterLimit(const sfRectangleShape* shape)
|
||||||
|
{
|
||||||
|
assert(shape);
|
||||||
|
return shape->getMiterLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
size_t sfRectangleShape_getPointCount(const sfRectangleShape* shape)
|
size_t sfRectangleShape_getPointCount(const sfRectangleShape* shape)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -196,6 +196,14 @@ void sfShape_setOutlineThickness(sfShape* shape, float thickness)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void sfShape_setMiterLimit(sfShape* shape, float miterLimit)
|
||||||
|
{
|
||||||
|
assert(shape);
|
||||||
|
shape->setMiterLimit(miterLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const sfTexture* sfShape_getTexture(const sfShape* shape)
|
const sfTexture* sfShape_getTexture(const sfShape* shape)
|
||||||
{
|
{
|
||||||
@@ -236,6 +244,14 @@ float sfShape_getOutlineThickness(const sfShape* shape)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
float sfShape_getMiterLimit(const sfShape* shape)
|
||||||
|
{
|
||||||
|
assert(shape);
|
||||||
|
return shape->getMiterLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
size_t sfShape_getPointCount(const sfShape* shape)
|
size_t sfShape_getPointCount(const sfShape* shape)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ TEST_CASE("[Graphics] sfShape")
|
|||||||
CHECK(outlineColor.b == sfWhite.b);
|
CHECK(outlineColor.b == sfWhite.b);
|
||||||
CHECK(outlineColor.a == sfWhite.a);
|
CHECK(outlineColor.a == sfWhite.a);
|
||||||
CHECK(sfShape_getOutlineThickness(shape) == 0);
|
CHECK(sfShape_getOutlineThickness(shape) == 0);
|
||||||
|
CHECK(sfShape_getMiterLimit(shape) == 10);
|
||||||
CHECK(sfShape_getPointCount(shape) == 3);
|
CHECK(sfShape_getPointCount(shape) == 3);
|
||||||
const sfVector2f point = sfShape_getPoint(shape, 0);
|
const sfVector2f point = sfShape_getPoint(shape, 0);
|
||||||
CHECK(point.x == 0);
|
CHECK(point.x == 0);
|
||||||
@@ -104,4 +105,12 @@ TEST_CASE("[Graphics] sfShape")
|
|||||||
CHECK(origin.y == 90);
|
CHECK(origin.y == 90);
|
||||||
sfShape_destroy(shape);
|
sfShape_destroy(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("Set/get miter limit")
|
||||||
|
{
|
||||||
|
sfShape* shape = sfShape_create(getPointCount, getPoint, &points);
|
||||||
|
sfShape_setMiterLimit(shape, 2);
|
||||||
|
CHECK(sfShape_getMiterLimit(shape) == 2);
|
||||||
|
sfShape_destroy(shape);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user