mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-12 17:45:05 +00:00
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
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:
parent
4b11fea32f
commit
543b705f2e
49 changed files with 1 additions and 120 deletions
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//load the tvg file
|
//load the tvg file
|
||||||
auto picture = tvg::Picture::gen();
|
auto picture = tvg::Picture::gen();
|
||||||
auto result = picture->load(EXAMPLE_DIR"/svg/favorite_on.svg");
|
auto result = picture->load(EXAMPLE_DIR"/svg/favorite_on.svg");
|
||||||
|
|
|
@ -72,8 +72,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
auto progress = tvgexam::progress(elapsed, animation->duration());
|
auto progress = tvgexam::progress(elapsed, animation->duration());
|
||||||
|
|
||||||
//Update animation frame only when it's changed
|
//Update animation frame only when it's changed
|
||||||
|
|
|
@ -139,8 +139,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
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;
|
if (!tvgexam::verify(tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf"))) return false;
|
||||||
|
|
||||||
//Prepare Image
|
//Prepare Image
|
||||||
|
|
|
@ -69,8 +69,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
shape->appendCircle(50, 100, 40, 100);
|
shape->appendCircle(50, 100, 40, 100);
|
||||||
|
|
|
@ -45,8 +45,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Background
|
//Background
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
shape->appendRect(0, 0, w, h);
|
shape->appendRect(0, 0, w, h);
|
||||||
|
|
|
@ -35,8 +35,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
if (!tvgexam::verify(canvas->remove())) return false;
|
if (!tvgexam::verify(canvas->remove())) return false;
|
||||||
|
|
||||||
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
||||||
|
|
|
@ -32,8 +32,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Background
|
//Background
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
shape->appendRect(0, 0, w, h); //x, y, w, h
|
shape->appendRect(0, 0, w, h); //x, y, w, h
|
||||||
|
|
|
@ -35,8 +35,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Shape (for BG)
|
//Shape (for BG)
|
||||||
auto bg = tvg::Shape::gen();
|
auto bg = tvg::Shape::gen();
|
||||||
bg->appendRect(0, 0, w, h);
|
bg->appendRect(0, 0, w, h);
|
||||||
|
@ -85,8 +83,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
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.
|
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
||||||
|
|
||||||
//Reset Shape
|
//Reset Shape
|
||||||
|
|
|
@ -34,8 +34,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//background
|
//background
|
||||||
auto bg = tvg::Shape::gen();
|
auto bg = tvg::Shape::gen();
|
||||||
bg->appendRect(0, 0, w, h);
|
bg->appendRect(0, 0, w, h);
|
||||||
|
@ -94,8 +92,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
auto progress = tvgexam::progress(elapsed, 2.5f, true); //2.5 seconds
|
auto progress = tvgexam::progress(elapsed, 2.5f, true); //2.5 seconds
|
||||||
|
|
||||||
//Clear the previously applied effects
|
//Clear the previously applied effects
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Star
|
//Star
|
||||||
auto shape1 = tvg::Shape::gen();
|
auto shape1 = tvg::Shape::gen();
|
||||||
shape1->moveTo(205, 35);
|
shape1->moveTo(205, 35);
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
const int colorCnt = 4;
|
const int colorCnt = 4;
|
||||||
tvg::Fill::ColorStop colorStops[colorCnt];
|
tvg::Fill::ColorStop colorStops[colorCnt];
|
||||||
colorStops[0] = {0.0f, 127, 39, 255, 255};
|
colorStops[0] = {0.0f, 127, 39, 255, 255};
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Solid Rectangle
|
//Solid Rectangle
|
||||||
{
|
{
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
tvg::Fill::ColorStop colorStops1[3];
|
tvg::Fill::ColorStop colorStops1[3];
|
||||||
colorStops1[0] = {0, 255, 0, 0, 150};
|
colorStops1[0] = {0, 255, 0, 0, 150};
|
||||||
colorStops1[1] = {0.5, 0, 0, 255, 150};
|
colorStops1[1] = {0.5, 0, 0, 255, 150};
|
||||||
|
|
|
@ -35,8 +35,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
tvgexam::verify(canvas->remove());
|
tvgexam::verify(canvas->remove());
|
||||||
|
|
||||||
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
||||||
|
|
|
@ -39,8 +39,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
picture = tvg::Picture::gen();
|
picture = tvg::Picture::gen();
|
||||||
|
|
||||||
if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/image/scale.jpg"))) return false;
|
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
|
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};
|
tvg::Matrix m = {1.0f, 0.0f, 0.0f, 0.0f, 0.1f, 0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
//center pivoting
|
//center pivoting
|
||||||
|
|
|
@ -32,8 +32,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Original
|
//Original
|
||||||
picture = tvg::Picture::gen();
|
picture = tvg::Picture::gen();
|
||||||
|
|
||||||
|
@ -48,8 +46,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
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.
|
auto progress = tvgexam::progress(elapsed, 3.0f, true); //play time 3 secs.
|
||||||
|
|
||||||
picture->scale((1.0f - progress) * 1.5f);
|
picture->scale((1.0f - progress) * 1.5f);
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Prepare Round Rectangle
|
//Prepare Round Rectangle
|
||||||
auto shape1 = tvg::Shape::gen();
|
auto shape1 = tvg::Shape::gen();
|
||||||
shape1->appendRect(0, 0, 400, 400); //x, y, w, h
|
shape1->appendRect(0, 0, 400, 400); //x, y, w, h
|
||||||
|
|
|
@ -77,8 +77,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
for (auto& animation : animations) {
|
for (auto& animation : animations) {
|
||||||
auto progress = tvgexam::progress(elapsed, animation->duration());
|
auto progress = tvgexam::progress(elapsed, animation->duration());
|
||||||
animation->frame(animation->totalFrame() * progress);
|
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
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//The default font for fallback in case
|
//The default font for fallback in case
|
||||||
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");
|
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
for (auto& animation : animations) {
|
for (auto& animation : animations) {
|
||||||
auto progress = tvgexam::progress(elapsed, animation->duration());
|
auto progress = tvgexam::progress(elapsed, animation->duration());
|
||||||
animation->frame(animation->totalFrame() * progress);
|
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
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//The default font for fallback in case
|
//The default font for fallback in case
|
||||||
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");
|
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//default slot
|
//default slot
|
||||||
{
|
{
|
||||||
auto progress = tvgexam::progress(elapsed, slot0->duration());
|
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
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Background
|
//Background
|
||||||
auto bg = tvg::Shape::gen();
|
auto bg = tvg::Shape::gen();
|
||||||
bg->appendRect(0, 0, w, h);
|
bg->appendRect(0, 0, w, h);
|
||||||
|
|
|
@ -162,8 +162,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//spinning effect
|
//spinning effect
|
||||||
if (effect.on) {
|
if (effect.on) {
|
||||||
auto elapsedTime = elapsed - effect.time;
|
auto elapsedTime = elapsed - effect.time;
|
||||||
|
|
|
@ -200,8 +200,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//on state tweening
|
//on state tweening
|
||||||
if (tween.active) return tweening(canvas);
|
if (tween.active) return tweening(canvas);
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Image
|
//Image
|
||||||
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
|
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
|
||||||
if (!file.is_open()) return false;
|
if (!file.is_open()) return false;
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Image
|
//Image
|
||||||
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
|
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
|
||||||
if (!file.is_open()) return false;
|
if (!file.is_open()) return false;
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Image source
|
//Image source
|
||||||
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
|
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
|
||||||
if (!file.is_open()) return false;
|
if (!file.is_open()) return false;
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Create a Scene
|
//Create a Scene
|
||||||
auto scene = tvg::Scene::gen();
|
auto scene = tvg::Scene::gen();
|
||||||
scene->opacity(175); //Apply opacity to scene (0 - 255)
|
scene->opacity(175); //Apply opacity to scene (0 - 255)
|
||||||
|
|
|
@ -43,8 +43,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
srand(100);
|
srand(100);
|
||||||
|
|
||||||
auto city = tvg::Picture::gen();
|
auto city = tvg::Picture::gen();
|
||||||
|
@ -100,7 +98,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
for (auto& p : raindrops) {
|
for (auto& p : raindrops) {
|
||||||
p.y += p.speed;
|
p.y += p.speed;
|
||||||
if (p.y > h) {
|
if (p.y > h) {
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Command Calls
|
//Command Calls
|
||||||
{
|
{
|
||||||
//Star
|
//Star
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
auto opacity = 36;
|
auto opacity = 36;
|
||||||
|
|
||||||
//Load jpg file from path
|
//Load jpg file from path
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Background
|
//Background
|
||||||
auto bg = tvg::Shape::gen();
|
auto bg = tvg::Shape::gen();
|
||||||
bg->appendRect(0, 0, w, h); //x, y, w, h
|
bg->appendRect(0, 0, w, h); //x, y, w, h
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Background
|
//Background
|
||||||
auto bg = tvg::Shape::gen();
|
auto bg = tvg::Shape::gen();
|
||||||
bg->appendRect(0, 0, w, h);
|
bg->appendRect(0, 0, w, h);
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//default font for fallback in case
|
//default font for fallback in case
|
||||||
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");
|
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Background
|
//Background
|
||||||
auto bg = tvg::Shape::gen();
|
auto bg = tvg::Shape::gen();
|
||||||
bg->appendRect(0, 0, w, h); //x, y, w, h
|
bg->appendRect(0, 0, w, h); //x, y, w, h
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Prepare Round Rectangle
|
//Prepare Round Rectangle
|
||||||
auto shape1 = tvg::Shape::gen();
|
auto shape1 = tvg::Shape::gen();
|
||||||
shape1->appendRect(0, 0, 400, 400); //x, y, w, h
|
shape1->appendRect(0, 0, 400, 400); //x, y, w, h
|
||||||
|
|
|
@ -74,8 +74,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//update per every 250ms
|
//update per every 250ms
|
||||||
//reorder with a circular list
|
//reorder with a circular list
|
||||||
if (elapsed - last > 250) {
|
if (elapsed - last > 250) {
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Create a Scene
|
//Create a Scene
|
||||||
auto scene = tvg::Scene::gen();
|
auto scene = tvg::Scene::gen();
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//BG
|
//BG
|
||||||
auto bg = tvg::Shape::gen();
|
auto bg = tvg::Shape::gen();
|
||||||
bg->appendRect(0, 0, w, h);
|
bg->appendRect(0, 0, w, h);
|
||||||
|
|
|
@ -37,8 +37,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//blur scene
|
//blur scene
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
blur[i] = tvg::Scene::gen();
|
blur[i] = tvg::Scene::gen();
|
||||||
|
@ -97,8 +95,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
auto progress = tvgexam::progress(elapsed, 2.5f, true); //2.5 seconds
|
auto progress = tvgexam::progress(elapsed, 2.5f, true); //2.5 seconds
|
||||||
|
|
||||||
//Apply GaussianBlur post effect (sigma, direction, border option, quality)
|
//Apply GaussianBlur post effect (sigma, direction, border option, quality)
|
||||||
|
|
|
@ -35,8 +35,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
if (!tvgexam::verify(canvas->remove())) return false;
|
if (!tvgexam::verify(canvas->remove())) return false;
|
||||||
|
|
||||||
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Prepare a Composite Shape (Rectangle + Rectangle + Circle + Circle)
|
//Prepare a Composite Shape (Rectangle + Rectangle + Circle + Circle)
|
||||||
auto shape4 = tvg::Shape::gen();
|
auto shape4 = tvg::Shape::gen();
|
||||||
shape4->appendRect(0, 0, 300, 300, 50, 50); //x, y, w, h, rx, ry
|
shape4->appendRect(0, 0, 300, 300, 50, 50); //x, y, w, h, rx, ry
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Shape 1
|
//Shape 1
|
||||||
auto shape1 = tvg::Shape::gen();
|
auto shape1 = tvg::Shape::gen();
|
||||||
shape1->appendRect(50, 50, 200, 200);
|
shape1->appendRect(50, 50, 200, 200);
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//StrokeJoin & StrokeCap
|
//StrokeJoin & StrokeCap
|
||||||
auto shape1 = tvg::Shape::gen();
|
auto shape1 = tvg::Shape::gen();
|
||||||
shape1->moveTo( 20, 50);
|
shape1->moveTo( 20, 50);
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//background
|
//background
|
||||||
{
|
{
|
||||||
auto bg = tvg::Shape::gen();
|
auto bg = tvg::Shape::gen();
|
||||||
|
|
|
@ -75,8 +75,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//The default font for fallback in case
|
//The default font for fallback in case
|
||||||
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");
|
tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf");
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Background
|
//Background
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
shape->appendRect(0, 0, w, h);
|
shape->appendRect(0, 0, w, h);
|
||||||
|
|
|
@ -35,8 +35,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
if (!tvgexam::verify(canvas->remove())) return false;
|
if (!tvgexam::verify(canvas->remove())) return false;
|
||||||
|
|
||||||
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Shape 1
|
//Shape 1
|
||||||
auto shape1 = tvg::Shape::gen();
|
auto shape1 = tvg::Shape::gen();
|
||||||
shape1->appendCircle(245, 125, 50, 120);
|
shape1->appendCircle(245, 125, 50, 120);
|
||||||
|
|
|
@ -30,8 +30,6 @@ struct UserExample : tvgexam::Example
|
||||||
{
|
{
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//Shape
|
//Shape
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
shape->appendRect(-100, -100, 200, 200);
|
shape->appendRect(-100, -100, 200, 200);
|
||||||
|
@ -43,8 +41,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
bool update(tvg::Canvas* canvas, uint32_t elapsed) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
if (!tvgexam::verify(canvas->remove())) return false;
|
if (!tvgexam::verify(canvas->remove())) return false;
|
||||||
|
|
||||||
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
auto progress = tvgexam::progress(elapsed, 2.0f, true); //play time 2 sec.
|
||||||
|
|
|
@ -34,8 +34,6 @@ struct UserExample : tvgexam::Example
|
||||||
|
|
||||||
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
bool content(tvg::Canvas* canvas, uint32_t w, uint32_t h) override
|
||||||
{
|
{
|
||||||
if (!canvas) return false;
|
|
||||||
|
|
||||||
//set viewport before canvas become dirty.
|
//set viewport before canvas become dirty.
|
||||||
if (!tvgexam::verify(canvas->viewport(0, 0, VPORT_SIZE, VPORT_SIZE))) return false;
|
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
|
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.
|
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;
|
if (!tvgexam::verify(canvas->viewport((w - VPORT_SIZE) * progress, (h - VPORT_SIZE) * progress, VPORT_SIZE, VPORT_SIZE))) return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue