TVG_EXPORT Tvg_Result tvg_shape_append_circle(Tvg_Paint* paint, float cx, float cy, float rx, float ry);
TVG_EXPORT Tvg_Result tvg_shape_append_arc(Tvg_Paint* paint, float cx, float cy, float radius, float startAngle, float sweep, uint8_t pie);
TVG_EXPORT Tvg_Result tvg_shape_append_path(Tvg_Paint* paint, const Tvg_Path_Command* cmds, uint32_t cmdCnt, const Tvg_Point* pts, uint32_t ptsCnt);
+TVG_EXPORT Tvg_Result tvg_shape_get_path_coords(const Tvg_Paint* paint, const Tvg_Point** pts, uint32_t* cnt);
+TVG_EXPORT Tvg_Result tvg_shape_get_path_commands(const Tvg_Paint* paint, const Tvg_Path_Command** cmds, uint32_t* cnt);
TVG_EXPORT Tvg_Result tvg_shape_set_stroke_width(Tvg_Paint* paint, float width);
TVG_EXPORT Tvg_Result tvg_shape_get_stroke_width(Tvg_Paint* paint, float* width);
TVG_EXPORT Tvg_Result tvg_shape_set_stroke_color(Tvg_Paint* paint, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
return (Tvg_Result) reinterpret_cast<Shape*>(paint)->appendPath((PathCommand*)cmds, cmdCnt, (Point*)pts, ptsCnt);
}
+TVG_EXPORT Tvg_Result tvg_shape_get_path_coords(const Tvg_Paint* paint, const Tvg_Point** pts, uint32_t* cnt)
+{
+ if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
+ auto ret = reinterpret_cast<const Shape*>(paint)->pathCoords((const Point**)pts);
+ if (cnt) *cnt = ret;
+ return TVG_RESULT_SUCCESS;
+}
+
+
+TVG_EXPORT Tvg_Result tvg_shape_get_path_commands(const Tvg_Paint* paint, const Tvg_Path_Command** cmds, uint32_t* cnt)
+{
+ if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
+ auto ret = reinterpret_cast<const Shape*>(paint)->pathCommands((const PathCommand**)cmds);
+ if (cnt) *cnt = ret;
+ return TVG_RESULT_SUCCESS;
+}
+
TVG_EXPORT Tvg_Result tvg_shape_set_stroke_width(Tvg_Paint* paint, float width)
{
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
+ tvg_shape_set_linear_gradient(shape, grad);\r
+ tvg_shape_set_radial_gradient(shape1, grad1);\r
+ tvg_shape_set_linear_gradient(shape2, grad2);\r
+ tvg_shape_set_linear_gradient(shape3, grad3);\r
\r
tvg_canvas_push(canvas, shape);\r
tvg_canvas_push(canvas, shape1);\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
+ tvg_shape_set_linear_gradient(shape4, grad4);\r
\r
Tvg_Gradient* grad5 = tvg_linear_gradient_new();\r
tvg_linear_gradient_set(grad5, 700, 700, 800, 800);\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
+ tvg_shape_set_linear_gradient(shape4, grad5);\r
tvg_canvas_push(canvas, shape4);\r
\r
Tvg_Gradient* grad6 = tvg_radial_gradient_new();\r
{.offset=1, .r=125, .g=0, .b=125, .a=255},\r
};\r
tvg_gradient_color_stops(grad6, color_stops6, 2);\r
- tvg_shape_radial_gradient_set(shape1, grad6);\r
+ tvg_shape_set_radial_gradient(shape1, grad6);\r
tvg_canvas_update(canvas);\r
\r
tvg_shape_set_stroke_width(shape,3);\r
tvg_shape_set_stroke_color(shape, 125, 0, 125, 255);\r
tvg_canvas_update_paint(canvas, shape);\r
\r
+ const Tvg_Path_Command* cmds;\r
+ uint32_t cmdCnt;\r
+ const Tvg_Point* pts;\r
+ uint32_t ptsCnt;\r
+\r
+ tvg_shape_get_path_commands(shape, &cmds, &cmdCnt);\r
+ printf("---- First Shape Commands(%u) ----\n", cmdCnt);\r
+ for(int i=0; i<cmdCnt; ++i)\r
+ printf("%d\n", cmds[i]);\r
+\r
+ tvg_shape_get_path_coords(shape, &pts, &ptsCnt);\r
+ printf("---- First Shape Points(%u) ----\n", ptsCnt);\r
+ for(int i=0; i<ptsCnt; ++i)\r
+ printf("(%.2lf, %.2lf)\n", pts[i].x, pts[i].y);\r
+ \r
tvg_canvas_draw(canvas);\r
tvg_canvas_sync(canvas);\r
\r