api: enhance Shape::fill() method usage.

Designate a default value for alpha which is mostly optional.
This commit is contained in:
Hermet Park 2023-06-06 12:03:11 +09:00 committed by Hermet Park
parent fbf8e8dfce
commit 1ae92daa9d
41 changed files with 148 additions and 152 deletions

View file

@ -355,6 +355,7 @@ public:
* *
* @note The bounding box doesn't indicate the final rendered region. It's the smallest rectangle that encloses the object. * @note The bounding box doesn't indicate the final rendered region. It's the smallest rectangle that encloses the object.
* @see Paint::bounds(float* x, float* y, float* w, float* h, bool transformed); * @see Paint::bounds(float* x, float* y, float* w, float* h, bool transformed);
* @deprecated Use bounds(float* x, float* y, float* w, float* h, bool transformed) instead
*/ */
TVG_DEPRECATED Result bounds(float* x, float* y, float* w, float* h) const noexcept; TVG_DEPRECATED Result bounds(float* x, float* y, float* w, float* h) const noexcept;
@ -990,7 +991,7 @@ public:
* @note Either a solid color or a gradient fill is applied, depending on what was set as last. * @note Either a solid color or a gradient fill is applied, depending on what was set as last.
* @note ClipPath won't use the fill values. (see: enum class CompositeMethod::ClipPath) * @note ClipPath won't use the fill values. (see: enum class CompositeMethod::ClipPath)
*/ */
Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept; Result fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
/** /**
* @brief Sets the gradient fill for all of the figures from the path. * @brief Sets the gradient fill for all of the figures from the path.
@ -1062,7 +1063,7 @@ public:
* *
* @return Result::Success when succeed. * @return Result::Success when succeed.
*/ */
Result fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept; Result fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
/** /**
* @brief Gets the fill rule value. * @brief Gets the fill rule value.

View file

@ -138,7 +138,7 @@ public:
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, static_cast<float>(w), static_cast<float>(h), 0, 0); shape->appendRect(0, 0, static_cast<float>(w), static_cast<float>(h), 0, 0);
shape->fill(r, g, b, 255); shape->fill(r, g, b);
if (canvas->push(std::move(shape)) != tvg::Result::Success) return 1; if (canvas->push(std::move(shape)) != tvg::Result::Success) return 1;
} }

View file

@ -45,10 +45,11 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (paint->identifier() == tvg::Shape::identifier()) { if (paint->identifier() == tvg::Shape::identifier()) {
auto shape = (tvg::Shape*) paint; auto shape = (tvg::Shape*) paint;
//override color? //override color?
uint8_t r, g, b, a; uint8_t r, g, b;
shape->fillColor(&r, &g, &b, &a); shape->fillColor(&r, &g, &b);
if (r == 255 && g == 180 && b == 0) if (r == 255 && g == 180 && b == 0)
shape->fill(0, 0, 255, a); shape->fill(0, 0, 255);
} }
//You can return false, to stop traversing immediately. //You can return false, to stop traversing immediately.

View file

@ -37,7 +37,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
// background // background
auto bg = tvg::Shape::gen(); auto bg = tvg::Shape::gen();
bg->appendRect(0,0,WIDTH, HEIGHT,0, 0); bg->appendRect(0,0,WIDTH, HEIGHT,0, 0);
bg->fill(255, 255, 255, 255); bg->fill(255, 255, 255);
canvas->push(std::move(bg)); canvas->push(std::move(bg));
// image // image
@ -54,7 +54,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto maskShape = tvg::Shape::gen(); auto maskShape = tvg::Shape::gen();
pMaskShape = maskShape.get(); pMaskShape = maskShape.get();
maskShape->appendCircle(180, 180, 75, 75); maskShape->appendCircle(180, 180, 75, 75);
maskShape->fill(125, 125, 125, 255); maskShape->fill(125, 125, 125);
maskShape->stroke(25, 25, 25, 255); maskShape->stroke(25, 25, 25, 255);
maskShape->stroke(tvg::StrokeJoin::Round); maskShape->stroke(tvg::StrokeJoin::Round);
maskShape->stroke(10); maskShape->stroke(10);
@ -63,7 +63,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
pMask = mask.get(); pMask = mask.get();
mask->appendCircle(180, 180, 75, 75); mask->appendCircle(180, 180, 75, 75);
mask->fill(255, 255, 255, 255); //AlphaMask RGB channels are unused. mask->fill(255, 255, 255); //AlphaMask RGB channels are unused.
picture2->composite(std::move(mask), tvg::CompositeMethod::AlphaMask); picture2->composite(std::move(mask), tvg::CompositeMethod::AlphaMask);
if (canvas->push(std::move(picture2)) != tvg::Result::Success) return; if (canvas->push(std::move(picture2)) != tvg::Result::Success) return;

View file

@ -71,21 +71,21 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Pie Fill //Pie Fill
auto shape7 = tvg::Shape::gen(); auto shape7 = tvg::Shape::gen();
shape7->appendArc(150, 650, 80, 10, 180, true); shape7->appendArc(150, 650, 80, 10, 180, true);
shape7->fill(255, 255, 255, 255); shape7->fill(255, 255, 255);
shape7->stroke(255, 0, 0, 255); shape7->stroke(255, 0, 0, 255);
shape7->stroke(2); shape7->stroke(2);
if (canvas->push(std::move(shape7)) != tvg::Result::Success) return; if (canvas->push(std::move(shape7)) != tvg::Result::Success) return;
auto shape8 = tvg::Shape::gen(); auto shape8 = tvg::Shape::gen();
shape8->appendArc(400, 650, 80, 0, 300, true); shape8->appendArc(400, 650, 80, 0, 300, true);
shape8->fill(255, 255, 255, 255); shape8->fill(255, 255, 255);
shape8->stroke(255, 0, 0, 255); shape8->stroke(255, 0, 0, 255);
shape8->stroke(2); shape8->stroke(2);
if (canvas->push(std::move(shape8)) != tvg::Result::Success) return; if (canvas->push(std::move(shape8)) != tvg::Result::Success) return;
auto shape9 = tvg::Shape::gen(); auto shape9 = tvg::Shape::gen();
shape9->appendArc(600, 650, 80, 300, 60, true); shape9->appendArc(600, 650, 80, 300, 60, true);
shape9->fill(255, 255, 255, 255); shape9->fill(255, 255, 255);
shape9->stroke(255, 0, 0, 255); shape9->stroke(255, 0, 0, 255);
shape9->stroke(2); shape9->stroke(2);
if (canvas->push(std::move(shape9)) != tvg::Result::Success) return; if (canvas->push(std::move(shape9)) != tvg::Result::Success) return;

View file

@ -35,19 +35,19 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Prepare Round Rectangle //Prepare Round Rectangle
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50, 50); //x, y, w, h, rx, ry shape1->appendRect(0, 0, 400, 400, 50, 50); //x, y, w, h, rx, ry
shape1->fill(0, 255, 0, 255); //r, g, b, a shape1->fill(0, 255, 0); //r, g, b
if (canvas->push(std::move(shape1)) != tvg::Result::Success) return; if (canvas->push(std::move(shape1)) != tvg::Result::Success) return;
//Prepare Circle //Prepare Circle
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH
shape2->fill(255, 255, 0, 170); //r, g, b, a shape2->fill(255, 255, 0, 170); //r, g, b, a
if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; if (canvas->push(std::move(shape2)) != tvg::Result::Success) return;
//Prepare Ellipse //Prepare Ellipse
auto shape3 = tvg::Shape::gen(); auto shape3 = tvg::Shape::gen();
shape3->appendCircle(400, 400, 250, 100); //cx, cy, radiusW, radiusH shape3->appendCircle(400, 400, 250, 100); //cx, cy, radiusW, radiusH
shape3->fill(255, 255, 255, 100); //r, g, b, a shape3->fill(255, 255, 255, 100); //r, g, b, a
if (canvas->push(std::move(shape3)) != tvg::Result::Success) return; if (canvas->push(std::move(shape3)) != tvg::Result::Success) return;
//Prepare Star //Prepare Star
@ -69,7 +69,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Prepare Opaque Ellipse //Prepare Opaque Ellipse
auto shape5 = tvg::Shape::gen(); auto shape5 = tvg::Shape::gen();
shape5->appendCircle(600, 650, 200, 150); shape5->appendCircle(600, 650, 200, 150);
shape5->fill(0, 0, 255, 255); shape5->fill(0, 0, 255);
if (canvas->push(std::move(shape5)) != tvg::Result::Success) return; if (canvas->push(std::move(shape5)) != tvg::Result::Success) return;
} }

View file

@ -47,7 +47,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Background //Background
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0);
shape->fill(255, 255, 255, 255); shape->fill(255, 255, 255);
if (canvas->push(std::move(shape)) != tvg::Result::Success) return; if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
////////////////////////////////////////////// //////////////////////////////////////////////
@ -56,7 +56,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto star1 = tvg::Shape::gen(); auto star1 = tvg::Shape::gen();
tvgDrawStar(star1.get()); tvgDrawStar(star1.get());
star1->fill(255, 255, 0, 255); star1->fill(255, 255, 0);
star1->stroke(255 ,0, 0, 255); star1->stroke(255 ,0, 0, 255);
star1->stroke(10); star1->stroke(10);
@ -72,7 +72,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto star2 = tvg::Shape::gen(); auto star2 = tvg::Shape::gen();
tvgDrawStar(star2.get()); tvgDrawStar(star2.get());
star2->fill(0, 255, 255, 255); star2->fill(0, 255, 255);
star2->stroke(0 ,255, 0, 255); star2->stroke(0 ,255, 0, 255);
star2->stroke(10); star2->stroke(10);
star2->opacity(100); star2->opacity(100);

View file

@ -46,7 +46,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
shape->lineTo(-173, 12.5); shape->lineTo(-173, 12.5);
shape->lineTo(-53, -5.5); shape->lineTo(-53, -5.5);
shape->close(); shape->close();
shape->fill(0, 0, 255, 255); shape->fill(0, 0, 255);
shape->stroke(3); shape->stroke(3);
shape->stroke(255, 255, 255, 255); shape->stroke(255, 255, 255, 255);

View file

@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
bg->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); bg->appendRect(0, 0, WIDTH, HEIGHT, 0, 0);
//fill property will be retained //fill property will be retained
bg->fill(255, 255, 255, 255); bg->fill(255, 255, 255);
if (canvas->push(std::move(bg)) != tvg::Result::Success) return; if (canvas->push(std::move(bg)) != tvg::Result::Success) return;
@ -50,7 +50,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape->appendRect(-100, -100, 200, 200, 0, 0); shape->appendRect(-100, -100, 200, 200, 0, 0);
//fill property will be retained //fill property will be retained
shape->fill(127, 255, 255, 255); shape->fill(127, 255, 255);
shape->stroke(0, 0, 255, 255); shape->stroke(0, 0, 255, 255);
shape->stroke(1); shape->stroke(1);
@ -67,7 +67,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
//Reset Shape //Reset Shape
if (pShape->reset() == tvg::Result::Success) { if (pShape->reset() == tvg::Result::Success) {
pShape->appendRect(-100 + (800 * progress), -100 + (800 * progress), 200, 200, (100 * progress), (100 * progress)); pShape->appendRect(-100 + (800 * progress), -100 + (800 * progress), 200, 200, (100 * progress), (100 * progress));
pShape->fill(127, 255, 255, 255); pShape->fill(127, 255, 255);
pShape->stroke(0, 0, 255, 255); pShape->stroke(0, 0, 255, 255);
pShape->stroke(30 * progress); pShape->stroke(30 * progress);

View file

@ -43,7 +43,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
float dashPattern[2] = {4, 4}; float dashPattern[2] = {4, 4};
shape1->stroke(dashPattern, 2); shape1->stroke(dashPattern, 2);
shape1->fill(255, 0, 0, 255); shape1->fill(255, 0, 0);
//Duplicate Shape, Switch fill method //Duplicate Shape, Switch fill method
auto shape2 = tvg::cast<tvg::Shape>(shape1->duplicate()); auto shape2 = tvg::cast<tvg::Shape>(shape1->duplicate());
@ -76,17 +76,17 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50, 50); shape1->appendRect(0, 0, 400, 400, 50, 50);
shape1->fill(0, 255, 0, 255); shape1->fill(0, 255, 0);
scene1->push(std::move(shape1)); scene1->push(std::move(shape1));
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendCircle(400, 400, 200, 200); shape2->appendCircle(400, 400, 200, 200);
shape2->fill(255, 255, 0, 255); shape2->fill(255, 255, 0);
scene1->push(std::move(shape2)); scene1->push(std::move(shape2));
auto shape3 = tvg::Shape::gen(); auto shape3 = tvg::Shape::gen();
shape3->appendCircle(600, 600, 150, 100); shape3->appendCircle(600, 600, 150, 100);
shape3->fill(0, 255, 255, 255); shape3->fill(0, 255, 255);
scene1->push(std::move(shape3)); scene1->push(std::move(shape3));
scene1->scale(0.25); scene1->scale(0.25);

View file

@ -38,7 +38,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape1->lineTo(385, 150); shape1->lineTo(385, 150);
shape1->lineTo(80, 355); shape1->lineTo(80, 355);
shape1->close(); shape1->close();
shape1->fill(255, 255, 255, 255); shape1->fill(255, 255, 255);
shape1->fill(tvg::FillRule::Winding); //Fill all winding shapes shape1->fill(tvg::FillRule::Winding); //Fill all winding shapes
if (canvas->push(std::move(shape1)) != tvg::Result::Success) return; if (canvas->push(std::move(shape1)) != tvg::Result::Success) return;
@ -51,7 +51,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape2->lineTo(715, 450); shape2->lineTo(715, 450);
shape2->lineTo(410, 655); shape2->lineTo(410, 655);
shape2->close(); shape2->close();
shape2->fill(255, 255, 255, 255); shape2->fill(255, 255, 255);
shape2->fill(tvg::FillRule::EvenOdd); //Fill polygons with even odd pattern shape2->fill(tvg::FillRule::EvenOdd); //Fill polygons with even odd pattern
if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; if (canvas->push(std::move(shape2)) != tvg::Result::Success) return;

View file

@ -38,7 +38,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Mask //Mask
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(200, 200, 125, 125); mask->appendCircle(200, 200, 125, 125);
mask->fill(255, 0, 0, 255); mask->fill(255, 0, 0);
auto fill = tvg::LinearGradient::gen(); auto fill = tvg::LinearGradient::gen();
fill->linear(0, 0, 400, 400); fill->linear(0, 0, 400, 400);
@ -70,7 +70,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Mask //Mask
auto mask1 = tvg::Shape::gen(); auto mask1 = tvg::Shape::gen();
mask1->appendCircle(600, 200, 125, 125); mask1->appendCircle(600, 200, 125, 125);
mask1->fill(255, 0, 0, 255); mask1->fill(255, 0, 0);
auto fill1 = tvg::LinearGradient::gen(); auto fill1 = tvg::LinearGradient::gen();
fill1->linear(400, 0, 800, 400); fill1->linear(400, 0, 800, 400);
@ -92,7 +92,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Mask //Mask
auto mask2 = tvg::Shape::gen(); auto mask2 = tvg::Shape::gen();
mask2->appendCircle(200, 600, 125, 125); mask2->appendCircle(200, 600, 125, 125);
mask2->fill(255, 0, 0, 255); mask2->fill(255, 0, 0);
auto fill2 = tvg::LinearGradient::gen(); auto fill2 = tvg::LinearGradient::gen();
fill2->linear(0, 400, 400, 800); fill2->linear(0, 400, 400, 800);
@ -124,7 +124,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Mask //Mask
auto mask3 = tvg::Shape::gen(); auto mask3 = tvg::Shape::gen();
mask3->appendCircle(600, 600, 125, 125); mask3->appendCircle(600, 600, 125, 125);
mask3->fill(255, 0, 0, 255); mask3->fill(255, 0, 0);
auto fill3 = tvg::LinearGradient::gen(); auto fill3 = tvg::LinearGradient::gen();
fill3->linear(400, 400, 800, 800); fill3->linear(400, 400, 800, 800);

View file

@ -34,17 +34,17 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Solid Rectangle //Solid Rectangle
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, 400, 400, 0, 0); shape->appendRect(0, 0, 400, 400, 0, 0);
shape->fill(255, 0, 0, 255); shape->fill(255, 0, 0);
//Mask //Mask
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(200, 200, 125, 125); mask->appendCircle(200, 200, 125, 125);
mask->fill(255, 100, 255, 255); mask->fill(255, 100, 255);
//Nested Mask //Nested Mask
auto nMask = tvg::Shape::gen(); auto nMask = tvg::Shape::gen();
nMask->appendCircle(220, 220, 125, 125); nMask->appendCircle(220, 220, 125, 125);
nMask->fill(255, 200, 255, 255); nMask->fill(255, 200, 255);
mask->composite(std::move(nMask), tvg::CompositeMethod::InvLumaMask); mask->composite(std::move(nMask), tvg::CompositeMethod::InvLumaMask);
shape->composite(std::move(mask), tvg::CompositeMethod::InvLumaMask); shape->composite(std::move(mask), tvg::CompositeMethod::InvLumaMask);
@ -61,13 +61,13 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask2 = tvg::Shape::gen(); auto mask2 = tvg::Shape::gen();
mask2->appendCircle(150, 500, 75, 75); mask2->appendCircle(150, 500, 75, 75);
mask2->appendRect(150, 500, 200, 200, 30, 30); mask2->appendRect(150, 500, 200, 200, 30, 30);
mask2->fill(255, 255, 255, 255); mask2->fill(255, 255, 255);
svg->composite(std::move(mask2), tvg::CompositeMethod::InvLumaMask); svg->composite(std::move(mask2), tvg::CompositeMethod::InvLumaMask);
if (canvas->push(std::move(svg)) != tvg::Result::Success) return; if (canvas->push(std::move(svg)) != tvg::Result::Success) return;
//Star //Star
auto star = tvg::Shape::gen(); auto star = tvg::Shape::gen();
star->fill(80, 80, 80, 255); star->fill(80, 80, 80);
star->moveTo(599, 34); star->moveTo(599, 34);
star->lineTo(653, 143); star->lineTo(653, 143);
star->lineTo(774, 160); star->lineTo(774, 160);
@ -85,7 +85,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Mask3 //Mask3
auto mask3 = tvg::Shape::gen(); auto mask3 = tvg::Shape::gen();
mask3->appendCircle(600, 200, 125, 125); mask3->appendCircle(600, 200, 125, 125);
mask3->fill(0, 255, 255, 255); mask3->fill(0, 255, 255);
star->composite(std::move(mask3), tvg::CompositeMethod::InvLumaMask); star->composite(std::move(mask3), tvg::CompositeMethod::InvLumaMask);
if (canvas->push(std::move(star)) != tvg::Result::Success) return; if (canvas->push(std::move(star)) != tvg::Result::Success) return;
@ -104,10 +104,10 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask4 = tvg::Scene::gen(); auto mask4 = tvg::Scene::gen();
auto mask4_rect = tvg::Shape::gen(); auto mask4_rect = tvg::Shape::gen();
mask4_rect->appendRect(500, 400, 200, 300, 0, 0); mask4_rect->appendRect(500, 400, 200, 300, 0, 0);
mask4_rect->fill(255, 255, 255, 255); mask4_rect->fill(255, 255, 255);
auto mask4_circle = tvg::Shape::gen(); auto mask4_circle = tvg::Shape::gen();
mask4_circle->appendCircle(600, 550, 125, 125); mask4_circle->appendCircle(600, 550, 125, 125);
mask4_circle->fill(128, 0, 128, 224); mask4_circle->fill(128, 0, 128);
if (mask4->push(std::move(mask4_rect)) != tvg::Result::Success) return; if (mask4->push(std::move(mask4_rect)) != tvg::Result::Success) return;
if (mask4->push(std::move(mask4_circle)) != tvg::Result::Success) return; if (mask4->push(std::move(mask4_circle)) != tvg::Result::Success) return;
image->composite(std::move(mask4), tvg::CompositeMethod::InvLumaMask); image->composite(std::move(mask4), tvg::CompositeMethod::InvLumaMask);

View file

@ -34,17 +34,17 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Solid Rectangle //Solid Rectangle
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, 400, 400, 0, 0); shape->appendRect(0, 0, 400, 400, 0, 0);
shape->fill(0, 0, 255, 255); shape->fill(0, 0, 255);
//Mask //Mask
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(200, 200, 125, 125); mask->appendCircle(200, 200, 125, 125);
mask->fill(255, 255, 255, 255); //InvAlphaMask RGB channels are unused. mask->fill(255, 255, 255); //InvAlphaMask RGB channels are unused.
//Nested Mask //Nested Mask
auto nMask = tvg::Shape::gen(); auto nMask = tvg::Shape::gen();
nMask->appendCircle(220, 220, 125, 125); nMask->appendCircle(220, 220, 125, 125);
nMask->fill(255, 255, 255, 255); //InvAlphaMask RGB channels are unused. nMask->fill(255, 255, 255); //InvAlphaMask RGB channels are unused.
mask->composite(std::move(nMask), tvg::CompositeMethod::InvAlphaMask); mask->composite(std::move(nMask), tvg::CompositeMethod::InvAlphaMask);
shape->composite(std::move(mask), tvg::CompositeMethod::InvAlphaMask); shape->composite(std::move(mask), tvg::CompositeMethod::InvAlphaMask);
@ -61,13 +61,13 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask2 = tvg::Shape::gen(); auto mask2 = tvg::Shape::gen();
mask2->appendCircle(150, 500, 75, 75); mask2->appendCircle(150, 500, 75, 75);
mask2->appendRect(150, 500, 200, 200, 30, 30); mask2->appendRect(150, 500, 200, 200, 30, 30);
mask2->fill(255, 255, 255, 255); //InvAlphaMask RGB channels are unused. mask2->fill(255, 255, 255); //InvAlphaMask RGB channels are unused.
svg->composite(std::move(mask2), tvg::CompositeMethod::InvAlphaMask); svg->composite(std::move(mask2), tvg::CompositeMethod::InvAlphaMask);
if (canvas->push(std::move(svg)) != tvg::Result::Success) return; if (canvas->push(std::move(svg)) != tvg::Result::Success) return;
//Star //Star
auto star = tvg::Shape::gen(); auto star = tvg::Shape::gen();
star->fill(80, 80, 80, 255); star->fill(80, 80, 80);
star->moveTo(599, 34); star->moveTo(599, 34);
star->lineTo(653, 143); star->lineTo(653, 143);
star->lineTo(774, 160); star->lineTo(774, 160);
@ -85,7 +85,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Mask3 //Mask3
auto mask3 = tvg::Shape::gen(); auto mask3 = tvg::Shape::gen();
mask3->appendCircle(600, 200, 125, 125); mask3->appendCircle(600, 200, 125, 125);
mask3->fill(255, 255, 255, 255); //InvAlphaMask RGB channels are unused. mask3->fill(255, 255, 255); //InvAlphaMask RGB channels are unused.
star->composite(std::move(mask3), tvg::CompositeMethod::InvAlphaMask); star->composite(std::move(mask3), tvg::CompositeMethod::InvAlphaMask);
if (canvas->push(std::move(star)) != tvg::Result::Success) return; if (canvas->push(std::move(star)) != tvg::Result::Success) return;
@ -115,7 +115,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
mask4->lineTo(426, 511); mask4->lineTo(426, 511);
mask4->lineTo(546, 493); mask4->lineTo(546, 493);
mask4->close(); mask4->close();
mask4->fill(255, 255, 255, 70); //InvAlphaMask RGB channels are unused. mask4->fill(255, 255, 255); //InvAlphaMask RGB channels are unused.
mask4->opacity(70);
image->composite(std::move(mask4), tvg::CompositeMethod::InvAlphaMask); image->composite(std::move(mask4), tvg::CompositeMethod::InvAlphaMask);
if (canvas->push(std::move(image)) != tvg::Result::Success) return; if (canvas->push(std::move(image)) != tvg::Result::Success) return;
} }

View file

@ -34,17 +34,17 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Solid Rectangle //Solid Rectangle
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, 400, 400, 0, 0); shape->appendRect(0, 0, 400, 400, 0, 0);
shape->fill(255, 0, 0, 255); shape->fill(255, 0, 0);
//Mask //Mask
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(200, 200, 125, 125); mask->appendCircle(200, 200, 125, 125);
mask->fill(255, 100, 255, 255); mask->fill(255, 100, 255);
//Nested Mask //Nested Mask
auto nMask = tvg::Shape::gen(); auto nMask = tvg::Shape::gen();
nMask->appendCircle(220, 220, 125, 125); nMask->appendCircle(220, 220, 125, 125);
nMask->fill(255, 200, 255, 255); nMask->fill(255, 200, 255);
mask->composite(std::move(nMask), tvg::CompositeMethod::LumaMask); mask->composite(std::move(nMask), tvg::CompositeMethod::LumaMask);
shape->composite(std::move(mask), tvg::CompositeMethod::LumaMask); shape->composite(std::move(mask), tvg::CompositeMethod::LumaMask);
@ -61,13 +61,13 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask2 = tvg::Shape::gen(); auto mask2 = tvg::Shape::gen();
mask2->appendCircle(150, 500, 75, 75); mask2->appendCircle(150, 500, 75, 75);
mask2->appendRect(150, 500, 200, 200, 30, 30); mask2->appendRect(150, 500, 200, 200, 30, 30);
mask2->fill(255, 255, 255, 255); mask2->fill(255, 255, 255);
svg->composite(std::move(mask2), tvg::CompositeMethod::LumaMask); svg->composite(std::move(mask2), tvg::CompositeMethod::LumaMask);
if (canvas->push(std::move(svg)) != tvg::Result::Success) return; if (canvas->push(std::move(svg)) != tvg::Result::Success) return;
//Star //Star
auto star = tvg::Shape::gen(); auto star = tvg::Shape::gen();
star->fill(80, 80, 80, 255); star->fill(80, 80, 80);
star->moveTo(599, 34); star->moveTo(599, 34);
star->lineTo(653, 143); star->lineTo(653, 143);
star->lineTo(774, 160); star->lineTo(774, 160);
@ -85,7 +85,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Mask3 //Mask3
auto mask3 = tvg::Shape::gen(); auto mask3 = tvg::Shape::gen();
mask3->appendCircle(600, 200, 125, 125); mask3->appendCircle(600, 200, 125, 125);
mask3->fill(0, 255, 255, 255); mask3->fill(0, 255, 255);
star->composite(std::move(mask3), tvg::CompositeMethod::LumaMask); star->composite(std::move(mask3), tvg::CompositeMethod::LumaMask);
if (canvas->push(std::move(star)) != tvg::Result::Success) return; if (canvas->push(std::move(star)) != tvg::Result::Success) return;
@ -104,10 +104,10 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask4 = tvg::Scene::gen(); auto mask4 = tvg::Scene::gen();
auto mask4_rect = tvg::Shape::gen(); auto mask4_rect = tvg::Shape::gen();
mask4_rect->appendRect(500, 400, 200, 300, 0, 0); mask4_rect->appendRect(500, 400, 200, 300, 0, 0);
mask4_rect->fill(255, 255, 255, 255); mask4_rect->fill(255, 255, 255);
auto mask4_circle = tvg::Shape::gen(); auto mask4_circle = tvg::Shape::gen();
mask4_circle->appendCircle(600, 550, 125, 125); mask4_circle->appendCircle(600, 550, 125, 125);
mask4_circle->fill(128, 0, 128, 224); mask4_circle->fill(128, 0, 128);
if (mask4->push(std::move(mask4_rect)) != tvg::Result::Success) return; if (mask4->push(std::move(mask4_rect)) != tvg::Result::Success) return;
if (mask4->push(std::move(mask4_circle)) != tvg::Result::Success) return; if (mask4->push(std::move(mask4_circle)) != tvg::Result::Success) return;
image->composite(std::move(mask4), tvg::CompositeMethod::LumaMask); image->composite(std::move(mask4), tvg::CompositeMethod::LumaMask);

View file

@ -34,17 +34,17 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Solid Rectangle //Solid Rectangle
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, 400, 400, 0, 0); shape->appendRect(0, 0, 400, 400, 0, 0);
shape->fill(0, 0, 255, 255); shape->fill(0, 0, 255);
//Mask //Mask
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(200, 200, 125, 125); mask->appendCircle(200, 200, 125, 125);
mask->fill(255, 255, 255, 255); //AlphaMask RGB channels are unused. mask->fill(255, 255, 255); //AlphaMask RGB channels are unused.
//Nested Mask //Nested Mask
auto nMask = tvg::Shape::gen(); auto nMask = tvg::Shape::gen();
nMask->appendCircle(220, 220, 125, 125); nMask->appendCircle(220, 220, 125, 125);
nMask->fill(255, 255, 255, 255); //AlphaMask RGB channels are unused. nMask->fill(255, 255, 255); //AlphaMask RGB channels are unused.
mask->composite(std::move(nMask), tvg::CompositeMethod::AlphaMask); mask->composite(std::move(nMask), tvg::CompositeMethod::AlphaMask);
shape->composite(std::move(mask), tvg::CompositeMethod::AlphaMask); shape->composite(std::move(mask), tvg::CompositeMethod::AlphaMask);
@ -61,13 +61,13 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask2 = tvg::Shape::gen(); auto mask2 = tvg::Shape::gen();
mask2->appendCircle(150, 500, 75, 75); mask2->appendCircle(150, 500, 75, 75);
mask2->appendRect(150, 500, 200, 200, 30, 30); mask2->appendRect(150, 500, 200, 200, 30, 30);
mask2->fill(255, 255, 255, 255); //AlphaMask RGB channels are unused. mask2->fill(255, 255, 255); //AlphaMask RGB channels are unused.
svg->composite(std::move(mask2), tvg::CompositeMethod::AlphaMask); svg->composite(std::move(mask2), tvg::CompositeMethod::AlphaMask);
if (canvas->push(std::move(svg)) != tvg::Result::Success) return; if (canvas->push(std::move(svg)) != tvg::Result::Success) return;
//Star //Star
auto star = tvg::Shape::gen(); auto star = tvg::Shape::gen();
star->fill(80, 80, 80, 255); star->fill(80, 80, 80);
star->moveTo(599, 34); star->moveTo(599, 34);
star->lineTo(653, 143); star->lineTo(653, 143);
star->lineTo(774, 160); star->lineTo(774, 160);
@ -86,7 +86,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Mask3 //Mask3
auto mask3 = tvg::Shape::gen(); auto mask3 = tvg::Shape::gen();
mask3->appendCircle(600, 200, 125, 125); mask3->appendCircle(600, 200, 125, 125);
mask3->fill(255, 255, 255, 255); //AlphaMask RGB channels are unused. mask3->fill(255, 255, 255); //AlphaMask RGB channels are unused.
mask3->opacity(200); mask3->opacity(200);
star->composite(std::move(mask3), tvg::CompositeMethod::AlphaMask); star->composite(std::move(mask3), tvg::CompositeMethod::AlphaMask);
if (canvas->push(std::move(star)) != tvg::Result::Success) return; if (canvas->push(std::move(star)) != tvg::Result::Success) return;
@ -115,7 +115,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
mask4->lineTo(426, 511); mask4->lineTo(426, 511);
mask4->lineTo(546, 493); mask4->lineTo(546, 493);
mask4->close(); mask4->close();
mask4->fill(255, 255, 255, 255); //AlphaMask RGB channels are unused. mask4->fill(255, 255, 255); //AlphaMask RGB channels are unused.
mask4->opacity(70); mask4->opacity(70);
image->composite(std::move(mask4), tvg::CompositeMethod::AlphaMask); image->composite(std::move(mask4), tvg::CompositeMethod::AlphaMask);
if (canvas->push(std::move(image)) != tvg::Result::Success) return; if (canvas->push(std::move(image)) != tvg::Result::Success) return;

View file

@ -42,11 +42,11 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape + Shape Mask Add //Shape + Shape Mask Add
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendCircle(125, 100, 50, 50); shape->appendCircle(125, 100, 50, 50);
shape->fill(255, 255, 255, 255); shape->fill(255, 255, 255);
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(175, 100, 50, 50); mask->appendCircle(175, 100, 50, 50);
mask->fill(255, 255, 255, 255); mask->fill(255, 255, 255);
shape->composite(std::move(mask), tvg::CompositeMethod::AddMask); shape->composite(std::move(mask), tvg::CompositeMethod::AddMask);
canvas->push(std::move(shape)); canvas->push(std::move(shape));
@ -54,11 +54,11 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape + Shape Mask Subtract //Shape + Shape Mask Subtract
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendCircle(375, 100, 50, 50); shape2->appendCircle(375, 100, 50, 50);
shape2->fill(255, 255, 255, 255); shape2->fill(255, 255, 255);
auto mask2 = tvg::Shape::gen(); auto mask2 = tvg::Shape::gen();
mask2->appendCircle(400, 100, 50, 50); mask2->appendCircle(400, 100, 50, 50);
mask2->fill(255, 255, 255, 255); mask2->fill(255, 255, 255);
shape2->composite(std::move(mask2), tvg::CompositeMethod::SubtractMask); shape2->composite(std::move(mask2), tvg::CompositeMethod::SubtractMask);
@ -67,11 +67,11 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape + Shape Mask Intersect //Shape + Shape Mask Intersect
auto shape3 = tvg::Shape::gen(); auto shape3 = tvg::Shape::gen();
shape3->appendCircle(625, 100, 50, 50); shape3->appendCircle(625, 100, 50, 50);
shape3->fill(255, 255, 255, 255); shape3->fill(255, 255, 255);
auto mask3 = tvg::Shape::gen(); auto mask3 = tvg::Shape::gen();
mask3->appendCircle(650, 100, 50, 50); mask3->appendCircle(650, 100, 50, 50);
mask3->fill(255, 255, 255, 255); mask3->fill(255, 255, 255);
shape3->composite(std::move(mask3), tvg::CompositeMethod::IntersectMask); shape3->composite(std::move(mask3), tvg::CompositeMethod::IntersectMask);
canvas->push(std::move(shape3)); canvas->push(std::move(shape3));
@ -79,11 +79,11 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape + Shape Mask Difference //Shape + Shape Mask Difference
auto shape4 = tvg::Shape::gen(); auto shape4 = tvg::Shape::gen();
shape4->appendCircle(875, 100, 50, 50); shape4->appendCircle(875, 100, 50, 50);
shape4->fill(255, 255, 255, 255); shape4->fill(255, 255, 255);
auto mask4 = tvg::Shape::gen(); auto mask4 = tvg::Shape::gen();
mask4->appendCircle(900, 100, 50, 50); mask4->appendCircle(900, 100, 50, 50);
mask4->fill(255, 255, 255, 255); mask4->fill(255, 255, 255);
shape4->composite(std::move(mask4), tvg::CompositeMethod::DifferenceMask); shape4->composite(std::move(mask4), tvg::CompositeMethod::DifferenceMask);
canvas->push(std::move(shape4)); canvas->push(std::move(shape4));
@ -93,7 +93,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape + Image Mask Add //Shape + Image Mask Add
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendCircle(150, 250, 50, 50); shape->appendCircle(150, 250, 50, 50);
shape->fill(255, 255, 255, 255); shape->fill(255, 255, 255);
auto mask = tvg::Picture::gen(); auto mask = tvg::Picture::gen();
if (mask->load(data, 200, 300, true) != tvg::Result::Success) return; if (mask->load(data, 200, 300, true) != tvg::Result::Success) return;
@ -105,7 +105,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape + Image Mask Subtract //Shape + Image Mask Subtract
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendCircle(400, 250, 50, 50); shape2->appendCircle(400, 250, 50, 50);
shape2->fill(255, 255, 255, 255); shape2->fill(255, 255, 255);
auto mask2 = tvg::Picture::gen(); auto mask2 = tvg::Picture::gen();
if (mask2->load(data, 200, 300, true) != tvg::Result::Success) return; if (mask2->load(data, 200, 300, true) != tvg::Result::Success) return;
@ -118,7 +118,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape + Image Mask Intersect //Shape + Image Mask Intersect
auto shape3 = tvg::Shape::gen(); auto shape3 = tvg::Shape::gen();
shape3->appendCircle(650, 250, 50, 50); shape3->appendCircle(650, 250, 50, 50);
shape3->fill(255, 255, 255, 255); shape3->fill(255, 255, 255);
auto mask3 = tvg::Picture::gen(); auto mask3 = tvg::Picture::gen();
if (mask3->load(data, 200, 300, true) != tvg::Result::Success) return; if (mask3->load(data, 200, 300, true) != tvg::Result::Success) return;
@ -131,7 +131,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape + Image Mask Difference //Shape + Image Mask Difference
auto shape4 = tvg::Shape::gen(); auto shape4 = tvg::Shape::gen();
shape4->appendCircle(900, 250, 50, 50); shape4->appendCircle(900, 250, 50, 50);
shape4->fill(255, 255, 255, 255); shape4->fill(255, 255, 255);
auto mask4 = tvg::Picture::gen(); auto mask4 = tvg::Picture::gen();
if (mask4->load(data, 200, 300, true) != tvg::Result::Success) return; if (mask4->load(data, 200, 300, true) != tvg::Result::Success) return;
@ -146,11 +146,11 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Rect + Rect Mask Add //Rect + Rect Mask Add
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(75, 500, 100, 100, 0, 0); shape->appendRect(75, 500, 100, 100, 0, 0);
shape->fill(255, 255, 255, 255); shape->fill(255, 255, 255);
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendRect(125, 450, 100, 100, 0, 0); mask->appendRect(125, 450, 100, 100, 0, 0);
mask->fill(255, 255, 255, 255); mask->fill(255, 255, 255);
shape->composite(std::move(mask), tvg::CompositeMethod::AddMask); shape->composite(std::move(mask), tvg::CompositeMethod::AddMask);
canvas->push(std::move(shape)); canvas->push(std::move(shape));
@ -158,11 +158,11 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Rect + Rect Mask Subtract //Rect + Rect Mask Subtract
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendRect(325, 500, 100, 100, 0, 0); shape2->appendRect(325, 500, 100, 100, 0, 0);
shape2->fill(255, 255, 255, 255); shape2->fill(255, 255, 255);
auto mask2 = tvg::Shape::gen(); auto mask2 = tvg::Shape::gen();
mask2->appendRect(375, 450, 100, 100, 0, 0); mask2->appendRect(375, 450, 100, 100, 0, 0);
mask2->fill(255, 255, 255, 255); mask2->fill(255, 255, 255);
shape2->composite(std::move(mask2), tvg::CompositeMethod::SubtractMask); shape2->composite(std::move(mask2), tvg::CompositeMethod::SubtractMask);
canvas->push(std::move(shape2)); canvas->push(std::move(shape2));
@ -170,11 +170,11 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Rect + Rect Mask Intersect //Rect + Rect Mask Intersect
auto shape3 = tvg::Shape::gen(); auto shape3 = tvg::Shape::gen();
shape3->appendRect(575, 500, 100, 100, 0, 0); shape3->appendRect(575, 500, 100, 100, 0, 0);
shape3->fill(255, 255, 255, 255); shape3->fill(255, 255, 255);
auto mask3 = tvg::Shape::gen(); auto mask3 = tvg::Shape::gen();
mask3->appendRect(625, 450, 100, 100, 0, 0); mask3->appendRect(625, 450, 100, 100, 0, 0);
mask3->fill(255, 255, 255, 255); mask3->fill(255, 255, 255);
shape3->composite(std::move(mask3), tvg::CompositeMethod::IntersectMask); shape3->composite(std::move(mask3), tvg::CompositeMethod::IntersectMask);
canvas->push(std::move(shape3)); canvas->push(std::move(shape3));
@ -182,11 +182,11 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Rect + Rect Mask Difference //Rect + Rect Mask Difference
auto shape4 = tvg::Shape::gen(); auto shape4 = tvg::Shape::gen();
shape4->appendRect(825, 500, 100, 100, 0, 0); shape4->appendRect(825, 500, 100, 100, 0, 0);
shape4->fill(255, 255, 255, 255); shape4->fill(255, 255, 255);
auto mask4 = tvg::Shape::gen(); auto mask4 = tvg::Shape::gen();
mask4->appendRect(875, 450, 100, 100, 0, 0); mask4->appendRect(875, 450, 100, 100, 0, 0);
mask4->fill(255, 255, 255, 255); mask4->fill(255, 255, 255);
shape4->composite(std::move(mask4), tvg::CompositeMethod::DifferenceMask); shape4->composite(std::move(mask4), tvg::CompositeMethod::DifferenceMask);
canvas->push(std::move(shape4)); canvas->push(std::move(shape4));
@ -202,7 +202,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(125, 700, 50, 50); mask->appendCircle(125, 700, 50, 50);
mask->fill(255, 255, 255, 255); mask->fill(255, 255, 255);
image->composite(std::move(mask), tvg::CompositeMethod::AddMask); image->composite(std::move(mask), tvg::CompositeMethod::AddMask);
canvas->push(std::move(image)); canvas->push(std::move(image));
@ -215,7 +215,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask2 = tvg::Shape::gen(); auto mask2 = tvg::Shape::gen();
mask2->appendCircle(375, 700, 50, 50); mask2->appendCircle(375, 700, 50, 50);
mask2->fill(255, 255, 255, 255); mask2->fill(255, 255, 255);
image2->composite(std::move(mask2), tvg::CompositeMethod::SubtractMask); image2->composite(std::move(mask2), tvg::CompositeMethod::SubtractMask);
canvas->push(std::move(image2)); canvas->push(std::move(image2));
@ -228,7 +228,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask3 = tvg::Shape::gen(); auto mask3 = tvg::Shape::gen();
mask3->appendCircle(625, 700, 50, 50); mask3->appendCircle(625, 700, 50, 50);
mask3->fill(255, 255, 255, 255); mask3->fill(255, 255, 255);
image3->composite(std::move(mask3), tvg::CompositeMethod::IntersectMask); image3->composite(std::move(mask3), tvg::CompositeMethod::IntersectMask);
canvas->push(std::move(image3)); canvas->push(std::move(image3));
@ -241,7 +241,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask4 = tvg::Shape::gen(); auto mask4 = tvg::Shape::gen();
mask4->appendCircle(875, 700, 50, 50); mask4->appendCircle(875, 700, 50, 50);
mask4->fill(255, 255, 255, 255); mask4->fill(255, 255, 255);
image4->composite(std::move(mask4), tvg::CompositeMethod::DifferenceMask); image4->composite(std::move(mask4), tvg::CompositeMethod::DifferenceMask);
canvas->push(std::move(image4)); canvas->push(std::move(image4));
} }
@ -264,7 +264,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(175, 900, 50, 50); mask->appendCircle(175, 900, 50, 50);
mask->fill(255, 255, 255, 255); mask->fill(255, 255, 255);
shape->composite(std::move(mask), tvg::CompositeMethod::AddMask); shape->composite(std::move(mask), tvg::CompositeMethod::AddMask);
canvas->push(std::move(shape)); canvas->push(std::move(shape));
@ -281,7 +281,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask2 = tvg::Shape::gen(); auto mask2 = tvg::Shape::gen();
mask2->appendCircle(400, 900, 50, 50); mask2->appendCircle(400, 900, 50, 50);
mask2->fill(255, 255, 255, 255); mask2->fill(255, 255, 255);
shape2->composite(std::move(mask2), tvg::CompositeMethod::SubtractMask); shape2->composite(std::move(mask2), tvg::CompositeMethod::SubtractMask);
@ -299,7 +299,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask3 = tvg::Shape::gen(); auto mask3 = tvg::Shape::gen();
mask3->appendCircle(650, 900, 50, 50); mask3->appendCircle(650, 900, 50, 50);
mask3->fill(255, 255, 255, 255); mask3->fill(255, 255, 255);
shape3->composite(std::move(mask3), tvg::CompositeMethod::IntersectMask); shape3->composite(std::move(mask3), tvg::CompositeMethod::IntersectMask);
canvas->push(std::move(shape3)); canvas->push(std::move(shape3));
@ -307,7 +307,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape + Shape Mask Difference //Shape + Shape Mask Difference
auto shape4 = tvg::Shape::gen(); auto shape4 = tvg::Shape::gen();
shape4->appendRect(800, 850, 100, 100, 10, 10); shape4->appendRect(800, 850, 100, 100, 10, 10);
shape4->fill(255, 255, 255, 255); shape4->fill(255, 255, 255);
//LinearGradient //LinearGradient
auto fill4 = tvg::LinearGradient::gen(); auto fill4 = tvg::LinearGradient::gen();
@ -318,7 +318,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask4 = tvg::Shape::gen(); auto mask4 = tvg::Shape::gen();
mask4->appendCircle(900, 900, 50, 50); mask4->appendCircle(900, 900, 50, 50);
mask4->fill(255, 255, 255, 255); mask4->fill(255, 255, 255);
shape4->composite(std::move(mask4), tvg::CompositeMethod::DifferenceMask); shape4->composite(std::move(mask4), tvg::CompositeMethod::DifferenceMask);
canvas->push(std::move(shape4)); canvas->push(std::move(shape4));

View file

@ -35,19 +35,19 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Prepare Round Rectangle //Prepare Round Rectangle
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50, 50); //x, y, w, h, rx, ry shape1->appendRect(0, 0, 400, 400, 50, 50); //x, y, w, h, rx, ry
shape1->fill(0, 255, 0, 255); //r, g, b, a shape1->fill(0, 255, 0); //r, g, b
if (canvas->push(std::move(shape1)) != tvg::Result::Success) return; if (canvas->push(std::move(shape1)) != tvg::Result::Success) return;
//Prepare Circle //Prepare Circle
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH
shape2->fill(255, 255, 0, 255); //r, g, b, a shape2->fill(255, 255, 0); //r, g, b
if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; if (canvas->push(std::move(shape2)) != tvg::Result::Success) return;
//Prepare Ellipse //Prepare Ellipse
auto shape3 = tvg::Shape::gen(); auto shape3 = tvg::Shape::gen();
shape3->appendCircle(600, 600, 150, 100); //cx, cy, radiusW, radiusH shape3->appendCircle(600, 600, 150, 100); //cx, cy, radiusW, radiusH
shape3->fill(0, 255, 255, 255); //r, g, b, a shape3->fill(0, 255, 255); //r, g, b
if (canvas->push(std::move(shape3)) != tvg::Result::Success) return; if (canvas->push(std::move(shape3)) != tvg::Result::Success) return;
} }

View file

@ -38,13 +38,13 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Prepare Circle //Prepare Circle
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
shape1->appendCircle(400, 400, 250, 250); shape1->appendCircle(400, 400, 250, 250);
shape1->fill(255, 255, 0, 255); shape1->fill(255, 255, 0);
scene->push(std::move(shape1)); scene->push(std::move(shape1));
//Round rectangle //Round rectangle
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendRect(450, 100, 200, 200, 50, 50); shape2->appendRect(450, 100, 200, 200, 50, 50);
shape2->fill(0, 255, 0, 255); shape2->fill(0, 255, 0);
shape2->stroke(10); shape2->stroke(10);
shape2->stroke(255, 255, 255, 255); shape2->stroke(255, 255, 255, 255);
scene->push(std::move(shape2)); scene->push(std::move(shape2));
@ -74,7 +74,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape3->lineTo(26, 161); shape3->lineTo(26, 161);
shape3->lineTo(146, 143); shape3->lineTo(146, 143);
shape3->close(); shape3->close();
shape3->fill(0, 0, 255, 255); shape3->fill(0, 0, 255);
shape3->stroke(10); shape3->stroke(10);
shape3->stroke(255, 255, 255, 255); shape3->stroke(255, 255, 255, 255);
shape3->opacity(127); shape3->opacity(127);
@ -96,7 +96,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape4->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy); shape4->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy);
shape4->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius); shape4->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius);
shape4->close(); shape4->close();
shape4->fill(255, 0, 0, 255); shape4->fill(255, 0, 0);
shape4->stroke(10); shape4->stroke(10);
shape4->stroke(0, 0, 255, 255); shape4->stroke(0, 0, 255, 255);
shape4->opacity(200); shape4->opacity(200);

View file

@ -45,7 +45,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape1->lineTo(26, 161); shape1->lineTo(26, 161);
shape1->lineTo(146, 143); shape1->lineTo(146, 143);
shape1->close(); shape1->close();
shape1->fill(0, 0, 255, 255); shape1->fill(0, 0, 255);
if (canvas->push(std::move(shape1)) != tvg::Result::Success) return; if (canvas->push(std::move(shape1)) != tvg::Result::Success) return;
@ -64,7 +64,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape2->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy); shape2->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy);
shape2->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius); shape2->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius);
shape2->close(); shape2->close();
shape2->fill(255, 0, 0, 255); shape2->fill(255, 0, 0);
if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; if (canvas->push(std::move(shape2)) != tvg::Result::Success) return;
} }

View file

@ -61,7 +61,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
shape1->appendPath(cmds, 11, pts, 10); //copy path data shape1->appendPath(cmds, 11, pts, 10); //copy path data
shape1->fill(0, 255, 0, 255); shape1->fill(0, 255, 0);
if (canvas->push(std::move(shape1)) != tvg::Result::Success) return; if (canvas->push(std::move(shape1)) != tvg::Result::Success) return;
/* Circle */ /* Circle */
@ -101,7 +101,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendPath(cmds2, 6, pts2, 13); //copy path data shape2->appendPath(cmds2, 6, pts2, 13); //copy path data
shape2->fill(255, 255, 0, 255); shape2->fill(255, 255, 0);
if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; if (canvas->push(std::move(shape2)) != tvg::Result::Success) return;
} }

