From: Mateusz Palkowski Date: Tue, 4 Aug 2020 10:11:24 +0000 (+0200) Subject: capi: Added C wrapper for setting spread type X-Git-Tag: accepted/tizen/unified/20200810.123122~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=083fa57c3e02c6623e9072403cd31bbc8190c833;p=platform%2Fcore%2Fgraphics%2Ftizenvg.git capi: Added C wrapper for setting spread type and test Change-Id: I3b4cd3740a82446fea60ed050814b03f32632f6d --- diff --git a/inc/thorvg_capi.h b/inc/thorvg_capi.h index ecd7ee6..17d663e 100644 --- a/inc/thorvg_capi.h +++ b/inc/thorvg_capi.h @@ -169,6 +169,7 @@ TVG_EXPORT Tvg_Result tvg_gradient_del(Tvg_Gradient* grad); TVG_EXPORT Tvg_Result tvg_linear_gradient_set(Tvg_Gradient* grad, float x1, float y1, float x2, float y2); TVG_EXPORT Tvg_Result tvg_radial_gradient_set(Tvg_Gradient* grad, float cx, float cy, float radius); TVG_EXPORT Tvg_Result tvg_gradient_color_stops(Tvg_Gradient* grad, const Tvg_Color_Stop* color_stop, uint32_t cnt); +TVG_EXPORT Tvg_Result tvg_gradient_spread(Tvg_Gradient* grad, const Tvg_Stroke_Fill); /************************************************************************/ diff --git a/src/bindings/capi/tvgCapi.cpp b/src/bindings/capi/tvgCapi.cpp index 9f9646e..6e61d8f 100644 --- a/src/bindings/capi/tvgCapi.cpp +++ b/src/bindings/capi/tvgCapi.cpp @@ -333,6 +333,12 @@ TVG_EXPORT Tvg_Result tvg_gradient_color_stops(Tvg_Gradient* grad, const Tvg_Col return (Tvg_Result) reinterpret_cast(grad)->colorStops(reinterpret_cast(color_stop), cnt); } +TVG_EXPORT Tvg_Result tvg_gradient_spread(Tvg_Gradient* grad, const Tvg_Stroke_Fill spread) +{ + return (Tvg_Result) reinterpret_cast(grad)->spread((FillSpread)spread); +} + + #ifdef __cplusplus } #endif diff --git a/test/testCapi.c b/test/testCapi.c index 3a307ab..90c4e1d 100644 --- a/test/testCapi.c +++ b/test/testCapi.c @@ -32,6 +32,7 @@ void testCapi() {.offset=1.0, .r=0, .g=0, .b=255, .a=255} }; + Tvg_Paint *shape1 = tvg_shape_new(); tvg_shape_append_rect(shape1, 500, 500, 100, 100, 30, 30); Tvg_Gradient* grad1 = tvg_radial_gradient_new(); @@ -43,13 +44,67 @@ void testCapi() {.offset=1.0, .r=0, .g=255, .b=255, .a=255} }; + Tvg_Paint *shape2 = tvg_shape_new(); + tvg_shape_append_rect(shape2, 400, 0, 800, 400, 20, 20); + Tvg_Gradient* grad2 = tvg_linear_gradient_new(); + tvg_linear_gradient_set(grad2, 400, 0, 450, 50); + Tvg_Color_Stop color_stops2[2] = + { + {.offset=0.0, .r=0, .g=0, .b=0, .a=255}, + {.offset=1, .r=255, .g=0, .b=0, .a=255}, + }; + + tvg_gradient_spread(grad2, TVG_STROKE_FILL_REPEAT); + + Tvg_Paint* shape3 = tvg_shape_new(); + tvg_shape_append_rect(shape3, 0, 400, 400, 800, 20, 20); + Tvg_Gradient* grad3 = tvg_linear_gradient_new(); + tvg_linear_gradient_set(grad3, 0, 400, 50, 450); + Tvg_Color_Stop color_stops3[2] = + { + {.offset=0.0, .r=0, .g=0, .b=0, .a=255}, + {.offset=1, .r=0, .g=255, .b=0, .a=255}, + }; + + tvg_gradient_spread(grad3, TVG_STROKE_FILL_REFLECT); + tvg_gradient_color_stops(grad, color_stops, 4); tvg_gradient_color_stops(grad1, color_stops1, 3); + tvg_gradient_color_stops(grad2, color_stops2, 2); + tvg_gradient_color_stops(grad3, color_stops3, 2); tvg_shape_linear_gradient_set(shape, grad); tvg_shape_radial_gradient_set(shape1, grad1); + tvg_shape_linear_gradient_set(shape2, grad2); + tvg_shape_linear_gradient_set(shape3, grad3); tvg_canvas_push(canvas, shape); tvg_canvas_push(canvas, shape1); + tvg_canvas_push(canvas, shape2); + tvg_canvas_push(canvas, shape3); + + Tvg_Paint* shape4 = tvg_shape_new(); + tvg_shape_append_rect(shape4, 700, 700, 100, 100, 20, 20); + Tvg_Gradient* grad4 = tvg_linear_gradient_new(); + tvg_linear_gradient_set(grad4, 700, 700, 800, 800); + Tvg_Color_Stop color_stops4[2] = + { + {.offset=0.0, .r=0, .g=0, .b=0, .a=255}, + {.offset=1, .r=0, .g=255, .b=0, .a=255}, + }; + tvg_gradient_color_stops(grad4, color_stops4, 2); + tvg_shape_linear_gradient_set(shape4, grad4); + + Tvg_Gradient* grad5 = tvg_linear_gradient_new(); + tvg_linear_gradient_set(grad5, 700, 700, 800, 800); + Tvg_Color_Stop color_stops5[2] = + { + {.offset=0.0, .r=0, .g=0, .b=255, .a=255}, + {.offset=1, .r=0, .g=255, .b=255, .a=255}, + }; + tvg_gradient_color_stops(grad5, color_stops5, 2); + tvg_shape_linear_gradient_set(shape4, grad5); + + tvg_canvas_push(canvas, shape4); tvg_canvas_draw(canvas); tvg_canvas_sync(canvas);