mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
capi: bindings for strokeTrim
Example Capi.cpp modyfied.
This commit is contained in:
parent
e868e6e343
commit
566b327f09
3 changed files with 51 additions and 0 deletions
|
@ -154,6 +154,11 @@ void testCapi()
|
|||
tvg_shape_append_arc(scene_shape1, 175.0f, 600.0f, 150.0f, -45.0f, 90.0f, 1);
|
||||
tvg_shape_append_arc(scene_shape1, 175.0f, 600.0f, 150.0f, 225.0f, -90.0f, 1);
|
||||
tvg_shape_set_fill_color(scene_shape1, 0, 0, 255, 150);
|
||||
tvg_shape_set_stroke_color(scene_shape1, 255, 255, 255, 155);
|
||||
tvg_shape_set_stroke_width(scene_shape1, 10.0f);
|
||||
tvg_shape_set_stroke_cap(scene_shape1, Tvg_Stroke_Cap::TVG_STROKE_CAP_ROUND);
|
||||
tvg_shape_set_stroke_join(scene_shape1, Tvg_Stroke_Join::TVG_STROKE_JOIN_ROUND);
|
||||
tvg_shape_set_stroke_trim(scene_shape1, 0.25f, 0.75f, true);
|
||||
|
||||
//Set an arc with a dashed stroke
|
||||
Tvg_Paint* scene_shape2 = tvg_paint_duplicate(scene_shape1);
|
||||
|
|
|
@ -1532,6 +1532,37 @@ TVG_API Tvg_Result tvg_shape_set_stroke_miterlimit(Tvg_Paint* paint, float miter
|
|||
TVG_API Tvg_Result tvg_shape_get_stroke_miterlimit(const Tvg_Paint* paint, float* miterlimit);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Sets the trim of the stroke along the defined path segment, allowing control over which part of the stroke is visible. (Experimental API)
|
||||
*
|
||||
* The values of the arguments @p begin, @p end, and @p offset are in the range of 0.0 to 1.0, representing the beginning of the path and the end, respectively.
|
||||
*
|
||||
* \param[in] begin Specifies the start of the segment to display along the path.
|
||||
* \param[in] end Specifies the end of the segment to display along the path.
|
||||
* \param[in] simultaneous Determines how to trim multiple paths within a single shape. If set to @c true (default), trimming is applied simultaneously to all paths;
|
||||
* Otherwise, all paths are treated as a single entity with a combined length equal to the sum of their individual lengths and are trimmed as such.
|
||||
*
|
||||
* \return Tvg_Result enumeration.
|
||||
* \retval TVG_RESULT_SUCCESS Succeed.
|
||||
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer.
|
||||
*/
|
||||
TVG_API Tvg_Result tvg_shape_set_stroke_trim(Tvg_Paint* paint, float begin, float end, bool simultaneous);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Gets the trim of the stroke along the defined path segment. (Experimental API)
|
||||
*
|
||||
* \param[out] begin The starting point of the segment to display along the path.
|
||||
* \param[out] end Specifies the end of the segment to display along the path.
|
||||
* \param[out] simultaneous Determines how to trim multiple paths within a shape.
|
||||
*
|
||||
* \return Tvg_Result enumeration.
|
||||
* \retval TVG_RESULT_SUCCESS Succeed.
|
||||
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer.
|
||||
*/
|
||||
TVG_API Tvg_Result tvg_shape_get_stroke_trim(Tvg_Paint* paint, float* begin, float* end, bool* simultaneous);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Sets the shape's solid color.
|
||||
*
|
||||
|
|
|
@ -461,6 +461,21 @@ TVG_API Tvg_Result tvg_shape_get_stroke_miterlimit(const Tvg_Paint* paint, float
|
|||
}
|
||||
|
||||
|
||||
TVG_API Tvg_Result tvg_shape_set_stroke_trim(Tvg_Paint* paint, float begin, float end, bool simultaneous)
|
||||
{
|
||||
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
|
||||
return (Tvg_Result) reinterpret_cast<Shape*>(paint)->strokeTrim(begin, end, simultaneous);
|
||||
}
|
||||
|
||||
|
||||
TVG_API Tvg_Result tvg_shape_get_stroke_trim(Tvg_Paint* paint, float* begin, float* end, bool* simultaneous)
|
||||
{
|
||||
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
|
||||
if (simultaneous) *simultaneous = reinterpret_cast<Shape*>(paint)->strokeTrim(begin, end);
|
||||
return TVG_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
TVG_API Tvg_Result tvg_shape_set_fill_color(Tvg_Paint* paint, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
||||
{
|
||||
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
|
||||
|
|
Loading…
Add table
Reference in a new issue