put missing const parameter and correct set/get naming.
attention, these two apis are changed!
tvg_gradient_color_stops() => tvg_gradient_set_color_stops()
tvg_gradient_spread() = tvg_gradient_set_spread()
Change-Id: I309b973b8e88bdf33232f95e5da30061b9c2a22b
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_get_stroke_width(const 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);
-TVG_EXPORT Tvg_Result tvg_shape_get_stroke_color(Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a);
+TVG_EXPORT Tvg_Result tvg_shape_get_stroke_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a);
TVG_EXPORT Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint* paint, const float* dashPattern, uint32_t cnt);
-TVG_EXPORT Tvg_Result tvg_shape_get_stroke_dash(Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt);
+TVG_EXPORT Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt);
TVG_EXPORT Tvg_Result tvg_shape_set_stroke_cap(Tvg_Paint* paint, Tvg_Stroke_Cap cap);
-TVG_EXPORT Tvg_Result tvg_shape_get_stroke_cap(Tvg_Paint* paint, Tvg_Stroke_Cap* cap);
+TVG_EXPORT Tvg_Result tvg_shape_get_stroke_cap(const Tvg_Paint* paint, Tvg_Stroke_Cap* cap);
TVG_EXPORT Tvg_Result tvg_shape_set_stroke_join(Tvg_Paint* paint, Tvg_Stroke_Join join);
-TVG_EXPORT Tvg_Result tvg_shape_get_stroke_join(Tvg_Paint* paint, Tvg_Stroke_Join* join);
+TVG_EXPORT Tvg_Result tvg_shape_get_stroke_join(const Tvg_Paint* paint, Tvg_Stroke_Join* join);
TVG_EXPORT Tvg_Result tvg_shape_set_fill_color(Tvg_Paint* paint, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
-TVG_EXPORT Tvg_Result tvg_shape_get_fill_color(Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a);
+TVG_EXPORT Tvg_Result tvg_shape_get_fill_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a);
TVG_EXPORT Tvg_Result tvg_shape_set_linear_gradient(Tvg_Paint* paint, Tvg_Gradient* grad);
TVG_EXPORT Tvg_Result tvg_shape_set_radial_gradient(Tvg_Paint* paint, Tvg_Gradient* grad);
-TVG_EXPORT Tvg_Result tvg_shape_get_gradient(Tvg_Paint* paint, Tvg_Gradient** grad);
+TVG_EXPORT Tvg_Result tvg_shape_get_gradient(const Tvg_Paint* paint, Tvg_Gradient** grad);
/************************************************************************/
/* Gradient API */
/************************************************************************/
TVG_EXPORT Tvg_Gradient* tvg_linear_gradient_new();
TVG_EXPORT Tvg_Gradient* tvg_radial_gradient_new();
-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);
+TVG_EXPORT Tvg_Result tvg_gradient_set_color_stops(Tvg_Gradient* grad, const Tvg_Color_Stop* color_stop, uint32_t cnt);
+TVG_EXPORT Tvg_Result tvg_gradient_set_spread(Tvg_Gradient* grad, const Tvg_Stroke_Fill);
+TVG_EXPORT Tvg_Result tvg_gradient_del(Tvg_Gradient* grad);
/************************************************************************/
/************************************************************************/
TVG_EXPORT Tvg_Paint* tvg_picture_new();
TVG_EXPORT Tvg_Result tvg_picture_load(Tvg_Paint* paint, const char* path);
-TVG_EXPORT Tvg_Result tvg_picture_get_viewbox(Tvg_Paint* paint, float* x, float* y, float* w, float* h);
+TVG_EXPORT Tvg_Result tvg_picture_get_viewbox(const Tvg_Paint* paint, float* x, float* y, float* w, float* h);
#ifdef __cplusplus
}
using namespace std;
using namespace tvg;
+#define CCP(A) const_cast<Tvg_Paint*>(A) //Const-Cast-Paint
+
#ifdef __cplusplus
extern "C" {
#endif
}
-TVG_EXPORT Tvg_Result tvg_shape_get_stroke_width(Tvg_Paint* paint, float* width)
+TVG_EXPORT Tvg_Result tvg_shape_get_stroke_width(const Tvg_Paint* paint, float* width)
{
if (!paint || !width) return TVG_RESULT_INVALID_ARGUMENT;
- *width = reinterpret_cast<Shape*>(paint)->strokeWidth();
+ *width = reinterpret_cast<Shape*>(CCP(paint))->strokeWidth();
return TVG_RESULT_SUCCESS;
}
}
-TVG_EXPORT Tvg_Result tvg_shape_get_stroke_color(Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a)
+TVG_EXPORT Tvg_Result tvg_shape_get_stroke_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a)
{
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
- return (Tvg_Result) reinterpret_cast<Shape*>(paint)->strokeColor(r, g, b, a);
+ return (Tvg_Result) reinterpret_cast<Shape*>(CCP(paint))->strokeColor(r, g, b, a);
}
}
-TVG_EXPORT Tvg_Result tvg_shape_get_stroke_dash(Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt)
+TVG_EXPORT Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt)
{
if (!paint || !cnt || !dashPattern) return TVG_RESULT_INVALID_ARGUMENT;
- *cnt = reinterpret_cast<Shape*>(paint)->strokeDash(dashPattern);
+ *cnt = reinterpret_cast<Shape*>(CCP(paint))->strokeDash(dashPattern);
return TVG_RESULT_SUCCESS;
}
}
-TVG_EXPORT Tvg_Result tvg_shape_get_stroke_cap(Tvg_Paint* paint, Tvg_Stroke_Cap* cap)
+TVG_EXPORT Tvg_Result tvg_shape_get_stroke_cap(const Tvg_Paint* paint, Tvg_Stroke_Cap* cap)
{
if (!paint || !cap) return TVG_RESULT_INVALID_ARGUMENT;
- *cap = (Tvg_Stroke_Cap) reinterpret_cast<Shape*>(paint)->strokeCap();
+ *cap = (Tvg_Stroke_Cap) reinterpret_cast<Shape*>(CCP(paint))->strokeCap();
return TVG_RESULT_SUCCESS;
}
}
-TVG_EXPORT Tvg_Result tvg_shape_get_stroke_join(Tvg_Paint* paint, Tvg_Stroke_Join* join)
+TVG_EXPORT Tvg_Result tvg_shape_get_stroke_join(const Tvg_Paint* paint, Tvg_Stroke_Join* join)
{
if (!paint || !join) return TVG_RESULT_INVALID_ARGUMENT;
- *join = (Tvg_Stroke_Join) reinterpret_cast<Shape*>(paint)->strokeJoin();
+ *join = (Tvg_Stroke_Join) reinterpret_cast<Shape*>(CCP(paint))->strokeJoin();
return TVG_RESULT_SUCCESS;
}
}
-TVG_EXPORT Tvg_Result tvg_shape_get_fill_color(Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a)
+TVG_EXPORT Tvg_Result tvg_shape_get_fill_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a)
{
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
- return (Tvg_Result) reinterpret_cast<Shape*>(paint)->fill(r, g, b, a);
+ return (Tvg_Result) reinterpret_cast<Shape*>(CCP(paint))->fill(r, g, b, a);
}
}
-TVG_EXPORT Tvg_Result tvg_shape_get_gradient(Tvg_Paint* paint, Tvg_Gradient** gradient)
+TVG_EXPORT Tvg_Result tvg_shape_get_gradient(const Tvg_Paint* paint, Tvg_Gradient** gradient)
{
if (!paint || !gradient) return TVG_RESULT_INVALID_ARGUMENT;
- *gradient = (Tvg_Gradient*)(reinterpret_cast<Shape*>(paint)->fill());
+ *gradient = (Tvg_Gradient*)(reinterpret_cast<Shape*>(CCP(paint))->fill());
return TVG_RESULT_SUCCESS;
}
}
-TVG_EXPORT Tvg_Result tvg_picture_get_viewbox(Tvg_Paint* paint, float* x, float* y, float* w, float* h)
+TVG_EXPORT Tvg_Result tvg_picture_get_viewbox(const Tvg_Paint* paint, float* x, float* y, float* w, float* h)
{
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
- return (Tvg_Result) reinterpret_cast<Picture*>(paint)->viewbox(x, y, w, h);
+ return (Tvg_Result) reinterpret_cast<Picture*>(CCP(paint))->viewbox(x, y, w, h);
}
return (Tvg_Result) reinterpret_cast<RadialGradient*>(grad)->radial(cx, cy, 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_set_color_stops(Tvg_Gradient* grad, const Tvg_Color_Stop* color_stop, uint32_t cnt)
{
if (!grad) return TVG_RESULT_INVALID_ARGUMENT;
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)
+TVG_EXPORT Tvg_Result tvg_gradient_set_spread(Tvg_Gradient* grad, const Tvg_Stroke_Fill spread)
{
if (!grad) return TVG_RESULT_INVALID_ARGUMENT;
return (Tvg_Result) reinterpret_cast<Fill*>(grad)->spread((FillSpread)spread);
{.offset=1, .r=255, .g=0, .b=0, .a=255},\r
};\r
\r
- tvg_gradient_spread(grad2, TVG_STROKE_FILL_REPEAT);\r
+ tvg_gradient_set_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
{.offset=1, .r=0, .g=255, .b=0, .a=255},\r
};\r
\r
- tvg_gradient_spread(grad3, TVG_STROKE_FILL_REFLECT);\r
+ tvg_gradient_set_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_gradient_set_color_stops(grad, color_stops, 4);\r
+ tvg_gradient_set_color_stops(grad1, color_stops1, 3);\r
+ tvg_gradient_set_color_stops(grad2, color_stops2, 2);\r
+ tvg_gradient_set_color_stops(grad3, color_stops3, 2);\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
{.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_gradient_set_color_stops(grad4, color_stops4, 2);\r
tvg_shape_set_linear_gradient(shape4, grad4);\r
\r
Tvg_Gradient* grad5 = tvg_linear_gradient_new();\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_gradient_set_color_stops(grad5, color_stops5, 2);\r
tvg_shape_set_linear_gradient(shape4, grad5);\r
tvg_canvas_push(canvas, shape4);\r
\r
{.offset=0.0, .r=0, .g=125, .b=0, .a=255},\r
{.offset=1, .r=125, .g=0, .b=125, .a=255},\r
};\r
- tvg_gradient_color_stops(grad6, color_stops6, 2);\r
+ tvg_gradient_set_color_stops(grad6, color_stops6, 2);\r
tvg_shape_set_radial_gradient(shape1, grad6);\r
tvg_canvas_update(canvas);\r
\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
+ for(int i=0; i < cmdCnt; ++i) {\r
printf("%d\n", cmds[i]);\r
+ }\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
+ for(int i=0; i < ptsCnt; ++i) {\r
printf("(%.2lf, %.2lf)\n", pts[i].x, pts[i].y);\r
- \r
+ }\r
+\r
tvg_canvas_draw(canvas);\r
tvg_canvas_sync(canvas);\r
\r