examples: refactored the examples directory

reorganized the resources folder,
distributing contents into categorized subfolders:
SVG, Lottie, Image, Font, and TVG.
This commit is contained in:
Hermet Park 2024-03-18 15:31:24 +09:00 committed by Jinny You
parent d9926edb2f
commit c79e8e6271
234 changed files with 44 additions and 44 deletions

View file

@ -33,7 +33,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//load the tvg file
auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/favorite_on.svg") != tvg::Result::Success) return;
if (picture->load(EXAMPLE_DIR"/svg/favorite_on.svg") != tvg::Result::Success) return;
picture->size(WIDTH, HEIGHT);
auto accessor = tvg::Accessor::gen();

View file

@ -43,12 +43,12 @@ void tvgDrawCmds(tvg::Canvas* canvas)
// image
auto picture1 = tvg::Picture::gen();
picture1->load(EXAMPLE_DIR"/cartman.svg");
picture1->load(EXAMPLE_DIR"/svg/cartman.svg");
picture1->size(400, 400);
canvas->push(std::move(picture1));
auto picture2 = tvg::Picture::gen();
picture2->load(EXAMPLE_DIR"/logo.svg");
picture2->load(EXAMPLE_DIR"/svg/logo.svg");
picture2->size(400, 400);
//mask

View file

@ -54,7 +54,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
if (picture->load(EXAMPLE_DIR"/sample.json") != tvg::Result::Success) {
if (picture->load(EXAMPLE_DIR"/lottie/sample.json") != tvg::Result::Success) {
cout << "Lottie is not supported. Did you enable Lottie Loader?" << endl;
return;
}

View file

@ -122,7 +122,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(shape9)) != tvg::Result::Success) return;
//Prepare Transformed Image
string path(EXAMPLE_DIR"/rawimage_200x300.raw");
string path(EXAMPLE_DIR"/image/rawimage_200x300.raw");
ifstream file(path, ios::binary);
if (!file.is_open()) return ;

View file

