From 7a5dc8d6fda6092e640e8ef5e4b0ca40d0e20f44 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 16 Jan 2026 13:00:59 +0900 Subject: [PATCH 1/2] updated push() -> add() calls according to the recent api changes --- src/Accessor.cpp | 2 +- src/Animation.cpp | 4 +-- src/Blending.cpp | 26 ++++++++-------- src/BoundingBox.cpp | 50 +++++++++++++++---------------- src/Clipping.cpp | 14 ++++----- src/CustomTransform.cpp | 2 +- src/DataLoad.cpp | 4 +-- src/DirectUpdate.cpp | 6 ++-- src/Duplicate.cpp | 28 +++++++++--------- src/EffectDropShadow.cpp | 26 ++++++++-------- src/FillRule.cpp | 4 +-- src/FillSpread.cpp | 12 ++++---- src/GradientMasking.cpp | 8 ++--- src/GradientStroke.cpp | 10 +++---- src/GradientTransform.cpp | 6 ++-- src/ImageRotation.cpp | 2 +- src/ImageScaling.cpp | 2 +- src/Intersects.cpp | 10 +++---- src/LinearGradient.cpp | 6 ++-- src/Lottie.cpp | 4 +-- src/LottieExpressions.cpp | 4 +-- src/LottieExtension.cpp | 32 ++++++++++---------- src/LottieInteraction.cpp | 4 +-- src/LottieTweening.cpp | 4 +-- src/LumaMasking.cpp | 24 +++++++-------- src/Masking.cpp | 16 +++++----- src/MaskingMethods.cpp | 62 +++++++++++++++++++-------------------- src/MultiCanvas.cpp | 4 +-- src/Opacity.cpp | 12 ++++---- src/Particles.cpp | 12 ++++---- src/Path.cpp | 8 ++--- src/PictureJpg.cpp | 4 +-- src/PicturePng.cpp | 6 ++-- src/PictureRaw.cpp | 6 ++-- src/PictureSvg.cpp | 4 +-- src/PictureWebp.cpp | 6 ++-- src/RadialGradient.cpp | 6 ++-- src/Retaining.cpp | 16 +++++----- src/Scene.cpp | 18 ++++++------ src/SceneBlending.cpp | 14 ++++----- src/SceneEffects.cpp | 32 ++++++++++---------- src/SceneTransform.cpp | 18 ++++++------ src/Shapes.cpp | 8 ++--- src/Stress.cpp | 2 +- src/Stroke.cpp | 22 +++++++------- src/StrokeLine.cpp | 30 +++++++++---------- src/StrokeMiterlimit.cpp | 8 ++--- src/Svg.cpp | 8 ++--- src/Text.cpp | 30 +++++++++---------- src/TextEffects.cpp | 10 +++---- src/TextLayout.cpp | 22 +++++++------- src/TextLineWrap.cpp | 6 ++-- src/Transform.cpp | 6 ++-- src/TrimPath.cpp | 4 +-- src/Viewport.cpp | 2 +- 55 files changed, 348 insertions(+), 348 deletions(-) diff --git a/src/Accessor.cpp b/src/Accessor.cpp index 2adf2cb..41c8287 100644 --- a/src/Accessor.cpp +++ b/src/Accessor.cpp @@ -65,7 +65,7 @@ struct UserExample : tvgexam::Example shape->strokeWidth(5); } - canvas->push(picture); + canvas->add(picture); return true; } diff --git a/src/Animation.cpp b/src/Animation.cpp index 1871c89..37250da 100644 --- a/src/Animation.cpp +++ b/src/Animation.cpp @@ -45,7 +45,7 @@ struct UserExample : tvgexam::Example shape->appendRect(0, 0, w, h); shape->fill(50, 50, 50); - canvas->push(shape); + canvas->add(shape); if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/sample.json"))) return false; @@ -56,7 +56,7 @@ struct UserExample : tvgexam::Example picture->scale(scale); picture->translate(float(w) * 0.5f, float(h) * 0.5f); - canvas->push(picture); + canvas->add(picture); return true; } diff --git a/src/Blending.cpp b/src/Blending.cpp index 1b6ff72..79b3626 100644 --- a/src/Blending.cpp +++ b/src/Blending.cpp @@ -36,20 +36,20 @@ struct UserExample : tvgexam::Example text->text(name); text->fill(255, 255, 255); text->translate(x + 20, y); - canvas->push(text); + canvas->add(text); //solid { auto bottom = tvg::Shape::gen(); bottom->appendRect(20.0f + x, 25.0f + y, 100.0f, 100.0f, 10.0f, 10.0f); bottom->fill(255, 255, 0); - canvas->push(bottom); + canvas->add(bottom); auto top = tvg::Shape::gen(); top->appendRect(45.0f + x, 50.0f + y, 100.0f, 100.0f, 10.0f, 10.0f); top->fill(0, 255, 255); top->blend(method); - canvas->push(top); + canvas->add(top); } //solid (half transparent) @@ -57,13 +57,13 @@ struct UserExample : tvgexam::Example auto bottom = tvg::Shape::gen(); bottom->appendRect(170.0f + x, 25.0f + y, 100.0f, 100.0f, 10.0f, 10.0f); bottom->fill(255, 255, 0, 127); - canvas->push(bottom); + canvas->add(bottom); auto top = tvg::Shape::gen(); top->appendRect(195.0f + x, 50.0f + y, 100.0f, 100.0f, 10.0f, 10.0f); top->fill(0, 255, 255, 127); top->blend(method); - canvas->push(top); + canvas->add(top); } //gradient blending @@ -79,7 +79,7 @@ struct UserExample : tvgexam::Example auto bottom = tvg::Shape::gen(); bottom->appendRect(325.0f + x, 25.0f + y, 100.0f, 100.0f, 10.0f, 10.0f); bottom->fill(fill); - canvas->push(bottom); + canvas->add(bottom); auto fill2 = tvg::LinearGradient::gen(); fill2->linear(350.0f + x, 50.0f + y, 450.0f + x, 150.0f + y); @@ -89,7 +89,7 @@ struct UserExample : tvgexam::Example top->appendRect(350.0f + x, 50.0f + y, 100.0f, 100.0f, 10.0f, 10.0f); top->fill(fill2); top->blend(method); - canvas->push(top); + canvas->add(top); } //image @@ -98,13 +98,13 @@ struct UserExample : tvgexam::Example bottom->load(data, 200, 300, tvg::ColorSpace::ARGB8888, true); bottom->translate(475 + x, 25.0f + y); bottom->scale(0.35f); - canvas->push(bottom); + canvas->add(bottom); auto top = bottom->duplicate(); top->translate(500.0f + x, 50.0f + y); top->rotate(-10.0f); top->blend(method); - canvas->push(top); + canvas->add(top); } //scene @@ -113,12 +113,12 @@ struct UserExample : tvgexam::Example bottom->load(EXAMPLE_DIR"/svg/tiger.svg"); bottom->translate(600.0f + x, 25.0f + y); bottom->scale(0.11f); - canvas->push(bottom); + canvas->add(bottom); auto top = bottom->duplicate(); top->translate(625.0f + x, 50.0f + y); top->blend(method); - canvas->push(top); + canvas->add(top); } //scene (half transparent) @@ -128,12 +128,12 @@ struct UserExample : tvgexam::Example bottom->translate(750.0f + x, 25.0f + y); bottom->scale(0.11f); bottom->opacity(127); - canvas->push(bottom); + canvas->add(bottom); auto top = bottom->duplicate(); top->translate(775.0f + x, 50.0f + y); top->blend(method); - canvas->push(top); + canvas->add(top); } } diff --git a/src/BoundingBox.cpp b/src/BoundingBox.cpp index bf0eb92..2c670eb 100644 --- a/src/BoundingBox.cpp +++ b/src/BoundingBox.cpp @@ -49,7 +49,7 @@ struct UserExample : tvgexam::Example bound->strokeWidth(2.0f); bound->strokeFill(255, 0, 0, 255); - canvas->push(bound); + canvas->add(bound); } //obb @@ -66,7 +66,7 @@ struct UserExample : tvgexam::Example bound->strokeDash(dash, 2); bound->strokeFill(255, 255, 255, 255); - canvas->push(bound); + canvas->add(bound); } } @@ -76,7 +76,7 @@ struct UserExample : tvgexam::Example auto shape = tvg::Shape::gen(); shape->appendCircle(50, 100, 40, 100); shape->fill(0, 30, 255); - canvas->push(shape); + canvas->add(shape); bbox(canvas, shape); } @@ -89,7 +89,7 @@ struct UserExample : tvgexam::Example text->fill(255, 255, 0); text->translate(100, 20); text->rotate(16.0f); - canvas->push(text); + canvas->add(text); bbox(canvas, text); } @@ -98,7 +98,7 @@ struct UserExample : tvgexam::Example shape->appendRect(200, 30, 100, 20); shape->fill(200, 150, 55); shape->rotate(30); - canvas->push(shape); + canvas->add(shape); bbox(canvas, shape); } @@ -113,7 +113,7 @@ struct UserExample : tvgexam::Example tvg::Matrix m = {1.732f, -1.0f, 30.0f, 1.0f, 1.732f, -70.0f, 0.0f, 0.0f, 1.0f}; shape->transform(m); - canvas->push(shape); + canvas->add(shape); bbox(canvas, shape); } @@ -122,7 +122,7 @@ struct UserExample : tvgexam::Example svg->load(EXAMPLE_DIR"/svg/tiger.svg"); svg->scale(0.3f); svg->translate(620, 50); - canvas->push(svg); + canvas->add(svg); bbox(canvas, svg); } @@ -132,7 +132,7 @@ struct UserExample : tvgexam::Example svg->scale(0.2f); svg->translate(140, 215); svg->rotate(45); - canvas->push(svg); + canvas->add(svg); bbox(canvas, svg); } @@ -144,9 +144,9 @@ struct UserExample : tvgexam::Example auto img = tvg::Picture::gen(); img->load(EXAMPLE_DIR"/image/test.png"); - scene->push(img); + scene->add(img); - canvas->push(scene); + canvas->add(scene); bbox(canvas, scene); } @@ -158,9 +158,9 @@ struct UserExample : tvgexam::Example auto img = tvg::Picture::gen(); img->load(EXAMPLE_DIR"/image/test.jpg"); - scene->push(img); + scene->add(img); - canvas->push(scene); + canvas->add(scene); bbox(canvas, scene); } @@ -170,7 +170,7 @@ struct UserExample : tvgexam::Example line->lineTo(770, 350); line->strokeWidth(20); line->strokeFill(55, 55, 0); - canvas->push(line); + canvas->add(line); bbox(canvas, line); } @@ -181,7 +181,7 @@ struct UserExample : tvgexam::Example curve->translate(50, 770); curve->strokeWidth(2.0f); curve->strokeFill(255, 255, 255); - canvas->push(curve); + canvas->add(curve); bbox(canvas, curve); } @@ -193,7 +193,7 @@ struct UserExample : tvgexam::Example curve->rotate(20.0f); curve->strokeWidth(2.0f); curve->strokeFill(255, 0, 255); - canvas->push(curve); + canvas->add(curve); bbox(canvas, curve); } @@ -209,9 +209,9 @@ struct UserExample : tvgexam::Example shape->fill(255, 0, 0); shape->close(); shape->rotate(20); - scene->push(shape); + scene->add(shape); - canvas->push(scene); + canvas->add(scene); bbox(canvas, scene); } @@ -231,9 +231,9 @@ struct UserExample : tvgexam::Example shape->strokeFill(255, 255, 255); shape->strokeJoin(tvg::StrokeJoin::Bevel); - scene->push(shape); + scene->add(shape); - canvas->push(scene); + canvas->add(scene); bbox(canvas, scene); } @@ -253,9 +253,9 @@ struct UserExample : tvgexam::Example shape->strokeWidth(20); shape->strokeFill(0, 0, 255); - scene->push(shape); + scene->add(shape); - canvas->push(scene); + canvas->add(scene); bbox(canvas, scene); } @@ -278,9 +278,9 @@ struct UserExample : tvgexam::Example tvg::Matrix m = {1.8794f, -0.6840f, 0.0f, 0.6840f, 1.8794f, 0.0f, 0.0f, 0.0f, 1.0f}; shape->transform(m); - scene->push(shape); + scene->add(shape); - canvas->push(scene); + canvas->add(scene); bbox(canvas, scene); } @@ -296,9 +296,9 @@ struct UserExample : tvgexam::Example text->fill(255, 255, 0); text->translate(0, 0); text->rotate(16.0f); - scene->push(text); + scene->add(text); - canvas->push(scene); + canvas->add(scene); bbox(canvas, scene); } diff --git a/src/Clipping.cpp b/src/Clipping.cpp index e86f93c..4bfaf9d 100644 --- a/src/Clipping.cpp +++ b/src/Clipping.cpp @@ -49,7 +49,7 @@ struct UserExample : tvgexam::Example auto shape = tvg::Shape::gen(); shape->appendRect(0, 0, w, h); shape->fill(255, 255, 255); - canvas->push(shape); + canvas->add(shape); { auto scene = tvg::Scene::gen(); @@ -85,13 +85,13 @@ struct UserExample : tvgexam::Example clip->appendCircle(200, 230, 130, 130); clip->translate(10, 10); - scene->push(star1); - scene->push(star2); + scene->add(star1); + scene->add(star2); //Clipping scene to shape scene->clip(clip); - canvas->push(scene); + canvas->add(scene); } { @@ -119,7 +119,7 @@ struct UserExample : tvgexam::Example //Clipping scene to rect(shape) star3->clip(clipRect); - canvas->push(star3); + canvas->add(star3); } { @@ -138,7 +138,7 @@ struct UserExample : tvgexam::Example //Clipping picture to path picture->clip(clipPath); - canvas->push(picture); + canvas->add(picture); } { @@ -154,7 +154,7 @@ struct UserExample : tvgexam::Example //Clipping shape1 to clipShape shape1->clip(clipShape); - canvas->push(shape1); + canvas->add(shape1); } return true; diff --git a/src/CustomTransform.cpp b/src/CustomTransform.cpp index c89a8c1..07573d5 100644 --- a/src/CustomTransform.cpp +++ b/src/CustomTransform.cpp @@ -93,7 +93,7 @@ struct UserExample : tvgexam::Example shape->transform(m); - canvas->push(shape); + canvas->add(shape); return true; } diff --git a/src/DataLoad.cpp b/src/DataLoad.cpp index ff709fc..a427650 100644 --- a/src/DataLoad.cpp +++ b/src/DataLoad.cpp @@ -37,14 +37,14 @@ struct UserExample : tvgexam::Example shape->appendRect(0, 0, w, h); //x, y, w, h shape->fill(255, 255, 255); //r, g, b - canvas->push(shape); + canvas->add(shape); auto picture = tvg::Picture::gen(); if (!tvgexam::verify(picture->load(svg, strlen(svg), "svg"))) return false; picture->size(w, h); - canvas->push(picture); + canvas->add(picture); return true; } diff --git a/src/DirectUpdate.cpp b/src/DirectUpdate.cpp index c0158b0..7c67f2c 100644 --- a/src/DirectUpdate.cpp +++ b/src/DirectUpdate.cpp @@ -39,7 +39,7 @@ struct UserExample : tvgexam::Example auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, w, h); bg->fill(255, 255, 255); - canvas->push(bg); + canvas->add(bg); //Solid Shape { @@ -51,7 +51,7 @@ struct UserExample : tvgexam::Example solid->strokeFill(0, 0, 255); solid->strokeWidth(1); - canvas->push(solid); + canvas->add(solid); } //Gradient Shape @@ -72,7 +72,7 @@ struct UserExample : tvgexam::Example fill->colorStops(colorStops, 3); gradient->fill(fill); - canvas->push(gradient); + canvas->add(gradient); } this->w = w; diff --git a/src/Duplicate.cpp b/src/Duplicate.cpp index 37ea2e5..4ea164d 100644 --- a/src/Duplicate.cpp +++ b/src/Duplicate.cpp @@ -64,9 +64,9 @@ struct UserExample : tvgexam::Example auto shape3 = shape2->duplicate(); shape3->translate(0, 440); - canvas->push(shape1); - canvas->push(shape2); - canvas->push(shape3); + canvas->add(shape1); + canvas->add(shape2); + canvas->add(shape3); } //Duplicate Scene @@ -77,17 +77,17 @@ struct UserExample : tvgexam::Example auto shape1 = tvg::Shape::gen(); shape1->appendRect(0, 0, 400, 400, 50, 50); shape1->fill(0, 255, 0); - scene1->push(shape1); + scene1->add(shape1); auto shape2 = tvg::Shape::gen(); shape2->appendCircle(400, 400, 200, 200); shape2->fill(255, 255, 0); - scene1->push(shape2); + scene1->add(shape2); auto shape3 = tvg::Shape::gen(); shape3->appendCircle(600, 600, 150, 100); shape3->fill(0, 255, 255); - scene1->push(shape3); + scene1->add(shape3); scene1->scale(0.25); scene1->translate(400, 0); @@ -96,8 +96,8 @@ struct UserExample : tvgexam::Example auto scene2 = scene1->duplicate(); scene2->translate(600, 0); - canvas->push(scene1); - canvas->push(scene2); + canvas->add(scene1); + canvas->add(scene2); } //Duplicate Picture - svg @@ -110,8 +110,8 @@ struct UserExample : tvgexam::Example auto picture2 = picture1->duplicate(); picture2->translate(550, 250); - canvas->push(picture1); - canvas->push(picture2); + canvas->add(picture1); + canvas->add(picture2); } //Duplicate Picture - raw @@ -133,8 +133,8 @@ struct UserExample : tvgexam::Example picture2->scale(0.7); picture2->rotate(8); - canvas->push(picture1); - canvas->push(picture2); + canvas->add(picture1); + canvas->add(picture2); free(data); } @@ -152,8 +152,8 @@ struct UserExample : tvgexam::Example auto text2 = text->duplicate(); text2->translate(0, 700); - canvas->push(text); - canvas->push(text2); + canvas->add(text); + canvas->add(text2); } return true; diff --git a/src/EffectDropShadow.cpp b/src/EffectDropShadow.cpp index c5f48a7..449bbdb 100644 --- a/src/EffectDropShadow.cpp +++ b/src/EffectDropShadow.cpp @@ -38,7 +38,7 @@ struct UserExample : tvgexam::Example auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, w, h); bg->fill(255, 255, 255); - canvas->push(bg); + canvas->add(bg); //Prepare a scene for post effects { @@ -50,8 +50,8 @@ struct UserExample : tvgexam::Example picture->origin(0.5f, 0.0f); picture->translate(float(w / 2), 0.0f); - scene1->push(picture); - canvas->push(scene1); + scene1->add(picture); + canvas->add(scene1); } //Prepare a scene for post effects @@ -64,8 +64,8 @@ struct UserExample : tvgexam::Example picture->origin(0.5f, 0.0f); picture->translate(float(w / 2), 250.0f); - scene2->push(picture); - canvas->push(scene2); + scene2->add(picture); + canvas->add(scene2); } //Prepare a scene for post effects @@ -78,8 +78,8 @@ struct UserExample : tvgexam::Example picture->origin(0.5f, 0.0f); picture->translate(float(w / 2), 550.0f); - scene3->push(picture); - canvas->push(scene3); + scene3->add(picture); + canvas->add(scene3); } return true; @@ -90,15 +90,15 @@ struct UserExample : tvgexam::Example auto progress = tvgexam::progress(elapsed, 2.5f, true); //2.5 seconds //Clear the previously applied effects - scene1->push(tvg::SceneEffect::ClearAll); + scene1->add(tvg::SceneEffect::Clear); //Apply DropShadow post effect (r, g, b, a, angle, distance, sigma of blurness, quality) - scene1->push(tvg::SceneEffect::DropShadow, 0, 0, 0, 125, 120.0, (double)(20.0f * progress), 3.0, 100); + scene1->add(tvg::SceneEffect::DropShadow, 0, 0, 0, 125, 120.0, (double)(20.0f * progress), 3.0, 100); - scene2->push(tvg::SceneEffect::ClearAll); - scene2->push(tvg::SceneEffect::DropShadow, 65, 143, 222, (int)(255.0f * progress), 135.0, 10.0, 3.0, 100); + scene2->add(tvg::SceneEffect::Clear); + scene2->add(tvg::SceneEffect::DropShadow, 65, 143, 222, (int)(255.0f * progress), 135.0, 10.0, 3.0, 100); - scene3->push(tvg::SceneEffect::ClearAll); - scene3->push(tvg::SceneEffect::DropShadow, 0, 0, 0, 125, (double)(360.0f * progress), 20.0, 0.0, 100); + scene3->add(tvg::SceneEffect::Clear); + scene3->add(tvg::SceneEffect::DropShadow, 0, 0, 0, 125, (double)(360.0f * progress), 20.0, 0.0, 100); canvas->update(); diff --git a/src/FillRule.cpp b/src/FillRule.cpp index 7d387a7..29c3918 100644 --- a/src/FillRule.cpp +++ b/src/FillRule.cpp @@ -42,7 +42,7 @@ struct UserExample : tvgexam::Example // Use the NonZero fill rule: fills all areas enclosed by paths with non-zero winding numbers shape1->fillRule(tvg::FillRule::NonZero); - canvas->push(shape1); + canvas->add(shape1); //Star 2 auto shape2 = tvg::Shape::gen(); @@ -56,7 +56,7 @@ struct UserExample : tvgexam::Example // Use the EvenOdd fill rule: fills areas where path overlaps an odd number of times shape2->fillRule(tvg::FillRule::EvenOdd); - canvas->push(shape2); + canvas->add(shape2); return true; } diff --git a/src/FillSpread.cpp b/src/FillSpread.cpp index 3d6b6d8..0ae5780 100644 --- a/src/FillSpread.cpp +++ b/src/FillSpread.cpp @@ -52,7 +52,7 @@ struct UserExample : tvgexam::Example fill1->spread(tvg::FillSpread::Pad); shape1->fill(fill1); - canvas->push(shape1); + canvas->add(shape1); //Reflect x1 = 280.0f; @@ -65,7 +65,7 @@ struct UserExample : tvgexam::Example fill2->spread(tvg::FillSpread::Reflect); shape2->fill(fill2); - canvas->push(shape2); + canvas->add(shape2); //Repeat x1 = 540.0f; @@ -78,7 +78,7 @@ struct UserExample : tvgexam::Example fill3->spread(tvg::FillSpread::Repeat); shape3->fill(fill3); - canvas->push(shape3); + canvas->add(shape3); } //Linear grad @@ -96,7 +96,7 @@ struct UserExample : tvgexam::Example fill1->spread(tvg::FillSpread::Pad); shape1->fill(fill1); - canvas->push(shape1); + canvas->add(shape1); //Reflect x1 = 280.0f; @@ -109,7 +109,7 @@ struct UserExample : tvgexam::Example fill2->spread(tvg::FillSpread::Reflect); shape2->fill(fill2); - canvas->push(shape2); + canvas->add(shape2); //Repeat x1 = 540.0f; @@ -122,7 +122,7 @@ struct UserExample : tvgexam::Example fill3->spread(tvg::FillSpread::Repeat); shape3->fill(fill3); - canvas->push(shape3); + canvas->add(shape3); return true; } diff --git a/src/GradientMasking.cpp b/src/GradientMasking.cpp index 863152b..37b2d3c 100644 --- a/src/GradientMasking.cpp +++ b/src/GradientMasking.cpp @@ -49,7 +49,7 @@ struct UserExample : tvgexam::Example shape->fill(fill); shape->mask(mask, tvg::MaskMethod::Alpha); - canvas->push(shape); + canvas->add(shape); } //Star @@ -81,7 +81,7 @@ struct UserExample : tvgexam::Example shape1->fill(fill1); shape1->mask(mask1, tvg::MaskMethod::Alpha); - canvas->push(shape1); + canvas->add(shape1); } //Solid Rectangle @@ -103,7 +103,7 @@ struct UserExample : tvgexam::Example shape2->fill(fill2); shape2->mask(mask2, tvg::MaskMethod::InvAlpha); - canvas->push(shape2); + canvas->add(shape2); } // Star @@ -135,7 +135,7 @@ struct UserExample : tvgexam::Example shape3->fill(fill3); shape3->mask(mask3, tvg::MaskMethod::InvAlpha); - canvas->push(shape3); + canvas->add(shape3); } return true; diff --git a/src/GradientStroke.cpp b/src/GradientStroke.cpp index 4aa23b3..f856743 100644 --- a/src/GradientStroke.cpp +++ b/src/GradientStroke.cpp @@ -75,7 +75,7 @@ struct UserExample : tvgexam::Example fill1->colorStops(colorStops1, 3); shape1->fill(fill1); - canvas->push(shape1); + canvas->add(shape1); // radial gradient stroke + duplicate auto shape2 = tvg::Shape::gen(); @@ -98,9 +98,9 @@ struct UserExample : tvgexam::Example auto shape4 = static_cast(shape2->duplicate()); shape4->translate(0, 400); - canvas->push(shape2); - canvas->push(shape3); - canvas->push(shape4); + canvas->add(shape2); + canvas->add(shape3); + canvas->add(shape4); // dashed gradient stroke auto shape5 = tvg::Shape::gen(); @@ -120,7 +120,7 @@ struct UserExample : tvgexam::Example shape5->fill(fill5); shape5->scale(0.8); - canvas->push(shape5); + canvas->add(shape5); return true; } diff --git a/src/GradientTransform.cpp b/src/GradientTransform.cpp index b28a56f..318d368 100644 --- a/src/GradientTransform.cpp +++ b/src/GradientTransform.cpp @@ -64,7 +64,7 @@ struct UserExample : tvgexam::Example shape->scale(1.0f - 0.75f * progress); shape->rotate(360.0f * progress); - canvas->push(shape); + canvas->add(shape); //Shape2 auto shape2 = tvg::Shape::gen(); @@ -86,7 +86,7 @@ struct UserExample : tvgexam::Example shape2->rotate(360 * progress); shape2->translate(480 + progress * 300, 480); - canvas->push(shape2); + canvas->add(shape2); //Shape3 auto shape3 = tvg::Shape::gen(); @@ -114,7 +114,7 @@ struct UserExample : tvgexam::Example shape3->rotate(-360.0f * progress); shape3->scale(0.5f + progress); - canvas->push(shape3); + canvas->add(shape3); return true; } diff --git a/src/ImageRotation.cpp b/src/ImageRotation.cpp index fd4693f..6d2ad67 100644 --- a/src/ImageRotation.cpp +++ b/src/ImageRotation.cpp @@ -45,7 +45,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/image/scale.jpg"))) return false; - canvas->push(picture); + canvas->add(picture); return true; } diff --git a/src/ImageScaling.cpp b/src/ImageScaling.cpp index f94dd3b..40d77d0 100644 --- a/src/ImageScaling.cpp +++ b/src/ImageScaling.cpp @@ -41,7 +41,7 @@ struct UserExample : tvgexam::Example picture->translate(w/2, h/2); picture->scale(1.5f); - canvas->push(picture); + canvas->add(picture); return true; } diff --git a/src/Intersects.cpp b/src/Intersects.cpp index 337f757..8bc7e27 100644 --- a/src/Intersects.cpp +++ b/src/Intersects.cpp @@ -59,7 +59,7 @@ struct UserExample : tvgexam::Example shape->scale(1.25f); - canvas->push(shape); + canvas->add(shape); } //clipped, rotated image @@ -74,7 +74,7 @@ struct UserExample : tvgexam::Example clip->appendCircle(900, 350, 200, 200); picture->clip(clip); - canvas->push(picture); + canvas->add(picture); } //normal text @@ -87,7 +87,7 @@ struct UserExample : tvgexam::Example text->translate(25, 800); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); } //vector scene @@ -97,7 +97,7 @@ struct UserExample : tvgexam::Example tiger->translate(700, 640); tiger->scale(0.5f); - canvas->push(tiger); + canvas->add(tiger); } //marquee @@ -107,7 +107,7 @@ struct UserExample : tvgexam::Example marquee->strokeWidth(2); marquee->strokeFill(255, 255, 0); marquee->fill(255, 255, 0, 50); - canvas->push(marquee); + canvas->add(marquee); } return true; diff --git a/src/LinearGradient.cpp b/src/LinearGradient.cpp index acc029c..cd15747 100644 --- a/src/LinearGradient.cpp +++ b/src/LinearGradient.cpp @@ -46,7 +46,7 @@ struct UserExample : tvgexam::Example fill->colorStops(colorStops, 2); shape1->fill(fill); - canvas->push(shape1); + canvas->add(shape1); //Prepare Circle auto shape2 = tvg::Shape::gen(); @@ -65,7 +65,7 @@ struct UserExample : tvgexam::Example fill2->colorStops(colorStops2, 3); shape2->fill(fill2); - canvas->push(shape2); + canvas->add(shape2); //Prepare Ellipse auto shape3 = tvg::Shape::gen(); @@ -85,7 +85,7 @@ struct UserExample : tvgexam::Example fill3->colorStops(colorStops3, 4); shape3->fill(fill3); - canvas->push(shape3); + canvas->add(shape3); return true; } diff --git a/src/Lottie.cpp b/src/Lottie.cpp index d023c29..4fbb36f 100644 --- a/src/Lottie.cpp +++ b/src/Lottie.cpp @@ -86,7 +86,7 @@ struct UserExample : tvgexam::Example auto shape = tvg::Shape::gen(); shape->appendRect(0, 0, w, h); shape->fill(75, 75, 75); - canvas->push(shape); + canvas->add(shape); this->w = w; this->h = h; @@ -96,7 +96,7 @@ struct UserExample : tvgexam::Example //Run animation loop for (auto& animation : animations) { - canvas->push(animation->picture()); + canvas->add(animation->picture()); } return true; diff --git a/src/LottieExpressions.cpp b/src/LottieExpressions.cpp index 6785a09..0d352fa 100644 --- a/src/LottieExpressions.cpp +++ b/src/LottieExpressions.cpp @@ -87,7 +87,7 @@ struct UserExample : tvgexam::Example shape->appendRect(0, 0, w, h); shape->fill(75, 75, 75); - canvas->push(shape); + canvas->add(shape); this->w = w; this->h = h; @@ -97,7 +97,7 @@ struct UserExample : tvgexam::Example //Run animation loop for (auto& animation : animations) { - canvas->push(animation->picture()); + canvas->add(animation->picture()); } return true; diff --git a/src/LottieExtension.cpp b/src/LottieExtension.cpp index 62997a7..3c8b88a 100644 --- a/src/LottieExtension.cpp +++ b/src/LottieExtension.cpp @@ -74,7 +74,7 @@ struct UserExample : tvgexam::Example auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, w, h); bg->fill(75, 75, 75); - canvas->push(bg); + canvas->add(bg); this->w = w; this->h = h; @@ -87,7 +87,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/slot0.json"))) return false; sizing(picture, 0); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -102,7 +102,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(slot->apply(slotId))) return false; sizing(picture, 1); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -117,7 +117,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(slot->apply(slotId))) return false; sizing(picture, 2); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -132,7 +132,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(slot->apply(slotId))) return false; sizing(picture, 3); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -147,7 +147,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(slot->apply(slotId))) return false; sizing(picture, 4); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -158,7 +158,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/slot5.json"))) return false; sizing(picture, 5); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -173,7 +173,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(slot->apply(slotId))) return false; sizing(picture, 6); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -188,7 +188,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(slot->apply(slotId))) return false; sizing(picture, 7); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -203,7 +203,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(slot->apply(slotId))) return false; sizing(picture, 8); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -219,7 +219,7 @@ struct UserExample : tvgexam::Example sizing(picture, 9); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -234,7 +234,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(slot->apply(slotId))) return false; sizing(picture, 10); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -249,7 +249,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(slot->apply(slotId))) return false; sizing(picture, 11); - canvas->push(picture); + canvas->add(picture); slots.push_back(std::move(slot)); } @@ -261,7 +261,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(marker->segment("sectionC"))) return false; sizing(picture, 12); - canvas->push(picture); + canvas->add(picture); } //asset resolver (image) @@ -282,7 +282,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/resolver1.json"))) return false; sizing(picture, 13); - canvas->push(picture); + canvas->add(picture); } //asset resolver (font) @@ -303,7 +303,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/resolver2.json"))) return false; sizing(picture, 14); - canvas->push(picture); + canvas->add(picture); } return true; diff --git a/src/LottieInteraction.cpp b/src/LottieInteraction.cpp index 553817d..1b3968d 100644 --- a/src/LottieInteraction.cpp +++ b/src/LottieInteraction.cpp @@ -122,7 +122,7 @@ struct UserExample : tvgexam::Example auto shape = tvg::Shape::gen(); shape->appendRect(100, 100, w - 200, h - 200); shape->fill(50, 50, 50); - canvas->push(std::move(shape)); + canvas->add(std::move(shape)); } if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/extensions/spin.json"))) return false; @@ -134,7 +134,7 @@ struct UserExample : tvgexam::Example picture->scale(scale); picture->translate(float(w) * 0.5f, float(h) * 0.5f); - canvas->push(picture); + canvas->add(picture); origin.x = float(w / 2); origin.y = float(h / 2); diff --git a/src/LottieTweening.cpp b/src/LottieTweening.cpp index f8ad630..5ca7f39 100644 --- a/src/LottieTweening.cpp +++ b/src/LottieTweening.cpp @@ -123,7 +123,7 @@ struct UserExample : tvgexam::Example shape->appendRect(0, 0, w, h); shape->fill(50, 50, 50); - canvas->push(shape); + canvas->add(shape); if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/lottie/emoji.json"))) return false; @@ -135,7 +135,7 @@ struct UserExample : tvgexam::Example picture->translate(float(w) * 0.5f, float(h) * 0.5f); - canvas->push(picture); + canvas->add(picture); init(); diff --git a/src/LumaMasking.cpp b/src/LumaMasking.cpp index 81f05bc..3baeb66 100644 --- a/src/LumaMasking.cpp +++ b/src/LumaMasking.cpp @@ -56,7 +56,7 @@ struct UserExample : tvgexam::Example mask->mask(nMask, tvg::MaskMethod::Luma); shape->mask(mask, tvg::MaskMethod::Luma); - canvas->push(shape); + canvas->add(shape); //SVG auto svg = tvg::Picture::gen(); @@ -71,7 +71,7 @@ struct UserExample : tvgexam::Example mask2->appendRect(150, 500, 200, 200, 30, 30); mask2->fill(255, 255, 255); svg->mask(mask2, tvg::MaskMethod::Luma); - canvas->push(svg); + canvas->add(svg); //Star auto star = tvg::Shape::gen(); @@ -95,7 +95,7 @@ struct UserExample : tvgexam::Example mask3->appendCircle(600, 200, 125, 125); mask3->fill(0, 255, 255); star->mask(mask3, tvg::MaskMethod::Luma); - canvas->push(star); + canvas->add(star); auto image = tvg::Picture::gen(); if (!tvgexam::verify(image->load(data, 200, 300, tvg::ColorSpace::ARGB8888, true))) return false; @@ -109,10 +109,10 @@ struct UserExample : tvgexam::Example auto mask4_circle = tvg::Shape::gen(); mask4_circle->appendCircle(600, 550, 125, 125); mask4_circle->fill(128, 0, 128); - mask4->push(mask4_rect); - mask4->push(mask4_circle); + mask4->add(mask4_rect); + mask4->add(mask4_circle); image->mask(mask4, tvg::MaskMethod::Luma); - canvas->push(image); + canvas->add(image); } //Inverse Luma Masking @@ -134,7 +134,7 @@ struct UserExample : tvgexam::Example mask->mask(nMask, tvg::MaskMethod::InvLuma); shape->mask(mask, tvg::MaskMethod::InvLuma); - canvas->push(shape); + canvas->add(shape); //SVG auto svg = tvg::Picture::gen(); @@ -149,7 +149,7 @@ struct UserExample : tvgexam::Example mask2->appendRect(950, 500, 200, 200, 30, 30); mask2->fill(255, 255, 255); svg->mask(mask2, tvg::MaskMethod::InvLuma); - canvas->push(svg); + canvas->add(svg); //Star auto star = tvg::Shape::gen(); @@ -173,7 +173,7 @@ struct UserExample : tvgexam::Example mask3->appendCircle(1400, 200, 125, 125); mask3->fill(0, 255, 255); star->mask(mask3, tvg::MaskMethod::InvLuma); - canvas->push(star); + canvas->add(star); auto image = tvg::Picture::gen(); if (!tvgexam::verify(image->load(data, 200, 300, tvg::ColorSpace::ARGB8888, true))) return false; @@ -187,10 +187,10 @@ struct UserExample : tvgexam::Example auto mask4_circle = tvg::Shape::gen(); mask4_circle->appendCircle(1400, 550, 125, 125); mask4_circle->fill(128, 0, 128); - mask4->push(mask4_rect); - mask4->push(mask4_circle); + mask4->add(mask4_rect); + mask4->add(mask4_circle); image->mask(mask4, tvg::MaskMethod::InvLuma); - canvas->push(image); + canvas->add(image); } free(data); diff --git a/src/Masking.cpp b/src/Masking.cpp index 46c2691..2206c4a 100644 --- a/src/Masking.cpp +++ b/src/Masking.cpp @@ -56,7 +56,7 @@ struct UserExample : tvgexam::Example mask->mask(nMask, tvg::MaskMethod::Alpha); shape->mask(mask, tvg::MaskMethod::Alpha); - canvas->push(shape); + canvas->add(shape); //SVG auto svg = tvg::Picture::gen(); @@ -71,7 +71,7 @@ struct UserExample : tvgexam::Example mask2->appendRect(150, 500, 200, 200, 30, 30); mask2->fill(255, 255, 255); //AlphaMask RGB channels are unused. svg->mask(mask2, tvg::MaskMethod::Alpha); - canvas->push(svg); + canvas->add(svg); //Star auto star = tvg::Shape::gen(); @@ -97,7 +97,7 @@ struct UserExample : tvgexam::Example mask3->fill(255, 255, 255); //AlphaMask RGB channels are unused. mask3->opacity(200); star->mask(mask3, tvg::MaskMethod::Alpha); - canvas->push(star); + canvas->add(star); auto image = tvg::Picture::gen(); if (!tvgexam::verify(image->load(data, 200, 300, tvg::ColorSpace::ARGB8888, true))) return false; @@ -119,7 +119,7 @@ struct UserExample : tvgexam::Example mask4->fill(255, 255, 255); //AlphaMask RGB channels are unused. mask4->opacity(70); image->mask(mask4, tvg::MaskMethod::Alpha); - canvas->push(image); + canvas->add(image); } //Inverse Masking @@ -141,7 +141,7 @@ struct UserExample : tvgexam::Example mask->mask(nMask, tvg::MaskMethod::InvAlpha); shape->mask(mask, tvg::MaskMethod::InvAlpha); - canvas->push(shape); + canvas->add(shape); //SVG auto svg = tvg::Picture::gen(); @@ -156,7 +156,7 @@ struct UserExample : tvgexam::Example mask2->appendRect(950, 500, 200, 200, 30, 30); mask2->fill(255, 255, 255); //InvAlphaMask RGB channels are unused. svg->mask(mask2, tvg::MaskMethod::InvAlpha); - canvas->push(svg); + canvas->add(svg); //Star auto star = tvg::Shape::gen(); @@ -180,7 +180,7 @@ struct UserExample : tvgexam::Example mask3->appendCircle(1400, 200, 125, 125); mask3->fill(255, 255, 255); //InvAlphaMask RGB channels are unused. star->mask(mask3, tvg::MaskMethod::InvAlpha); - canvas->push(star); + canvas->add(star); auto image = tvg::Picture::gen(); if (!tvgexam::verify(image->load(data, 200, 300, tvg::ColorSpace::ABGR8888, true))) return false; @@ -202,7 +202,7 @@ struct UserExample : tvgexam::Example mask4->fill(255, 255, 255); //InvAlphaMask RGB channels are unused. mask4->opacity(70); image->mask(mask4, tvg::MaskMethod::InvAlpha); - canvas->push(image); + canvas->add(image); } free(data); diff --git a/src/MaskingMethods.cpp b/src/MaskingMethods.cpp index 31b8383..658e848 100644 --- a/src/MaskingMethods.cpp +++ b/src/MaskingMethods.cpp @@ -41,7 +41,7 @@ struct UserExample : tvgexam::Example auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, 625, h); bg->fill(50, 50, 50); - canvas->push(bg); + canvas->add(bg); { //Shape + Shape Mask Add @@ -58,7 +58,7 @@ struct UserExample : tvgexam::Example add->fill(255, 255, 255); mask->mask(add, tvg::MaskMethod::Add); shape->mask(mask, tvg::MaskMethod::Alpha); - canvas->push(shape); + canvas->add(shape); //Shape + Shape Mask Subtract auto shape2 = tvg::Shape::gen(); @@ -74,7 +74,7 @@ struct UserExample : tvgexam::Example sub->fill(255, 255, 255); mask2->mask(sub, tvg::MaskMethod::Subtract); shape2->mask(mask2, tvg::MaskMethod::Alpha); - canvas->push(shape2); + canvas->add(shape2); //Shape + Shape Mask Intersect auto shape3 = tvg::Shape::gen(); @@ -90,7 +90,7 @@ struct UserExample : tvgexam::Example inter->fill(255, 255, 255); mask3->mask(inter, tvg::MaskMethod::Intersect); shape3->mask(mask3, tvg::MaskMethod::Alpha); - canvas->push(shape3); + canvas->add(shape3); //Shape + Shape Mask Difference auto shape4 = tvg::Shape::gen(); @@ -106,7 +106,7 @@ struct UserExample : tvgexam::Example diff->fill(255, 255, 255); mask4->mask(diff, tvg::MaskMethod::Difference); shape4->mask(mask4, tvg::MaskMethod::Alpha); - canvas->push(shape4); + canvas->add(shape4); //Shape + Shape Mask Lighten auto shape5 = tvg::Shape::gen(); @@ -122,7 +122,7 @@ struct UserExample : tvgexam::Example light->fill(255, 255, 255); mask5->mask(light, tvg::MaskMethod::Lighten); shape5->mask(mask5, tvg::MaskMethod::Alpha); - canvas->push(shape5); + canvas->add(shape5); //Shape + Shape Mask Darken auto shape6 = tvg::Shape::gen(); @@ -138,7 +138,7 @@ struct UserExample : tvgexam::Example dark->fill(255, 255, 255); mask6->mask(dark, tvg::MaskMethod::Darken); shape6->mask(mask6, tvg::MaskMethod::Alpha); - canvas->push(shape6); + canvas->add(shape6); } { //Shape + Shape Mask Add @@ -155,7 +155,7 @@ struct UserExample : tvgexam::Example add->fill(255, 255, 255); mask->mask(add, tvg::MaskMethod::Add); shape->mask(mask, tvg::MaskMethod::InvAlpha); - canvas->push(shape); + canvas->add(shape); //Shape + Shape Mask Subtract auto shape2 = tvg::Shape::gen(); @@ -171,7 +171,7 @@ struct UserExample : tvgexam::Example sub->fill(255, 255, 255); mask2->mask(sub, tvg::MaskMethod::Subtract); shape2->mask(mask2, tvg::MaskMethod::InvAlpha); - canvas->push(shape2); + canvas->add(shape2); //Shape + Shape Mask Intersect auto shape3 = tvg::Shape::gen(); @@ -187,7 +187,7 @@ struct UserExample : tvgexam::Example inter->fill(255, 255, 255); mask3->mask(inter, tvg::MaskMethod::Intersect); shape3->mask(mask3, tvg::MaskMethod::InvAlpha); - canvas->push(shape3); + canvas->add(shape3); //Shape + Shape Mask Difference auto shape4 = tvg::Shape::gen(); @@ -203,7 +203,7 @@ struct UserExample : tvgexam::Example diff->fill(255, 255, 255); mask4->mask(diff, tvg::MaskMethod::Difference); shape4->mask(mask4, tvg::MaskMethod::InvAlpha); - canvas->push(shape4); + canvas->add(shape4); //Shape + Shape Mask Lighten auto shape5 = tvg::Shape::gen(); @@ -219,7 +219,7 @@ struct UserExample : tvgexam::Example light->fill(255, 255, 255); mask5->mask(light, tvg::MaskMethod::Lighten); shape5->mask(mask5, tvg::MaskMethod::InvAlpha); - canvas->push(shape5); + canvas->add(shape5); //Shape + Shape Mask Darken auto shape6 = tvg::Shape::gen(); @@ -235,7 +235,7 @@ struct UserExample : tvgexam::Example dark->fill(255, 255, 255); mask6->mask(dark, tvg::MaskMethod::Darken); shape6->mask(mask6, tvg::MaskMethod::InvAlpha); - canvas->push(shape6); + canvas->add(shape6); } { //Rect + Rect Mask Add @@ -252,7 +252,7 @@ struct UserExample : tvgexam::Example add->fill(255, 255, 255); mask->mask(add, tvg::MaskMethod::Add); shape->mask(mask, tvg::MaskMethod::Alpha); - canvas->push(shape); + canvas->add(shape); //Rect + Rect Mask Subtract auto shape2 = tvg::Shape::gen(); @@ -268,7 +268,7 @@ struct UserExample : tvgexam::Example sub->fill(255, 255, 255); mask2->mask(sub, tvg::MaskMethod::Subtract); shape2->mask(mask2, tvg::MaskMethod::Alpha); - canvas->push(shape2); + canvas->add(shape2); //Rect + Rect Mask Intersect auto shape3 = tvg::Shape::gen(); @@ -284,7 +284,7 @@ struct UserExample : tvgexam::Example inter->fill(255, 255, 255); mask3->mask(inter, tvg::MaskMethod::Intersect); shape3->mask(mask3, tvg::MaskMethod::Alpha); - canvas->push(shape3); + canvas->add(shape3); //Rect + Rect Mask Difference auto shape4 = tvg::Shape::gen(); @@ -300,7 +300,7 @@ struct UserExample : tvgexam::Example diff->fill(255, 255, 255); mask4->mask(diff, tvg::MaskMethod::Difference); shape4->mask(mask4, tvg::MaskMethod::Alpha); - canvas->push(shape4); + canvas->add(shape4); //Rect + Rect Mask Lighten auto shape5 = tvg::Shape::gen(); @@ -316,7 +316,7 @@ struct UserExample : tvgexam::Example light->fill(255, 255, 255); mask5->mask(light, tvg::MaskMethod::Lighten); shape5->mask(mask5, tvg::MaskMethod::Alpha); - canvas->push(shape5); + canvas->add(shape5); //Rect + Rect Mask Darken auto shape6 = tvg::Shape::gen(); @@ -332,7 +332,7 @@ struct UserExample : tvgexam::Example dark->fill(255, 255, 255); mask6->mask(dark, tvg::MaskMethod::Darken); shape6->mask(mask6, tvg::MaskMethod::Alpha); - canvas->push(shape6); + canvas->add(shape6); } { //Transformed Image + Shape Mask Add @@ -351,7 +351,7 @@ struct UserExample : tvgexam::Example add->fill(255, 255, 255); mask->mask(add, tvg::MaskMethod::Add); image->mask(mask, tvg::MaskMethod::Alpha); - canvas->push(image); + canvas->add(image); //Transformed Image + Shape Mask Subtract auto image2 = tvg::Picture::gen(); @@ -369,7 +369,7 @@ struct UserExample : tvgexam::Example sub->fill(255, 255, 255); mask2->mask(sub, tvg::MaskMethod::Subtract); image2->mask(mask2, tvg::MaskMethod::Alpha); - canvas->push(image2); + canvas->add(image2); //Transformed Image + Shape Mask Intersect auto image3 = tvg::Picture::gen(); @@ -387,7 +387,7 @@ struct UserExample : tvgexam::Example inter->fill(255, 255, 255, 127); mask3->mask(inter, tvg::MaskMethod::Intersect); image3->mask(mask3, tvg::MaskMethod::Alpha); - canvas->push(image3); + canvas->add(image3); //Transformed Image + Shape Mask Difference auto image4 = tvg::Picture::gen(); @@ -405,7 +405,7 @@ struct UserExample : tvgexam::Example diff->fill(255, 255, 255); mask4->mask(diff, tvg::MaskMethod::Difference); image4->mask(mask4, tvg::MaskMethod::Alpha); - canvas->push(image4); + canvas->add(image4); //Transformed Image + Shape Mask Lighten auto image5 = tvg::Picture::gen(); @@ -423,7 +423,7 @@ struct UserExample : tvgexam::Example light->fill(255, 255, 255); mask5->mask(light, tvg::MaskMethod::Lighten); image5->mask(mask5, tvg::MaskMethod::Alpha); - canvas->push(image5); + canvas->add(image5); //Transformed Image + Shape Mask Darken auto image6 = tvg::Picture::gen(); @@ -441,7 +441,7 @@ struct UserExample : tvgexam::Example dark->fill(255, 255, 255); mask6->mask(dark, tvg::MaskMethod::Darken); image6->mask(mask6, tvg::MaskMethod::Alpha); - canvas->push(image6); + canvas->add(image6); } { //Transformed Image + Shape Mask Add @@ -460,7 +460,7 @@ struct UserExample : tvgexam::Example add->fill(255, 255, 255); mask->mask(add, tvg::MaskMethod::Add); image->mask(mask, tvg::MaskMethod::InvAlpha); - canvas->push(image); + canvas->add(image); //Transformed Image + Shape Mask Subtract auto image2 = tvg::Picture::gen(); @@ -478,7 +478,7 @@ struct UserExample : tvgexam::Example sub->fill(255, 255, 255); mask2->mask(sub, tvg::MaskMethod::Subtract); image2->mask(mask2, tvg::MaskMethod::InvAlpha); - canvas->push(image2); + canvas->add(image2); //Transformed Image + Shape Mask Intersect auto image3 = tvg::Picture::gen(); @@ -496,7 +496,7 @@ struct UserExample : tvgexam::Example inter->fill(255, 255, 255, 127); mask3->mask(inter, tvg::MaskMethod::Intersect); image3->mask(mask3, tvg::MaskMethod::InvAlpha); - canvas->push(image3); + canvas->add(image3); //Transformed Image + Shape Mask Difference auto image4 = tvg::Picture::gen(); @@ -514,7 +514,7 @@ struct UserExample : tvgexam::Example diff->fill(255, 255, 255); mask4->mask(diff, tvg::MaskMethod::Difference); image4->mask(mask4, tvg::MaskMethod::InvAlpha); - canvas->push(image4); + canvas->add(image4); //Transformed Image + Shape Mask Lighten auto image5 = tvg::Picture::gen(); @@ -532,7 +532,7 @@ struct UserExample : tvgexam::Example light->fill(255, 255, 255); mask5->mask(light, tvg::MaskMethod::Lighten); image5->mask(mask5, tvg::MaskMethod::InvAlpha); - canvas->push(image5); + canvas->add(image5); //Transformed Image + Shape Mask Darken auto image6 = tvg::Picture::gen(); @@ -550,7 +550,7 @@ struct UserExample : tvgexam::Example dark->fill(255, 255, 255); mask6->mask(dark, tvg::MaskMethod::Darken); image6->mask(mask6, tvg::MaskMethod::InvAlpha); - canvas->push(image6); + canvas->add(image6); } free(data); return true; diff --git a/src/MultiCanvas.cpp b/src/MultiCanvas.cpp index 4795e48..b29347d 100644 --- a/src/MultiCanvas.cpp +++ b/src/MultiCanvas.cpp @@ -38,7 +38,7 @@ void content(tvg::Canvas* canvas) auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, SIZE, SIZE); bg->fill(255, 255, 255); - canvas->push(bg); + canvas->add(bg); auto picture = tvg::Picture::gen(); picture->origin(0.5f, 0.5f); @@ -50,7 +50,7 @@ void content(tvg::Canvas* canvas) picture->scale(scale); picture->translate(SIZE * 0.5f, SIZE * 0.5f); - canvas->push(picture); + canvas->add(picture); } diff --git a/src/Opacity.cpp b/src/Opacity.cpp index 4b3a92a..afc9c28 100644 --- a/src/Opacity.cpp +++ b/src/Opacity.cpp @@ -38,7 +38,7 @@ struct UserExample : tvgexam::Example auto shape1 = tvg::Shape::gen(); shape1->appendCircle(400, 400, 250, 250); shape1->fill(255, 255, 0); - scene->push(shape1); + scene->add(shape1); //Round rectangle auto shape2 = tvg::Shape::gen(); @@ -46,10 +46,10 @@ struct UserExample : tvgexam::Example shape2->fill(0, 255, 0); shape2->strokeWidth(10); shape2->strokeFill(255, 255, 255); - scene->push(shape2); + scene->add(shape2); //Draw the Scene onto the Canvas - canvas->push(scene); + canvas->add(scene); //Create a Scene 2 auto scene2 = tvg::Scene::gen(); @@ -76,7 +76,7 @@ struct UserExample : tvgexam::Example shape3->strokeFill(255, 255, 255); shape3->opacity(127); - scene2->push(shape3); + scene2->add(shape3); //Circle auto shape4 = tvg::Shape::gen(); @@ -98,10 +98,10 @@ struct UserExample : tvgexam::Example shape4->strokeFill(0, 0, 255); shape4->opacity(200); shape4->scale(3); - scene2->push(shape4); + scene2->add(shape4); //Draw the Scene onto the Canvas - canvas->push(scene2); + canvas->add(scene2); return true; } diff --git a/src/Particles.cpp b/src/Particles.cpp index 9295400..9566900 100644 --- a/src/Particles.cpp +++ b/src/Particles.cpp @@ -47,12 +47,12 @@ struct UserExample : tvgexam::Example auto city = tvg::Picture::gen(); city->load(EXAMPLE_DIR"/image/particle.jpg"); - canvas->push(city); + canvas->add(city); auto cloud1 = tvg::Picture::gen(); cloud1->load(EXAMPLE_DIR"/image/clouds.png"); cloud1->opacity(60); - canvas->push(cloud1); + canvas->add(cloud1); float size; cloud1->size(&size, nullptr); @@ -61,21 +61,21 @@ struct UserExample : tvgexam::Example auto cloud2 = cloud1->duplicate(); cloud2->opacity(30); cloud2->translate(400, 100); - canvas->push(cloud2); + canvas->add(cloud2); clouds.push_back({cloud2, 400, 100, 0.125f, size}); auto cloud3 = cloud1->duplicate(); cloud3->opacity(20); cloud3->translate(1200, 200); - canvas->push(cloud3); + canvas->add(cloud3); clouds.push_back({cloud3, 1200, 200, 0.075f, size}); auto darkness = tvg::Shape::gen(); darkness->appendRect(0, 0, w, h); darkness->fill(0, 0, 0, 150); - canvas->push(darkness); + canvas->add(darkness); //rain drops size = w / COUNT; @@ -87,7 +87,7 @@ struct UserExample : tvgexam::Example raindrops.push_back({shape, x, float(rand()%h), 10 + float(rand() % 100) * 0.1f, 0 /* unused */}); shape->appendRect(0, 0, 1, rand() % 15 + size); shape->fill(255, 255, 255, 55 + rand() % 100); - canvas->push(shape); + canvas->add(shape); } this->w = w; diff --git a/src/Path.cpp b/src/Path.cpp index a93081c..a933a04 100644 --- a/src/Path.cpp +++ b/src/Path.cpp @@ -48,7 +48,7 @@ struct UserExample : tvgexam::Example shape1->lineTo(146, 143); shape1->close(); shape1->fill(0, 0, 255); - canvas->push(shape1); + canvas->add(shape1); //Circle auto shape2 = tvg::Shape::gen(); @@ -66,7 +66,7 @@ struct UserExample : tvgexam::Example shape2->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius); shape2->close(); shape2->fill(255, 0, 0); - canvas->push(shape2); + canvas->add(shape2); } //Commands Copy @@ -104,7 +104,7 @@ struct UserExample : tvgexam::Example shape1->appendPath(cmds, 11, pts, 10); //copy path data shape1->fill(0, 255, 0); shape1->translate(400, 0); - canvas->push(shape1); + canvas->add(shape1); /* Circle */ auto cx = 550.0f; @@ -145,7 +145,7 @@ struct UserExample : tvgexam::Example shape2->appendPath(cmds2, 6, pts2, 13); //copy path data shape2->fill(255, 255, 0); shape2->translate(-300, 0); - canvas->push(shape2); + canvas->add(shape2); } return true; diff --git a/src/PictureJpg.cpp b/src/PictureJpg.cpp index 7e0bab5..67ee1f2 100644 --- a/src/PictureJpg.cpp +++ b/src/PictureJpg.cpp @@ -40,7 +40,7 @@ struct UserExample : tvgexam::Example picture->rotate(30 * i); picture->size(200, 200); picture->opacity(opacity + opacity * i); - canvas->push(picture); + canvas->add(picture); } //Open file manually @@ -60,7 +60,7 @@ struct UserExample : tvgexam::Example free(data); picture->translate(400, 0); picture->scale(0.8); - canvas->push(picture); + canvas->add(picture); return true; } diff --git a/src/PicturePng.cpp b/src/PicturePng.cpp index a994081..b7358a3 100644 --- a/src/PicturePng.cpp +++ b/src/PicturePng.cpp @@ -34,7 +34,7 @@ struct UserExample : tvgexam::Example auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, w, h); //x, y, w, h bg->fill(255, 255, 255); //r, g, b - canvas->push(bg); + canvas->add(bg); //Load png file from path auto opacity = 31; @@ -46,7 +46,7 @@ struct UserExample : tvgexam::Example picture->rotate(30 * i); picture->size(200, 200); picture->opacity(opacity + opacity * i); - canvas->push(picture); + canvas->add(picture); } //Open file manually @@ -65,7 +65,7 @@ struct UserExample : tvgexam::Example free(data); picture->translate(380, 0); picture->scale(0.8); - canvas->push(picture); + canvas->add(picture); return true; } diff --git a/src/PictureRaw.cpp b/src/PictureRaw.cpp index e6f4e85..27a92f9 100644 --- a/src/PictureRaw.cpp +++ b/src/PictureRaw.cpp @@ -34,7 +34,7 @@ struct UserExample : tvgexam::Example auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, w, h); bg->fill(255, 255, 255); - canvas->push(bg); + canvas->add(bg); string path(EXAMPLE_DIR"/image/rawimage_200x300.raw"); ifstream file(path, ios::binary); @@ -46,7 +46,7 @@ struct UserExample : tvgexam::Example auto picture = tvg::Picture::gen(); if (!tvgexam::verify(picture->load(data, 200, 300, tvg::ColorSpace::ARGB8888, true))) return false; picture->translate(400, 250); - canvas->push(picture); + canvas->add(picture); auto picture2 = tvg::Picture::gen(); if (!tvgexam::verify(picture2->load(data, 200, 300, tvg::ColorSpace::ARGB8888, true))) return false; @@ -61,7 +61,7 @@ struct UserExample : tvgexam::Example picture2->clip(circle); - canvas->push(picture2); + canvas->add(picture2); free(data); diff --git a/src/PictureSvg.cpp b/src/PictureSvg.cpp index b373490..bc3b86e 100644 --- a/src/PictureSvg.cpp +++ b/src/PictureSvg.cpp @@ -43,7 +43,7 @@ struct UserExample : tvgexam::Example picture->rotate(30 * i); picture->size(200, 200); picture->opacity(opacity + opacity * i); - canvas->push(picture); + canvas->add(picture); } //Open file manually @@ -63,7 +63,7 @@ struct UserExample : tvgexam::Example free(data); picture->translate(400, 0); picture->scale(0.4); - canvas->push(picture); + canvas->add(picture); return true; } diff --git a/src/PictureWebp.cpp b/src/PictureWebp.cpp index 91a7345..4c594b3 100644 --- a/src/PictureWebp.cpp +++ b/src/PictureWebp.cpp @@ -34,7 +34,7 @@ struct UserExample : tvgexam::Example auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, w, h); //x, y, w, h bg->fill(255, 255, 255); //r, g, b - canvas->push(bg); + canvas->add(bg); //Load webp file from path auto opacity = 31; @@ -46,7 +46,7 @@ struct UserExample : tvgexam::Example picture->rotate(30 * i); picture->size(200, 200); picture->opacity(opacity + opacity * i); - canvas->push(picture); + canvas->add(picture); } //Open file manually @@ -65,7 +65,7 @@ struct UserExample : tvgexam::Example free(data); picture->translate(400, 0); picture->scale(0.8); - canvas->push(picture); + canvas->add(picture); return true; } diff --git a/src/RadialGradient.cpp b/src/RadialGradient.cpp index 3097b95..43fb897 100644 --- a/src/RadialGradient.cpp +++ b/src/RadialGradient.cpp @@ -46,7 +46,7 @@ struct UserExample : tvgexam::Example fill->colorStops(colorStops, 2); shape1->fill(fill); - canvas->push(shape1); + canvas->add(shape1); //Prepare Circle auto shape2 = tvg::Shape::gen(); @@ -65,7 +65,7 @@ struct UserExample : tvgexam::Example fill2->colorStops(colorStops2, 3); shape2->fill(fill2); - canvas->push(shape2); + canvas->add(shape2); //Prepare Ellipse auto shape3 = tvg::Shape::gen(); @@ -85,7 +85,7 @@ struct UserExample : tvgexam::Example fill3->colorStops(colorStops3, 4); shape3->fill(fill3); - canvas->push(shape3); + canvas->add(shape3); return true; } diff --git a/src/Retaining.cpp b/src/Retaining.cpp index da6f685..737e936 100644 --- a/src/Retaining.cpp +++ b/src/Retaining.cpp @@ -36,19 +36,19 @@ struct UserExample : tvgexam::Example auto shape1 = tvg::Shape::gen(); shape1->appendRect(0, 0, 480, 480, 50, 50); //x, y, w, h, rx, ry shape1->fill(0, 255, 0); //r, g, b - canvas->push(shape1); + canvas->add(shape1); //Prepare Round Rectangle2 auto shape2 = tvg::Shape::gen(); shape2->appendRect(140, 140, 480, 480, 50, 50); //x, y, w, h, rx, ry shape2->fill(255, 255, 0); //r, g, b - canvas->push(shape2); + canvas->add(shape2); //Prepare Round Rectangle3 auto shape3 = tvg::Shape::gen(); shape3->appendRect(280, 280, 480, 480, 50, 50); //x, y, w, h, rx, ry shape3->fill(0, 255, 255); //r, g, b - canvas->push(shape3); + canvas->add(shape3); //Prepare Scene auto scene = tvg::Scene::gen(); @@ -58,16 +58,16 @@ struct UserExample : tvgexam::Example shape4->fill(255, 0, 0); shape4->strokeWidth(5); shape4->strokeFill(255, 255, 255); - scene->push(shape4); + scene->add(shape4); auto shape5 = tvg::Shape::gen(); shape5->appendCircle(630, 630, 190, 190); shape5->fill(255, 0, 255); shape5->strokeWidth(5); shape5->strokeFill(255, 255, 255); - scene->push(shape5); + scene->add(shape5); - canvas->push(scene); + canvas->add(scene); return true; } @@ -84,9 +84,9 @@ struct UserExample : tvgexam::Example //Prevent deleting from canvas->remove() paint->ref(); - //Re-push the front paint to the end of the root scene + //Add again the front paint to the end of the root scene tvgexam::verify(canvas->remove(paint)); - tvgexam::verify(canvas->push(paint)); + tvgexam::verify(canvas->add(paint)); //Make it pair ref() - unref() paint->unref(); diff --git a/src/Scene.cpp b/src/Scene.cpp index b20fc86..9217006 100644 --- a/src/Scene.cpp +++ b/src/Scene.cpp @@ -37,19 +37,19 @@ struct UserExample : tvgexam::Example auto shape1 = tvg::Shape::gen(); shape1->appendRect(0, 0, 400, 400, 50, 50); //x, y, w, h, rx, ry shape1->fill(0, 255, 0); //r, g, b - scene->push(shape1); + scene->add(shape1); //Prepare Circle auto shape2 = tvg::Shape::gen(); shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH shape2->fill(255, 255, 0); //r, g, b - scene->push(shape2); + scene->add(shape2); //Prepare Ellipse auto shape3 = tvg::Shape::gen(); shape3->appendCircle(600, 600, 150, 100); //cx, cy, radiusW, radiusH shape3->fill(0, 255, 255); //r, g, b - scene->push(shape3); + scene->add(shape3); //Create another Scene auto scene2 = tvg::Scene::gen(); @@ -70,7 +70,7 @@ struct UserExample : tvgexam::Example shape4->lineTo(146, 143); shape4->close(); shape4->fill(0, 0, 255); - scene2->push(shape4); + scene2->add(shape4); //Circle auto shape5 = tvg::Shape::gen(); @@ -87,13 +87,13 @@ struct UserExample : tvgexam::Example 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); - scene2->push(shape5); + scene2->add(shape5); - //Push scene2 onto the scene - scene->push(scene2); + //Add scene2 to the scene + scene->add(scene2); - //Draw the Scene onto the Canvas - canvas->push(scene); + //Add the Scene to the Canvas + canvas->add(scene); return true; } diff --git a/src/SceneBlending.cpp b/src/SceneBlending.cpp index d7a9a16..0e8cbbe 100644 --- a/src/SceneBlending.cpp +++ b/src/SceneBlending.cpp @@ -34,7 +34,7 @@ struct UserExample : tvgexam::Example auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, w, h); bg->fill(100, 100, 100); - canvas->push(bg); + canvas->add(bg); //Create a Scene auto scene = tvg::Scene::gen(); @@ -44,7 +44,7 @@ struct UserExample : tvgexam::Example auto shape1 = tvg::Shape::gen(); shape1->appendCircle(400, 400, 250, 250); shape1->fill(255, 255, 0); - scene->push(shape1); + scene->add(shape1); //Round rectangle auto shape2 = tvg::Shape::gen(); @@ -52,10 +52,10 @@ struct UserExample : tvgexam::Example shape2->fill(0, 255, 0); shape2->strokeWidth(10); shape2->strokeFill(255, 255, 255); - scene->push(shape2); + scene->add(shape2); //Draw the Scene onto the Canvas - canvas->push(scene); + canvas->add(scene); //Create a Scene 2 auto scene2 = tvg::Scene::gen(); @@ -83,7 +83,7 @@ struct UserExample : tvgexam::Example shape3->strokeFill(255, 255, 255); shape3->opacity(127); - scene2->push(shape3); + scene2->add(shape3); //Circle auto shape4 = tvg::Shape::gen(); @@ -105,10 +105,10 @@ struct UserExample : tvgexam::Example shape4->strokeFill(0, 0, 255); shape4->opacity(200); shape4->scale(3); - scene2->push(shape4); + scene2->add(shape4); //Draw the Scene onto the Canvas - canvas->push(scene2); + canvas->add(scene2); return true; } diff --git a/src/SceneEffects.cpp b/src/SceneEffects.cpp index 3ce3632..2976b38 100644 --- a/src/SceneEffects.cpp +++ b/src/SceneEffects.cpp @@ -46,8 +46,8 @@ struct UserExample : tvgexam::Example picture->size(SIZE, SIZE); picture->translate(SIZE * i, 0); - blur[i]->push(picture); - canvas->push(blur[i]); + blur[i]->add(picture); + canvas->add(blur[i]); } //fill scene @@ -59,8 +59,8 @@ struct UserExample : tvgexam::Example picture->size(SIZE, SIZE); picture->translate(0, SIZE); - fill->push(picture); - canvas->push(fill); + fill->add(picture); + canvas->add(fill); } //tint scene @@ -72,8 +72,8 @@ struct UserExample : tvgexam::Example picture->size(SIZE, SIZE); picture->translate(SIZE, SIZE); - tint->push(picture); - canvas->push(tint); + tint->add(picture); + canvas->add(tint); } //trinton scene @@ -85,8 +85,8 @@ struct UserExample : tvgexam::Example picture->size(SIZE, SIZE); picture->translate(SIZE * 2, SIZE); - trintone->push(picture); - canvas->push(trintone); + trintone->add(picture); + canvas->add(trintone); } @@ -99,21 +99,21 @@ struct UserExample : tvgexam::Example //Apply GaussianBlur post effect (sigma, direction, border option, quality) for (int i = 0; i < 3; ++i) { - blur[i]->push(tvg::SceneEffect::ClearAll); - blur[i]->push(tvg::SceneEffect::GaussianBlur, 10.0 * double(progress), i, 0, 100); + blur[i]->add(tvg::SceneEffect::Clear); + blur[i]->add(tvg::SceneEffect::GaussianBlur, 10.0 * double(progress), i, 0, 100); } //Apply Fill post effect (rgba) - fill->push(tvg::SceneEffect::ClearAll); - fill->push(tvg::SceneEffect::Fill, 0, (int)(progress * 255), 0, (int)(255.0f * progress)); + fill->add(tvg::SceneEffect::Clear); + fill->add(tvg::SceneEffect::Fill, 0, (int)(progress * 255), 0, (int)(255.0f * progress)); //Apply Tint post effect (black:rgb, white:rgb, intensity) - tint->push(tvg::SceneEffect::ClearAll); - tint->push(tvg::SceneEffect::Tint, 0, 0, 0, 0, (int)(progress * 255), 0, (double)(progress * 100.0f)); + tint->add(tvg::SceneEffect::Clear); + tint->add(tvg::SceneEffect::Tint, 0, 0, 0, 0, (int)(progress * 255), 0, (double)(progress * 100.0f)); //Apply Tritone post effect (shadow:rgb, midtone:rgb, highlight:rgb, blending with original) - trintone->push(tvg::SceneEffect::ClearAll); - trintone->push(tvg::SceneEffect::Tritone, 0, (int)(progress * 255), 0, 199, 110, 36, 255, 255, 255, 0); + trintone->add(tvg::SceneEffect::Clear); + trintone->add(tvg::SceneEffect::Tritone, 0, (int)(progress * 255), 0, 199, 110, 36, 255, 255, 255, 0); canvas->update(); diff --git a/src/SceneTransform.cpp b/src/SceneTransform.cpp index a7016f0..6ad07f4 100644 --- a/src/SceneTransform.cpp +++ b/src/SceneTransform.cpp @@ -48,19 +48,19 @@ struct UserExample : tvgexam::Example shape1->fill(0, 255, 0); //r, g, b shape1->strokeWidth(5); //width shape1->strokeFill(255, 255, 255); //r, g, b - scene->push(shape1); + scene->add(shape1); //Prepare Circle (Scene1) auto shape2 = tvg::Shape::gen(); shape2->appendCircle(-165, -150, 200, 200); //cx, cy, radiusW, radiusH shape2->fill(255, 255, 0); //r, g, b - scene->push(shape2); + scene->add(shape2); //Prepare Ellipse (Scene1) auto shape3 = tvg::Shape::gen(); shape3->appendCircle(265, 250, 150, 100); //cx, cy, radiusW, radiusH shape3->fill(0, 255, 255); //r, g, b - scene->push(shape3); + scene->add(shape3); scene->translate(430, 430); scene->scale(0.7f); @@ -87,7 +87,7 @@ struct UserExample : tvgexam::Example shape4->fill(0, 0, 255, 127); shape4->strokeWidth(3); //width shape4->strokeFill(0, 0, 255); //r, g, b - scene2->push(shape4); + scene2->add(shape4); //Circle (Scene2) auto shape5 = tvg::Shape::gen(); @@ -105,16 +105,16 @@ struct UserExample : tvgexam::Example shape5->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius); shape5->close(); shape5->fill(255, 0, 0, 127); - scene2->push(shape5); + scene2->add(shape5); scene2->translate(500, 350); scene2->rotate(360 * progress); - //Push scene2 onto the scene - scene->push(scene2); + //Add scene2 to the scene + scene->add(scene2); - //Draw the Scene onto the Canvas - canvas->push(scene); + //Add the Scene to the Canvas + canvas->add(scene); return true; } diff --git a/src/Shapes.cpp b/src/Shapes.cpp index 66fd6e2..f1ef95b 100644 --- a/src/Shapes.cpp +++ b/src/Shapes.cpp @@ -36,25 +36,25 @@ struct UserExample : tvgexam::Example shape4->appendCircle(400, 150, 150, 150); //cx, cy, radiusW, radiusH shape4->appendCircle(600, 150, 150, 100); //cx, cy, radiusW, radiusH shape4->fill(255, 255, 0); //r, g, b - canvas->push(shape4); + canvas->add(shape4); //Prepare Round Rectangle auto shape1 = tvg::Shape::gen(); shape1->appendRect(0, 450, 300, 300, 50, 50); //x, y, w, h, rx, ry shape1->fill(0, 255, 0); //r, g, b - canvas->push(shape1); + canvas->add(shape1); //Prepare Circle auto shape2 = tvg::Shape::gen(); shape2->appendCircle(400, 600, 150, 150); //cx, cy, radiusW, radiusH shape2->fill(255, 255, 0); //r, g, b - canvas->push(shape2); + canvas->add(shape2); //Prepare Ellipse auto shape3 = tvg::Shape::gen(); shape3->appendCircle(600, 600, 150, 100); //cx, cy, radiusW, radiusH shape3->fill(0, 255, 255); //r, g, b - canvas->push(shape3); + canvas->add(shape3); return true; } diff --git a/src/Stress.cpp b/src/Stress.cpp index d830f86..7852c5c 100644 --- a/src/Stress.cpp +++ b/src/Stress.cpp @@ -37,7 +37,7 @@ struct UserExample : tvgexam::Example s->fill(rand() % 255, rand() % 255, rand() % 255, 253 + rand() % 3); s->strokeFill(255, 255, 255); s->strokeWidth(3); - canvas->push(s); + canvas->add(s); } return true; } diff --git a/src/Stroke.cpp b/src/Stroke.cpp index a02474f..b0d95ed 100644 --- a/src/Stroke.cpp +++ b/src/Stroke.cpp @@ -38,7 +38,7 @@ struct UserExample : tvgexam::Example shape1->strokeJoin(tvg::StrokeJoin::Bevel); //default is Bevel shape1->strokeWidth(10); //width: 10px - canvas->push(shape1); + canvas->add(shape1); //Shape 2 auto shape2 = tvg::Shape::gen(); @@ -48,7 +48,7 @@ struct UserExample : tvgexam::Example shape2->strokeJoin(tvg::StrokeJoin::Round); shape2->strokeWidth(10); - canvas->push(shape2); + canvas->add(shape2); //Shape 3 auto shape3 = tvg::Shape::gen(); @@ -58,7 +58,7 @@ struct UserExample : tvgexam::Example shape3->strokeJoin(tvg::StrokeJoin::Miter); shape3->strokeWidth(10); - canvas->push(shape3); + canvas->add(shape3); //Shape 4 auto shape4 = tvg::Shape::gen(); @@ -67,7 +67,7 @@ struct UserExample : tvgexam::Example shape4->strokeFill(255, 255, 255); shape4->strokeWidth(1); - canvas->push(shape4); + canvas->add(shape4); //Shape 5 auto shape5 = tvg::Shape::gen(); @@ -76,7 +76,7 @@ struct UserExample : tvgexam::Example shape5->strokeFill(255, 255, 255); shape5->strokeWidth(2); - canvas->push(shape5); + canvas->add(shape5); //Shape 6 auto shape6 = tvg::Shape::gen(); @@ -85,7 +85,7 @@ struct UserExample : tvgexam::Example shape6->strokeFill(255, 255, 255); shape6->strokeWidth(4); - canvas->push(shape6); + canvas->add(shape6); //Stroke width test for (int i = 0; i < 10; ++i) { @@ -95,7 +95,7 @@ struct UserExample : tvgexam::Example hline->strokeFill(255, 255, 255); //color: r, g, b hline->strokeWidth(i + 1); //stroke width hline->strokeCap(tvg::StrokeCap::Round); //default is Square - canvas->push(hline); + canvas->add(hline); auto vline = tvg::Shape::gen(); vline->moveTo(500 + (25 * i), 550); @@ -103,7 +103,7 @@ struct UserExample : tvgexam::Example vline->strokeFill(255, 255, 255); //color: r, g, b vline->strokeWidth(i + 1); //stroke width vline->strokeCap(tvg::StrokeCap::Round); //default is Square - canvas->push(vline); + canvas->add(vline); } //Stroke cap test @@ -116,15 +116,15 @@ struct UserExample : tvgexam::Example auto line2 = static_cast(line1->duplicate()); auto line3 = static_cast(line1->duplicate()); - canvas->push(line1); + canvas->add(line1); line2->strokeCap(tvg::StrokeCap::Square); line2->translate(0, 50); - canvas->push(line2); + canvas->add(line2); line3->strokeCap(tvg::StrokeCap::Butt); line3->translate(0, 100); - canvas->push(line3); + canvas->add(line3); return true; } diff --git a/src/StrokeLine.cpp b/src/StrokeLine.cpp index 695c881..9272ed7 100644 --- a/src/StrokeLine.cpp +++ b/src/StrokeLine.cpp @@ -41,7 +41,7 @@ struct UserExample : tvgexam::Example shape1->strokeWidth(10); shape1->strokeJoin(tvg::StrokeJoin::Round); shape1->strokeCap(tvg::StrokeCap::Round); - canvas->push(shape1); + canvas->add(shape1); auto shape2 = tvg::Shape::gen(); shape2->moveTo(270, 50); @@ -53,7 +53,7 @@ struct UserExample : tvgexam::Example shape2->strokeWidth(10); shape2->strokeJoin(tvg::StrokeJoin::Bevel); shape2->strokeCap(tvg::StrokeCap::Square); - canvas->push(shape2); + canvas->add(shape2); auto shape3 = tvg::Shape::gen(); shape3->moveTo(520, 50); @@ -65,7 +65,7 @@ struct UserExample : tvgexam::Example shape3->strokeWidth(10); shape3->strokeJoin(tvg::StrokeJoin::Miter); shape3->strokeCap(tvg::StrokeCap::Butt); - canvas->push(shape3); + canvas->add(shape3); //Stroke Dash auto shape4 = tvg::Shape::gen(); @@ -81,7 +81,7 @@ struct UserExample : tvgexam::Example float dashPattern1[2] = {20, 10}; shape4->strokeDash(dashPattern1, 2); - canvas->push(shape4); + canvas->add(shape4); auto shape5 = tvg::Shape::gen(); shape5->moveTo(270, 230); @@ -96,7 +96,7 @@ struct UserExample : tvgexam::Example float dashPattern2[2] = {10, 10}; shape5->strokeDash(dashPattern2, 2); - canvas->push(shape5); + canvas->add(shape5); auto shape6 = tvg::Shape::gen(); shape6->moveTo(520, 230); @@ -111,7 +111,7 @@ struct UserExample : tvgexam::Example float dashPattern3[6] = {10, 10, 1, 8, 1, 10}; shape6->strokeDash(dashPattern3, 6); - canvas->push(shape6); + canvas->add(shape6); //Closed Shape Stroke auto shape7 = tvg::Shape::gen(); @@ -123,7 +123,7 @@ struct UserExample : tvgexam::Example shape7->strokeWidth(15); shape7->strokeJoin(tvg::StrokeJoin::Round); shape7->strokeCap(tvg::StrokeCap::Round); - canvas->push(shape7); + canvas->add(shape7); auto shape8 = tvg::Shape::gen(); shape8->moveTo(320, 440); @@ -134,7 +134,7 @@ struct UserExample : tvgexam::Example shape8->strokeWidth(15); shape8->strokeJoin(tvg::StrokeJoin::Bevel); shape8->strokeCap(tvg::StrokeCap::Square); - canvas->push(shape8); + canvas->add(shape8); auto shape9 = tvg::Shape::gen(); shape9->moveTo(570, 440); @@ -145,7 +145,7 @@ struct UserExample : tvgexam::Example shape9->strokeWidth(15); shape9->strokeJoin(tvg::StrokeJoin::Miter); shape9->strokeCap(tvg::StrokeCap::Butt); - canvas->push(shape9); + canvas->add(shape9); //Stroke Dash for Circle and Rect auto shape10 = tvg::Shape::gen(); @@ -156,7 +156,7 @@ struct UserExample : tvgexam::Example shape10->strokeJoin(tvg::StrokeJoin::Round); shape10->strokeCap(tvg::StrokeCap::Round); shape10->strokeDash(dashPattern1, 2); - canvas->push(shape10); + canvas->add(shape10); auto shape11 = tvg::Shape::gen(); shape11->appendCircle(320, 700, 20, 60); @@ -166,7 +166,7 @@ struct UserExample : tvgexam::Example shape11->strokeJoin(tvg::StrokeJoin::Bevel); shape11->strokeCap(tvg::StrokeCap::Square); shape11->strokeDash(dashPattern2, 2); - canvas->push(shape11); + canvas->add(shape11); auto shape12 = tvg::Shape::gen(); shape12->appendCircle(570, 700, 20, 60); @@ -176,7 +176,7 @@ struct UserExample : tvgexam::Example shape12->strokeJoin(tvg::StrokeJoin::Miter); shape12->strokeCap(tvg::StrokeCap::Butt); shape12->strokeDash(dashPattern3, 6); - canvas->push(shape12); + canvas->add(shape12); //Zero length Dashes float dashPattern[] = {0, 20}; @@ -189,7 +189,7 @@ struct UserExample : tvgexam::Example shape13->strokeDash(dashPattern, 2); shape13->strokeJoin(tvg::StrokeJoin::Round); shape13->strokeCap(tvg::StrokeCap::Round); - canvas->push(shape13); + canvas->add(shape13); auto shape14 = tvg::Shape::gen(); shape14->appendCircle(320, 850, 20, 60); @@ -199,7 +199,7 @@ struct UserExample : tvgexam::Example shape14->strokeDash(dashPattern, 2); shape14->strokeJoin(tvg::StrokeJoin::Bevel); shape14->strokeCap(tvg::StrokeCap::Square); - canvas->push(shape14); + canvas->add(shape14); auto shape15 = tvg::Shape::gen(); shape15->appendCircle(570, 850, 20, 60); @@ -209,7 +209,7 @@ struct UserExample : tvgexam::Example shape15->strokeDash(dashPattern, 2); shape15->strokeJoin(tvg::StrokeJoin::Miter); shape15->strokeCap(tvg::StrokeCap::Butt); //butt has no cap expansions, so no visible - canvas->push(shape15); + canvas->add(shape15); return true; } diff --git a/src/StrokeMiterlimit.cpp b/src/StrokeMiterlimit.cpp index 08ca03e..86ddf0c 100644 --- a/src/StrokeMiterlimit.cpp +++ b/src/StrokeMiterlimit.cpp @@ -35,7 +35,7 @@ struct UserExample : tvgexam::Example auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, w, h); //x, y, w, h bg->fill(200, 200, 255); //r, g, b - canvas->push(bg); + canvas->add(bg); } //wild @@ -65,7 +65,7 @@ struct UserExample : tvgexam::Example static float ml = path->strokeMiterlimit(); cout << "stroke miterlimit = " << ml << endl; - canvas->push(path); + canvas->add(path); } //blueprint @@ -78,7 +78,7 @@ struct UserExample : tvgexam::Example picture->opacity(42); picture->translate(24, 0); - canvas->push(picture); + canvas->add(picture); } //svg @@ -138,7 +138,7 @@ struct UserExample : tvgexam::Example auto picture = tvg::Picture::gen(); if (!tvgexam::verify(picture->load(svgText.data(), svgText.size(), "svg", "", true))) return false; picture->scale(20); - canvas->push(picture); + canvas->add(picture); } return true; diff --git a/src/Svg.cpp b/src/Svg.cpp index bbd6943..4922e48 100644 --- a/src/Svg.cpp +++ b/src/Svg.cpp @@ -73,7 +73,7 @@ struct UserExample : tvgexam::Example shape->appendRect(0, 0, w, h); shape->fill(255, 255, 255); - canvas->push(shape); + canvas->add(shape); this->w = w; this->h = h; @@ -82,11 +82,11 @@ struct UserExample : tvgexam::Example this->scandir(EXAMPLE_DIR"/svg"); /* This showcase demonstrates the asynchronous loading of tvg. - For this, pictures are pushed at a certain sync time. + For this, pictures are added at a certain sync time. This allows time for the tvg resources to finish loading; - otherwise, you can push pictures immediately. */ + otherwise, you can add pictures immediately. */ for (auto& paint : pictures) { - canvas->push(paint); + canvas->add(paint); } pictures.clear(); diff --git a/src/Text.cpp b/src/Text.cpp index 569ed8a..6e8af12 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -34,7 +34,7 @@ struct UserExample : tvgexam::Example auto shape = tvg::Shape::gen(); shape->appendRect(0, 0, w, h); shape->fill(75, 75, 75); - canvas->push(shape); + canvas->add(shape); //Load a necessary font data. //The loaded font will be released when the Initializer::term() is called. @@ -62,7 +62,7 @@ struct UserExample : tvgexam::Example text->size(80); text->text("THORVG Text"); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); auto text2 = tvg::Text::gen(); text2->font("Arial"); @@ -71,7 +71,7 @@ struct UserExample : tvgexam::Example text2->text("Font = \"Arial\", Size = 40, Style = Italic"); text2->translate(0, 150); text2->fill(255, 255, 255); - canvas->push(text2); + canvas->add(text2); auto text3 = tvg::Text::gen(); text3->font(nullptr); //Use any font @@ -79,7 +79,7 @@ struct UserExample : tvgexam::Example text3->text("Kerning Test: VA, AV, TJ, JT"); text3->fill(255, 255, 255); text3->translate(0, 225); - canvas->push(text3); + canvas->add(text3); auto text4 = tvg::Text::gen(); text4->font("Arial"); @@ -87,7 +87,7 @@ struct UserExample : tvgexam::Example text4->text("Purple Text"); text4->fill(255, 0, 255); text4->translate(0, 310); - canvas->push(text4); + canvas->add(text4); auto text5 = tvg::Text::gen(); text5->font("Arial"); @@ -95,7 +95,7 @@ struct UserExample : tvgexam::Example text5->text("Gray Text"); text5->fill(150, 150, 150); text5->translate(220, 310); - canvas->push(text5); + canvas->add(text5); auto text6 = tvg::Text::gen(); text6->font("Arial"); @@ -103,7 +103,7 @@ struct UserExample : tvgexam::Example text6->text("Yellow Text"); text6->fill(255, 255, 0); text6->translate(400, 310); - canvas->push(text6); + canvas->add(text6); auto text7 = tvg::Text::gen(); text7->font("NOTO-SANS-KR"); @@ -112,7 +112,7 @@ struct UserExample : tvgexam::Example text7->fill(0, 0, 0); text7->translate(600, 400); text7->rotate(30); - canvas->push(text7); + canvas->add(text7); auto text8 = tvg::Text::gen(); text8->font("NOTO-SANS-KR"); @@ -121,7 +121,7 @@ struct UserExample : tvgexam::Example text8->text("Transformed Text - 90'"); text8->translate(600, 400); text8->rotate(90); - canvas->push(text8); + canvas->add(text8); auto text9 = tvg::Text::gen(); text9->font("NOTO-SANS-KR"); @@ -130,7 +130,7 @@ struct UserExample : tvgexam::Example text9->text("Transformed Text - 180'"); text9->translate(800, 400); text9->rotate(180); - canvas->push(text9); + canvas->add(text9); //gradient texts float x, y, w2, h2; @@ -155,7 +155,7 @@ struct UserExample : tvgexam::Example text10->translate(0, 350); - canvas->push(text10); + canvas->add(text10); auto text11 = tvg::Text::gen(); text11->font("NanumGothicCoding"); @@ -179,7 +179,7 @@ struct UserExample : tvgexam::Example text11->translate(0, 450); - canvas->push(text11); + canvas->add(text11); auto text12 = tvg::Text::gen(); text12->font("SentyCloud"); @@ -188,7 +188,7 @@ struct UserExample : tvgexam::Example text12->outline(3, 255, 200, 200); text12->text("\xe4\xb8\x8d\xe5\x88\xb0\xe9\x95\xbf\xe5\x9f\x8e\xe9\x9d\x9e\xe5\xa5\xbd\xe6\xb1\x89\xef\xbc\x81"); text12->translate(0, 525); - canvas->push(text12); + canvas->add(text12); auto text13 = tvg::Text::gen(); text13->font("Arial"); @@ -196,7 +196,7 @@ struct UserExample : tvgexam::Example text13->fill(255, 255, 255); text13->text("LINE-FEED TEST. THIS IS THE FIRST LINE - \nTHIS IS THE SECOND LINE."); text13->translate(0, 625); - canvas->push(text13); + canvas->add(text13); auto text14 = tvg::Text::gen(); text14->font("Arial"); @@ -205,7 +205,7 @@ struct UserExample : tvgexam::Example text14->spacing(1.5f, 1.5f); text14->text("1.5x SPACING TEST. THIS IS THE FIRST LINE - \nTHIS IS THE SECOND LINE."); text14->translate(0, 700); - canvas->push(text14); + canvas->add(text14); return true; } diff --git a/src/TextEffects.cpp b/src/TextEffects.cpp index 4408728..b2740c6 100644 --- a/src/TextEffects.cpp +++ b/src/TextEffects.cpp @@ -45,7 +45,7 @@ struct UserExample : tvgexam::Example auto shape = tvg::Shape::gen(); shape->appendRect(0, 0, 600, 600); shape->fill(50, 50, 50); - canvas->push(shape); + canvas->add(shape); // Rainbow effect on title float r = std::sin(time) * 127 + 128; @@ -62,7 +62,7 @@ struct UserExample : tvgexam::Example float x, y, w, h; animTitle->bounds(&x, &y, &w, &h); animTitle->translate(300 - w * 0.5f, 150 - h * 0.5f); - canvas->push(animTitle); + canvas->add(animTitle); // Pulsing subtitle float scale = 1 + std::sin(time * 2) * 0.1f; @@ -74,7 +74,7 @@ struct UserExample : tvgexam::Example animSubtitle->bounds(&x, &y, &w, &h); animSubtitle->translate(300 - w * 0.5f, 220 - h * 0.5f); - canvas->push(animSubtitle); + canvas->add(animSubtitle); // Rotating text auto rotatingText = tvg::Text::gen(); @@ -101,7 +101,7 @@ struct UserExample : tvgexam::Example tvg::Matrix m = {cosVal, -sinVal, tx, sinVal, cosVal, ty, 0, 0, 1}; rotatingText->transform(m); - canvas->push(rotatingText); + canvas->add(rotatingText); // Wave effect text size_t waveLen = strlen(waveText); @@ -118,7 +118,7 @@ struct UserExample : tvgexam::Example charText->bounds(&x, &y, &w, &h); charText->translate(150 + i * 30 - w * 0.5f, 400 + yOffset - h * 0.5f); - canvas->push(charText); + canvas->add(charText); } canvas->update(); diff --git a/src/TextLayout.cpp b/src/TextLayout.cpp index 408426b..4fdf603 100644 --- a/src/TextLayout.cpp +++ b/src/TextLayout.cpp @@ -58,7 +58,7 @@ struct UserExample : tvgexam::Example lines->close(); lines->moveTo(900, 0); lines->lineTo(900, h); - canvas->push(lines); + canvas->add(lines); auto fontSize = 15.0f; w -= border * 2.0f; @@ -74,7 +74,7 @@ struct UserExample : tvgexam::Example text->layout(w, h); text->text("Top-Left"); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); } //top center @@ -87,7 +87,7 @@ struct UserExample : tvgexam::Example text->layout(w, h); text->text("Top-Center"); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); } //top right @@ -100,7 +100,7 @@ struct UserExample : tvgexam::Example text->layout(w, h); text->text("Top-End"); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); } //middle left @@ -113,7 +113,7 @@ struct UserExample : tvgexam::Example text->layout(w, h); text->text("Middle-Left"); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); } //middle center @@ -126,7 +126,7 @@ struct UserExample : tvgexam::Example text->layout(w, h); text->text("Middle-Center"); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); } //middle right @@ -139,7 +139,7 @@ struct UserExample : tvgexam::Example text->layout(w, h); text->text("Middle-End"); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); } //bottom left @@ -152,7 +152,7 @@ struct UserExample : tvgexam::Example text->layout(w, h); text->text("Bottom-Left"); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); } //bottom center @@ -165,7 +165,7 @@ struct UserExample : tvgexam::Example text->layout(w, h); text->text("Bottom-Center"); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); } //bottom right @@ -178,7 +178,7 @@ struct UserExample : tvgexam::Example text->layout(w, h); text->text("Bottom-End"); text->fill(255, 255, 255); - canvas->push(text); + canvas->add(text); } //origin @@ -193,7 +193,7 @@ struct UserExample : tvgexam::Example text->fill(255, 255, 255); text->translate(900, 200 + i * 100); text->align(alignments[i].x, alignments[i].y); - canvas->push(text); + canvas->add(text); } return true; diff --git a/src/TextLineWrap.cpp b/src/TextLineWrap.cpp index ecd848f..f89da9d 100644 --- a/src/TextLineWrap.cpp +++ b/src/TextLineWrap.cpp @@ -38,13 +38,13 @@ struct UserExample : tvgexam::Example txt->size(12); txt->text(title); txt->fill(200, 200, 200); - canvas->push(txt); + canvas->add(txt); auto lines = tvg::Shape::gen(); lines->strokeFill(100, 100, 100); lines->strokeWidth(1); lines->appendRect(x, y + 30.0f, size.x, size.y); - canvas->push(lines); + canvas->add(lines); } void text(tvg::Canvas* canvas, const char* content, const tvg::Point& pos, const tvg::Point& align, tvg::TextWrap wrapMode) @@ -58,7 +58,7 @@ struct UserExample : tvgexam::Example txt->align(align.x, align.y); txt->wrap(wrapMode); txt->fill(255, 255, 255); - canvas->push(txt); + canvas->add(txt); } bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override diff --git a/src/Transform.cpp b/src/Transform.cpp index b1d9074..0b364fc 100644 --- a/src/Transform.cpp +++ b/src/Transform.cpp @@ -50,7 +50,7 @@ struct UserExample : tvgexam::Example shape->scale(1.0f - 0.75f * progress); shape->rotate(360 * progress); - canvas->push(shape); + canvas->add(shape); //Shape2 auto shape2 = tvg::Shape::gen(); @@ -59,7 +59,7 @@ struct UserExample : tvgexam::Example shape2->translate(480, 480); shape2->rotate(360 * progress); shape2->translate(400 + progress * 300, 400); - canvas->push(shape2); + canvas->add(shape2); //Shape3 auto shape3 = tvg::Shape::gen(); @@ -71,7 +71,7 @@ struct UserExample : tvgexam::Example shape3->translate(560, 560); shape3->rotate(-360.0f * progress); shape3->scale(0.5f + progress); - canvas->push(shape3); + canvas->add(shape3); return true; } diff --git a/src/TrimPath.cpp b/src/TrimPath.cpp index 195546d..3ff228e 100644 --- a/src/TrimPath.cpp +++ b/src/TrimPath.cpp @@ -52,8 +52,8 @@ struct UserExample : tvgexam::Example shape2->strokeDash(dashPatterns, 2, 10); shape2->trimpath(0.25f, 0.75f, true); - canvas->push(shape1); - canvas->push(shape2); + canvas->add(shape1); + canvas->add(shape2); return true; } diff --git a/src/Viewport.cpp b/src/Viewport.cpp index 1b950ae..527802b 100644 --- a/src/Viewport.cpp +++ b/src/Viewport.cpp @@ -47,7 +47,7 @@ struct UserExample : tvgexam::Example if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/svg/tiger.svg"))) return false; picture->size(w, h); picture->mask(mask, tvg::MaskMethod::Alpha); - canvas->push(picture); + canvas->add(picture); this->w = w; this->h = h; From 95ffddb1dfeea7107e27bced44b1dd7745407e92 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 16 Jan 2026 13:19:30 +0900 Subject: [PATCH 2/2] activate capi example - this example is enabled at compilation if the system has thorvg_capi - revised the lottie compilation with more precise symbol check --- src/Capi.cpp | 350 ++++++++++++++++++++++++++++++++++++++++++++++++ src/meson.build | 22 ++- 2 files changed, 369 insertions(+), 3 deletions(-) create mode 100644 src/Capi.cpp diff --git a/src/Capi.cpp b/src/Capi.cpp new file mode 100644 index 0000000..d98cc9f --- /dev/null +++ b/src/Capi.cpp @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2020 - 2026 the ThorVG project. All rights reserved. + + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include + +#define WIDTH 800 +#define HEIGHT 800 + +/************************************************************************/ +/* Capi Test Code */ +/************************************************************************/ + +static Tvg_Canvas canvas = NULL; +static Tvg_Animation animation = NULL; + +void contents() +{ + //Linear gradient shape with a linear gradient stroke + { + //Set a shape + Tvg_Paint shape1 = tvg_shape_new(); + tvg_shape_move_to(shape1, 25.0f, 25.0f); + tvg_shape_line_to(shape1, 375.0f, 25.0f); + tvg_shape_cubic_to(shape1, 500.0f, 100.0f, -500.0f, 200.0f, 375.0f, 375.0f); + tvg_shape_close(shape1); + + //Prepare a gradient for the fill + Tvg_Gradient grad = tvg_linear_gradient_new(); + tvg_linear_gradient_set(grad, 25.0f, 25.0f, 200.0f, 200.0f); + Tvg_Color_Stop color_stops[4] = {{0.00f, 255, 0, 0, 155}, {0.33f, 0, 255, 0, 100}, {0.66f, 255, 0, 255, 100}, {1.00f, 0, 0, 255, 155}}; + tvg_gradient_set_color_stops(grad, color_stops, 4); + tvg_gradient_set_spread(grad, TVG_STROKE_FILL_REFLECT); + + //Prepare a gradient for the stroke + Tvg_Gradient grad_stroke = tvg_gradient_duplicate(grad); + + //Set a gradient fill + tvg_shape_set_gradient(shape1, grad); + + //Set a gradient stroke + tvg_shape_set_stroke_width(shape1, 20.0f); + tvg_shape_set_stroke_gradient(shape1, grad_stroke); + tvg_shape_set_stroke_join(shape1, TVG_STROKE_JOIN_ROUND); + + tvg_canvas_add(canvas, shape1); + } + + //Solid transformed shape + { + //Set a shape + Tvg_Paint shape = tvg_shape_new(); + tvg_shape_move_to(shape, 25.0f, 25.0f); + tvg_shape_line_to(shape, 375.0f, 25.0f); + tvg_shape_cubic_to(shape, 500.0f, 100.0f, -500.0f, 200.0f, 375.0f, 375.0f); + tvg_shape_close(shape); + tvg_shape_set_fill_color(shape, 255, 255, 255, 128); + + //Transform a shape + tvg_paint_scale(shape, 0.3f); + tvg_paint_translate(shape, 100.0f, 100.0f); + + tvg_canvas_add(canvas, shape); + } + + + //Radial gradient shape with a radial dashed stroke + { + //Set a shape + Tvg_Paint shape = tvg_shape_new(); + tvg_shape_append_rect(shape, 550.0f, 20.0f, 100.0f, 50.0f, 0.0f, 0.0f, true); + tvg_shape_append_circle(shape, 600.0f, 150.0f, 100.0f, 50.0f, true); + tvg_shape_append_rect(shape, 550.0f, 230.0f, 100.0f, 100.0f, 20.0f, 40.0f, true); + + //Prepare a radial gradient for the fill + Tvg_Gradient grad = tvg_radial_gradient_new(); + tvg_radial_gradient_set(grad, 600.0f, 180.0f, 50.0f, 640.0f, 180.0f, 0.0f); + Tvg_Color_Stop color_stops2[3] = {{0.0f, 255, 0, 255, 255}, {0.5f, 0, 0, 255, 255}, {1.0f, 50, 55, 155, 255}}; + tvg_gradient_set_color_stops(grad, color_stops2, 3); + tvg_gradient_set_spread(grad, TVG_STROKE_FILL_PAD); + + //Set a gradient fill + tvg_shape_set_gradient(shape, grad); + + //Prepare a radial gradient for the stroke + uint32_t cnt; + const Tvg_Color_Stop* color_stops2_get; + tvg_gradient_get_color_stops(grad, &color_stops2_get, &cnt); + + float cx, cy, r, fx, fy, fr; + tvg_radial_gradient_get(grad, &cx, &cy, &r, &fx, &fy, &fr); + + Tvg_Gradient grad_stroke = tvg_radial_gradient_new(); + tvg_radial_gradient_set(grad_stroke, cx, cy, r, fx, fy, fr); + tvg_gradient_set_color_stops(grad_stroke, color_stops2_get, cnt); + tvg_gradient_set_spread(grad_stroke, TVG_STROKE_FILL_REPEAT); + + //Set a gradient stroke + tvg_shape_set_stroke_width(shape, 30.0f); + tvg_shape_set_stroke_gradient(shape, grad_stroke); + + tvg_paint_set_opacity(shape, 200); + + //Add the shape to the canvas + tvg_canvas_add(canvas, shape); + } + + //Scene + { + //Set a scene + Tvg_Paint scene = tvg_scene_new(); + + //Set circles + Tvg_Paint scene_shape1 = tvg_shape_new(); + tvg_shape_append_circle(scene_shape1, 80.0f, 650.f, 40.0f, 140.0f, true); + tvg_shape_append_circle(scene_shape1, 180.0f, 600.f, 40.0f, 60.0f, true); + tvg_shape_set_fill_color(scene_shape1, 0, 0, 255, 150); + tvg_shape_set_stroke_color(scene_shape1, 75, 25, 155, 255); + tvg_shape_set_stroke_width(scene_shape1, 10.0f); + tvg_shape_set_stroke_cap(scene_shape1, Tvg_Stroke_Cap::TVG_STROKE_CAP_ROUND); + tvg_shape_set_stroke_join(scene_shape1, Tvg_Stroke_Join::TVG_STROKE_JOIN_ROUND); + tvg_shape_set_trimpath(scene_shape1, 0.25f, 0.75f, true); + + //Set circles with a dashed stroke + Tvg_Paint scene_shape2 = tvg_paint_duplicate(scene_shape1); + tvg_shape_set_fill_color(scene_shape2, 75, 25, 155, 200); + + //Prapare a dash for the stroke + float dashPattern[4] = {15.0f, 30.0f, 2.0f, 30.0f}; + tvg_shape_set_stroke_dash(scene_shape2, dashPattern, 4, 0.0f); + tvg_shape_set_stroke_cap(scene_shape2, TVG_STROKE_CAP_ROUND); + tvg_shape_set_stroke_color(scene_shape2, 0, 0, 255, 255); + tvg_shape_set_stroke_width(scene_shape2, 15.0f); + + //Transform a shape + tvg_paint_scale(scene_shape2, 0.8f); + tvg_paint_rotate(scene_shape2, -90.0f); + tvg_paint_translate(scene_shape2, -200.0f, 800.0f); + + //Add the shapes to the scene + tvg_scene_add(scene, scene_shape1); + tvg_scene_add(scene, scene_shape2); + + //Add the scene to the canvas + tvg_canvas_add(canvas, scene); + } + + //Masked picture + { + //Set a scene + Tvg_Paint pict = tvg_picture_new(); + if (tvg_picture_load(pict, EXAMPLE_DIR"/svg/tiger.svg") != TVG_RESULT_SUCCESS) { + printf("Problem with loading an svg file\n"); + tvg_paint_rel(pict); + } else { + float w, h; + tvg_picture_get_size(pict, &w, &h); + tvg_picture_set_size(pict, w/2, h/2); + Tvg_Matrix m = {0.8f, 0.0f, 400.0f, 0.0f, 0.8f, 400.0f, 0.0f, 0.0f, 1.0f}; + tvg_paint_set_transform(pict, &m); + + // Set a composite shape + Tvg_Paint comp = tvg_shape_new(); + tvg_shape_append_circle(comp, 600.0f, 600.0f, 100.0f, 100.0f, true); + tvg_shape_set_fill_color(comp, 0, 0, 0, 200); + tvg_paint_set_mask_method(pict, comp, TVG_MASK_METHOD_INVERSE_ALPHA); + + //Add the scene to the canvas + tvg_canvas_add(canvas, pict); + } + } + + //Animation with a picture + { + animation = tvg_animation_new(); + Tvg_Paint pict_lottie = tvg_animation_get_picture(animation); + if (tvg_picture_load(pict_lottie, EXAMPLE_DIR"/lottie/sample.json") != TVG_RESULT_SUCCESS) { + printf("Problem with loading a lottie file\n"); + tvg_animation_del(animation); + animation = NULL; + } else { + tvg_paint_scale(pict_lottie, 0.75f); + tvg_canvas_add(canvas, pict_lottie); + } + } + + //Text 1 + { + //load from a file + if (tvg_font_load(EXAMPLE_DIR"/font/SentyCloud.ttf") != TVG_RESULT_SUCCESS) { + printf("Problem with loading the font from the file. Did you enable TTF Loader?\n"); + } + + Tvg_Paint text = tvg_text_new(); + tvg_text_set_font(text, "SentyCloud"); + tvg_text_set_size(text, 25.0f); + tvg_text_set_color(text, 200, 200, 255); + tvg_text_set_text(text, "\xE7\xB4\xA2\xE5\xB0\x94\x56\x47\x20\xE6\x98\xAF\xE6\x9C\x80\xE5\xA5\xBD\xE7\x9A\x84"); + tvg_paint_translate(text, 50.0f, 380.0f); + tvg_canvas_add(canvas, text); + } + + //Text 2 with Scene effect + { + Tvg_Paint scene = tvg_scene_new(); + + //load from a memory + FILE* file = fopen(EXAMPLE_DIR"/font/Arial.ttf", "rb"); + if (file) { + fseek(file, 0, SEEK_END); + size_t data_size = ftell(file); + fseek(file, 0, SEEK_SET); + char* data = (char*)malloc(data_size); + if (fread(data, 1, data_size, file) == data_size) { + if (tvg_font_load_data("Arial", data, data_size, "ttf", true) != TVG_RESULT_SUCCESS) { + printf("Problem with loading the font file from a memory. Did you enable TTF Loader?\n"); + } + } + free(data); + fclose(file); + } + + Tvg_Gradient grad = tvg_radial_gradient_new(); + tvg_radial_gradient_set(grad, 200.0f, 200.0f, 20.0f, 200.0f, 200.0f, 0.0f); + Tvg_Color_Stop color_stops[2] = {{0.0f, 255, 255, 255, 255}, {1.0f, 0, 0, 255, 255}}; + tvg_gradient_set_color_stops(grad, color_stops, 2); + tvg_gradient_set_spread(grad, TVG_STROKE_FILL_REFLECT); + + Tvg_Paint text = tvg_text_new(); + tvg_text_set_font(text, "Arial"); + tvg_text_set_size(text, 40.0f); + tvg_text_set_outline(text, 2, 255, 0, 0); + tvg_text_set_italic(text, 0.18f); + tvg_text_set_gradient(text, grad); + tvg_text_set_text(text, "ThorVG is the best"); + tvg_paint_translate(text, 20.0f, 420.0f); + + //Apply GaussianBlur post effect (sigma, direction, border option, quality) + tvg_scene_add_effect_gaussian_blur(scene, 2.5, 0, 0, 100); + tvg_scene_add(scene, text); + + tvg_canvas_add(canvas, scene); + } +} + + +float progress(uint32_t elapsed, float durationInSec) +{ + auto duration = (uint32_t)(durationInSec * 1000.0f); //sec -> millisec. + auto clamped = elapsed % duration; + return ((float)clamped / (float)duration); +} + + +/************************************************************************/ +/* Entry Point */ +/************************************************************************/ + +int main(int argc, char **argv) +{ + tvg_engine_init(4); + + SDL_Init(SDL_INIT_VIDEO); + + SDL_Window* window = SDL_CreateWindow("ThorVG Example (Software)", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_SHOWN); + SDL_Surface* surface = SDL_GetWindowSurface(window); + + //create the canvas + canvas = tvg_swcanvas_create(TVG_ENGINE_OPTION_DEFAULT); + tvg_swcanvas_set_target(canvas, (uint32_t*)surface->pixels, surface->w, surface->pitch / 4, surface->h, TVG_COLORSPACE_ARGB8888); + + contents(); + + //display the first frame + tvg_canvas_draw(canvas, true); + tvg_canvas_sync(canvas); + SDL_UpdateWindowSurface(window); + + //app main loop! + SDL_Event event; + auto running = true; + auto ptime = SDL_GetTicks(); + auto elapsed = 0; + + while (running) { + //SDL event handling + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_QUIT: { + running = false; + break; + } + case SDL_KEYUP: { + if (event.key.keysym.sym == SDLK_ESCAPE) { + running = false; + } + break; + } + } + } + + //update the animation + if (animation) { + float duration, totalFrame; + tvg_animation_get_duration(animation, &duration); + tvg_animation_get_total_frame(animation, &totalFrame); + tvg_animation_set_frame(animation, totalFrame * progress(elapsed, duration)); + } + + //draw the canvas + tvg_canvas_update(canvas); + tvg_canvas_draw(canvas, true); + tvg_canvas_sync(canvas); + + SDL_UpdateWindowSurface(window); + + auto ctime = SDL_GetTicks(); + elapsed += (ctime - ptime); + ptime = ctime; + } + + SDL_DestroyWindow(window); + + SDL_Quit(); + + tvg_engine_term(); + + return 0; +} diff --git a/src/meson.build b/src/meson.build index 6968f90..325e991 100644 --- a/src/meson.build +++ b/src/meson.build @@ -86,9 +86,16 @@ source_file = [ ] thorvg_inc = include_directories(join_paths(thorvg_dep.get_variable(pkgconfig: 'includedir'), 'thorvg-1')) -thorvg_lottie = cc.has_header('thorvg_lottie.h', include_directories: thorvg_inc) -if thorvg_lottie +# Lottie Examples +lottie_example = ''' + #include + int main(int argc, char **argv) { + return tvg::LottieAnimation::gen() ? 0 : 1; + } +''' + +if cc.links(lottie_example, dependencies : thorvg_dep, include_directories : thorvg_inc) source_file += [ 'Lottie.cpp', 'LottieExpressions.cpp', @@ -96,8 +103,17 @@ if thorvg_lottie 'LottieInteraction.cpp', 'LottieTweening.cpp' ] + message('ThorVG Lottie found. Enabled Lottie examples.') +else + message('ThorVG Lottie not found. Skipping Lottie examples.') +endif + +# CAPI Examples +if cc.has_function('tvg_shape_new', prefix: '#include ', include_directories: thorvg_inc, dependencies: thorvg_dep) + source_file += ['Capi.cpp'] + message('ThorVG CAPI found. Enabled Capi examples.') else - message('thorvg_lottie.h not found. Skipping Lottie examples.') + message('ThorVG CAPI not found. Skipping Capi examples.') endif foreach current_file : source_file