mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 06:34:01 +00:00
test: update transform sample
Change-Id: I7f1416d9e32b241e50b7e2132764cac28d590a93
This commit is contained in:
parent
fdbf42f478
commit
2f833298c3
1 changed files with 34 additions and 3 deletions
|
@ -9,6 +9,8 @@ using namespace std;
|
|||
static uint32_t buffer[WIDTH * HEIGHT];
|
||||
unique_ptr<tvg::SwCanvas> canvas = nullptr;
|
||||
tvg::Shape* pShape = nullptr;
|
||||
tvg::Shape* pShape2 = nullptr;
|
||||
tvg::Shape* pShape3 = nullptr;
|
||||
|
||||
void tvgtest()
|
||||
{
|
||||
|
@ -16,7 +18,7 @@ void tvgtest()
|
|||
canvas = tvg::SwCanvas::gen();
|
||||
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
|
||||
|
||||
//Shape
|
||||
//Shape1
|
||||
auto shape = tvg::Shape::gen();
|
||||
|
||||
/* Acquire shape pointer to access it again.
|
||||
|
@ -28,10 +30,28 @@ void tvgtest()
|
|||
shape->appendCircle(115, 100, 100, 100);
|
||||
shape->appendCircle(115, 200, 170, 100);
|
||||
shape->fill(255, 255, 255, 255);
|
||||
shape->translate(285, 300);
|
||||
|
||||
shape->translate(385, 400);
|
||||
canvas->push(move(shape));
|
||||
|
||||
//Shape2
|
||||
auto shape2 = tvg::Shape::gen();
|
||||
pShape2 = shape2.get();
|
||||
shape2->appendRect(-50, -50, 100, 100, 0);
|
||||
shape2->fill(0, 255, 255, 255);
|
||||
shape2->translate(400, 400);
|
||||
canvas->push(move(shape2));
|
||||
|
||||
//Shape3
|
||||
auto shape3 = tvg::Shape::gen();
|
||||
pShape3 = shape3.get();
|
||||
|
||||
/* Look, how shape3's origin is different with shape2
|
||||
The center of the shape is the anchor point for transformation. */
|
||||
shape3->appendRect(100, 100, 150, 50, 20);
|
||||
shape3->fill(255, 0, 255, 255);
|
||||
shape3->translate(400, 400);
|
||||
canvas->push(move(shape3));
|
||||
|
||||
//Draw first frame
|
||||
canvas->draw();
|
||||
canvas->sync();
|
||||
|
@ -43,12 +63,23 @@ void transit_cb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progres
|
|||
You can update only necessary properties of this shape,
|
||||
while retaining other properties. */
|
||||
|
||||
//Update Shape1
|
||||
pShape->scale(1 - 0.75 * progress);
|
||||
pShape->rotate(360 * progress);
|
||||
|
||||
//Update shape for drawing (this may work asynchronously)
|
||||
canvas->update(pShape);
|
||||
|
||||
//Update Shape2
|
||||
pShape2->rotate(360 * progress);
|
||||
pShape2->translate(400 + progress * 300, 400);
|
||||
canvas->update(pShape2);
|
||||
|
||||
//Update Shape2
|
||||
pShape3->rotate(-360 * progress);
|
||||
pShape3->scale(0.5 + progress);
|
||||
canvas->update(pShape3);
|
||||
|
||||
//Draw Next frames
|
||||
canvas->draw();
|
||||
canvas->sync();
|
||||
|
|
Loading…
Add table
Reference in a new issue