examples: refactored the examples directory
reorganized the resources folder, distributing contents into categorized subfolders: SVG, Lottie, Image, Font, and TVG.
|
@ -33,7 +33,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
//load the tvg file
|
//load the tvg file
|
||||||
auto picture = tvg::Picture::gen();
|
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);
|
picture->size(WIDTH, HEIGHT);
|
||||||
|
|
||||||
auto accessor = tvg::Accessor::gen();
|
auto accessor = tvg::Accessor::gen();
|
||||||
|
|
|
@ -43,12 +43,12 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
// image
|
// image
|
||||||
auto picture1 = tvg::Picture::gen();
|
auto picture1 = tvg::Picture::gen();
|
||||||
picture1->load(EXAMPLE_DIR"/cartman.svg");
|
picture1->load(EXAMPLE_DIR"/svg/cartman.svg");
|
||||||
picture1->size(400, 400);
|
picture1->size(400, 400);
|
||||||
canvas->push(std::move(picture1));
|
canvas->push(std::move(picture1));
|
||||||
|
|
||||||
auto picture2 = tvg::Picture::gen();
|
auto picture2 = tvg::Picture::gen();
|
||||||
picture2->load(EXAMPLE_DIR"/logo.svg");
|
picture2->load(EXAMPLE_DIR"/svg/logo.svg");
|
||||||
picture2->size(400, 400);
|
picture2->size(400, 400);
|
||||||
|
|
||||||
//mask
|
//mask
|
||||||
|
|
|
@ -54,7 +54,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
|
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;
|
cout << "Lottie is not supported. Did you enable Lottie Loader?" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
if (canvas->push(std::move(shape9)) != tvg::Result::Success) return;
|
if (canvas->push(std::move(shape9)) != tvg::Result::Success) return;
|
||||||
|
|
||||||
//Prepare Transformed Image
|
//Prepare Transformed Image
|
||||||
string path(EXAMPLE_DIR"/rawimage_200x300.raw");
|
string path(EXAMPLE_DIR"/image/rawimage_200x300.raw");
|
||||||
|
|
||||||
ifstream file(path, ios::binary);
|
ifstream file(path, ios::binary);
|
||||||
if (!file.is_open()) return ;
|
if (!file.is_open()) return ;
|
||||||
|
|
|
@ -181,7 +181,7 @@ void testCapi()
|
||||||
//////5. Masked picture
|
//////5. Masked picture
|
||||||
//Set a scene
|
//Set a scene
|
||||||
Tvg_Paint* pict = tvg_picture_new();
|
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");
|
printf("Problem with loading an svg file\n");
|
||||||
tvg_paint_del(pict);
|
tvg_paint_del(pict);
|
||||||
} else {
|
} else {
|
||||||
|
@ -204,7 +204,7 @@ void testCapi()
|
||||||
//////6. Animation with a picture
|
//////6. Animation with a picture
|
||||||
animation = tvg_animation_new();
|
animation = tvg_animation_new();
|
||||||
Tvg_Paint* pict_lottie = tvg_animation_get_picture(animation);
|
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");
|
printf("Problem with loading an lottie file\n");
|
||||||
tvg_animation_del(animation);
|
tvg_animation_del(animation);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -121,7 +121,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
auto picture = tvg::Picture::gen();
|
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->scale(3);
|
||||||
picture->translate(50, 400);
|
picture->translate(50, 400);
|
||||||
|
|
|
@ -102,7 +102,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
//Duplicate Picture - svg
|
//Duplicate Picture - svg
|
||||||
{
|
{
|
||||||
auto picture1 = tvg::Picture::gen();
|
auto picture1 = tvg::Picture::gen();
|
||||||
picture1->load(EXAMPLE_DIR"/tiger.svg");
|
picture1->load(EXAMPLE_DIR"/svg/tiger.svg");
|
||||||
picture1->translate(350, 200);
|
picture1->translate(350, 200);
|
||||||
picture1->scale(0.25);
|
picture1->scale(0.25);
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
//Duplicate Picture - raw
|
//Duplicate Picture - raw
|
||||||
{
|
{
|
||||||
string path(EXAMPLE_DIR"/rawimage_200x300.raw");
|
string path(EXAMPLE_DIR"/image/rawimage_200x300.raw");
|
||||||
ifstream file(path, ios::binary);
|
ifstream file(path, ios::binary);
|
||||||
if (!file.is_open()) return ;
|
if (!file.is_open()) return ;
|
||||||
uint32_t* data = (uint32_t*)malloc(sizeof(uint32_t) * 200 * 300);
|
uint32_t* data = (uint32_t*)malloc(sizeof(uint32_t) * 200 * 300);
|
||||||
|
@ -141,7 +141,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
//Duplicate Text
|
//Duplicate Text
|
||||||
{
|
{
|
||||||
auto text = tvg::Text::gen();
|
auto text = tvg::Text::gen();
|
||||||
text->load(EXAMPLE_DIR"/Arial.ttf");
|
text->load(EXAMPLE_DIR"/font/Arial.ttf");
|
||||||
text->font("Arial", 50);
|
text->font("Arial", 50);
|
||||||
text->translate(0, 650);
|
text->translate(0, 650);
|
||||||
text->text("ThorVG Text");
|
text->text("ThorVG Text");
|
||||||
|
|
|
@ -30,7 +30,7 @@ void exportGif()
|
||||||
{
|
{
|
||||||
auto animation = tvg::Animation::gen();
|
auto animation = tvg::Animation::gen();
|
||||||
auto picture = animation->picture();
|
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;
|
cout << "Lottie is not supported. Did you enable Lottie Loader?" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
//Original
|
//Original
|
||||||
auto picture = tvg::Picture::gen();
|
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;
|
cout << "The PNG file is not loaded correctly. Did you enable PNG Loader?" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
//Original
|
//Original
|
||||||
auto picture = tvg::Picture::gen();
|
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;
|
cout << "The PNG file is not loaded correctly. Did you enable PNG Loader?" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
//SVG
|
//SVG
|
||||||
auto svg = tvg::Picture::gen();
|
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->opacity(100);
|
||||||
svg->scale(3);
|
svg->scale(3);
|
||||||
svg->translate(50, 400);
|
svg->translate(50, 400);
|
||||||
|
@ -90,7 +90,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
|
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
|
||||||
|
|
||||||
//Image
|
//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;
|
if (!file.is_open()) return;
|
||||||
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
||||||
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);
|
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);
|
||||||
|
|
|
@ -52,7 +52,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
//SVG
|
//SVG
|
||||||
auto svg = tvg::Picture::gen();
|
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->opacity(100);
|
||||||
svg->scale(3);
|
svg->scale(3);
|
||||||
svg->translate(50, 400);
|
svg->translate(50, 400);
|
||||||
|
@ -90,7 +90,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
|
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
|
||||||
|
|
||||||
//Image
|
//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;
|
if (!file.is_open()) return;
|
||||||
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
||||||
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);
|
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);
|
||||||
|
|
|
@ -108,7 +108,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
|
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
|
//Run animation loop
|
||||||
for (auto& animation : animations) {
|
for (auto& animation : animations) {
|
||||||
|
|
|
@ -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]}}})";
|
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;
|
cout << "Lottie is not supported. Did you enable Lottie Loader?" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
//SVG
|
//SVG
|
||||||
auto svg = tvg::Picture::gen();
|
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->opacity(100);
|
||||||
svg->scale(3);
|
svg->scale(3);
|
||||||
svg->translate(50, 400);
|
svg->translate(50, 400);
|
||||||
|
@ -90,7 +90,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
|
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
|
||||||
|
|
||||||
//Image
|
//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;
|
if (!file.is_open()) return;
|
||||||
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
||||||
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);
|
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);
|
||||||
|
|
|
@ -52,7 +52,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
//SVG
|
//SVG
|
||||||
auto svg = tvg::Picture::gen();
|
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->opacity(100);
|
||||||
svg->scale(3);
|
svg->scale(3);
|
||||||
svg->translate(50, 400);
|
svg->translate(50, 400);
|
||||||
|
@ -92,7 +92,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
|
if (canvas->push(std::move(star)) != tvg::Result::Success) return;
|
||||||
|
|
||||||
//Image
|
//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;
|
if (!file.is_open()) return;
|
||||||
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
||||||
file.read(reinterpret_cast<char*>(data), sizeof (uint32_t) * 200 * 300);
|
file.read(reinterpret_cast<char*>(data), sizeof (uint32_t) * 200 * 300);
|
||||||
|
|
|
@ -32,7 +32,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
if (!canvas) return;
|
if (!canvas) return;
|
||||||
|
|
||||||
//Image source
|
//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;
|
if (!file.is_open()) return;
|
||||||
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
||||||
file.read(reinterpret_cast<char*>(data), sizeof (uint32_t) * 200 * 300);
|
file.read(reinterpret_cast<char*>(data), sizeof (uint32_t) * 200 * 300);
|
||||||
|
|
|
@ -238,9 +238,9 @@ int main(int argc, char **argv)
|
||||||
evas_object_smart_callback_add(win, "delete,request", win_del, 0);
|
evas_object_smart_callback_add(win, "delete,request", win_del, 0);
|
||||||
|
|
||||||
if (tvgEngine == tvg::CanvasEngine::Sw) {
|
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 {
|
} 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);
|
evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
|
||||||
|
|
|
@ -43,7 +43,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
mask->opacity(125);
|
mask->opacity(125);
|
||||||
|
|
||||||
auto picture = tvg::Picture::gen();
|
auto picture = tvg::Picture::gen();
|
||||||
picture->load(EXAMPLE_DIR"/tiger.svg");
|
picture->load(EXAMPLE_DIR"/svg/tiger.svg");
|
||||||
picture->size(WIDTH, HEIGHT);
|
picture->size(WIDTH, HEIGHT);
|
||||||
picture->composite(std::move(mask), tvg::CompositeMethod::AlphaMask);
|
picture->composite(std::move(mask), tvg::CompositeMethod::AlphaMask);
|
||||||
pPicture = picture.get();
|
pPicture = picture.get();
|
||||||
|
|
|
@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
//Load jpg file from path
|
//Load jpg file from path
|
||||||
for (int i = 0; i < 7; ++i) {
|
for (int i = 0; i < 7; ++i) {
|
||||||
auto picture = tvg::Picture::gen();
|
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;
|
cout << "JPG is not supported. Did you enable JPG Loader?" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Open file manually
|
//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;
|
if (!file.is_open()) return;
|
||||||
auto begin = file.tellg();
|
auto begin = file.tellg();
|
||||||
file.seekg(0, std::ios::end);
|
file.seekg(0, std::ios::end);
|
||||||
|
|
|
@ -42,7 +42,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
for (int i = 0; i < 7; ++i) {
|
for (int i = 0; i < 7; ++i) {
|
||||||
auto picture = tvg::Picture::gen();
|
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;
|
cout << "PNG is not supported. Did you enable PNG Loader?" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Open file manually
|
//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;
|
if (!file.is_open()) return;
|
||||||
auto begin = file.tellg();
|
auto begin = file.tellg();
|
||||||
file.seekg(0, std::ios::end);
|
file.seekg(0, std::ios::end);
|
||||||
|
|
|
@ -38,7 +38,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
|
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);
|
ifstream file(path, ios::binary);
|
||||||
if (!file.is_open()) return ;
|
if (!file.is_open()) return ;
|
||||||
|
|
|
@ -38,7 +38,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
canvas->push(std::move(bg));
|
canvas->push(std::move(bg));
|
||||||
|
|
||||||
char buf[PATH_MAX];
|
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();
|
auto picture = tvg::Picture::gen();
|
||||||
tvg::Result ret = picture->load(buf);
|
tvg::Result ret = picture->load(buf);
|
||||||
|
|
|
@ -33,7 +33,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
//load the tvg file
|
//load the tvg file
|
||||||
auto picture = tvg::Picture::gen();
|
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;
|
cout << "TVG is not supported. Did you enable TVG Loader?" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
for (int i = 0; i < 7; ++i) {
|
for (int i = 0; i < 7; ++i) {
|
||||||
auto picture = tvg::Picture::gen();
|
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;
|
cout << "WEBP is not supported. Did you enable WEBP Loader?" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Open file manually
|
//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;
|
if (!file.is_open()) return;
|
||||||
auto begin = file.tellg();
|
auto begin = file.tellg();
|
||||||
file.seekg(0, std::ios::end);
|
file.seekg(0, std::ios::end);
|
||||||
|
|
|
@ -85,7 +85,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
|
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.
|
/* This showcase shows you asynchrounous loading of svg.
|
||||||
For this, pushing pictures at a certian sync time.
|
For this, pushing pictures at a certian sync time.
|
||||||
|
|
|
@ -39,7 +39,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
|
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
|
||||||
|
|
||||||
//Raw Image
|
//Raw Image
|
||||||
string path(EXAMPLE_DIR"/rawimage_200x300.raw");
|
string path(EXAMPLE_DIR"/image/rawimage_200x300.raw");
|
||||||
|
|
||||||
ifstream file(path, ios::binary);
|
ifstream file(path, ios::binary);
|
||||||
if (!file.is_open()) return ;
|
if (!file.is_open()) return ;
|
||||||
|
|
|
@ -40,17 +40,17 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
//The loaded font will be released when the Initializer::term() is called.
|
//The loaded font will be released when the Initializer::term() is called.
|
||||||
//Otherwise, you can immedately unload the font data.
|
//Otherwise, you can immedately unload the font data.
|
||||||
//Please check Text::unload() APIs.
|
//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;
|
cout << "TTF is not supported. Did you enable TTF Loader?" << endl;
|
||||||
return;
|
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;
|
cout << "TTF is not supported. Did you enable TTF Loader?" << endl;
|
||||||
return;
|
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;
|
cout << "TTF is not supported. Did you enable TTF Loader?" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
|
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.
|
/* This showcase shows you asynchrounous loading of tvg.
|
||||||
For this, pushing pictures at a certian sync time.
|
For this, pushing pictures at a certian sync time.
|
||||||
|
|
|
@ -193,7 +193,7 @@ void exportTvg()
|
||||||
//prepare image source
|
//prepare image source
|
||||||
const int width = 200;
|
const int width = 200;
|
||||||
const int height = 300;
|
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;
|
if (!file.is_open()) return;
|
||||||
uint32_t *data = (uint32_t*) malloc(sizeof(uint32_t) * width * height);
|
uint32_t *data = (uint32_t*) malloc(sizeof(uint32_t) * width * height);
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 310 KiB After Width: | Height: | Size: 310 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 399 KiB After Width: | Height: | Size: 399 KiB |
Before Width: | Height: | Size: 450 KiB After Width: | Height: | Size: 450 KiB |
Before Width: | Height: | Size: 426 KiB After Width: | Height: | Size: 426 KiB |