View file

@ -37,7 +37,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(WIDTH/2, HEIGHT/2, WIDTH/2, HEIGHT/2); mask->appendCircle(WIDTH/2, HEIGHT/2, WIDTH/2, HEIGHT/2);
mask->fill(255, 255, 255, 255); mask->fill(255, 255, 255);
//Use the opacity for a half-translucent mask. //Use the opacity for a half-translucent mask.
mask->opacity(125); mask->opacity(125);

View file

@ -34,7 +34,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Background //Background
auto bg = tvg::Shape::gen(); auto bg = tvg::Shape::gen();
bg->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry bg->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry
bg->fill(255, 255, 255, 255); //r, g, b, a bg->fill(255, 255, 255); //r, g, b
canvas->push(std::move(bg)); canvas->push(std::move(bg));
//Load png file from path //Load png file from path

View file

@ -34,7 +34,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Background //Background
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0);
shape->fill(255, 255, 255, 255); shape->fill(255, 255, 255);
if (canvas->push(std::move(shape)) != tvg::Result::Success) return; if (canvas->push(std::move(shape)) != tvg::Result::Success) return;

View file

@ -37,19 +37,19 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Prepare Round Rectangle //Prepare Round Rectangle
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50, 50); //x, y, w, h, rx, ry shape1->appendRect(0, 0, 400, 400, 50, 50); //x, y, w, h, rx, ry
shape1->fill(0, 255, 0, 255); //r, g, b, a shape1->fill(0, 255, 0); //r, g, b
scene->push(std::move(shape1)); scene->push(std::move(shape1));
//Prepare Circle //Prepare Circle
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH
shape2->fill(255, 255, 0, 255); //r, g, b, a shape2->fill(255, 255, 0); //r, g, b
scene->push(std::move(shape2)); scene->push(std::move(shape2));
//Prepare Ellipse //Prepare Ellipse
auto shape3 = tvg::Shape::gen(); auto shape3 = tvg::Shape::gen();
shape3->appendCircle(600, 600, 150, 100); //cx, cy, radiusW, radiusH shape3->appendCircle(600, 600, 150, 100); //cx, cy, radiusW, radiusH
shape3->fill(0, 255, 255, 255); //r, g, b, a shape3->fill(0, 255, 255); //r, g, b
scene->push(std::move(shape3)); scene->push(std::move(shape3));
//Create another Scene //Create another Scene
@ -71,7 +71,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape4->lineTo(26, 161); shape4->lineTo(26, 161);
shape4->lineTo(146, 143); shape4->lineTo(146, 143);
shape4->close(); shape4->close();
shape4->fill(0, 0, 255, 255); shape4->fill(0, 0, 255);
scene2->push(std::move(shape4)); scene2->push(std::move(shape4));
//Circle //Circle
@ -88,7 +88,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape5->cubicTo(cx + radius, cy + halfRadius, cx + halfRadius, cy + radius, cx, cy+ radius); shape5->cubicTo(cx + radius, cy + halfRadius, cx + halfRadius, cy + radius, cx, cy+ radius);
shape5->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy); shape5->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy);
shape5->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius); shape5->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius);
shape5->fill(255, 0, 0, 255); shape5->fill(255, 0, 0);
scene2->push(std::move(shape5)); scene2->push(std::move(shape5));
//Push scene2 onto the scene //Push scene2 onto the scene

