From 1ae92daa9d879d36d0a3800d155e855c21b103e3 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 6 Jun 2023 12:03:11 +0900 Subject: [PATCH] api: enhance Shape::fill() method usage. Designate a default value for alpha which is mostly optional. --- inc/thorvg.h | 5 ++- src/bin/svg2png/svg2png.cpp | 2 +- src/examples/Accessor.cpp | 7 ++-- src/examples/AnimateMasking.cpp | 6 +-- src/examples/Arc.cpp | 6 +-- src/examples/Blending.cpp | 8 ++-- src/examples/ClipPath.cpp | 6 +-- src/examples/CustomTransform.cpp | 2 +- src/examples/DirectUpdate.cpp | 6 +-- src/examples/Duplicate.cpp | 8 ++-- src/examples/FillRule.cpp | 4 +- src/examples/GradientMasking.cpp | 8 ++-- src/examples/InvLumaMasking.cpp | 16 +++---- src/examples/InvMasking.cpp | 15 +++---- src/examples/LumaMasking.cpp | 16 +++---- src/examples/Masking.cpp | 14 +++---- src/examples/MaskingMethods.cpp | 58 +++++++++++++------------- src/examples/MultiShapes.cpp | 6 +-- src/examples/Opacity.cpp | 8 ++-- src/examples/Path.cpp | 4 +- src/examples/PathCopy.cpp | 4 +- src/examples/Performance.cpp | 2 +- src/examples/PicturePng.cpp | 2 +- src/examples/PictureRaw.cpp | 2 +- src/examples/Scene.cpp | 10 ++--- src/examples/SceneClipper.cpp | 2 +- src/examples/SceneTransform.cpp | 6 +-- src/examples/Shape.cpp | 2 +- src/examples/Stacking.cpp | 10 ++--- src/examples/Stress.cpp | 2 +- src/examples/Stroke.cpp | 12 +++--- src/examples/Svg.cpp | 2 +- src/examples/Svg2.cpp | 2 +- src/examples/Texmap.cpp | 4 +- src/examples/Transform.cpp | 6 +-- src/examples/Tvg.cpp | 2 +- src/examples/TvgSaver.cpp | 10 +---- src/examples/Update.cpp | 4 +- src/lib/tvgShape.cpp | 1 - src/loaders/svg/tvgSvgSceneBuilder.cpp | 4 +- test/testAccessor.cpp | 6 +-- 41 files changed, 148 insertions(+), 152 deletions(-) diff --git a/inc/thorvg.h b/inc/thorvg.h index 56101a4b..a5364819 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -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. * @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; @@ -990,7 +991,7 @@ public: * @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) */ - 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. @@ -1062,7 +1063,7 @@ public: * * @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. diff --git a/src/bin/svg2png/svg2png.cpp b/src/bin/svg2png/svg2png.cpp index 5c1d327a..9b59be0e 100644 --- a/src/bin/svg2png/svg2png.cpp +++ b/src/bin/svg2png/svg2png.cpp @@ -138,7 +138,7 @@ public: auto shape = tvg::Shape::gen(); shape->appendRect(0, 0, static_cast(w), static_cast(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; } diff --git a/src/examples/Accessor.cpp b/src/examples/Accessor.cpp index ab39aa69..353c96a7 100644 --- a/src/examples/Accessor.cpp +++ b/src/examples/Accessor.cpp @@ -45,10 +45,11 @@ void tvgDrawCmds(tvg::Canvas* canvas) if (paint->identifier() == tvg::Shape::identifier()) { auto shape = (tvg::Shape*) paint; //override color? - uint8_t r, g, b, a; - shape->fillColor(&r, &g, &b, &a); + uint8_t r, g, b; + shape->fillColor(&r, &g, &b); 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. diff --git a/src/examples/AnimateMasking.cpp b/src/examples/AnimateMasking.cpp index 52d70858..149b4585 100644 --- a/src/examples/AnimateMasking.cpp +++ b/src/examples/AnimateMasking.cpp @@ -37,7 +37,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) // background auto bg = tvg::Shape::gen(); bg->appendRect(0,0,WIDTH, HEIGHT,0, 0); - bg->fill(255, 255, 255, 255); + bg->fill(255, 255, 255); canvas->push(std::move(bg)); // image @@ -54,7 +54,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto maskShape = tvg::Shape::gen(); pMaskShape = maskShape.get(); 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(tvg::StrokeJoin::Round); maskShape->stroke(10); @@ -63,7 +63,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask = tvg::Shape::gen(); pMask = mask.get(); 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); if (canvas->push(std::move(picture2)) != tvg::Result::Success) return; diff --git a/src/examples/Arc.cpp b/src/examples/Arc.cpp index aafa0b73..307328de 100644 --- a/src/examples/Arc.cpp +++ b/src/examples/Arc.cpp @@ -71,21 +71,21 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Pie Fill auto shape7 = tvg::Shape::gen(); 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(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, 255); + shape8->fill(255, 255, 255); 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, 255); + shape9->fill(255, 255, 255); shape9->stroke(255, 0, 0, 255); shape9->stroke(2); if (canvas->push(std::move(shape9)) != tvg::Result::Success) return; diff --git a/src/examples/Blending.cpp b/src/examples/Blending.cpp index f94da15f..ef92552f 100644 --- a/src/examples/Blending.cpp +++ b/src/examples/Blending.cpp @@ -35,19 +35,19 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Prepare Round Rectangle auto shape1 = tvg::Shape::gen(); 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; //Prepare Circle auto shape2 = tvg::Shape::gen(); 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; //Prepare Ellipse auto shape3 = tvg::Shape::gen(); 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; //Prepare Star @@ -69,7 +69,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Prepare Opaque Ellipse auto shape5 = tvg::Shape::gen(); 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; } diff --git a/src/examples/ClipPath.cpp b/src/examples/ClipPath.cpp index 8b6a5a3b..dcb42efb 100644 --- a/src/examples/ClipPath.cpp +++ b/src/examples/ClipPath.cpp @@ -47,7 +47,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Background auto shape = tvg::Shape::gen(); 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; ////////////////////////////////////////////// @@ -56,7 +56,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto star1 = tvg::Shape::gen(); tvgDrawStar(star1.get()); - star1->fill(255, 255, 0, 255); + star1->fill(255, 255, 0); star1->stroke(255 ,0, 0, 255); star1->stroke(10); @@ -72,7 +72,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto star2 = tvg::Shape::gen(); tvgDrawStar(star2.get()); - star2->fill(0, 255, 255, 255); + star2->fill(0, 255, 255); star2->stroke(0 ,255, 0, 255); star2->stroke(10); star2->opacity(100); diff --git a/src/examples/CustomTransform.cpp b/src/examples/CustomTransform.cpp index 73fedf6d..d0f1a730 100644 --- a/src/examples/CustomTransform.cpp +++ b/src/examples/CustomTransform.cpp @@ -46,7 +46,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) shape->lineTo(-173, 12.5); shape->lineTo(-53, -5.5); shape->close(); - shape->fill(0, 0, 255, 255); + shape->fill(0, 0, 255); shape->stroke(3); shape->stroke(255, 255, 255, 255); diff --git a/src/examples/DirectUpdate.cpp b/src/examples/DirectUpdate.cpp index 8d22ca7b..64e00a5d 100644 --- a/src/examples/DirectUpdate.cpp +++ b/src/examples/DirectUpdate.cpp @@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) bg->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //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; @@ -50,7 +50,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape->appendRect(-100, -100, 200, 200, 0, 0); //fill property will be retained - shape->fill(127, 255, 255, 255); + shape->fill(127, 255, 255); shape->stroke(0, 0, 255, 255); shape->stroke(1); @@ -67,7 +67,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) //Reset Shape 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, 255); + pShape->fill(127, 255, 255); pShape->stroke(0, 0, 255, 255); pShape->stroke(30 * progress); diff --git a/src/examples/Duplicate.cpp b/src/examples/Duplicate.cpp index 19b77da6..be9e9676 100644 --- a/src/examples/Duplicate.cpp +++ b/src/examples/Duplicate.cpp @@ -43,7 +43,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) float dashPattern[2] = {4, 4}; shape1->stroke(dashPattern, 2); - shape1->fill(255, 0, 0, 255); + shape1->fill(255, 0, 0); //Duplicate Shape, Switch fill method auto shape2 = tvg::cast(shape1->duplicate()); @@ -76,17 +76,17 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape1 = tvg::Shape::gen(); shape1->appendRect(0, 0, 400, 400, 50, 50); - shape1->fill(0, 255, 0, 255); + shape1->fill(0, 255, 0); scene1->push(std::move(shape1)); auto shape2 = tvg::Shape::gen(); shape2->appendCircle(400, 400, 200, 200); - shape2->fill(255, 255, 0, 255); + shape2->fill(255, 255, 0); scene1->push(std::move(shape2)); auto shape3 = tvg::Shape::gen(); shape3->appendCircle(600, 600, 150, 100); - shape3->fill(0, 255, 255, 255); + shape3->fill(0, 255, 255); scene1->push(std::move(shape3)); scene1->scale(0.25); diff --git a/src/examples/FillRule.cpp b/src/examples/FillRule.cpp index 913eff6b..5f456754 100644 --- a/src/examples/FillRule.cpp +++ b/src/examples/FillRule.cpp @@ -38,7 +38,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape1->lineTo(385, 150); shape1->lineTo(80, 355); shape1->close(); - shape1->fill(255, 255, 255, 255); + shape1->fill(255, 255, 255); shape1->fill(tvg::FillRule::Winding); //Fill all winding shapes 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(410, 655); shape2->close(); - shape2->fill(255, 255, 255, 255); + shape2->fill(255, 255, 255); shape2->fill(tvg::FillRule::EvenOdd); //Fill polygons with even odd pattern if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; diff --git a/src/examples/GradientMasking.cpp b/src/examples/GradientMasking.cpp index 2472976f..16f7daa0 100644 --- a/src/examples/GradientMasking.cpp +++ b/src/examples/GradientMasking.cpp @@ -38,7 +38,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Mask auto mask = tvg::Shape::gen(); mask->appendCircle(200, 200, 125, 125); - mask->fill(255, 0, 0, 255); + mask->fill(255, 0, 0); auto fill = tvg::LinearGradient::gen(); fill->linear(0, 0, 400, 400); @@ -70,7 +70,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Mask auto mask1 = tvg::Shape::gen(); mask1->appendCircle(600, 200, 125, 125); - mask1->fill(255, 0, 0, 255); + mask1->fill(255, 0, 0); auto fill1 = tvg::LinearGradient::gen(); fill1->linear(400, 0, 800, 400); @@ -92,7 +92,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Mask auto mask2 = tvg::Shape::gen(); mask2->appendCircle(200, 600, 125, 125); - mask2->fill(255, 0, 0, 255); + mask2->fill(255, 0, 0); auto fill2 = tvg::LinearGradient::gen(); fill2->linear(0, 400, 400, 800); @@ -124,7 +124,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Mask auto mask3 = tvg::Shape::gen(); mask3->appendCircle(600, 600, 125, 125); - mask3->fill(255, 0, 0, 255); + mask3->fill(255, 0, 0); auto fill3 = tvg::LinearGradient::gen(); fill3->linear(400, 400, 800, 800); diff --git a/src/examples/InvLumaMasking.cpp b/src/examples/InvLumaMasking.cpp index 766326c0..a48731d5 100644 --- a/src/examples/InvLumaMasking.cpp +++ b/src/examples/InvLumaMasking.cpp @@ -34,17 +34,17 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Solid Rectangle auto shape = tvg::Shape::gen(); shape->appendRect(0, 0, 400, 400, 0, 0); - shape->fill(255, 0, 0, 255); + shape->fill(255, 0, 0); //Mask auto mask = tvg::Shape::gen(); mask->appendCircle(200, 200, 125, 125); - mask->fill(255, 100, 255, 255); + mask->fill(255, 100, 255); //Nested Mask auto nMask = tvg::Shape::gen(); 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); shape->composite(std::move(mask), tvg::CompositeMethod::InvLumaMask); @@ -61,13 +61,13 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask2 = tvg::Shape::gen(); mask2->appendCircle(150, 500, 75, 75); 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); if (canvas->push(std::move(svg)) != tvg::Result::Success) return; //Star auto star = tvg::Shape::gen(); - star->fill(80, 80, 80, 255); + star->fill(80, 80, 80); star->moveTo(599, 34); star->lineTo(653, 143); star->lineTo(774, 160); @@ -85,7 +85,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Mask3 auto mask3 = tvg::Shape::gen(); 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); 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_rect = tvg::Shape::gen(); 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(); 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_circle)) != tvg::Result::Success) return; image->composite(std::move(mask4), tvg::CompositeMethod::InvLumaMask); diff --git a/src/examples/InvMasking.cpp b/src/examples/InvMasking.cpp index 02d2b61c..c5f7e5e4 100644 --- a/src/examples/InvMasking.cpp +++ b/src/examples/InvMasking.cpp @@ -34,17 +34,17 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Solid Rectangle auto shape = tvg::Shape::gen(); shape->appendRect(0, 0, 400, 400, 0, 0); - shape->fill(0, 0, 255, 255); + shape->fill(0, 0, 255); //Mask auto mask = tvg::Shape::gen(); 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 auto nMask = tvg::Shape::gen(); 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); shape->composite(std::move(mask), tvg::CompositeMethod::InvAlphaMask); @@ -61,13 +61,13 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask2 = tvg::Shape::gen(); mask2->appendCircle(150, 500, 75, 75); 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); if (canvas->push(std::move(svg)) != tvg::Result::Success) return; //Star auto star = tvg::Shape::gen(); - star->fill(80, 80, 80, 255); + star->fill(80, 80, 80); star->moveTo(599, 34); star->lineTo(653, 143); star->lineTo(774, 160); @@ -85,7 +85,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Mask3 auto mask3 = tvg::Shape::gen(); 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); 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(546, 493); 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); if (canvas->push(std::move(image)) != tvg::Result::Success) return; } diff --git a/src/examples/LumaMasking.cpp b/src/examples/LumaMasking.cpp index 3c84a9d2..2311e1dc 100644 --- a/src/examples/LumaMasking.cpp +++ b/src/examples/LumaMasking.cpp @@ -34,17 +34,17 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Solid Rectangle auto shape = tvg::Shape::gen(); shape->appendRect(0, 0, 400, 400, 0, 0); - shape->fill(255, 0, 0, 255); + shape->fill(255, 0, 0); //Mask auto mask = tvg::Shape::gen(); mask->appendCircle(200, 200, 125, 125); - mask->fill(255, 100, 255, 255); + mask->fill(255, 100, 255); //Nested Mask auto nMask = tvg::Shape::gen(); 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); shape->composite(std::move(mask), tvg::CompositeMethod::LumaMask); @@ -61,13 +61,13 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask2 = tvg::Shape::gen(); mask2->appendCircle(150, 500, 75, 75); 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); if (canvas->push(std::move(svg)) != tvg::Result::Success) return; //Star auto star = tvg::Shape::gen(); - star->fill(80, 80, 80, 255); + star->fill(80, 80, 80); star->moveTo(599, 34); star->lineTo(653, 143); star->lineTo(774, 160); @@ -85,7 +85,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Mask3 auto mask3 = tvg::Shape::gen(); 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); 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_rect = tvg::Shape::gen(); 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(); 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_circle)) != tvg::Result::Success) return; image->composite(std::move(mask4), tvg::CompositeMethod::LumaMask); diff --git a/src/examples/Masking.cpp b/src/examples/Masking.cpp index 62312726..40e40c51 100644 --- a/src/examples/Masking.cpp +++ b/src/examples/Masking.cpp @@ -34,17 +34,17 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Solid Rectangle auto shape = tvg::Shape::gen(); shape->appendRect(0, 0, 400, 400, 0, 0); - shape->fill(0, 0, 255, 255); + shape->fill(0, 0, 255); //Mask auto mask = tvg::Shape::gen(); 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 auto nMask = tvg::Shape::gen(); 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); shape->composite(std::move(mask), tvg::CompositeMethod::AlphaMask); @@ -61,13 +61,13 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask2 = tvg::Shape::gen(); mask2->appendCircle(150, 500, 75, 75); 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); if (canvas->push(std::move(svg)) != tvg::Result::Success) return; //Star auto star = tvg::Shape::gen(); - star->fill(80, 80, 80, 255); + star->fill(80, 80, 80); star->moveTo(599, 34); star->lineTo(653, 143); star->lineTo(774, 160); @@ -86,7 +86,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Mask3 auto mask3 = tvg::Shape::gen(); 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); star->composite(std::move(mask3), tvg::CompositeMethod::AlphaMask); 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(546, 493); 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); image->composite(std::move(mask4), tvg::CompositeMethod::AlphaMask); if (canvas->push(std::move(image)) != tvg::Result::Success) return; diff --git a/src/examples/MaskingMethods.cpp b/src/examples/MaskingMethods.cpp index e0a6359a..7b4c4a91 100644 --- a/src/examples/MaskingMethods.cpp +++ b/src/examples/MaskingMethods.cpp @@ -42,11 +42,11 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape + Shape Mask Add auto shape = tvg::Shape::gen(); shape->appendCircle(125, 100, 50, 50); - shape->fill(255, 255, 255, 255); + shape->fill(255, 255, 255); auto mask = tvg::Shape::gen(); 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); canvas->push(std::move(shape)); @@ -54,11 +54,11 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape + Shape Mask Subtract auto shape2 = tvg::Shape::gen(); shape2->appendCircle(375, 100, 50, 50); - shape2->fill(255, 255, 255, 255); + shape2->fill(255, 255, 255); auto mask2 = tvg::Shape::gen(); 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); @@ -67,11 +67,11 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape + Shape Mask Intersect auto shape3 = tvg::Shape::gen(); shape3->appendCircle(625, 100, 50, 50); - shape3->fill(255, 255, 255, 255); + shape3->fill(255, 255, 255); auto mask3 = tvg::Shape::gen(); 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); canvas->push(std::move(shape3)); @@ -79,11 +79,11 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape + Shape Mask Difference auto shape4 = tvg::Shape::gen(); shape4->appendCircle(875, 100, 50, 50); - shape4->fill(255, 255, 255, 255); + shape4->fill(255, 255, 255); auto mask4 = tvg::Shape::gen(); 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); canvas->push(std::move(shape4)); @@ -93,7 +93,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape + Image Mask Add auto shape = tvg::Shape::gen(); shape->appendCircle(150, 250, 50, 50); - shape->fill(255, 255, 255, 255); + shape->fill(255, 255, 255); auto mask = tvg::Picture::gen(); if (mask->load(data, 200, 300, true) != tvg::Result::Success) return; @@ -105,7 +105,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape + Image Mask Subtract auto shape2 = tvg::Shape::gen(); shape2->appendCircle(400, 250, 50, 50); - shape2->fill(255, 255, 255, 255); + shape2->fill(255, 255, 255); auto mask2 = tvg::Picture::gen(); if (mask2->load(data, 200, 300, true) != tvg::Result::Success) return; @@ -118,7 +118,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape + Image Mask Intersect auto shape3 = tvg::Shape::gen(); shape3->appendCircle(650, 250, 50, 50); - shape3->fill(255, 255, 255, 255); + shape3->fill(255, 255, 255); auto mask3 = tvg::Picture::gen(); if (mask3->load(data, 200, 300, true) != tvg::Result::Success) return; @@ -131,7 +131,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape + Image Mask Difference auto shape4 = tvg::Shape::gen(); shape4->appendCircle(900, 250, 50, 50); - shape4->fill(255, 255, 255, 255); + shape4->fill(255, 255, 255); auto mask4 = tvg::Picture::gen(); if (mask4->load(data, 200, 300, true) != tvg::Result::Success) return; @@ -146,11 +146,11 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Rect + Rect Mask Add auto shape = tvg::Shape::gen(); shape->appendRect(75, 500, 100, 100, 0, 0); - shape->fill(255, 255, 255, 255); + shape->fill(255, 255, 255); auto mask = tvg::Shape::gen(); 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); canvas->push(std::move(shape)); @@ -158,11 +158,11 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Rect + Rect Mask Subtract auto shape2 = tvg::Shape::gen(); shape2->appendRect(325, 500, 100, 100, 0, 0); - shape2->fill(255, 255, 255, 255); + shape2->fill(255, 255, 255); auto mask2 = tvg::Shape::gen(); 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); canvas->push(std::move(shape2)); @@ -170,11 +170,11 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Rect + Rect Mask Intersect auto shape3 = tvg::Shape::gen(); shape3->appendRect(575, 500, 100, 100, 0, 0); - shape3->fill(255, 255, 255, 255); + shape3->fill(255, 255, 255); auto mask3 = tvg::Shape::gen(); 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); canvas->push(std::move(shape3)); @@ -182,11 +182,11 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Rect + Rect Mask Difference auto shape4 = tvg::Shape::gen(); shape4->appendRect(825, 500, 100, 100, 0, 0); - shape4->fill(255, 255, 255, 255); + shape4->fill(255, 255, 255); auto mask4 = tvg::Shape::gen(); 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); canvas->push(std::move(shape4)); @@ -202,7 +202,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask = tvg::Shape::gen(); 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); canvas->push(std::move(image)); @@ -215,7 +215,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask2 = tvg::Shape::gen(); 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); canvas->push(std::move(image2)); @@ -228,7 +228,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask3 = tvg::Shape::gen(); 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); canvas->push(std::move(image3)); @@ -241,7 +241,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask4 = tvg::Shape::gen(); 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); canvas->push(std::move(image4)); } @@ -264,7 +264,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask = tvg::Shape::gen(); 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); canvas->push(std::move(shape)); @@ -281,7 +281,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask2 = tvg::Shape::gen(); 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); @@ -299,7 +299,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask3 = tvg::Shape::gen(); 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); canvas->push(std::move(shape3)); @@ -307,7 +307,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape + Shape Mask Difference auto shape4 = tvg::Shape::gen(); shape4->appendRect(800, 850, 100, 100, 10, 10); - shape4->fill(255, 255, 255, 255); + shape4->fill(255, 255, 255); //LinearGradient auto fill4 = tvg::LinearGradient::gen(); @@ -318,7 +318,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask4 = tvg::Shape::gen(); 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); canvas->push(std::move(shape4)); diff --git a/src/examples/MultiShapes.cpp b/src/examples/MultiShapes.cpp index 77ba2f49..342020e5 100644 --- a/src/examples/MultiShapes.cpp +++ b/src/examples/MultiShapes.cpp @@ -35,19 +35,19 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Prepare Round Rectangle auto shape1 = tvg::Shape::gen(); 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; //Prepare Circle auto shape2 = tvg::Shape::gen(); 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; //Prepare Ellipse auto shape3 = tvg::Shape::gen(); 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; } diff --git a/src/examples/Opacity.cpp b/src/examples/Opacity.cpp index a63894fe..025bf62f 100644 --- a/src/examples/Opacity.cpp +++ b/src/examples/Opacity.cpp @@ -38,13 +38,13 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Prepare Circle auto shape1 = tvg::Shape::gen(); shape1->appendCircle(400, 400, 250, 250); - shape1->fill(255, 255, 0, 255); + shape1->fill(255, 255, 0); scene->push(std::move(shape1)); //Round rectangle auto shape2 = tvg::Shape::gen(); shape2->appendRect(450, 100, 200, 200, 50, 50); - shape2->fill(0, 255, 0, 255); + shape2->fill(0, 255, 0); shape2->stroke(10); shape2->stroke(255, 255, 255, 255); scene->push(std::move(shape2)); @@ -74,7 +74,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape3->lineTo(26, 161); shape3->lineTo(146, 143); shape3->close(); - shape3->fill(0, 0, 255, 255); + shape3->fill(0, 0, 255); shape3->stroke(10); shape3->stroke(255, 255, 255, 255); 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 - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius); shape4->close(); - shape4->fill(255, 0, 0, 255); + shape4->fill(255, 0, 0); shape4->stroke(10); shape4->stroke(0, 0, 255, 255); shape4->opacity(200); diff --git a/src/examples/Path.cpp b/src/examples/Path.cpp index 25713c7d..156c2636 100644 --- a/src/examples/Path.cpp +++ b/src/examples/Path.cpp @@ -45,7 +45,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape1->lineTo(26, 161); shape1->lineTo(146, 143); shape1->close(); - shape1->fill(0, 0, 255, 255); + shape1->fill(0, 0, 255); 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 - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius); shape2->close(); - shape2->fill(255, 0, 0, 255); + shape2->fill(255, 0, 0); if (canvas->push(std::move(shape2)) != tvg::Result::Success) return; } diff --git a/src/examples/PathCopy.cpp b/src/examples/PathCopy.cpp index 91c4a7e5..63d4380b 100644 --- a/src/examples/PathCopy.cpp +++ b/src/examples/PathCopy.cpp @@ -61,7 +61,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape1 = tvg::Shape::gen(); 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; /* Circle */ @@ -101,7 +101,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape2 = tvg::Shape::gen(); 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; } diff --git a/src/examples/Performance.cpp b/src/examples/Performance.cpp index 048c060f..6c12271f 100644 --- a/src/examples/Performance.cpp +++ b/src/examples/Performance.cpp @@ -37,7 +37,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask = tvg::Shape::gen(); 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. mask->opacity(125); diff --git a/src/examples/PicturePng.cpp b/src/examples/PicturePng.cpp index 78d97369..e24be677 100644 --- a/src/examples/PicturePng.cpp +++ b/src/examples/PicturePng.cpp @@ -34,7 +34,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Background auto bg = tvg::Shape::gen(); 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)); //Load png file from path diff --git a/src/examples/PictureRaw.cpp b/src/examples/PictureRaw.cpp index 24d91f39..1be8b333 100644 --- a/src/examples/PictureRaw.cpp +++ b/src/examples/PictureRaw.cpp @@ -34,7 +34,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Background auto shape = tvg::Shape::gen(); 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; diff --git a/src/examples/Scene.cpp b/src/examples/Scene.cpp index 3679da3f..1dd1471c 100644 --- a/src/examples/Scene.cpp +++ b/src/examples/Scene.cpp @@ -37,19 +37,19 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Prepare Round Rectangle auto shape1 = tvg::Shape::gen(); 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)); //Prepare Circle auto shape2 = tvg::Shape::gen(); 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)); //Prepare Ellipse auto shape3 = tvg::Shape::gen(); 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)); //Create another Scene @@ -71,7 +71,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape4->lineTo(26, 161); shape4->lineTo(146, 143); shape4->close(); - shape4->fill(0, 0, 255, 255); + shape4->fill(0, 0, 255); scene2->push(std::move(shape4)); //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 - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy); 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)); //Push scene2 onto the scene diff --git a/src/examples/SceneClipper.cpp b/src/examples/SceneClipper.cpp index b1bb88ff..01cf6487 100644 --- a/src/examples/SceneClipper.cpp +++ b/src/examples/SceneClipper.cpp @@ -70,7 +70,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape->appendRect(100, 100, 400, 400, 50, 50); shape->stroke(0, 0, 255, 255); shape->stroke(10); - shape->fill(255, 255, 255, 255); + 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 1adc1b83..985a4799 100644 --- a/src/examples/SceneTransform.cpp +++ b/src/examples/SceneTransform.cpp @@ -39,7 +39,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) //Prepare Round Rectangle (Scene1) auto shape1 = tvg::Shape::gen(); 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(255, 255, 255, 255); //r, g, b, a scene->push(std::move(shape1)); @@ -47,13 +47,13 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) //Prepare Circle (Scene1) auto shape2 = tvg::Shape::gen(); 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)); //Prepare Ellipse (Scene1) auto shape3 = tvg::Shape::gen(); 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->translate(350, 350); diff --git a/src/examples/Shape.cpp b/src/examples/Shape.cpp index 1cb7ba29..9bf04afb 100644 --- a/src/examples/Shape.cpp +++ b/src/examples/Shape.cpp @@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) 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, 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)); } diff --git a/src/examples/Stacking.cpp b/src/examples/Stacking.cpp index 34deefa6..be6c15d0 100644 --- a/src/examples/Stacking.cpp +++ b/src/examples/Stacking.cpp @@ -39,21 +39,21 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape1 = tvg::Shape::gen(); paints[0] = shape1.get(); 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; //Prepare Round Rectangle2 auto shape2 = tvg::Shape::gen(); paints[1] = shape2.get(); 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; //Prepare Round Rectangle3 auto shape3 = tvg::Shape::gen(); paints[2] = shape3.get(); 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; //Prepare Scene @@ -62,14 +62,14 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto shape4 = tvg::Shape::gen(); shape4->appendCircle(400, 400, 100, 100); - shape4->fill(255, 0, 0, 255); + shape4->fill(255, 0, 0); shape4->stroke(5); 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, 255); + shape5->fill(255, 0, 255); shape5->stroke(5); shape5->stroke(255, 255, 255, 255); scene->push(std::move(shape5)); diff --git a/src/examples/Stress.cpp b/src/examples/Stress.cpp index 591eb782..c476c11e 100644 --- a/src/examples/Stress.cpp +++ b/src/examples/Stress.cpp @@ -91,7 +91,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Background auto shape = tvg::Shape::gen(); 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; diff --git a/src/examples/Stroke.cpp b/src/examples/Stroke.cpp index 78e13375..9aa4d632 100644 --- a/src/examples/Stroke.cpp +++ b/src/examples/Stroke.cpp @@ -33,7 +33,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape 1 auto shape1 = tvg::Shape::gen(); 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(tvg::StrokeJoin::Bevel); //default is Bevel shape1->stroke(10); //width: 10px @@ -43,7 +43,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape 2 auto shape2 = tvg::Shape::gen(); 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(tvg::StrokeJoin::Round); shape2->stroke(10); @@ -53,7 +53,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape 3 auto shape3 = tvg::Shape::gen(); 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(tvg::StrokeJoin::Miter); shape3->stroke(10); @@ -63,7 +63,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape 4 auto shape4 = tvg::Shape::gen(); 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(1); @@ -72,7 +72,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape 5 auto shape5 = tvg::Shape::gen(); 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(2); @@ -81,7 +81,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape 6 auto shape6 = tvg::Shape::gen(); 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(4); diff --git a/src/examples/Svg.cpp b/src/examples/Svg.cpp index 032c0e16..ad659d84 100644 --- a/src/examples/Svg.cpp +++ b/src/examples/Svg.cpp @@ -79,7 +79,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Background auto shape = tvg::Shape::gen(); 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; diff --git a/src/examples/Svg2.cpp b/src/examples/Svg2.cpp index a07e19d2..ef7b362e 100644 --- a/src/examples/Svg2.cpp +++ b/src/examples/Svg2.cpp @@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Background auto shape = tvg::Shape::gen(); 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; diff --git a/src/examples/Texmap.cpp b/src/examples/Texmap.cpp index 6b8fd8e3..a54cdad6 100644 --- a/src/examples/Texmap.cpp +++ b/src/examples/Texmap.cpp @@ -34,7 +34,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Background auto shape = tvg::Shape::gen(); 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; @@ -78,7 +78,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask = tvg::Shape::gen(); 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); diff --git a/src/examples/Transform.cpp b/src/examples/Transform.cpp index 87e62eb5..7afa356f 100644 --- a/src/examples/Transform.cpp +++ b/src/examples/Transform.cpp @@ -38,7 +38,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) shape->appendRect(-185, -200, 300, 300, 100, 100); shape->appendCircle(115, 100, 100, 100); shape->appendCircle(115, 200, 170, 100); - shape->fill(255, 255, 255, 255); + shape->fill(255, 255, 255); shape->translate(385, 400); shape->scale(1 - 0.75 * progress); shape->rotate(360 * progress); @@ -48,7 +48,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) //Shape2 auto shape2 = tvg::Shape::gen(); shape2->appendRect(-50, -50, 100, 100, 0, 0); - shape2->fill(0, 255, 255, 255); + shape2->fill(0, 255, 255); shape2->translate(400, 400); shape2->rotate(360 * progress); 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 The center of the shape is the anchor point for transformation. */ shape3->appendRect(100, 100, 150, 50, 20, 20); - shape3->fill(255, 0, 255, 255); + shape3->fill(255, 0, 255); shape3->translate(400, 400); shape3->rotate(-360 * progress); shape3->scale(0.5 + progress); diff --git a/src/examples/Tvg.cpp b/src/examples/Tvg.cpp index 4db6f79c..a8ea7690 100644 --- a/src/examples/Tvg.cpp +++ b/src/examples/Tvg.cpp @@ -65,7 +65,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Background auto shape = tvg::Shape::gen(); 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; diff --git a/src/examples/TvgSaver.cpp b/src/examples/TvgSaver.cpp index 876758a8..e808cee1 100644 --- a/src/examples/TvgSaver.cpp +++ b/src/examples/TvgSaver.cpp @@ -85,7 +85,6 @@ unique_ptr tvgClippedImage(uint32_t * data, int width, int heigth) auto imageClip = tvg::Shape::gen(); imageClip->appendCircle(400, 200, 80, 180); - imageClip->fill(0, 0, 0, 155); imageClip->translate(200, 0); image->composite(std::move(imageClip), tvg::CompositeMethod::ClipPath); @@ -102,7 +101,7 @@ unique_ptr tvgMaskedSvg() auto svgMask = tvg::Shape::gen(); tvgDrawStar(svgMask.get()); - svgMask->fill(0, 0, 0, 255); + svgMask->fill(0, 0, 0); svgMask->translate(30, 440); svgMask->opacity(200); svgMask->scale(0.7); @@ -169,10 +168,6 @@ unique_ptr tvgCircle1(tvg::Fill::ColorStop* colorStops, int colorSto { auto circ = tvg::Shape::gen(); 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); return circ; @@ -182,7 +177,6 @@ unique_ptr tvgCircle2(tvg::Fill::ColorStop* colorStops, int colorSto { auto circ = tvg::Shape::gen(); circ->appendCircle(400, 425, 50, 50); - circ->fill(0, 255, 0, 155); auto fill = tvg::RadialGradient::gen(); fill->radial(400, 425, 50); fill->colorStops(colorStops, colorStopsCnt); @@ -252,7 +246,7 @@ void exportTvg() //inv mask applied to the main scene auto mask = tvg::Shape::gen(); 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); //save the tvg file diff --git a/src/examples/Update.cpp b/src/examples/Update.cpp index 073f38dd..26a452e7 100644 --- a/src/examples/Update.cpp +++ b/src/examples/Update.cpp @@ -33,7 +33,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Shape auto shape = tvg::Shape::gen(); shape->appendRect(-100, -100, 200, 200, 0, 0); - shape->fill(255, 255, 255, 255); + shape->fill(255, 255, 255); canvas->push(std::move(shape)); } @@ -47,7 +47,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) //Shape auto shape = tvg::Shape::gen(); 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->scale(1 - 0.75 * progress); shape->rotate(360 * progress); diff --git a/src/lib/tvgShape.cpp b/src/lib/tvgShape.cpp index d5639454..76a94525 100644 --- a/src/lib/tvgShape.cpp +++ b/src/lib/tvgShape.cpp @@ -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 { pImpl->rs.color[0] = r; diff --git a/src/loaders/svg/tvgSvgSceneBuilder.cpp b/src/loaders/svg/tvgSvgSceneBuilder.cpp index c536a24d..92963456 100644 --- a/src/loaders/svg/tvgSvgSceneBuilder.cpp +++ b/src/loaders/svg/tvgSvgSceneBuilder.cpp @@ -739,7 +739,7 @@ static unique_ptr _sceneBuildHelper(const SvgNode* node, const Box& vBox, if (shape) { if (isMaskWhite) { 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() || (shape->strokeColor(&r, &g, &b, nullptr) == Result::Success && (r < 255 || g < 255 || b < 255))) { *isMaskWhite = false; @@ -801,7 +801,7 @@ unique_ptr svgSceneBuild(SvgLoaderData& loaderData, Box vBox, float w, fl auto viewBoxClip = Shape::gen(); viewBoxClip->appendRect(0, 0, w, h, 0, 0); - viewBoxClip->fill(0, 0, 0, 255); + viewBoxClip->fill(0, 0, 0); auto compositeLayer = Scene::gen(); compositeLayer->composite(std::move(viewBoxClip), CompositeMethod::ClipPath); diff --git a/test/testAccessor.cpp b/test/testAccessor.cpp index 7750f85e..0f0ce6c6 100644 --- a/test/testAccessor.cpp +++ b/test/testAccessor.cpp @@ -63,10 +63,10 @@ TEST_CASE("Set", "[tvgAccessor]") { if (paint->identifier() == tvg::Shape::identifier()) { auto shape = (tvg::Shape*) paint; - uint8_t r, g, b, a; - shape->fillColor(&r, &g, &b, &a); + uint8_t r, g, b; + shape->fillColor(&r, &g, &b); if (r == 37 && g == 47 && b == 53) - shape->fill(0, 0, 255, a); + shape->fill(0, 0, 255); } return true; };