example: code clean up++
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run

that exception handling is helpless
This commit is contained in:
Hermet Park 2025-07-09 18:37:56 +09:00 committed by Hermet Park
parent 4b11fea32f
commit 543b705f2e
49 changed files with 1 additions and 120 deletions

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//load the tvg file
auto picture = tvg::Picture::gen();
auto result = picture->load(EXAMPLE_DIR"/svg/favorite_on.svg");

View file

@ -72,8 +72,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
auto progress = tvgexam::progress(elapsed, animation->duration());
//Update animation frame only when it's changed

View file

@ -139,8 +139,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
if (!tvgexam::verify(tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf"))) return false;
//Prepare Image

View file

@ -69,8 +69,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
{
auto shape = tvg::Shape::gen();
shape->appendCircle(50, 100, 40, 100);

View file

@ -45,8 +45,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Background
auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, w, h);

View file

@ -35,8 +35,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
if (!tvgexam::verify(canvas->remove())) return false;
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.

View file

@ -32,8 +32,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Background
auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, w, h); //x, y, w, h

View file

@ -35,8 +35,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Shape (for BG)
auto bg = tvg::Shape::gen();
bg->appendRect(0, 0, w, h);
@ -85,8 +83,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
//Reset Shape

View file

@ -34,8 +34,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//background
auto bg = tvg::Shape::gen();
bg->appendRect(0, 0, w, h);
@ -94,8 +92,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
auto progress = tvgexam::progress(elapsed, 2.5f, true); //2.5 seconds
//Clear the previously applied effects

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Star
auto shape1 = tvg::Shape::gen();
shape1->moveTo(205, 35);

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
const int colorCnt = 4;
tvg::Fill::ColorStop colorStops[colorCnt];
colorStops[0] = {0.0f, 127, 39, 255, 255};

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Solid Rectangle
{
auto shape = tvg::Shape::gen();

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
tvg::Fill::ColorStop colorStops1[3];
colorStops1[0] = {0, 255, 0, 0, 150};
colorStops1[1] = {0.5, 0, 0, 255, 150};

View file

@ -35,8 +35,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
tvgexam::verify(canvas->remove());
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.

View file

@ -39,8 +39,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
picture = tvg::Picture::gen();
if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/image/scale.jpg"))) return false;
@ -52,8 +50,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
tvg::Matrix m = {1.0f, 0.0f, 0.0f, 0.0f, 0.1f, 0.0f, 0.0f, 0.0f, 1.0f};
//center pivoting

View file

@ -32,8 +32,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Original
picture = tvg::Picture::gen();
@ -48,8 +46,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
auto progress = tvgexam::progress(elapsed, 3.0f, true); //play time 3 secs.
picture->scale((1.0f - progress) * 1.5f);

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Prepare Round Rectangle
auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400); //x, y, w, h

View file

@ -77,8 +77,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
for (auto& animation : animations) {
auto progress = tvgexam::progress(elapsed, animation->duration());
animation->frame(animation->totalFrame() * progress);
@ -91,8 +89,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//The default font for fallback in case
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");

View file

@ -77,8 +77,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
for (auto& animation : animations) {
auto progress = tvgexam::progress(elapsed, animation->duration());
animation->frame(animation->totalFrame() * progress);
@ -91,8 +89,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//The default font for fallback in case
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");

View file

@ -66,8 +66,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
//default slot
{
auto progress = tvgexam::progress(elapsed, slot0->duration());
@ -147,8 +145,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Background
auto bg = tvg::Shape::gen();
bg->appendRect(0, 0, w, h);

View file

@ -162,8 +162,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
//spinning effect
if (effect.on) {
auto elapsedTime = elapsed - effect.time;

View file

@ -200,8 +200,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
//on state tweening
if (tween.active) return tweening(canvas);

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Image
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
if (!file.is_open()) return false;

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Image
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
if (!file.is_open()) return false;

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Image source
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
if (!file.is_open()) return false;

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Create a Scene
auto scene = tvg::Scene::gen();
scene->opacity(175); //Apply opacity to scene (0 - 255)

View file

@ -43,8 +43,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
srand(100);
auto city = tvg::Picture::gen();
@ -100,7 +98,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
for (auto& p : raindrops) {
p.y += p.speed;
if (p.y > h) {

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Command Calls
{
//Star

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
auto opacity = 36;
//Load jpg file from path

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Background
auto bg = tvg::Shape::gen();
bg->appendRect(0, 0, w, h); //x, y, w, h

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Background
auto bg = tvg::Shape::gen();
bg->appendRect(0, 0, w, h);

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//default font for fallback in case
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Background
auto bg = tvg::Shape::gen();
bg->appendRect(0, 0, w, h); //x, y, w, h

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Prepare Round Rectangle
auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400); //x, y, w, h

View file

@ -74,8 +74,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
//update per every 250ms
//reorder with a circular list
if (elapsed - last > 250) {

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Create a Scene
auto scene = tvg::Scene::gen();

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//BG
auto bg = tvg::Shape::gen();
bg->appendRect(0, 0, w, h);

View file

@ -37,8 +37,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//blur scene
for (int i = 0; i < 3; ++i) {
blur[i] = tvg::Scene::gen();
@ -97,8 +95,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
auto progress = tvgexam::progress(elapsed, 2.5f, true); //2.5 seconds
//Apply GaussianBlur post effect (sigma, direction, border option, quality)

View file

@ -35,8 +35,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
if (!tvgexam::verify(canvas->remove())) return false;
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Prepare a Composite Shape (Rectangle + Rectangle + Circle + Circle)
auto shape4 = tvg::Shape::gen();
shape4->appendRect(0, 0, 300, 300, 50, 50); //x, y, w, h, rx, ry

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Shape 1
auto shape1 = tvg::Shape::gen();
shape1->appendRect(50, 50, 200, 200);

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//StrokeJoin & StrokeCap
auto shape1 = tvg::Shape::gen();
shape1->moveTo( 20, 50);

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//background
{
auto bg = tvg::Shape::gen();

View file

@ -75,8 +75,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//The default font for fallback in case
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Background
auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, w, h);

View file

@ -35,8 +35,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
if (!tvgexam::verify(canvas->remove())) return false;
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Shape 1
auto shape1 = tvg::Shape::gen();
shape1->appendCircle(245, 125, 50, 120);

View file

@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
{
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//Shape
auto shape = tvg::Shape::gen();
shape->appendRect(-100, -100, 200, 200);
@ -43,8 +41,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
if (!tvgexam::verify(canvas->remove())) return false;
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.

View file

@ -34,8 +34,6 @@ struct UserExample : tvgexam::Example
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
{
if (!canvas) return false;
//set viewport before canvas become dirty.
if (!tvgexam::verify(canvas->viewport(0, 0, VPORT_SIZE, VPORT_SIZE))) return false;
@ -59,8 +57,6 @@ struct UserExample : tvgexam::Example
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
{
if (!canvas) return false;
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
if (!tvgexam::verify(canvas->viewport((w - VPORT_SIZE) * progress, (h - VPORT_SIZE) * progress, VPORT_SIZE, VPORT_SIZE))) return false;