View file

@ -70,7 +70,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape->appendRect(100, 100, 400, 400, 50, 50); shape->appendRect(100, 100, 400, 400, 50, 50);
shape->stroke(0, 0, 255, 255); shape->stroke(0, 0, 255, 255);
shape->stroke(10); shape->stroke(10);
shape->fill(255, 255, 255, 255); shape->fill(255, 255, 255);
shape->composite(std::move(clipper), tvg::CompositeMethod::ClipPath); shape->composite(std::move(clipper), tvg::CompositeMethod::ClipPath);
if (canvas->push(std::move(shape)) != tvg::Result::Success) return; if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
} }

View file

@ -39,7 +39,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
//Prepare Round Rectangle (Scene1) //Prepare Round Rectangle (Scene1)
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
shape1->appendRect(-235, -250, 400, 400, 50, 50); //x, y, w, h, rx, ry shape1->appendRect(-235, -250, 400, 400, 50, 50); //x, y, w, h, rx, ry
shape1->fill(0, 255, 0, 255); //r, g, b, a shape1->fill(0, 255, 0); //r, g, b
shape1->stroke(5); //width shape1->stroke(5); //width
shape1->stroke(255, 255, 255, 255); //r, g, b, a shape1->stroke(255, 255, 255, 255); //r, g, b, a
scene->push(std::move(shape1)); scene->push(std::move(shape1));
@ -47,13 +47,13 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
//Prepare Circle (Scene1) //Prepare Circle (Scene1)
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendCircle(-165, -150, 200, 200); //cx, cy, radiusW, radiusH shape2->appendCircle(-165, -150, 200, 200); //cx, cy, radiusW, radiusH
shape2->fill(255, 255, 0, 255); //r, g, b, a shape2->fill(255, 255, 0); //r, g, b
scene->push(std::move(shape2)); scene->push(std::move(shape2));
//Prepare Ellipse (Scene1) //Prepare Ellipse (Scene1)
auto shape3 = tvg::Shape::gen(); auto shape3 = tvg::Shape::gen();
shape3->appendCircle(265, 250, 150, 100); //cx, cy, radiusW, radiusH shape3->appendCircle(265, 250, 150, 100); //cx, cy, radiusW, radiusH
shape3->fill(0, 255, 255, 255); //r, g, b, a shape3->fill(0, 255, 255); //r, g, b
scene->push(std::move(shape3)); scene->push(std::move(shape3));
scene->translate(350, 350); scene->translate(350, 350);