@ -181,7 +181,7 @@ void testCapi()
//////5. Masked picture
//Set a scene
Tvg_Paint* pict = tvg_picture_new();
if (tvg_picture_load(pict, EXAMPLE_DIR"/tiger.svg") != TVG_RESULT_SUCCESS) {
if (tvg_picture_load(pict, EXAMPLE_DIR"/svg/tiger.svg") != TVG_RESULT_SUCCESS) {
printf("Problem with loading an svg file\n");
tvg_paint_del(pict);
} else {
@ -204,7 +204,7 @@ void testCapi()
//////6. 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"/sample.json") != TVG_RESULT_SUCCESS) {
if (tvg_picture_load(pict_lottie, EXAMPLE_DIR"/lottie/sample.json") != TVG_RESULT_SUCCESS) {
printf("Problem with loading an lottie file\n");
tvg_animation_del(animation);
} else {

View file

@ -121,7 +121,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//////////////////////////////////////////////
auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/cartman.svg") != tvg::Result::Success) return;
if (picture->load(EXAMPLE_DIR"/svg/cartman.svg") != tvg::Result::Success) return;
picture->scale(3);
picture->translate(50, 400);

View file

@ -102,7 +102,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Duplicate Picture - svg
{
auto picture1 = tvg::Picture::gen();
picture1->load(EXAMPLE_DIR"/tiger.svg");
picture1->load(EXAMPLE_DIR"/svg/tiger.svg");
picture1->translate(350, 200);
picture1->scale(0.25);
@ -115,7 +115,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Duplicate Picture - raw
{
string path(EXAMPLE_DIR"/rawimage_200x300.raw");
string path(EXAMPLE_DIR"/image/rawimage_200x300.raw");
ifstream file(path, ios::binary);
if (!file.is_open()) return ;
uint32_t* data = (uint32_t*)malloc(sizeof(uint32_t) * 200 * 300);
@ -141,7 +141,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Duplicate Text
{
auto text = tvg::Text::gen();
text->load(EXAMPLE_DIR"/Arial.ttf");
text->load(EXAMPLE_DIR"/font/Arial.ttf");
text->font("Arial", 50);
text->translate(0, 650);
text->text("ThorVG Text");

View file

@ -30,7 +30,7 @@ void exportGif()
{
auto animation = tvg::Animation::gen();
auto picture = animation->picture();
if (picture->load(EXAMPLE_DIR"/walker.json") != tvg::Result::Success) {
if (picture->load(EXAMPLE_DIR"/lottie/walker.json") != tvg::Result::Success) {
cout << "Lottie is not supported. Did you enable Lottie Loader?" << endl;
return;
}

View file

@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Original
auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/scaledown.jpg") != tvg::Result::Success) {
if (picture->load(EXAMPLE_DIR"/image/scaledown.jpg") != tvg::Result::Success) {
cout << "The PNG file is not loaded correctly. Did you enable PNG Loader?" << endl;
return;
}

View file

@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Original
auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/scaleup.jpg") != tvg::Result::Success) {
if (picture->load(EXAMPLE_DIR"/image/scaleup.jpg") != tvg::Result::Success) {
cout << "The PNG file is not loaded correctly. Did you enable PNG Loader?" << endl;
return;
}

View file

@ -52,7 +52,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//SVG
auto svg = tvg::Picture::gen();
if (svg->load(EXAMPLE_DIR"/cartman.svg") != tvg::Result::Success) return;
if (svg->load(EXAMPLE_DIR"/svg/cartman.svg") != tvg::Result::Success) return;
svg->opacity(100);
svg->scale(3);
svg->translate(50, 400);
@ -90,7 +90,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
//Image
ifstream file(EXAMPLE_DIR"/rawimage_200x300.raw", ios::binary);
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
if (!file.is_open()) return;
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);

View file

@ -52,7 +52,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//SVG
auto svg = tvg::Picture::gen();
if (svg->load(EXAMPLE_DIR"/cartman.svg") != tvg::Result::Success) return;
if (svg->load(EXAMPLE_DIR"/svg/cartman.svg") != tvg::Result::Success) return;
svg->opacity(100);
svg->scale(3);
svg->translate(50, 400);
@ -90,7 +90,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
//Image
ifstream file(EXAMPLE_DIR"/rawimage_200x300.raw", ios::binary);
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
if (!file.is_open()) return;
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);

View file

@ -108,7 +108,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, lottieDirCallback, canvas);
eina_file_dir_list(EXAMPLE_DIR"/lottie", EINA_TRUE, lottieDirCallback, canvas);
//Run animation loop
for (auto& animation : animations) {

View file

@ -54,7 +54,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
const char* slotJson = R"({"gradient_fill":{"p":{"a":0,"k":[0,0.1,0.1,0.2,1,1,0.1,0.2,0.1,1]}}})";
if (picture->load(EXAMPLE_DIR"/slotsample.json") != tvg::Result::Success) {
if (picture->load(EXAMPLE_DIR"/lottie/extensions/slotsample.json") != tvg::Result::Success) {
cout << "Lottie is not supported. Did you enable Lottie Loader?" << endl;
return;
}

View file

@ -52,7 +52,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//SVG
auto svg = tvg::Picture::gen();
if (svg->load(EXAMPLE_DIR"/cartman.svg") != tvg::Result::Success) return;
if (svg->load(EXAMPLE_DIR"/svg/cartman.svg") != tvg::Result::Success) return;
svg->opacity(100);
svg->scale(3);
svg->translate(50, 400);
@ -90,7 +90,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
//Image
ifstream file(EXAMPLE_DIR"/rawimage_200x300.raw", ios::binary);
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
if (!file.is_open()) return;
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);

View file

@ -52,7 +52,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//SVG
auto svg = tvg::Picture::gen();
if (svg->load(EXAMPLE_DIR"/cartman.svg") != tvg::Result::Success) return;
if (svg->load(EXAMPLE_DIR"/svg/cartman.svg") != tvg::Result::Success) return;
svg->opacity(100);
svg->scale(3);
svg->translate(50, 400);
@ -92,7 +92,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
//Image
ifstream file(EXAMPLE_DIR"/rawimage_200x300.raw", ios::binary);
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
if (!file.is_open()) return;
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
file.read(reinterpret_cast<char*>(data), sizeof (uint32_t) * 200 * 300);

View file

@ -32,7 +32,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (!canvas) return;
//Image source
ifstream file(EXAMPLE_DIR"/rawimage_200x300.raw", ios::binary);
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
if (!file.is_open()) return;
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
file.read(reinterpret_cast<char*>(data), sizeof (uint32_t) * 200 * 300);

View file

@ -238,9 +238,9 @@ int main(int argc, char **argv)
evas_object_smart_callback_add(win, "delete,request", win_del, 0);
if (tvgEngine == tvg::CanvasEngine::Sw) {
eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, tvgSwTest, win);
eina_file_dir_list(EXAMPLE_DIR"/svg", EINA_TRUE, tvgSwTest, win);
} else {
eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, tvgGlTest, win);
eina_file_dir_list(EXAMPLE_DIR"/svg", EINA_TRUE, tvgGlTest, win);
}
evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);

View file

@ -43,7 +43,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
mask->opacity(125);
auto picture = tvg::Picture::gen();
picture->load(EXAMPLE_DIR"/tiger.svg");
picture->load(EXAMPLE_DIR"/svg/tiger.svg");
picture->size(WIDTH, HEIGHT);
picture->composite(std::move(mask), tvg::CompositeMethod::AlphaMask);
pPicture = picture.get();

View file

@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Load jpg file from path
for (int i = 0; i < 7; ++i) {
auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/test.jpg") != tvg::Result::Success) {
if (picture->load(EXAMPLE_DIR"/image/test.jpg") != tvg::Result::Success) {
cout << "JPG is not supported. Did you enable JPG Loader?" << endl;
return;
}
@ -48,7 +48,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
}
//Open file manually
ifstream file(EXAMPLE_DIR"/test.jpg", ios::binary);
ifstream file(EXAMPLE_DIR"/image/test.jpg", ios::binary);
if (!file.is_open()) return;
auto begin = file.tellg();
file.seekg(0, std::ios::end);

View file

@ -42,7 +42,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
for (int i = 0; i < 7; ++i) {
auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/test.png") != tvg::Result::Success) {
if (picture->load(EXAMPLE_DIR"/image/test.png") != tvg::Result::Success) {
cout << "PNG is not supported. Did you enable PNG Loader?" << endl;
return;
}
@ -54,7 +54,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
}
//Open file manually
ifstream file(EXAMPLE_DIR"/test.png", ios::binary);
ifstream file(EXAMPLE_DIR"/image/test.png", ios::binary);
if (!file.is_open()) return;
auto begin = file.tellg();
file.seekg(0, std::ios::end);

View file

@ -38,7 +38,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
string path(EXAMPLE_DIR"/rawimage_200x300.raw");
string path(EXAMPLE_DIR"/image/rawimage_200x300.raw");
ifstream file(path, ios::binary);
if (!file.is_open()) return ;

View file

@ -38,7 +38,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
canvas->push(std::move(bg));
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), EXAMPLE_DIR"/logo.svg");
snprintf(buf, sizeof(buf), EXAMPLE_DIR"/svg/logo.svg");
auto picture = tvg::Picture::gen();
tvg::Result ret = picture->load(buf);

View file

@ -33,7 +33,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//load the tvg file
auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/test.tvg") != tvg::Result::Success) {
if (picture->load(EXAMPLE_DIR"/tvg/test.tvg") != tvg::Result::Success) {
cout << "TVG is not supported. Did you enable TVG Loader?" << endl;
return;
}

View file

@ -42,7 +42,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
for (int i = 0; i < 7; ++i) {
auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/test.webp") != tvg::Result::Success) {
if (picture->load(EXAMPLE_DIR"/image/test.webp") != tvg::Result::Success) {
cout << "WEBP is not supported. Did you enable WEBP Loader?" << endl;
return;
}
@ -54,7 +54,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
}
//Open file manually
ifstream file(EXAMPLE_DIR"/test.webp", ios::binary);
ifstream file(EXAMPLE_DIR"/image/test.webp", ios::binary);
if (!file.is_open()) return;
auto begin = file.tellg();
file.seekg(0, std::ios::end);

View file

@ -85,7 +85,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, svgDirCallback, canvas);
eina_file_dir_list(EXAMPLE_DIR"/svg", EINA_TRUE, svgDirCallback, canvas);
/* This showcase shows you asynchrounous loading of svg.
For this, pushing pictures at a certian sync time.

View file

@ -39,7 +39,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
//Raw Image
string path(EXAMPLE_DIR"/rawimage_200x300.raw");
string path(EXAMPLE_DIR"/image/rawimage_200x300.raw");
ifstream file(path, ios::binary);
if (!file.is_open()) return ;

View file

@ -40,17 +40,17 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//The loaded font will be released when the Initializer::term() is called.
//Otherwise, you can immedately unload the font data.
//Please check Text::unload() APIs.
if (tvg::Text::load(EXAMPLE_DIR"/Arial.ttf") != tvg::Result::Success) {
if (tvg::Text::load(EXAMPLE_DIR"/font/Arial.ttf") != tvg::Result::Success) {
cout << "TTF is not supported. Did you enable TTF Loader?" << endl;
return;
}
if (tvg::Text::load(EXAMPLE_DIR"/NanumGothicCoding.ttf") != tvg::Result::Success) {
if (tvg::Text::load(EXAMPLE_DIR"/font/NanumGothicCoding.ttf") != tvg::Result::Success) {
cout << "TTF is not supported. Did you enable TTF Loader?" << endl;
return;
}
if (tvg::Text::load(EXAMPLE_DIR"/SentyCloud.ttf") != tvg::Result::Success) {
if (tvg::Text::load(EXAMPLE_DIR"/font/SentyCloud.ttf") != tvg::Result::Success) {
cout << "TTF is not supported. Did you enable TTF Loader?" << endl;
return;
}

View file

@ -71,7 +71,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, tvgDirCallback, canvas);
eina_file_dir_list(EXAMPLE_DIR"/tvg", EINA_TRUE, tvgDirCallback, canvas);
/* This showcase shows you asynchrounous loading of tvg.
For this, pushing pictures at a certian sync time.

View file

@ -193,7 +193,7 @@ void exportTvg()
//prepare image source
const int width = 200;
const int height = 300;
ifstream file(EXAMPLE_DIR"/rawimage_200x300.raw", ios::binary);
ifstream file(EXAMPLE_DIR"/image/rawimage_200x300.raw", ios::binary);
if (!file.is_open()) return;
uint32_t *data = (uint32_t*) malloc(sizeof(uint32_t) * width * height);
if (!data) return;

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

Before

Width:  |  Height:  |  Size: 310 KiB

After

Width:  |  Height:  |  Size: 310 KiB

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

Before

Width:  |  Height:  |  Size: 399 KiB

After

Width:  |  Height:  |  Size: 399 KiB

View file

Before

Width:  |  Height:  |  Size: 450 KiB

After

Width:  |  Height:  |  Size: 450 KiB

View file

Before

Width:  |  Height:  |  Size: 426 KiB

After

Width:  |  Height:  |  Size: 426 KiB

Some files were not shown because too many files have changed in this diff Show more