Revert "api: enhance Shape::stroke() method usage."

This reverts commit 6cbc1de570.
Setting def value for 'a' makes it impossible to overload
the 'stroke' api with 3 values (needed for introducing dash offset).
This commit is contained in:
Mira Grudzinska 2023-08-18 22:19:10 +02:00 committed by Hermet Park
parent 899ea77695
commit c1e4e0808a
21 changed files with 61 additions and 61 deletions

View file

@ -980,11 +980,11 @@ public:
* @param[in] r The red color channel value in the range [0 ~ 255]. The default value is 0.
* @param[in] g The green color channel value in the range [0 ~ 255]. The default value is 0.
* @param[in] b The blue color channel value in the range [0 ~ 255]. The default value is 0.
* @param[in] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque. The default value is 0.
* @param[in] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque.
*
* @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 stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept;
/**
* @brief Sets the gradient fill of the stroke for all of the figures from the path.
@ -1157,7 +1157,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 strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept;
/**
* @brief Gets the pointer to the gradient fill of the stroke.

View file

@ -55,7 +55,7 @@ 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(25, 25, 25, 255);
maskShape->stroke(tvg::StrokeJoin::Round);
maskShape->stroke(10);
canvas->push(std::move(maskShape));

View file

@ -33,38 +33,38 @@ 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(255, 255, 255, 255);
shape1->stroke(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(255, 255, 255, 255);
shape2->stroke(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(255, 255, 255, 255);
shape3->stroke(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(255, 255, 255, 255);
shape4->stroke(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(255, 255, 255, 255);
shape5->stroke(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(255, 255, 255, 255);
shape6->stroke(2);
if (canvas->push(std::move(shape6)) != tvg::Result::Success) return;
@ -72,21 +72,21 @@ void tvgDrawCmds(tvg::Canvas* canvas)
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(255, 0, 0, 255);
shape7->stroke(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(255, 0, 0, 255);
shape8->stroke(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(255, 0, 0, 255);
shape9->stroke(2);
if (canvas->push(std::move(shape9)) != tvg::Result::Success) return;
}

View file

@ -56,7 +56,7 @@ 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(255 ,0, 0, 255);
star1->stroke(10);
//Move Star1
@ -72,7 +72,7 @@ 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(0 ,255, 0, 255);
star2->stroke(10);
star2->opacity(100);
@ -105,7 +105,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
fill->colorStops(colorStops, 2);
star3->fill(std::move(fill));
star3->stroke(255 ,0, 0);
star3->stroke(255 ,0, 0, 255);
star3->stroke(10);
star3->translate(400, 0);

View file

@ -48,7 +48,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
shape->close();
shape->fill(0, 0, 255);
shape->stroke(3);
shape->stroke(255, 255, 255);
shape->stroke(255, 255, 255, 255);
//Transform Matrix
tvg::Matrix m = {1, 0, 0, 0, 1, 0, 0, 0, 1};

View file

@ -51,7 +51,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//fill property will be retained
shape->fill(127, 255, 255);
shape->stroke(0, 0, 255);
shape->stroke(0, 0, 255, 255);
shape->stroke(1);
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
@ -68,7 +68,7 @@ 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(0, 0, 255, 255);
pShape->stroke(30 * progress);
//Update shape for drawing (this may work asynchronously)

View file

@ -39,7 +39,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape1->appendRect(220, 10, 100, 100);
shape1->stroke(3);
shape1->stroke(0, 255, 0);
shape1->stroke(0, 255, 0, 255);
float dashPattern[2] = {4, 4};
shape1->stroke(dashPattern, 2);

View file

@ -60,7 +60,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape1->lineTo(100, 150);
shape1->close();
shape1->stroke(0, 255, 0);
shape1->stroke(0, 255, 0, 255);
shape1->stroke(20);
shape1->stroke(tvg::StrokeJoin::Miter);
shape1->stroke(tvg::StrokeCap::Butt);

View file

@ -80,7 +80,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
star->lineTo(546, 143);
star->close();
star->stroke(10);
star->stroke(255, 255, 255);
star->stroke(255, 255, 255, 255);
//Mask3
auto mask3 = tvg::Shape::gen();

View file

@ -80,7 +80,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
star->lineTo(546, 143);
star->close();
star->stroke(10);
star->stroke(255, 255, 255);
star->stroke(255, 255, 255, 255);
//Mask3
auto mask3 = tvg::Shape::gen();

View file

@ -80,7 +80,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
star->lineTo(546, 143);
star->close();
star->stroke(10);
star->stroke(255, 255, 255);
star->stroke(255, 255, 255, 255);
//Mask3
auto mask3 = tvg::Shape::gen();

View file

@ -81,7 +81,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
star->close();
star->stroke(30);
star->stroke(tvg::StrokeJoin::Miter);
star->stroke(255, 255, 255);
star->stroke(255, 255, 255, 255);
//Mask3
auto mask3 = tvg::Shape::gen();

View file

@ -45,7 +45,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape2->appendRect(450, 100, 200, 200, 50, 50);
shape2->fill(0, 255, 0);
shape2->stroke(10);
shape2->stroke(255, 255, 255);
shape2->stroke(255, 255, 255, 255);
scene->push(std::move(shape2));
@ -74,7 +74,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape3->close();
shape3->fill(0, 0, 255);
shape3->stroke(10);
shape3->stroke(255, 255, 255);
shape3->stroke(255, 255, 255, 255);
shape3->opacity(127);
scene2->push(std::move(shape3));
@ -96,7 +96,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape4->close();
shape4->fill(255, 0, 0);
shape4->stroke(10);
shape4->stroke(0, 0, 255);
shape4->stroke(0, 0, 255, 255);
shape4->opacity(200);
shape4->scale(3);
scene2->push(std::move(shape4));

View file

@ -55,14 +55,14 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape4->appendCircle(400, 400, 100, 100);
shape4->fill(255, 0, 0);
shape4->stroke(5);
shape4->stroke(255, 255, 255);
shape4->stroke(255, 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->stroke(255, 255, 255, 255);
scene->push(std::move(shape5));
if (canvas->push(std::move(scene)) != tvg::Result::Success) return;

View file

@ -51,7 +51,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape2->appendRect(450, 100, 200, 200, 50, 50);
shape2->fill(0, 255, 0);
shape2->stroke(10);
shape2->stroke(255, 255, 255);
shape2->stroke(255, 255, 255, 255);
scene->push(std::move(shape2));
//Draw the Scene onto the Canvas
@ -80,7 +80,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape3->close();
shape3->fill(0, 0, 255);
shape3->stroke(10);
shape3->stroke(255, 255, 255);
shape3->stroke(255, 255, 255, 255);
shape3->opacity(127);
scene2->push(std::move(shape3));
@ -102,7 +102,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape4->close();
shape4->fill(255, 0, 0);
shape4->stroke(10);
shape4->stroke(0, 0, 255);
shape4->stroke(0, 0, 255, 255);
shape4->opacity(200);
shape4->scale(3);
scene2->push(std::move(shape4));

View file

@ -68,7 +68,7 @@ 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(0, 0, 255, 255);
shape->stroke(10);
shape->fill(255, 255, 255);
shape->composite(std::move(clipper), tvg::CompositeMethod::ClipPath);

View file

@ -40,7 +40,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
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->stroke(255, 255, 255, 255); //r, g, b, a
scene->push(std::move(shape1));
//Prepare Circle (Scene1)
@ -79,7 +79,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
shape4->close();
shape4->fill(0, 0, 255, 127);
shape4->stroke(3); //width
shape4->stroke(0, 0, 255); //r, g, b
shape4->stroke(0, 0, 255, 255); //r, g, b, a
scene2->push(std::move(shape4));
//Circle (Scene2)

View file

@ -34,7 +34,7 @@ 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(255, 255, 255, 255); //color: r, g, b, a
shape1->stroke(tvg::StrokeJoin::Bevel); //default is Bevel
shape1->stroke(10); //width: 10px
@ -44,7 +44,7 @@ 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(255, 255, 255, 255);
shape2->stroke(tvg::StrokeJoin::Round);
shape2->stroke(10);
@ -54,7 +54,7 @@ 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(255, 255, 255, 255);
shape3->stroke(tvg::StrokeJoin::Miter);
shape3->stroke(10);
@ -64,7 +64,7 @@ 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(255, 255, 255, 255);
shape4->stroke(1);
if (canvas->push(std::move(shape4)) != tvg::Result::Success) return;
@ -73,7 +73,7 @@ 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(255, 255, 255, 255);
shape5->stroke(2);
if (canvas->push(std::move(shape5)) != tvg::Result::Success) return;
@ -82,7 +82,7 @@ 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(255, 255, 255, 255);
shape6->stroke(4);
if (canvas->push(std::move(shape6)) != tvg::Result::Success) return;
@ -92,7 +92,7 @@ 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(255, 255, 255, 255); //color: r, g, b, a
hline->stroke(i + 1); //stroke width
hline->stroke(tvg::StrokeCap::Round); //default is Square
if (canvas->push(std::move(hline)) != tvg::Result::Success) return;
@ -100,7 +100,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
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(255, 255, 255, 255); //color: r, g, b, a
vline->stroke(i + 1); //stroke width
vline->stroke(tvg::StrokeCap::Round); //default is Square
if (canvas->push(std::move(vline)) != tvg::Result::Success) return;
@ -110,7 +110,7 @@ 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(255, 255, 255, 255); //color: r, g, b, a
line1->stroke(15);
line1->stroke(tvg::StrokeCap::Round);

View file

@ -37,7 +37,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape1->lineTo(220, 200);
shape1->lineTo( 70, 170);
shape1->lineTo( 70, 30);
shape1->stroke(255, 0, 0);
shape1->stroke(255, 0, 0, 255);
shape1->stroke(10);
shape1->stroke(tvg::StrokeJoin::Round);
shape1->stroke(tvg::StrokeCap::Round);
@ -49,7 +49,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape2->lineTo(470, 200);
shape2->lineTo(320, 170);
shape2->lineTo(320, 30);
shape2->stroke(255, 255, 0);
shape2->stroke(255, 255, 0, 255);
shape2->stroke(10);
shape2->stroke(tvg::StrokeJoin::Bevel);
shape2->stroke(tvg::StrokeCap::Square);
@ -61,7 +61,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape3->lineTo(720, 200);
shape3->lineTo(570, 170);
shape3->lineTo(570, 30);
shape3->stroke(0, 255, 0);
shape3->stroke(0, 255, 0, 255);
shape3->stroke(10);
shape3->stroke(tvg::StrokeJoin::Miter);
shape3->stroke(tvg::StrokeCap::Butt);
@ -74,7 +74,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape4->lineTo(220, 380);
shape4->lineTo( 70, 330);
shape4->lineTo( 70, 210);
shape4->stroke(255, 0, 0);
shape4->stroke(255, 0, 0, 255);
shape4->stroke(5);
shape4->stroke(tvg::StrokeJoin::Round);
shape4->stroke(tvg::StrokeCap::Round);
@ -89,7 +89,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape5->lineTo(470, 380);
shape5->lineTo(320, 330);
shape5->lineTo(320, 210);
shape5->stroke(255, 255, 0);
shape5->stroke(255, 255, 0, 255);
shape5->stroke(5);
shape5->stroke(tvg::StrokeJoin::Bevel);
shape5->stroke(tvg::StrokeCap::Square);
@ -104,7 +104,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape6->lineTo(720, 380);
shape6->lineTo(570, 330);
shape6->lineTo(570, 210);
shape6->stroke(0, 255, 0);
shape6->stroke(0, 255, 0, 255);
shape6->stroke(5);
shape6->stroke(tvg::StrokeJoin::Miter);
shape6->stroke(tvg::StrokeCap::Butt);
@ -116,7 +116,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//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(255, 0, 0, 255);
shape7->stroke(7);
shape7->stroke(tvg::StrokeJoin::Round);
shape7->stroke(tvg::StrokeCap::Round);
@ -124,7 +124,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto shape8 = tvg::Shape::gen();
shape8->appendArc(320, 400, 160, 10, 70, false);
shape8->stroke(255, 255, 0);
shape8->stroke(255, 255, 0, 255);
shape8->stroke(7);
shape8->stroke(tvg::StrokeJoin::Bevel);
shape8->stroke(tvg::StrokeCap::Square);
@ -132,7 +132,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto shape9 = tvg::Shape::gen();
shape9->appendArc(570, 400, 160, 10, 70, true);
shape9->stroke(0, 255, 0);
shape9->stroke(0, 255, 0, 255);
shape9->stroke(7);
shape9->stroke(tvg::StrokeJoin::Miter);
shape9->stroke(tvg::StrokeCap::Butt);
@ -143,7 +143,7 @@ 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(255, 0, 0, 255);
shape10->stroke(5);
shape10->stroke(tvg::StrokeJoin::Round);
shape10->stroke(tvg::StrokeCap::Round);
@ -154,7 +154,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
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(255, 255, 0, 255);
shape11->stroke(5);
shape11->stroke(tvg::StrokeJoin::Bevel);
shape11->stroke(tvg::StrokeCap::Square);
@ -165,7 +165,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
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(0, 255, 0, 255);
shape12->stroke(5);
shape12->stroke(tvg::StrokeJoin::Miter);
shape12->stroke(tvg::StrokeCap::Butt);

View file

@ -53,9 +53,9 @@ 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->stroke(20); // stroke width
path->stroke(120, 120, 255, 255); // stroke color
// path->stroke(tvg::StrokeJoin::Round);
// path->stroke(tvg::StrokeJoin::Bevel);

View file

@ -789,7 +789,7 @@ static unique_ptr<Scene> _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->strokeColor(&r, &g, &b, nullptr) == Result::Success && (r < 255 || g < 255 || b < 255))) {
*isMaskWhite = false;
}
}