View file

@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
shape1->appendRect(100, 100, 300, 300, 100, 100); //x, y, w, h, rx, ry shape1->appendRect(100, 100, 300, 300, 100, 100); //x, y, w, h, rx, ry
shape1->appendCircle(400, 400, 100, 100); //cx, cy, radiusW, radiusH shape1->appendCircle(400, 400, 100, 100); //cx, cy, radiusW, radiusH
shape1->appendCircle(400, 500, 170, 100); //cx, cy, radiusW, radiusH shape1->appendCircle(400, 500, 170, 100); //cx, cy, radiusW, radiusH
shape1->fill(255, 255, 0, 255); //r, g, b, a shape1->fill(255, 255, 0); //r, g, b
canvas->push(std::move(shape1)); canvas->push(std::move(shape1));
} }

View file

@ -39,21 +39,21 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
paints[0] = shape1.get(); paints[0] = shape1.get();
shape1->appendRect(0, 0, 400, 400, 50, 50); //x, y, w, h, rx, ry shape1->appendRect(0, 0, 400, 400, 50, 50); //x, y, w, h, rx, ry
shape1->fill(0, 255, 0, 255); //r, g, b, a shape1->fill(0, 255, 0); //r, g, b
if (canvas->push(std::move(shape1)) != tvg::Result::Success) return; if (canvas->push(std::move(shape1)) != tvg::Result::Success) return;
//Prepare Round Rectangle2 //Prepare Round Rectangle2
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
paints[1] = shape2.get(); paints[1] = shape2.get();
shape2->appendRect(100, 100, 400, 400, 50, 50); //x, y, w, h, rx, ry shape2->appendRect(100, 100, 400, 400, 50, 50); //x, y, w, h, rx, ry
shape2->fill(255, 255, 0, 255); //r, g, b, a shape2->fill(255, 255, 0); //r, g, b
if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; if (canvas->push(std::move(shape2)) != tvg::Result::Success) return;
//Prepare Round Rectangle3 //Prepare Round Rectangle3
auto shape3 = tvg::Shape::gen(); auto shape3 = tvg::Shape::gen();
paints[2] = shape3.get(); paints[2] = shape3.get();
shape3->appendRect(200, 200, 400, 400, 50, 50); //x, y, w, h, rx, ry shape3->appendRect(200, 200, 400, 400, 50, 50); //x, y, w, h, rx, ry
shape3->fill(0, 255, 255, 255); //r, g, b, a shape3->fill(0, 255, 255); //r, g, b
if (canvas->push(std::move(shape3)) != tvg::Result::Success) return; if (canvas->push(std::move(shape3)) != tvg::Result::Success) return;
//Prepare Scene //Prepare Scene
@ -62,14 +62,14 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto shape4 = tvg::Shape::gen(); auto shape4 = tvg::Shape::gen();
shape4->appendCircle(400, 400, 100, 100); shape4->appendCircle(400, 400, 100, 100);
shape4->fill(255, 0, 0, 255); shape4->fill(255, 0, 0);
shape4->stroke(5); shape4->stroke(5);
shape4->stroke(255, 255, 255, 255); shape4->stroke(255, 255, 255, 255);
scene->push(std::move(shape4)); scene->push(std::move(shape4));
auto shape5 = tvg::Shape::gen(); auto shape5 = tvg::Shape::gen();
shape5->appendCircle(550, 550, 150, 150); shape5->appendCircle(550, 550, 150, 150);
shape5->fill(255, 0, 255, 255); shape5->fill(255, 0, 255);
shape5->stroke(5); shape5->stroke(5);
shape5->stroke(255, 255, 255, 255); shape5->stroke(255, 255, 255, 255);
scene->push(std::move(shape5)); scene->push(std::move(shape5));

