diff --git a/inc/thorvg.h b/inc/thorvg.h index 7286dc18..e96e92b2 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -946,7 +946,7 @@ public: * * @return Result::Success when succeed, Result::FailedAllocation otherwise. */ - Result stroke(float width) noexcept; + Result strokeWidth(float width) noexcept; /** * @brief Sets the color of the stroke for all of the figures from the path. @@ -958,7 +958,7 @@ public: * * @return Result::Success when succeed, Result::FailedAllocation otherwise. */ - Result stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept; + Result strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept; /** * @brief Sets the gradient fill of the stroke for all of the figures from the path. @@ -969,7 +969,7 @@ public: * @retval Result::FailedAllocation An internal error with a memory allocation for an object to be filled. * @retval Result::MemoryCorruption In case a @c nullptr is passed as the argument. */ - Result stroke(std::unique_ptr f) noexcept; + Result strokeFill(std::unique_ptr f) noexcept; /** * @brief Sets the dash pattern of the stroke. @@ -984,7 +984,7 @@ public: * @note To reset the stroke dash pattern, pass @c nullptr to @p dashPattern and zero to @p cnt. * @warning @p cnt must be greater than 1 if the dash pattern is valid. */ - Result stroke(const float* dashPattern, uint32_t cnt) noexcept; + Result strokeDash(const float* dashPattern, uint32_t cnt) noexcept; /** * @brief Sets the cap style of the stroke in the open sub-paths. @@ -993,7 +993,7 @@ public: * * @return Result::Success when succeed, Result::FailedAllocation otherwise. */ - Result stroke(StrokeCap cap) noexcept; + Result strokeCap(StrokeCap cap) noexcept; /** * @brief Sets the join style for stroked path segments. @@ -1004,7 +1004,7 @@ public: * * @return Result::Success when succeed, Result::FailedAllocation otherwise. */ - Result stroke(StrokeJoin join) noexcept; + Result strokeJoin(StrokeJoin join) noexcept; /** @@ -1131,7 +1131,7 @@ public: * * @return Result::Success when succeed, Result::InsufficientCondition otherwise. */ - Result strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept; + Result strokeFill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept; /** * @brief Gets the pointer to the gradient fill of the stroke. diff --git a/src/bindings/capi/tvgCapi.cpp b/src/bindings/capi/tvgCapi.cpp index 7d602e4f..8d5d31a7 100644 --- a/src/bindings/capi/tvgCapi.cpp +++ b/src/bindings/capi/tvgCapi.cpp @@ -334,7 +334,7 @@ TVG_API Tvg_Result tvg_shape_get_path_commands(const Tvg_Paint* paint, const Tvg TVG_API Tvg_Result tvg_shape_set_stroke_width(Tvg_Paint* paint, float width) { if (!paint) return TVG_RESULT_INVALID_ARGUMENT; - return (Tvg_Result) reinterpret_cast(paint)->stroke(width); + return (Tvg_Result) reinterpret_cast(paint)->strokeWidth(width); } @@ -349,28 +349,28 @@ TVG_API Tvg_Result tvg_shape_get_stroke_width(const Tvg_Paint* paint, float* wid TVG_API Tvg_Result tvg_shape_set_stroke_color(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(paint)->stroke(r, g, b, a); + return (Tvg_Result) reinterpret_cast(paint)->strokeFill(r, g, b, a); } TVG_API 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(paint)->strokeColor(r, g, b, a); + return (Tvg_Result) reinterpret_cast(paint)->strokeFill(r, g, b, a); } TVG_API Tvg_Result tvg_shape_set_stroke_linear_gradient(Tvg_Paint* paint, Tvg_Gradient* gradient) { if (!paint) return TVG_RESULT_INVALID_ARGUMENT; - return (Tvg_Result) reinterpret_cast(paint)->stroke(unique_ptr((LinearGradient*)(gradient))); + return (Tvg_Result) reinterpret_cast(paint)->strokeFill(unique_ptr((LinearGradient*)(gradient))); } TVG_API Tvg_Result tvg_shape_set_stroke_radial_gradient(Tvg_Paint* paint, Tvg_Gradient* gradient) { if (!paint) return TVG_RESULT_INVALID_ARGUMENT; - return (Tvg_Result) reinterpret_cast(paint)->stroke(unique_ptr((RadialGradient*)(gradient))); + return (Tvg_Result) reinterpret_cast(paint)->strokeFill(unique_ptr((RadialGradient*)(gradient))); } @@ -385,7 +385,7 @@ TVG_API Tvg_Result tvg_shape_get_stroke_gradient(const Tvg_Paint* paint, Tvg_Gra TVG_API Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint* paint, const float* dashPattern, uint32_t cnt) { if (!paint) return TVG_RESULT_INVALID_ARGUMENT; - return (Tvg_Result) reinterpret_cast(paint)->stroke(dashPattern, cnt); + return (Tvg_Result) reinterpret_cast(paint)->strokeDash(dashPattern, cnt); } @@ -400,7 +400,7 @@ TVG_API Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float TVG_API Tvg_Result tvg_shape_set_stroke_cap(Tvg_Paint* paint, Tvg_Stroke_Cap cap) { if (!paint) return TVG_RESULT_INVALID_ARGUMENT; - return (Tvg_Result) reinterpret_cast(paint)->stroke((StrokeCap)cap); + return (Tvg_Result) reinterpret_cast(paint)->strokeCap((StrokeCap)cap); } @@ -415,7 +415,7 @@ TVG_API Tvg_Result tvg_shape_get_stroke_cap(const Tvg_Paint* paint, Tvg_Stroke_C TVG_API Tvg_Result tvg_shape_set_stroke_join(Tvg_Paint* paint, Tvg_Stroke_Join join) { if (!paint) return TVG_RESULT_INVALID_ARGUMENT; - return (Tvg_Result) reinterpret_cast(paint)->stroke((StrokeJoin)join); + return (Tvg_Result) reinterpret_cast(paint)->strokeJoin((StrokeJoin)join); } diff --git a/src/examples/AnimateMasking.cpp b/src/examples/AnimateMasking.cpp index 840e7baa..2312001c 100644 --- a/src/examples/AnimateMasking.cpp +++ b/src/examples/AnimateMasking.cpp @@ -55,9 +55,9 @@ void tvgDrawCmds(tvg::Canvas* canvas) pMaskShape = maskShape.get(); maskShape->appendCircle(180, 180, 75, 75); maskShape->fill(125, 125, 125); - maskShape->stroke(25, 25, 25); - maskShape->stroke(tvg::StrokeJoin::Round); - maskShape->stroke(10); + maskShape->strokeFill(25, 25, 25); + maskShape->strokeJoin(tvg::StrokeJoin::Round); + maskShape->strokeWidth(10); canvas->push(std::move(maskShape)); auto mask = tvg::Shape::gen(); diff --git a/src/examples/Arc.cpp b/src/examples/Arc.cpp index 533410e2..6eabffe5 100644 --- a/src/examples/Arc.cpp +++ b/src/examples/Arc.cpp @@ -33,61 +33,61 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Arc Line auto shape1 = tvg::Shape::gen(); shape1->appendArc(150, 150, 80, 10, 180, false); - shape1->stroke(255, 255, 255); - shape1->stroke(2); + shape1->strokeFill(255, 255, 255); + shape1->strokeWidth(2); if (canvas->push(std::move(shape1)) != tvg::Result::Success) return; auto shape2 = tvg::Shape::gen(); shape2->appendArc(400, 150, 80, 0, 300, false); - shape2->stroke(255, 255, 255); - shape2->stroke(2); + shape2->strokeFill(255, 255, 255); + shape2->strokeWidth(2); if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; auto shape3 = tvg::Shape::gen(); shape3->appendArc(600, 150, 80, 300, 60, false); - shape3->stroke(255, 255, 255); - shape3->stroke(2); + shape3->strokeFill(255, 255, 255); + shape3->strokeWidth(2); if (canvas->push(std::move(shape3)) != tvg::Result::Success) return; //Pie Line auto shape4 = tvg::Shape::gen(); shape4->appendArc(150, 400, 80, 10, 180, true); - shape4->stroke(255, 255, 255); - shape4->stroke(2); + shape4->strokeFill(255, 255, 255); + shape4->strokeWidth(2); if (canvas->push(std::move(shape4)) != tvg::Result::Success) return; auto shape5 = tvg::Shape::gen(); shape5->appendArc(400, 400, 80, 0, 300, true); - shape5->stroke(255, 255, 255); - shape5->stroke(2); + shape5->strokeFill(255, 255, 255); + shape5->strokeWidth(2); if (canvas->push(std::move(shape5)) != tvg::Result::Success) return; auto shape6 = tvg::Shape::gen(); shape6->appendArc(600, 400, 80, 300, 60, true); - shape6->stroke(255, 255, 255); - shape6->stroke(2); + shape6->strokeFill(255, 255, 255); + shape6->strokeWidth(2); if (canvas->push(std::move(shape6)) != tvg::Result::Success) return; //Pie Fill auto shape7 = tvg::Shape::gen(); shape7->appendArc(150, 650, 80, 10, 180, true); shape7->fill(255, 255, 255); - shape7->stroke(255, 0, 0); - shape7->stroke(2); + shape7->strokeFill(255, 0, 0); + shape7->strokeWidth(2); if (canvas->push(std::move(shape7)) != tvg::Result::Success) return; auto shape8 = tvg::Shape::gen(); shape8->appendArc(400, 650, 80, 0, 300, true); shape8->fill(255, 255, 255); - shape8->stroke(255, 0, 0); - shape8->stroke(2); + shape8->strokeFill(255, 0, 0); + shape8->strokeWidth(2); if (canvas->push(std::move(shape8)) != tvg::Result::Success) return; auto shape9 = tvg::Shape::gen(); shape9->appendArc(600, 650, 80, 300, 60, true); shape9->fill(255, 255, 255); - shape9->stroke(255, 0, 0); - shape9->stroke(2); + shape9->strokeFill(255, 0, 0); + shape9->strokeWidth(2); if (canvas->push(std::move(shape9)) != tvg::Result::Success) return; } diff --git a/src/examples/ClipPath.cpp b/src/examples/ClipPath.cpp index 2c5b5a90..5f3ad50e 100644 --- a/src/examples/ClipPath.cpp +++ b/src/examples/ClipPath.cpp @@ -56,8 +56,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto star1 = tvg::Shape::gen(); tvgDrawStar(star1.get()); star1->fill(255, 255, 0); - star1->stroke(255 ,0, 0); - star1->stroke(10); + star1->strokeFill(255 ,0, 0); + star1->strokeWidth(10); //Move Star1 star1->translate(-10, -10); @@ -72,8 +72,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto star2 = tvg::Shape::gen(); tvgDrawStar(star2.get()); star2->fill(0, 255, 255); - star2->stroke(0 ,255, 0); - star2->stroke(10); + star2->strokeFill(0 ,255, 0); + star2->strokeWidth(10); star2->opacity(100); //Move Star2 @@ -105,8 +105,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) fill->colorStops(colorStops, 2); star3->fill(std::move(fill)); - star3->stroke(255 ,0, 0); - star3->stroke(10); + star3->strokeFill(255 ,0, 0); + star3->strokeWidth(10); star3->translate(400, 0); // color/alpha/opacity are ignored for a clip object - no need to set them diff --git a/src/examples/CustomTransform.cpp b/src/examples/CustomTransform.cpp index 700d8703..676852e0 100644 --- a/src/examples/CustomTransform.cpp +++ b/src/examples/CustomTransform.cpp @@ -47,8 +47,8 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) shape->lineTo(-53, -5.5); shape->close(); shape->fill(0, 0, 255); - shape->stroke(3); - shape->stroke(255, 255, 255); + shape->strokeWidth(3); + shape->strokeFill(255, 255, 255); //Transform Matrix tvg::Matrix m = {1, 0, 0, 0, 1, 0, 0, 0, 1}; diff --git a/src/examples/DirectUpdate.cpp b/src/examples/DirectUpdate.cpp index 56060038..f00ec4e8 100644 --- a/src/examples/DirectUpdate.cpp +++ b/src/examples/DirectUpdate.cpp @@ -51,8 +51,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) //fill property will be retained shape->fill(127, 255, 255); - shape->stroke(0, 0, 255); - shape->stroke(1); + shape->strokeFill(0, 0, 255); + shape->strokeWidth(1); if (canvas->push(std::move(shape)) != tvg::Result::Success) return; } @@ -68,8 +68,8 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) if (pShape->reset() == tvg::Result::Success) { pShape->appendRect(-100 + (800 * progress), -100 + (800 * progress), 200, 200, (100 * progress), (100 * progress)); pShape->fill(127, 255, 255); - pShape->stroke(0, 0, 255); - pShape->stroke(30 * progress); + pShape->strokeFill(0, 0, 255); + pShape->strokeWidth(30 * progress); //Update shape for drawing (this may work asynchronously) canvas->update(pShape); diff --git a/src/examples/Duplicate.cpp b/src/examples/Duplicate.cpp index 696e2d7e..9f2649d7 100644 --- a/src/examples/Duplicate.cpp +++ b/src/examples/Duplicate.cpp @@ -38,11 +38,11 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape1->appendRect(10, 10, 200, 200); shape1->appendRect(220, 10, 100, 100); - shape1->stroke(3); - shape1->stroke(0, 255, 0); + shape1->strokeWidth(3); + shape1->strokeFill(0, 255, 0); float dashPattern[2] = {4, 4}; - shape1->stroke(dashPattern, 2); + shape1->strokeDash(dashPattern, 2); shape1->fill(255, 0, 0); //Duplicate Shape, Switch fill method diff --git a/src/examples/GradientStroke.cpp b/src/examples/GradientStroke.cpp index c7d9d239..043aa6be 100644 --- a/src/examples/GradientStroke.cpp +++ b/src/examples/GradientStroke.cpp @@ -60,15 +60,15 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape1->lineTo(100, 150); shape1->close(); - shape1->stroke(0, 255, 0); - shape1->stroke(20); - shape1->stroke(tvg::StrokeJoin::Miter); - shape1->stroke(tvg::StrokeCap::Butt); + shape1->strokeFill(0, 255, 0); + shape1->strokeWidth(20); + shape1->strokeJoin(tvg::StrokeJoin::Miter); + shape1->strokeCap(tvg::StrokeCap::Butt); auto fillStroke1 = tvg::LinearGradient::gen(); fillStroke1->linear(100, 100, 250, 250); fillStroke1->colorStops(colorStops1, 3); - shape1->stroke(std::move(fillStroke1)); + shape1->strokeFill(std::move(fillStroke1)); auto fill1 = tvg::LinearGradient::gen(); fill1->linear(100, 100, 250, 250); @@ -80,12 +80,12 @@ void tvgDrawCmds(tvg::Canvas* canvas) // radial gradient stroke + duplicate auto shape2 = tvg::Shape::gen(); shape2->appendCircle(600, 175, 100, 60); - shape2->stroke(80); + shape2->strokeWidth(80); auto fillStroke2 = tvg::RadialGradient::gen(); fillStroke2->radial(600, 175, 100); fillStroke2->colorStops(colorStops2, 2); - shape2->stroke(std::move(fillStroke2)); + shape2->strokeFill(std::move(fillStroke2)); auto shape3 = tvg::cast(shape2->duplicate()); shape3->translate(0, 200); @@ -93,7 +93,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto fillStroke3 = tvg::LinearGradient::gen(); fillStroke3->linear(500, 115, 700, 235); fillStroke3->colorStops(colorStops3, 2); - shape3->stroke(std::move(fillStroke3)); + shape3->strokeFill(std::move(fillStroke3)); auto shape4 = tvg::cast(shape2->duplicate()); shape4->translate(0, 400); @@ -106,13 +106,13 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape5 = tvg::Shape::gen(); shape5->appendRect(100, 500, 300, 300, 50, 80); - shape5->stroke(20); - shape5->stroke(dashPattern1, 2); - shape5->stroke(tvg::StrokeCap::Butt); + shape5->strokeWidth(20); + shape5->strokeDash(dashPattern1, 2); + shape5->strokeCap(tvg::StrokeCap::Butt); auto fillStroke5 = tvg::LinearGradient::gen(); fillStroke5->linear(150, 450, 450, 750); fillStroke5->colorStops(colorStops3, 2); - shape5->stroke(std::move(fillStroke5)); + shape5->strokeFill(std::move(fillStroke5)); auto fill5 = tvg::LinearGradient::gen(); fill5->linear(150, 450, 450, 750); diff --git a/src/examples/InvLumaMasking.cpp b/src/examples/InvLumaMasking.cpp index 6ff26f97..d3d848fe 100644 --- a/src/examples/InvLumaMasking.cpp +++ b/src/examples/InvLumaMasking.cpp @@ -79,8 +79,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) star->lineTo(426, 161); star->lineTo(546, 143); star->close(); - star->stroke(10); - star->stroke(255, 255, 255); + star->strokeWidth(10); + star->strokeFill(255, 255, 255); //Mask3 auto mask3 = tvg::Shape::gen(); diff --git a/src/examples/InvMasking.cpp b/src/examples/InvMasking.cpp index a7c1f7f9..9125ad78 100644 --- a/src/examples/InvMasking.cpp +++ b/src/examples/InvMasking.cpp @@ -79,8 +79,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) star->lineTo(426, 161); star->lineTo(546, 143); star->close(); - star->stroke(10); - star->stroke(255, 255, 255); + star->strokeWidth(10); + star->strokeFill(255, 255, 255); //Mask3 auto mask3 = tvg::Shape::gen(); diff --git a/src/examples/LumaMasking.cpp b/src/examples/LumaMasking.cpp index 406ff1d1..3f04e8fc 100644 --- a/src/examples/LumaMasking.cpp +++ b/src/examples/LumaMasking.cpp @@ -79,8 +79,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) star->lineTo(426, 161); star->lineTo(546, 143); star->close(); - star->stroke(10); - star->stroke(255, 255, 255); + star->strokeWidth(10); + star->strokeFill(255, 255, 255); //Mask3 auto mask3 = tvg::Shape::gen(); diff --git a/src/examples/Masking.cpp b/src/examples/Masking.cpp index 40daae55..f1f7e4d8 100644 --- a/src/examples/Masking.cpp +++ b/src/examples/Masking.cpp @@ -79,9 +79,9 @@ void tvgDrawCmds(tvg::Canvas* canvas) star->lineTo(426, 161); star->lineTo(546, 143); star->close(); - star->stroke(30); - star->stroke(tvg::StrokeJoin::Miter); - star->stroke(255, 255, 255); + star->strokeWidth(30); + star->strokeJoin(tvg::StrokeJoin::Miter); + star->strokeFill(255, 255, 255); //Mask3 auto mask3 = tvg::Shape::gen(); diff --git a/src/examples/Opacity.cpp b/src/examples/Opacity.cpp index 2c2dc286..07c9657e 100644 --- a/src/examples/Opacity.cpp +++ b/src/examples/Opacity.cpp @@ -44,8 +44,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape2 = tvg::Shape::gen(); shape2->appendRect(450, 100, 200, 200, 50, 50); shape2->fill(0, 255, 0); - shape2->stroke(10); - shape2->stroke(255, 255, 255); + shape2->strokeWidth(10); + shape2->strokeFill(255, 255, 255); scene->push(std::move(shape2)); @@ -73,8 +73,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape3->lineTo(146, 143); shape3->close(); shape3->fill(0, 0, 255); - shape3->stroke(10); - shape3->stroke(255, 255, 255); + shape3->strokeWidth(10); + shape3->strokeFill(255, 255, 255); shape3->opacity(127); scene2->push(std::move(shape3)); @@ -95,8 +95,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape4->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius); shape4->close(); shape4->fill(255, 0, 0); - shape4->stroke(10); - shape4->stroke(0, 0, 255); + shape4->strokeWidth(10); + shape4->strokeFill(0, 0, 255); shape4->opacity(200); shape4->scale(3); scene2->push(std::move(shape4)); diff --git a/src/examples/Retaining.cpp b/src/examples/Retaining.cpp index 746e986b..2d42c6de 100644 --- a/src/examples/Retaining.cpp +++ b/src/examples/Retaining.cpp @@ -54,15 +54,15 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape4 = tvg::Shape::gen(); shape4->appendCircle(400, 400, 100, 100); shape4->fill(255, 0, 0); - shape4->stroke(5); - shape4->stroke(255, 255, 255); + shape4->strokeWidth(5); + shape4->strokeFill(255, 255, 255); scene->push(std::move(shape4)); auto shape5 = tvg::Shape::gen(); shape5->appendCircle(550, 550, 150, 150); shape5->fill(255, 0, 255); - shape5->stroke(5); - shape5->stroke(255, 255, 255); + shape5->strokeWidth(5); + shape5->strokeFill(255, 255, 255); scene->push(std::move(shape5)); if (canvas->push(std::move(scene)) != tvg::Result::Success) return; diff --git a/src/examples/SceneBlending.cpp b/src/examples/SceneBlending.cpp index 50734807..624f9b7d 100644 --- a/src/examples/SceneBlending.cpp +++ b/src/examples/SceneBlending.cpp @@ -50,8 +50,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape2 = tvg::Shape::gen(); shape2->appendRect(450, 100, 200, 200, 50, 50); shape2->fill(0, 255, 0); - shape2->stroke(10); - shape2->stroke(255, 255, 255); + shape2->strokeWidth(10); + shape2->strokeFill(255, 255, 255); scene->push(std::move(shape2)); //Draw the Scene onto the Canvas @@ -79,8 +79,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape3->lineTo(146, 143); shape3->close(); shape3->fill(0, 0, 255); - shape3->stroke(10); - shape3->stroke(255, 255, 255); + shape3->strokeWidth(10); + shape3->strokeFill(255, 255, 255); shape3->opacity(127); scene2->push(std::move(shape3)); @@ -101,8 +101,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape4->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius); shape4->close(); shape4->fill(255, 0, 0); - shape4->stroke(10); - shape4->stroke(0, 0, 255); + shape4->strokeWidth(10); + shape4->strokeFill(0, 0, 255); shape4->opacity(200); shape4->scale(3); scene2->push(std::move(shape4)); diff --git a/src/examples/SceneClipper.cpp b/src/examples/SceneClipper.cpp index 0dcb6c52..666feffa 100644 --- a/src/examples/SceneClipper.cpp +++ b/src/examples/SceneClipper.cpp @@ -68,8 +68,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Source auto shape = tvg::Shape::gen(); shape->appendRect(100, 100, 400, 400, 50, 50); - shape->stroke(0, 0, 255); - shape->stroke(10); + shape->strokeFill(0, 0, 255); + shape->strokeWidth(10); shape->fill(255, 255, 255); shape->composite(std::move(clipper), tvg::CompositeMethod::ClipPath); if (canvas->push(std::move(shape)) != tvg::Result::Success) return; diff --git a/src/examples/SceneTransform.cpp b/src/examples/SceneTransform.cpp index 36199946..e0ca1925 100644 --- a/src/examples/SceneTransform.cpp +++ b/src/examples/SceneTransform.cpp @@ -39,8 +39,8 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) auto shape1 = tvg::Shape::gen(); shape1->appendRect(-235, -250, 400, 400, 50, 50); //x, y, w, h, rx, ry shape1->fill(0, 255, 0); //r, g, b - shape1->stroke(5); //width - shape1->stroke(255, 255, 255); //r, g, b + shape1->strokeWidth(5); //width + shape1->strokeFill(255, 255, 255); //r, g, b scene->push(std::move(shape1)); //Prepare Circle (Scene1) @@ -78,8 +78,8 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) shape4->lineTo(-53, -5.5); shape4->close(); shape4->fill(0, 0, 255, 127); - shape4->stroke(3); //width - shape4->stroke(0, 0, 255); //r, g, b + shape4->strokeWidth(3); //width + shape4->strokeFill(0, 0, 255); //r, g, b scene2->push(std::move(shape4)); //Circle (Scene2) diff --git a/src/examples/Stroke.cpp b/src/examples/Stroke.cpp index 7d48a1e8..4186644f 100644 --- a/src/examples/Stroke.cpp +++ b/src/examples/Stroke.cpp @@ -34,9 +34,9 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape1 = tvg::Shape::gen(); shape1->appendRect(50, 50, 200, 200); shape1->fill(50, 50, 50); - shape1->stroke(255, 255, 255); //color: r, g, b - shape1->stroke(tvg::StrokeJoin::Bevel); //default is Bevel - shape1->stroke(10); //width: 10px + shape1->strokeFill(255, 255, 255); //color: r, g, b + shape1->strokeJoin(tvg::StrokeJoin::Bevel); //default is Bevel + shape1->strokeWidth(10); //width: 10px if (canvas->push(std::move(shape1)) != tvg::Result::Success) return; @@ -44,9 +44,9 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape2 = tvg::Shape::gen(); shape2->appendRect(300, 50, 200, 200); shape2->fill(50, 50, 50); - shape2->stroke(255, 255, 255); - shape2->stroke(tvg::StrokeJoin::Round); - shape2->stroke(10); + shape2->strokeFill(255, 255, 255); + shape2->strokeJoin(tvg::StrokeJoin::Round); + shape2->strokeWidth(10); if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; @@ -54,9 +54,9 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape3 = tvg::Shape::gen(); shape3->appendRect(550, 50, 200, 200); shape3->fill(50, 50, 50); - shape3->stroke(255, 255, 255); - shape3->stroke(tvg::StrokeJoin::Miter); - shape3->stroke(10); + shape3->strokeFill(255, 255, 255); + shape3->strokeJoin(tvg::StrokeJoin::Miter); + shape3->strokeWidth(10); if (canvas->push(std::move(shape3)) != tvg::Result::Success) return; @@ -64,8 +64,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape4 = tvg::Shape::gen(); shape4->appendCircle(150, 400, 100, 100); shape4->fill(50, 50, 50); - shape4->stroke(255, 255, 255); - shape4->stroke(1); + shape4->strokeFill(255, 255, 255); + shape4->strokeWidth(1); if (canvas->push(std::move(shape4)) != tvg::Result::Success) return; @@ -73,8 +73,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape5 = tvg::Shape::gen(); shape5->appendCircle(400, 400, 100, 100); shape5->fill(50, 50, 50); - shape5->stroke(255, 255, 255); - shape5->stroke(2); + shape5->strokeFill(255, 255, 255); + shape5->strokeWidth(2); if (canvas->push(std::move(shape5)) != tvg::Result::Success) return; @@ -82,8 +82,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape6 = tvg::Shape::gen(); shape6->appendCircle(650, 400, 100, 100); shape6->fill(50, 50, 50); - shape6->stroke(255, 255, 255); - shape6->stroke(4); + shape6->strokeFill(255, 255, 255); + shape6->strokeWidth(4); if (canvas->push(std::move(shape6)) != tvg::Result::Success) return; @@ -92,17 +92,17 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto hline = tvg::Shape::gen(); hline->moveTo(50, 550 + (25 * i)); hline->lineTo(300, 550 + (25 * i)); - hline->stroke(255, 255, 255); //color: r, g, b - hline->stroke(i + 1); //stroke width - hline->stroke(tvg::StrokeCap::Round); //default is Square + hline->strokeFill(255, 255, 255); //color: r, g, b + hline->strokeWidth(i + 1); //stroke width + hline->strokeCap(tvg::StrokeCap::Round); //default is Square if (canvas->push(std::move(hline)) != tvg::Result::Success) return; auto vline = tvg::Shape::gen(); vline->moveTo(500 + (25 * i), 550); vline->lineTo(500 + (25 * i), 780); - vline->stroke(255, 255, 255); //color: r, g, b - vline->stroke(i + 1); //stroke width - vline->stroke(tvg::StrokeCap::Round); //default is Square + vline->strokeFill(255, 255, 255); //color: r, g, b + vline->strokeWidth(i + 1); //stroke width + vline->strokeCap(tvg::StrokeCap::Round); //default is Square if (canvas->push(std::move(vline)) != tvg::Result::Success) return; } @@ -110,19 +110,19 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto line1 = tvg::Shape::gen(); line1->moveTo(360, 580); line1->lineTo(450, 580); - line1->stroke(255, 255, 255); //color: r, g, b - line1->stroke(15); - line1->stroke(tvg::StrokeCap::Round); + line1->strokeFill(255, 255, 255); //color: r, g, b + line1->strokeWidth(15); + line1->strokeCap(tvg::StrokeCap::Round); auto line2 = tvg::cast(line1->duplicate()); auto line3 = tvg::cast(line1->duplicate()); if (canvas->push(std::move(line1)) != tvg::Result::Success) return; - line2->stroke(tvg::StrokeCap::Square); + line2->strokeCap(tvg::StrokeCap::Square); line2->translate(0, 50); if (canvas->push(std::move(line2)) != tvg::Result::Success) return; - line3->stroke(tvg::StrokeCap::Butt); + line3->strokeCap(tvg::StrokeCap::Butt); line3->translate(0, 100); if (canvas->push(std::move(line3)) != tvg::Result::Success) return; } diff --git a/src/examples/StrokeLine.cpp b/src/examples/StrokeLine.cpp index 4515bb1e..518797d4 100644 --- a/src/examples/StrokeLine.cpp +++ b/src/examples/StrokeLine.cpp @@ -37,10 +37,10 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape1->lineTo(220, 200); shape1->lineTo( 70, 170); shape1->lineTo( 70, 30); - shape1->stroke(255, 0, 0); - shape1->stroke(10); - shape1->stroke(tvg::StrokeJoin::Round); - shape1->stroke(tvg::StrokeCap::Round); + shape1->strokeFill(255, 0, 0); + shape1->strokeWidth(10); + shape1->strokeJoin(tvg::StrokeJoin::Round); + shape1->strokeCap(tvg::StrokeCap::Round); if (canvas->push(std::move(shape1)) != tvg::Result::Success) return; auto shape2 = tvg::Shape::gen(); @@ -49,10 +49,10 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape2->lineTo(470, 200); shape2->lineTo(320, 170); shape2->lineTo(320, 30); - shape2->stroke(255, 255, 0); - shape2->stroke(10); - shape2->stroke(tvg::StrokeJoin::Bevel); - shape2->stroke(tvg::StrokeCap::Square); + shape2->strokeFill(255, 255, 0); + shape2->strokeWidth(10); + shape2->strokeJoin(tvg::StrokeJoin::Bevel); + shape2->strokeCap(tvg::StrokeCap::Square); if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; auto shape3 = tvg::Shape::gen(); @@ -61,10 +61,10 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape3->lineTo(720, 200); shape3->lineTo(570, 170); shape3->lineTo(570, 30); - shape3->stroke(0, 255, 0); - shape3->stroke(10); - shape3->stroke(tvg::StrokeJoin::Miter); - shape3->stroke(tvg::StrokeCap::Butt); + shape3->strokeFill(0, 255, 0); + shape3->strokeWidth(10); + shape3->strokeJoin(tvg::StrokeJoin::Miter); + shape3->strokeCap(tvg::StrokeCap::Butt); if (canvas->push(std::move(shape3)) != tvg::Result::Success) return; //Test for Stroke Dash @@ -74,13 +74,13 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape4->lineTo(220, 380); shape4->lineTo( 70, 330); shape4->lineTo( 70, 210); - shape4->stroke(255, 0, 0); - shape4->stroke(5); - shape4->stroke(tvg::StrokeJoin::Round); - shape4->stroke(tvg::StrokeCap::Round); + shape4->strokeFill(255, 0, 0); + shape4->strokeWidth(5); + shape4->strokeJoin(tvg::StrokeJoin::Round); + shape4->strokeCap(tvg::StrokeCap::Round); float dashPattern1[2] = {20, 10}; - shape4->stroke(dashPattern1, 2); + shape4->strokeDash(dashPattern1, 2); if (canvas->push(std::move(shape4)) != tvg::Result::Success) return; auto shape5 = tvg::Shape::gen(); @@ -89,13 +89,13 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape5->lineTo(470, 380); shape5->lineTo(320, 330); shape5->lineTo(320, 210); - shape5->stroke(255, 255, 0); - shape5->stroke(5); - shape5->stroke(tvg::StrokeJoin::Bevel); - shape5->stroke(tvg::StrokeCap::Square); + shape5->strokeFill(255, 255, 0); + shape5->strokeWidth(5); + shape5->strokeJoin(tvg::StrokeJoin::Bevel); + shape5->strokeCap(tvg::StrokeCap::Square); float dashPattern2[2] = {10, 10}; - shape5->stroke(dashPattern2, 2); + shape5->strokeDash(dashPattern2, 2); if (canvas->push(std::move(shape5)) != tvg::Result::Success) return; auto shape6 = tvg::Shape::gen(); @@ -104,38 +104,38 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape6->lineTo(720, 380); shape6->lineTo(570, 330); shape6->lineTo(570, 210); - shape6->stroke(0, 255, 0); - shape6->stroke(5); - shape6->stroke(tvg::StrokeJoin::Miter); - shape6->stroke(tvg::StrokeCap::Butt); + shape6->strokeFill(0, 255, 0); + shape6->strokeWidth(5); + shape6->strokeJoin(tvg::StrokeJoin::Miter); + shape6->strokeCap(tvg::StrokeCap::Butt); float dashPattern3[6] = {10, 10, 1, 8, 1, 10}; - shape6->stroke(dashPattern3, 6); + shape6->strokeDash(dashPattern3, 6); if (canvas->push(std::move(shape6)) != tvg::Result::Success) return; //For a comparison with shapes 10-12 auto shape7 = tvg::Shape::gen(); shape7->appendArc(70, 400, 160, 10, 70, true); - shape7->stroke(255, 0, 0); - shape7->stroke(7); - shape7->stroke(tvg::StrokeJoin::Round); - shape7->stroke(tvg::StrokeCap::Round); + shape7->strokeFill(255, 0, 0); + shape7->strokeWidth(7); + shape7->strokeJoin(tvg::StrokeJoin::Round); + shape7->strokeCap(tvg::StrokeCap::Round); if (canvas->push(std::move(shape7)) != tvg::Result::Success) return; auto shape8 = tvg::Shape::gen(); shape8->appendArc(320, 400, 160, 10, 70, false); - shape8->stroke(255, 255, 0); - shape8->stroke(7); - shape8->stroke(tvg::StrokeJoin::Bevel); - shape8->stroke(tvg::StrokeCap::Square); + shape8->strokeFill(255, 255, 0); + shape8->strokeWidth(7); + shape8->strokeJoin(tvg::StrokeJoin::Bevel); + shape8->strokeCap(tvg::StrokeCap::Square); if (canvas->push(std::move(shape8)) != tvg::Result::Success) return; auto shape9 = tvg::Shape::gen(); shape9->appendArc(570, 400, 160, 10, 70, true); - shape9->stroke(0, 255, 0); - shape9->stroke(7); - shape9->stroke(tvg::StrokeJoin::Miter); - shape9->stroke(tvg::StrokeCap::Butt); + shape9->strokeFill(0, 255, 0); + shape9->strokeWidth(7); + shape9->strokeJoin(tvg::StrokeJoin::Miter); + shape9->strokeCap(tvg::StrokeCap::Butt); if (canvas->push(std::move(shape9)) != tvg::Result::Success) return; //Test for Stroke Dash for Arc, Circle, Rect @@ -143,33 +143,33 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape10->appendArc(70, 600, 160, 10, 30, true); shape10->appendCircle(70, 700, 20, 60); shape10->appendRect(130, 710, 100, 40); - shape10->stroke(255, 0, 0); - shape10->stroke(5); - shape10->stroke(tvg::StrokeJoin::Round); - shape10->stroke(tvg::StrokeCap::Round); - shape10->stroke(dashPattern1, 2); + shape10->strokeFill(255, 0, 0); + shape10->strokeWidth(5); + shape10->strokeJoin(tvg::StrokeJoin::Round); + shape10->strokeCap(tvg::StrokeCap::Round); + shape10->strokeDash(dashPattern1, 2); if (canvas->push(std::move(shape10)) != tvg::Result::Success) return; auto shape11 = tvg::Shape::gen(); shape11->appendArc(320, 600, 160, 10, 30, false); shape11->appendCircle(320, 700, 20, 60); shape11->appendRect(380, 710, 100, 40); - shape11->stroke(255, 255, 0); - shape11->stroke(5); - shape11->stroke(tvg::StrokeJoin::Bevel); - shape11->stroke(tvg::StrokeCap::Square); - shape11->stroke(dashPattern2, 2); + shape11->strokeFill(255, 255, 0); + shape11->strokeWidth(5); + shape11->strokeJoin(tvg::StrokeJoin::Bevel); + shape11->strokeCap(tvg::StrokeCap::Square); + shape11->strokeDash(dashPattern2, 2); if (canvas->push(std::move(shape11)) != tvg::Result::Success) return; auto shape12 = tvg::Shape::gen(); shape12->appendArc(570, 600, 160, 10, 30, true); shape12->appendCircle(570, 700, 20, 60); shape12->appendRect(630, 710, 100, 40); - shape12->stroke(0, 255, 0); - shape12->stroke(5); - shape12->stroke(tvg::StrokeJoin::Miter); - shape12->stroke(tvg::StrokeCap::Butt); - shape12->stroke(dashPattern3, 6); + shape12->strokeFill(0, 255, 0); + shape12->strokeWidth(5); + shape12->strokeJoin(tvg::StrokeJoin::Miter); + shape12->strokeCap(tvg::StrokeCap::Butt); + shape12->strokeDash(dashPattern3, 6); if (canvas->push(std::move(shape12)) != tvg::Result::Success) return; } diff --git a/src/examples/StrokeMiterlimit.cpp b/src/examples/StrokeMiterlimit.cpp index bd0123f8..604aad47 100644 --- a/src/examples/StrokeMiterlimit.cpp +++ b/src/examples/StrokeMiterlimit.cpp @@ -53,13 +53,13 @@ void goWild(tvg::Canvas* canvas) path->lineTo(460, top / 2); path->close(); - path->fill(150, 150, 255); // fill color - path->stroke(20); // stroke width - path->stroke(120, 120, 255); // stroke color + path->fill(150, 150, 255); // fill color + path->strokeWidth(20); // stroke width + path->strokeFill(120, 120, 255); // stroke color - // path->stroke(tvg::StrokeJoin::Round); - // path->stroke(tvg::StrokeJoin::Bevel); - path->stroke(tvg::StrokeJoin::Miter); + // path->strokeJoin(tvg::StrokeJoin::Round); + // path->strokeJoin(tvg::StrokeJoin::Bevel); + path->strokeJoin(tvg::StrokeJoin::Miter); path->strokeMiterlimit(10); static float ml = path->strokeMiterlimit(); diff --git a/src/examples/TvgSaver.cpp b/src/examples/TvgSaver.cpp index e808cee1..209c1d88 100644 --- a/src/examples/TvgSaver.cpp +++ b/src/examples/TvgSaver.cpp @@ -157,9 +157,9 @@ unique_ptr tvgGradientShape(tvg::Fill::ColorStop* colorStops, int co auto shape = tvg::Shape::gen(); shape->appendCircle(200, 200, 180, 80); shape->fill(std::move(fillShape)); - shape->stroke(20); - shape->stroke(dashPattern, 2); - shape->stroke(std::move(fillStroke)); + shape->strokeWidth(20); + shape->strokeDash(dashPattern, 2); + shape->strokeFill(std::move(fillStroke)); return shape; } diff --git a/src/loaders/lottie/tvgLottieBuilder.cpp b/src/loaders/lottie/tvgLottieBuilder.cpp index f47a00b9..c5376555 100644 --- a/src/loaders/lottie/tvgLottieBuilder.cpp +++ b/src/loaders/lottie/tvgLottieBuilder.cpp @@ -194,7 +194,7 @@ static void _updateTransform(TVG_UNUSED LottieGroup* parent, LottieObject** chil //FIXME: preserve the stroke width. too workaround, need a better design. if (P(ctx.propagator)->rs.strokeWidth() > 0.0f) { - ctx.propagator->stroke(P(ctx.propagator)->rs.strokeWidth() / sqrt(matrix.e11 * matrix.e11 + matrix.e12 * matrix.e12)); + ctx.propagator->strokeWidth(P(ctx.propagator)->rs.strokeWidth() / sqrt(matrix.e11 * matrix.e11 + matrix.e12 * matrix.e12)); } } @@ -217,9 +217,9 @@ static void _updateGroup(LottieGroup* parent, LottieObject** child, float frameN static void _updateStroke(LottieStroke* stroke, float frameNo, RenderContext& ctx) { - ctx.propagator->stroke(stroke->width(frameNo)); - ctx.propagator->stroke(stroke->cap); - ctx.propagator->stroke(stroke->join); + ctx.propagator->strokeWidth(stroke->width(frameNo)); + ctx.propagator->strokeCap(stroke->cap); + ctx.propagator->strokeJoin(stroke->join); ctx.propagator->strokeMiterlimit(stroke->miterLimit); if (stroke->dashattr) { @@ -228,7 +228,7 @@ static void _updateStroke(LottieStroke* stroke, float frameNo, RenderContext& ct dashes[1] = dashes[0] + stroke->dashGap(frameNo); P(ctx.propagator)->strokeDash(dashes, 2, stroke->dashOffset(frameNo)); } else { - ctx.propagator->stroke(nullptr, 0); + ctx.propagator->strokeDash(nullptr, 0); } } @@ -240,7 +240,7 @@ static bool _fragmentedStroking(LottieObject** child, queue& cont contexts.push(ctx); auto& fragment = contexts.back(); - fragment.propagator->stroke(0.0f); + fragment.propagator->strokeWidth(0.0f); fragment.begin = child - 1; ctx.stroking = true; @@ -256,8 +256,7 @@ static void _updateSolidStroke(TVG_UNUSED LottieGroup* parent, LottieObject** ch ctx.merging = nullptr; auto color = stroke->color(frameNo); - ctx.propagator->stroke(color.rgb[0], color.rgb[1], color.rgb[2], stroke->opacity(frameNo)); - + ctx.propagator->strokeFill(color.rgb[0], color.rgb[1], color.rgb[2], stroke->opacity(frameNo)); _updateStroke(static_cast(stroke), frameNo, ctx); } @@ -269,8 +268,7 @@ static void _updateGradientStroke(TVG_UNUSED LottieGroup* parent, LottieObject** auto stroke = static_cast(*child); ctx.merging = nullptr; - ctx.propagator->stroke(unique_ptr(stroke->fill(frameNo))); - + ctx.propagator->strokeFill(unique_ptr(stroke->fill(frameNo))); _updateStroke(static_cast(stroke), frameNo, ctx); } diff --git a/src/loaders/svg/tvgSvgSceneBuilder.cpp b/src/loaders/svg/tvgSvgSceneBuilder.cpp index 1791df57..f3b6015f 100644 --- a/src/loaders/svg/tvgSvgSceneBuilder.cpp +++ b/src/loaders/svg/tvgSvgSceneBuilder.cpp @@ -347,9 +347,9 @@ static void _applyProperty(SvgLoaderData& loaderData, SvgNode* node, Shape* vg, if (node->type == SvgNodeType::G || node->type == SvgNodeType::Use) return; //Apply the stroke style property - vg->stroke(style->stroke.width); - vg->stroke(style->stroke.cap); - vg->stroke(style->stroke.join); + vg->strokeWidth(style->stroke.width); + vg->strokeCap(style->stroke.cap); + vg->strokeJoin(style->stroke.join); vg->strokeMiterlimit(style->stroke.miterlimit); if (style->stroke.dash.array.count > 0) { P(vg)->strokeDash(style->stroke.dash.array.data, style->stroke.dash.array.count, style->stroke.dash.offset); @@ -357,26 +357,26 @@ static void _applyProperty(SvgLoaderData& loaderData, SvgNode* node, Shape* vg, //If stroke property is nullptr then do nothing if (style->stroke.paint.none) { - vg->stroke(0.0f); + vg->strokeWidth(0.0f); } else if (style->stroke.paint.gradient) { Box bBox = vBox; if (!style->stroke.paint.gradient->userSpace) bBox = _boundingBox(vg); if (style->stroke.paint.gradient->type == SvgGradientType::Linear) { auto linear = _applyLinearGradientProperty(style->stroke.paint.gradient, vg, bBox, style->stroke.opacity); - vg->stroke(std::move(linear)); + vg->strokeFill(std::move(linear)); } else if (style->stroke.paint.gradient->type == SvgGradientType::Radial) { auto radial = _applyRadialGradientProperty(style->stroke.paint.gradient, vg, bBox, style->stroke.opacity); - vg->stroke(std::move(radial)); + vg->strokeFill(std::move(radial)); } } else if (style->stroke.paint.url) { //TODO: Apply the color pointed by url } else if (style->stroke.paint.curColor) { //Apply the current style color - vg->stroke(style->color.r, style->color.g, style->color.b, style->stroke.opacity); + vg->strokeFill(style->color.r, style->color.g, style->color.b, style->stroke.opacity); } else { //Apply the stroke color - vg->stroke(style->stroke.paint.color.r, style->stroke.paint.color.g, style->stroke.paint.color.b, style->stroke.opacity); + vg->strokeFill(style->stroke.paint.color.r, style->stroke.paint.color.g, style->stroke.paint.color.b, style->stroke.opacity); } _applyComposition(loaderData, vg, node, vBox, svgPath); @@ -804,7 +804,7 @@ static unique_ptr _sceneBuildHelper(SvgLoaderData& loaderData, const SvgN uint8_t r, g, b; shape->fillColor(&r, &g, &b); if (shape->fill() || r < 255 || g < 255 || b < 255 || shape->strokeFill() || - (shape->strokeColor(&r, &g, &b) == Result::Success && (r < 255 || g < 255 || b < 255))) { + (shape->strokeFill(&r, &g, &b) == Result::Success && (r < 255 || g < 255 || b < 255))) { *isMaskWhite = false; } } diff --git a/src/loaders/tvg/tvgTvgBinInterpreter.cpp b/src/loaders/tvg/tvgTvgBinInterpreter.cpp index 76ab2133..40e06578 100644 --- a/src/loaders/tvg/tvgTvgBinInterpreter.cpp +++ b/src/loaders/tvg/tvgTvgBinInterpreter.cpp @@ -284,7 +284,7 @@ static bool _parseShapeStrokeDashPattern(const char *ptr, const char *end, Shape return false; } - shape->stroke(dashPattern, dashPatternCnt); + shape->strokeDash(dashPattern, dashPatternCnt); free(dashPattern); } return true; @@ -300,12 +300,12 @@ static bool _parseShapeStroke(const char *ptr, const char *end, Shape *shape) switch (block.type) { case TVG_TAG_SHAPE_STROKE_CAP: { if (block.length != SIZE(TvgBinFlag)) return false; - shape->stroke((StrokeCap) *block.data); + shape->strokeCap((StrokeCap) *block.data); break; } case TVG_TAG_SHAPE_STROKE_JOIN: { if (block.length != SIZE(TvgBinFlag)) return false; - shape->stroke((StrokeJoin) *block.data); + shape->strokeJoin((StrokeJoin) *block.data); break; } case TVG_TAG_SHAPE_STROKE_ORDER: { @@ -317,18 +317,18 @@ static bool _parseShapeStroke(const char *ptr, const char *end, Shape *shape) if (block.length != SIZE(float)) return false; float width; READ_FLOAT(&width, block.data); - shape->stroke(width); + shape->strokeWidth(width); break; } case TVG_TAG_SHAPE_STROKE_COLOR: { if (block.length != 4) return false; - shape->stroke(block.data[0], block.data[1], block.data[2], block.data[3]); + shape->strokeFill(block.data[0], block.data[1], block.data[2], block.data[3]); break; } case TVG_TAG_SHAPE_STROKE_FILL: { auto fill = _parseShapeFill(block.data, block.end); if (!fill) return false; - shape->stroke(std::move(fill)); + shape->strokeFill(std::move(fill)); break; } case TVG_TAG_SHAPE_STROKE_DASHPTRN: { diff --git a/src/renderer/gl_engine/tvgGlRenderer.cpp b/src/renderer/gl_engine/tvgGlRenderer.cpp index d7a34adb..295e5e8d 100644 --- a/src/renderer/gl_engine/tvgGlRenderer.cpp +++ b/src/renderer/gl_engine/tvgGlRenderer.cpp @@ -271,7 +271,7 @@ bool GlRenderer::renderShape(RenderData data) if (flags & (RenderUpdateFlag::Stroke | RenderUpdateFlag::Transform)) { - sdata->rshape->strokeColor(&r, &g, &b, &a); + sdata->rshape->strokeFill(&r, &g, &b, &a); if (a > 0) { drawPrimitive(*sdata, r, g, b, a, RenderUpdateFlag::Stroke); @@ -372,7 +372,7 @@ RenderData GlRenderer::prepare(const RenderShape& rshape, RenderData data, const //invisible? uint8_t alphaF = 0, alphaS = 0; rshape.fillColor(nullptr, nullptr, nullptr, &alphaF); - rshape.strokeColor(nullptr, nullptr, nullptr, &alphaS); + rshape.strokeFill(nullptr, nullptr, nullptr, &alphaS); if ( ((sdata->updateFlag & RenderUpdateFlag::Gradient) == 0) && ((sdata->updateFlag & RenderUpdateFlag::Color) && alphaF == 0) && diff --git a/src/renderer/sw_engine/tvgSwRenderer.cpp b/src/renderer/sw_engine/tvgSwRenderer.cpp index 049aa3d1..1cd47113 100644 --- a/src/renderer/sw_engine/tvgSwRenderer.cpp +++ b/src/renderer/sw_engine/tvgSwRenderer.cpp @@ -350,7 +350,7 @@ static void _renderStroke(SwShapeTask* task, SwSurface* surface, uint8_t opacity if (auto strokeFill = task->rshape->strokeFill()) { rasterGradientStroke(surface, &task->shape, strokeFill->identifier()); } else { - if (task->rshape->strokeColor(&r, &g, &b, &a)) { + if (task->rshape->strokeFill(&r, &g, &b, &a)) { a = MULTIPLY(opacity, a); if (a > 0) rasterStroke(surface, &task->shape, r, g, b, a); } diff --git a/src/renderer/tvgRender.h b/src/renderer/tvgRender.h index 7752ed69..9dcf37cb 100644 --- a/src/renderer/tvgRender.h +++ b/src/renderer/tvgRender.h @@ -196,7 +196,7 @@ struct RenderShape return true; } - bool strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const + bool strokeFill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const { if (!stroke) return false; diff --git a/src/renderer/tvgShape.cpp b/src/renderer/tvgShape.cpp index ebae44c0..cf87936d 100644 --- a/src/renderer/tvgShape.cpp +++ b/src/renderer/tvgShape.cpp @@ -293,7 +293,7 @@ Result Shape::order(bool strokeFirst) noexcept } -Result Shape::stroke(float width) noexcept +Result Shape::strokeWidth(float width) noexcept { if (!pImpl->strokeWidth(width)) return Result::FailedAllocation; @@ -307,23 +307,23 @@ float Shape::strokeWidth() const noexcept } -Result Shape::stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept +Result Shape::strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept { - if (!pImpl->strokeColor(r, g, b, a)) return Result::FailedAllocation; + if (!pImpl->strokeFill(r, g, b, a)) return Result::FailedAllocation; return Result::Success; } -Result Shape::strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept +Result Shape::strokeFill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept { - if (!pImpl->rs.strokeColor(r, g, b, a)) return Result::InsufficientCondition; + if (!pImpl->rs.strokeFill(r, g, b, a)) return Result::InsufficientCondition; return Result::Success; } -Result Shape::stroke(unique_ptr f) noexcept +Result Shape::strokeFill(unique_ptr f) noexcept { return pImpl->strokeFill(std::move(f)); } @@ -335,7 +335,7 @@ const Fill* Shape::strokeFill() const noexcept } -Result Shape::stroke(const float* dashPattern, uint32_t cnt) noexcept +Result Shape::strokeDash(const float* dashPattern, uint32_t cnt) noexcept { return pImpl->strokeDash(dashPattern, cnt, 0); } @@ -347,7 +347,7 @@ uint32_t Shape::strokeDash(const float** dashPattern) const noexcept } -Result Shape::stroke(StrokeCap cap) noexcept +Result Shape::strokeCap(StrokeCap cap) noexcept { if (!pImpl->strokeCap(cap)) return Result::FailedAllocation; @@ -355,7 +355,7 @@ Result Shape::stroke(StrokeCap cap) noexcept } -Result Shape::stroke(StrokeJoin join) noexcept +Result Shape::strokeJoin(StrokeJoin join) noexcept { if (!pImpl->strokeJoin(join)) return Result::FailedAllocation; diff --git a/src/renderer/tvgShape.h b/src/renderer/tvgShape.h index bb266866..8602601f 100644 --- a/src/renderer/tvgShape.h +++ b/src/renderer/tvgShape.h @@ -249,7 +249,7 @@ struct Shape::Impl return true; } - bool strokeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) + bool strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { if (!rs.stroke) rs.stroke = new RenderStroke(); if (rs.stroke->fill) { diff --git a/src/savers/tvg/tvgTvgSaver.cpp b/src/savers/tvg/tvgTvgSaver.cpp index e1d4f917..352dbb59 100644 --- a/src/savers/tvg/tvgTvgSaver.cpp +++ b/src/savers/tvg/tvgTvgSaver.cpp @@ -100,8 +100,8 @@ static bool _merge(Shape* from, Shape* to) r = g = b = a = r2 = g2 = b2 = a2 = 0; - from->strokeColor(&r, &g, &b, &a); - to->strokeColor(&r2, &g2, &b2, &a2); + from->strokeFill(&r, &g, &b, &a); + to->strokeFill(&r2, &g2, &b2, &a2); if (r != r2 || g != g2 || b != b2 || a != a2) return false; @@ -472,7 +472,7 @@ TvgBinCounter TvgSaver::serializeStroke(const Shape* shape, const Matrix* pTrans cnt += serializeFill(fill, TVG_TAG_SHAPE_STROKE_FILL, (preTransform ? pTransform : nullptr)); } else { uint8_t color[4] = {0, 0, 0, 0}; - shape->strokeColor(color, color + 1, color + 2, color + 3); + shape->strokeFill(color, color + 1, color + 2, color + 3); cnt += writeTagProperty(TVG_TAG_SHAPE_STROKE_COLOR, SIZE(color), &color); } @@ -566,7 +566,7 @@ TvgBinCounter TvgSaver::serializeShape(const Shape* shape, const Matrix* pTransf //stroke if (shape->strokeWidth() > 0) { uint8_t color[4] = {0, 0, 0, 0}; - shape->strokeColor(color, color + 1, color + 2, color + 3); + shape->strokeFill(color, color + 1, color + 2, color + 3); auto fill = shape->strokeFill(); if (fill || color[3] > 0) { if (!mathEqual(cTransform->e11, cTransform->e22) || (mathZero(cTransform->e11) && !mathEqual(cTransform->e12, cTransform->e21)) || shape->strokeDash(nullptr) > 0) preTransform = false; diff --git a/test/testShape.cpp b/test/testShape.cpp index 23b198f3..1d104871 100644 --- a/test/testShape.cpp +++ b/test/testShape.cpp @@ -146,29 +146,29 @@ TEST_CASE("Stroking", "[tvgShape]") REQUIRE(shape->order(false) == Result::Success); //Stroke Width - REQUIRE(shape->stroke(0) == Result::Success); + REQUIRE(shape->strokeWidth(0) == Result::Success); REQUIRE(shape->strokeWidth() == 0); - REQUIRE(shape->stroke(300) == Result::Success); + REQUIRE(shape->strokeWidth(300) == Result::Success); REQUIRE(shape->strokeWidth() == 300); //Stroke Color uint8_t r, g, b, a; - REQUIRE(shape->stroke(0, 50, 100, 200) == Result::Success); - REQUIRE(shape->strokeColor(nullptr, nullptr, &b, nullptr) == Result::Success); + REQUIRE(shape->strokeFill(0, 50, 100, 200) == Result::Success); + REQUIRE(shape->strokeFill(nullptr, nullptr, &b, nullptr) == Result::Success); REQUIRE(b == 100); - REQUIRE(shape->strokeColor(&r, &g, &b, &a) == Result::Success); + REQUIRE(shape->strokeFill(&r, &g, &b, &a) == Result::Success); REQUIRE(r == 0); REQUIRE(g == 50); REQUIRE(b == 100); REQUIRE(a == 200); - REQUIRE(shape->strokeColor(nullptr, nullptr, nullptr, nullptr) == Result::Success); + REQUIRE(shape->strokeFill(nullptr, nullptr, nullptr, nullptr) == Result::Success); //Stroke Dash float dashPattern[3] = {0, 1.5f, 2.22f}; - REQUIRE(shape->stroke(dashPattern, 3) == Result::InvalidArguments); + REQUIRE(shape->strokeDash(dashPattern, 3) == Result::InvalidArguments); float dashPattern2[3] = {1.0f, 1.5f, 2.22f}; - REQUIRE(shape->stroke(dashPattern2, 3) == Result::Success); + REQUIRE(shape->strokeDash(dashPattern2, 3) == Result::Success); const float* dashPattern3; REQUIRE(shape->strokeDash(nullptr) == 3); @@ -177,18 +177,18 @@ TEST_CASE("Stroking", "[tvgShape]") REQUIRE(dashPattern3[1] == 1.5f); REQUIRE(dashPattern3[2] == 2.22f); - REQUIRE(shape->stroke(nullptr, 0) == Result::Success); + REQUIRE(shape->strokeDash(nullptr, 0) == Result::Success); //Stroke Cap REQUIRE(shape->strokeCap() == StrokeCap::Square); - REQUIRE(shape->stroke(StrokeCap::Round) == Result::Success); - REQUIRE(shape->stroke(StrokeCap::Butt) == Result::Success); + REQUIRE(shape->strokeCap(StrokeCap::Round) == Result::Success); + REQUIRE(shape->strokeCap(StrokeCap::Butt) == Result::Success); REQUIRE(shape->strokeCap() == StrokeCap::Butt); //Stroke Join REQUIRE(shape->strokeJoin() == StrokeJoin::Bevel); - REQUIRE(shape->stroke(StrokeJoin::Miter) == Result::Success); - REQUIRE(shape->stroke(StrokeJoin::Round) == Result::Success); + REQUIRE(shape->strokeJoin(StrokeJoin::Miter) == Result::Success); + REQUIRE(shape->strokeJoin(StrokeJoin::Round) == Result::Success); REQUIRE(shape->strokeJoin() == StrokeJoin::Round); //Stroke Miterlimit diff --git a/test/testSwEngine.cpp b/test/testSwEngine.cpp index ef60a9d4..dc1551f7 100644 --- a/test/testSwEngine.cpp +++ b/test/testSwEngine.cpp @@ -45,8 +45,8 @@ TEST_CASE("Basic draw", "[tvgSwEngine]") REQUIRE(shape1); REQUIRE(shape1->appendArc(150, 150, 80, 10, 180, false) == Result::Success); - REQUIRE(shape1->stroke(255, 255, 255, 255) == Result::Success); - REQUIRE(shape1->stroke(2) == Result::Success); + REQUIRE(shape1->strokeFill(255, 255, 255, 255) == Result::Success); + REQUIRE(shape1->strokeWidth(2) == Result::Success); REQUIRE(canvas->push(std::move(shape1)) == Result::Success); //Cubic @@ -56,7 +56,7 @@ TEST_CASE("Basic draw", "[tvgSwEngine]") REQUIRE(shape2->moveTo(50, 25) == Result::Success); REQUIRE(shape2->cubicTo(62, 25, 75, 38, 75, 50) == Result::Success); REQUIRE(shape2->close() == Result::Success); - REQUIRE(shape2->stroke(1) == Result::Success); + REQUIRE(shape2->strokeWidth(1) == Result::Success); REQUIRE(canvas->push(std::move(shape2)) == Result::Success); //Line @@ -80,10 +80,10 @@ TEST_CASE("Basic draw", "[tvgSwEngine]") REQUIRE(shape4->lineTo(25, 25) == Result::Success); REQUIRE(shape4->cubicTo(50, 50, 75, -75, 50, 100) == Result::Success); REQUIRE(shape4->close() == Result::Success); - REQUIRE(shape4->stroke(255, 0, 0, 255) == Result::Success); - REQUIRE(shape4->stroke(2) == Result::Success); - REQUIRE(shape4->stroke(dashPattern, 2) == Result::Success); - REQUIRE(shape4->stroke(StrokeCap::Round) == Result::Success); + REQUIRE(shape4->strokeFill(255, 0, 0, 255) == Result::Success); + REQUIRE(shape4->strokeWidth(2) == Result::Success); + REQUIRE(shape4->strokeDash(dashPattern, 2) == Result::Success); + REQUIRE(shape4->strokeCap(StrokeCap::Round) == Result::Success); REQUIRE(canvas->push(std::move(shape4)) == Result::Success); //Draw