capi: Added C wrapper for setting spread type 04/240204/5
authorMateusz Palkowski <m.palkowski@samsung.com>
Tue, 4 Aug 2020 10:11:24 +0000 (12:11 +0200)
committerHermet Park <chuneon.park@samsung.com>
Thu, 6 Aug 2020 08:09:40 +0000 (08:09 +0000)
and test

Change-Id: I3b4cd3740a82446fea60ed050814b03f32632f6d

inc/thorvg_capi.h
src/bindings/capi/tvgCapi.cpp
test/testCapi.c

index ecd7ee6..17d663e 100644 (file)
@@ -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);
 
 
 /************************************************************************/
index 9f9646e..6e61d8f 100644 (file)
@@ -333,6 +333,12 @@ TVG_EXPORT Tvg_Result tvg_gradient_color_stops(Tvg_Gradient* grad, const Tvg_Col
     return (Tvg_Result) reinterpret_cast<Fill*>(grad)->colorStops(reinterpret_cast<const Fill::ColorStop*>(color_stop), cnt);
 }
 
+TVG_EXPORT Tvg_Result tvg_gradient_spread(Tvg_Gradient* grad, const Tvg_Stroke_Fill spread)
+{
+    return (Tvg_Result) reinterpret_cast<Fill*>(grad)->spread((FillSpread)spread);
+}
+
+
 #ifdef __cplusplus
 }
 #endif
index 3a307ab..90c4e1d 100644 (file)
@@ -32,6 +32,7 @@ void testCapi()
         {.offset=1.0, .r=0, .g=0, .b=255, .a=255}\r
     };\r
 \r
+\r
     Tvg_Paint *shape1 = tvg_shape_new();\r
     tvg_shape_append_rect(shape1, 500, 500, 100, 100, 30, 30);\r
     Tvg_Gradient* grad1 = tvg_radial_gradient_new();\r
@@ -43,13 +44,67 @@ void testCapi()
         {.offset=1.0, .r=0, .g=255, .b=255, .a=255}\r
     };\r
 \r
+    Tvg_Paint *shape2 = tvg_shape_new();\r
+    tvg_shape_append_rect(shape2, 400, 0, 800, 400, 20, 20);\r
+    Tvg_Gradient* grad2 = tvg_linear_gradient_new();\r
+    tvg_linear_gradient_set(grad2, 400, 0, 450, 50);\r
+    Tvg_Color_Stop color_stops2[2] =\r
+    {\r
+        {.offset=0.0, .r=0, .g=0, .b=0, .a=255},\r
+        {.offset=1, .r=255, .g=0, .b=0, .a=255},\r
+    };\r
+\r
+    tvg_gradient_spread(grad2, TVG_STROKE_FILL_REPEAT);\r
+\r
+    Tvg_Paint* shape3 = tvg_shape_new();\r
+    tvg_shape_append_rect(shape3, 0, 400, 400, 800, 20, 20);\r
+    Tvg_Gradient* grad3 = tvg_linear_gradient_new();\r
+    tvg_linear_gradient_set(grad3, 0, 400, 50, 450);\r
+    Tvg_Color_Stop color_stops3[2] =\r
+    {\r
+        {.offset=0.0, .r=0, .g=0, .b=0, .a=255},\r
+        {.offset=1, .r=0, .g=255, .b=0, .a=255},\r
+    };\r
+\r
+    tvg_gradient_spread(grad3, TVG_STROKE_FILL_REFLECT);\r
+\r
     tvg_gradient_color_stops(grad, color_stops, 4);\r
     tvg_gradient_color_stops(grad1, color_stops1, 3);\r
+    tvg_gradient_color_stops(grad2, color_stops2, 2);\r
+    tvg_gradient_color_stops(grad3, color_stops3, 2);\r
     tvg_shape_linear_gradient_set(shape, grad);\r
     tvg_shape_radial_gradient_set(shape1, grad1);\r
+    tvg_shape_linear_gradient_set(shape2, grad2);\r
+    tvg_shape_linear_gradient_set(shape3, grad3);\r
 \r
     tvg_canvas_push(canvas, shape);\r
     tvg_canvas_push(canvas, shape1);\r
+    tvg_canvas_push(canvas, shape2);\r
+    tvg_canvas_push(canvas, shape3);\r
+\r
+    Tvg_Paint* shape4 = tvg_shape_new();\r
+    tvg_shape_append_rect(shape4, 700, 700, 100, 100, 20, 20);\r
+    Tvg_Gradient* grad4 = tvg_linear_gradient_new();\r
+    tvg_linear_gradient_set(grad4, 700, 700, 800, 800);\r
+    Tvg_Color_Stop color_stops4[2] =\r
+    {\r
+        {.offset=0.0, .r=0, .g=0, .b=0, .a=255},\r
+        {.offset=1, .r=0, .g=255, .b=0, .a=255},\r
+    };\r
+    tvg_gradient_color_stops(grad4, color_stops4, 2);\r
+    tvg_shape_linear_gradient_set(shape4, grad4);\r
+\r
+    Tvg_Gradient* grad5 = tvg_linear_gradient_new();\r
+    tvg_linear_gradient_set(grad5, 700, 700, 800, 800);\r
+    Tvg_Color_Stop color_stops5[2] =\r
+    {\r
+        {.offset=0.0, .r=0, .g=0, .b=255, .a=255},\r
+        {.offset=1, .r=0, .g=255, .b=255, .a=255},\r
+    };\r
+    tvg_gradient_color_stops(grad5, color_stops5, 2);\r
+    tvg_shape_linear_gradient_set(shape4, grad5);\r
+\r
+    tvg_canvas_push(canvas, shape4);\r
 \r
     tvg_canvas_draw(canvas);\r
     tvg_canvas_sync(canvas);\r