View file

@ -91,7 +91,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Background //Background
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry
shape->fill(255, 255, 255, 255); //r, g, b, a shape->fill(255, 255, 255); //r, g, b
if (canvas->push(std::move(shape)) != tvg::Result::Success) return; if (canvas->push(std::move(shape)) != tvg::Result::Success) return;

View file

@ -33,7 +33,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape 1 //Shape 1
auto shape1 = tvg::Shape::gen(); auto shape1 = tvg::Shape::gen();
shape1->appendRect(50, 50, 200, 200, 0, 0); shape1->appendRect(50, 50, 200, 200, 0, 0);
shape1->fill(50, 50, 50, 255); shape1->fill(50, 50, 50);
shape1->stroke(255, 255, 255, 255); //color: r, g, b, a shape1->stroke(255, 255, 255, 255); //color: r, g, b, a
shape1->stroke(tvg::StrokeJoin::Bevel); //default is Bevel shape1->stroke(tvg::StrokeJoin::Bevel); //default is Bevel
shape1->stroke(10); //width: 10px shape1->stroke(10); //width: 10px
@ -43,7 +43,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape 2 //Shape 2
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendRect(300, 50, 200, 200, 0, 0); shape2->appendRect(300, 50, 200, 200, 0, 0);
shape2->fill(50, 50, 50, 255); shape2->fill(50, 50, 50);
shape2->stroke(255, 255, 255, 255); shape2->stroke(255, 255, 255, 255);
shape2->stroke(tvg::StrokeJoin::Round); shape2->stroke(tvg::StrokeJoin::Round);
shape2->stroke(10); shape2->stroke(10);
@ -53,7 +53,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape 3 //Shape 3
auto shape3 = tvg::Shape::gen(); auto shape3 = tvg::Shape::gen();
shape3->appendRect(550, 50, 200, 200, 0, 0); shape3->appendRect(550, 50, 200, 200, 0, 0);
shape3->fill(50, 50, 50, 255); shape3->fill(50, 50, 50);
shape3->stroke(255, 255, 255, 255); shape3->stroke(255, 255, 255, 255);
shape3->stroke(tvg::StrokeJoin::Miter); shape3->stroke(tvg::StrokeJoin::Miter);
shape3->stroke(10); shape3->stroke(10);
@ -63,7 +63,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape 4 //Shape 4
auto shape4 = tvg::Shape::gen(); auto shape4 = tvg::Shape::gen();
shape4->appendCircle(150, 400, 100, 100); shape4->appendCircle(150, 400, 100, 100);
shape4->fill(50, 50, 50, 255); shape4->fill(50, 50, 50);
shape4->stroke(255, 255, 255, 255); shape4->stroke(255, 255, 255, 255);
shape4->stroke(1); shape4->stroke(1);
@ -72,7 +72,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape 5 //Shape 5
auto shape5 = tvg::Shape::gen(); auto shape5 = tvg::Shape::gen();
shape5->appendCircle(400, 400, 100, 100); shape5->appendCircle(400, 400, 100, 100);
shape5->fill(50, 50, 50, 255); shape5->fill(50, 50, 50);
shape5->stroke(255, 255, 255, 255); shape5->stroke(255, 255, 255, 255);
shape5->stroke(2); shape5->stroke(2);
@ -81,7 +81,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape 6 //Shape 6
auto shape6 = tvg::Shape::gen(); auto shape6 = tvg::Shape::gen();
shape6->appendCircle(650, 400, 100, 100); shape6->appendCircle(650, 400, 100, 100);
shape6->fill(50, 50, 50, 255); shape6->fill(50, 50, 50);
shape6->stroke(255, 255, 255, 255); shape6->stroke(255, 255, 255, 255);
shape6->stroke(4); shape6->stroke(4);

View file

@ -79,7 +79,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Background //Background
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry
shape->fill(255, 255, 255, 255); //r, g, b, a shape->fill(255, 255, 255); //r, g, b
if (canvas->push(std::move(shape)) != tvg::Result::Success) return; if (canvas->push(std::move(shape)) != tvg::Result::Success) return;

View file

@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Background //Background
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry
shape->fill(255, 255, 255, 255); //r, g, b, a shape->fill(255, 255, 255); //r, g, b
if (canvas->push(std::move(shape)) != tvg::Result::Success) return; if (canvas->push(std::move(shape)) != tvg::Result::Success) return;

View file

@ -34,7 +34,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Background //Background
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0);
shape->fill(255, 255, 255, 255); shape->fill(255, 255, 255);
if (canvas->push(std::move(shape)) != tvg::Result::Success) return; if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
@ -78,7 +78,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(700, 700, 200, 200); mask->appendCircle(700, 700, 200, 200);
mask->fill(255, 255, 255, 255); mask->fill(255, 255, 255);
picture2->composite(std::move(mask), tvg::CompositeMethod::AlphaMask); picture2->composite(std::move(mask), tvg::CompositeMethod::AlphaMask);

View file

@ -38,7 +38,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
shape->appendRect(-185, -200, 300, 300, 100, 100); shape->appendRect(-185, -200, 300, 300, 100, 100);
shape->appendCircle(115, 100, 100, 100); shape->appendCircle(115, 100, 100, 100);
shape->appendCircle(115, 200, 170, 100); shape->appendCircle(115, 200, 170, 100);
shape->fill(255, 255, 255, 255); shape->fill(255, 255, 255);
shape->translate(385, 400); shape->translate(385, 400);
shape->scale(1 - 0.75 * progress); shape->scale(1 - 0.75 * progress);
shape->rotate(360 * progress); shape->rotate(360 * progress);
@ -48,7 +48,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
//Shape2 //Shape2
auto shape2 = tvg::Shape::gen(); auto shape2 = tvg::Shape::gen();
shape2->appendRect(-50, -50, 100, 100, 0, 0); shape2->appendRect(-50, -50, 100, 100, 0, 0);
shape2->fill(0, 255, 255, 255); shape2->fill(0, 255, 255);
shape2->translate(400, 400); shape2->translate(400, 400);
shape2->rotate(360 * progress); shape2->rotate(360 * progress);
shape2->translate(400 + progress * 300, 400); shape2->translate(400 + progress * 300, 400);
@ -60,7 +60,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
/* Look, how shape3's origin is different with shape2 /* Look, how shape3's origin is different with shape2
The center of the shape is the anchor point for transformation. */ The center of the shape is the anchor point for transformation. */
shape3->appendRect(100, 100, 150, 50, 20, 20); shape3->appendRect(100, 100, 150, 50, 20, 20);
shape3->fill(255, 0, 255, 255); shape3->fill(255, 0, 255);
shape3->translate(400, 400); shape3->translate(400, 400);
shape3->rotate(-360 * progress); shape3->rotate(-360 * progress);
shape3->scale(0.5 + progress); shape3->scale(0.5 + progress);

View file

@ -65,7 +65,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Background //Background
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry
shape->fill(255, 255, 255, 255); //r, g, b, a shape->fill(255, 255, 255); //r, g, b
if (canvas->push(std::move(shape)) != tvg::Result::Success) return; if (canvas->push(std::move(shape)) != tvg::Result::Success) return;

View file

@ -85,7 +85,6 @@ unique_ptr<tvg::Paint> tvgClippedImage(uint32_t * data, int width, int heigth)
auto imageClip = tvg::Shape::gen(); auto imageClip = tvg::Shape::gen();
imageClip->appendCircle(400, 200, 80, 180); imageClip->appendCircle(400, 200, 80, 180);
imageClip->fill(0, 0, 0, 155);
imageClip->translate(200, 0); imageClip->translate(200, 0);
image->composite(std::move(imageClip), tvg::CompositeMethod::ClipPath); image->composite(std::move(imageClip), tvg::CompositeMethod::ClipPath);
@ -102,7 +101,7 @@ unique_ptr<tvg::Paint> tvgMaskedSvg()
auto svgMask = tvg::Shape::gen(); auto svgMask = tvg::Shape::gen();
tvgDrawStar(svgMask.get()); tvgDrawStar(svgMask.get());
svgMask->fill(0, 0, 0, 255); svgMask->fill(0, 0, 0);
svgMask->translate(30, 440); svgMask->translate(30, 440);
svgMask->opacity(200); svgMask->opacity(200);
svgMask->scale(0.7); svgMask->scale(0.7);
@ -169,10 +168,6 @@ unique_ptr<tvg::Paint> tvgCircle1(tvg::Fill::ColorStop* colorStops, int colorSto
{ {
auto circ = tvg::Shape::gen(); auto circ = tvg::Shape::gen();
circ->appendCircle(400, 375, 50, 50); circ->appendCircle(400, 375, 50, 50);
auto fill = tvg::RadialGradient::gen();
fill->radial(400, 375, 50);
fill->colorStops(colorStops, colorStopsCnt);
circ->fill(std::move(fill));
circ->fill(0, 255, 0, 155); circ->fill(0, 255, 0, 155);
return circ; return circ;
@ -182,7 +177,6 @@ unique_ptr<tvg::Paint> tvgCircle2(tvg::Fill::ColorStop* colorStops, int colorSto
{ {
auto circ = tvg::Shape::gen(); auto circ = tvg::Shape::gen();
circ->appendCircle(400, 425, 50, 50); circ->appendCircle(400, 425, 50, 50);
circ->fill(0, 255, 0, 155);
auto fill = tvg::RadialGradient::gen(); auto fill = tvg::RadialGradient::gen();
fill->radial(400, 425, 50); fill->radial(400, 425, 50);
fill->colorStops(colorStops, colorStopsCnt); fill->colorStops(colorStops, colorStopsCnt);
@ -252,7 +246,7 @@ void exportTvg()
//inv mask applied to the main scene //inv mask applied to the main scene
auto mask = tvg::Shape::gen(); auto mask = tvg::Shape::gen();
mask->appendCircle(400, 400, 15, 15); mask->appendCircle(400, 400, 15, 15);
mask->fill(0, 0, 0, 255); mask->fill(0, 0, 0);
scene->composite(std::move(mask), tvg::CompositeMethod::InvAlphaMask); scene->composite(std::move(mask), tvg::CompositeMethod::InvAlphaMask);
//save the tvg file //save the tvg file

View file

@ -33,7 +33,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Shape //Shape
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(-100, -100, 200, 200, 0, 0); shape->appendRect(-100, -100, 200, 200, 0, 0);
shape->fill(255, 255, 255, 255); shape->fill(255, 255, 255);
canvas->push(std::move(shape)); canvas->push(std::move(shape));
} }
@ -47,7 +47,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
//Shape //Shape
auto shape = tvg::Shape::gen(); auto shape = tvg::Shape::gen();
shape->appendRect(-100, -100, 200, 200, (100 * progress), (100 * progress)); shape->appendRect(-100, -100, 200, 200, (100 * progress), (100 * progress));
shape->fill(rand()%255, rand()%255, rand()%255, 255); shape->fill(rand()%255, rand()%255, rand()%255);
shape->translate(800 * progress, 800 * progress); shape->translate(800 * progress, 800 * progress);
shape->scale(1 - 0.75 * progress); shape->scale(1 - 0.75 * progress);
shape->rotate(360 * progress); shape->rotate(360 * progress);

View file

@ -242,7 +242,6 @@ Result Shape::appendRect(float x, float y, float w, float h, float rx, float ry)
} }
//TODO: kill alpha at TVG 1.0, because we also have opacity
Result Shape::fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept Result Shape::fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept
{ {
pImpl->rs.color[0] = r; pImpl->rs.color[0] = r;

View file

@ -739,7 +739,7 @@ static unique_ptr<Scene> _sceneBuildHelper(const SvgNode* node, const Box& vBox,
if (shape) { if (shape) {
if (isMaskWhite) { if (isMaskWhite) {
uint8_t r, g, b; uint8_t r, g, b;
shape->fillColor(&r, &g, &b, nullptr); shape->fillColor(&r, &g, &b);
if (shape->fill() || r < 255 || g < 255 || b < 255 || shape->strokeFill() || if (shape->fill() || r < 255 || g < 255 || b < 255 || shape->strokeFill() ||
(shape->strokeColor(&r, &g, &b, nullptr) == Result::Success && (r < 255 || g < 255 || b < 255))) { (shape->strokeColor(&r, &g, &b, nullptr) == Result::Success && (r < 255 || g < 255 || b < 255))) {
*isMaskWhite = false; *isMaskWhite = false;
@ -801,7 +801,7 @@ unique_ptr<Scene> svgSceneBuild(SvgLoaderData& loaderData, Box vBox, float w, fl
auto viewBoxClip = Shape::gen(); auto viewBoxClip = Shape::gen();
viewBoxClip->appendRect(0, 0, w, h, 0, 0); viewBoxClip->appendRect(0, 0, w, h, 0, 0);
viewBoxClip->fill(0, 0, 0, 255); viewBoxClip->fill(0, 0, 0);
auto compositeLayer = Scene::gen(); auto compositeLayer = Scene::gen();
compositeLayer->composite(std::move(viewBoxClip), CompositeMethod::ClipPath); compositeLayer->composite(std::move(viewBoxClip), CompositeMethod::ClipPath);

View file

@ -63,10 +63,10 @@ TEST_CASE("Set", "[tvgAccessor]")
{ {
if (paint->identifier() == tvg::Shape::identifier()) { if (paint->identifier() == tvg::Shape::identifier()) {
auto shape = (tvg::Shape*) paint; auto shape = (tvg::Shape*) paint;
uint8_t r, g, b, a; uint8_t r, g, b;
shape->fillColor(&r, &g, &b, &a); shape->fillColor(&r, &g, &b);
if (r == 37 && g == 47 && b == 53) if (r == 37 && g == 47 && b == 53)
shape->fill(0, 0, 255, a); shape->fill(0, 0, 255);
} }
return true; return true;
}; };