mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 14:41:50 +00:00
examples: update testDuplicate.
Added shape gradient fill to check duplication feature.
This commit is contained in:
parent
12cd858d72
commit
a85540397c
1 changed files with 25 additions and 10 deletions
|
@ -21,24 +21,39 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
shape1->fill(255, 0, 0, 255);
|
shape1->fill(255, 0, 0, 255);
|
||||||
|
|
||||||
//Create second shape and duplicate parameters
|
//Create second shape and duplicate parameters
|
||||||
auto shape2 = shape1->duplicate();
|
auto shape2 = unique_ptr<tvg::Shape>(static_cast<tvg::Shape*>(shape1->duplicate()));
|
||||||
|
|
||||||
//Create third shape, duplicate from first and add some new parameters
|
//Create third shape, duplicate from first and add some new parameters
|
||||||
auto shape3 = shape1->duplicate();
|
auto shape3 = unique_ptr<tvg::Shape>(static_cast<tvg::Shape*>(shape1->duplicate()));
|
||||||
|
|
||||||
//Get access to valid derived class type
|
//Move shape3 to new postion to don't cover second shape
|
||||||
tvg::Shape* shapePtr = reinterpret_cast<tvg::Shape*>(shape3.get());
|
|
||||||
|
|
||||||
//move shape3 to new postion to don't cover second shape
|
|
||||||
shape3->translate(0, 220);
|
shape3->translate(0, 220);
|
||||||
|
|
||||||
//append new paths
|
//Append New paths
|
||||||
shapePtr->appendRect(340, 10, 100, 100, 0, 0);
|
shape3->appendRect(340, 10, 100, 100, 0, 0);
|
||||||
shapePtr->fill(0, 0, 255, 255);
|
|
||||||
|
//Fill shap3 with Linear Gradient
|
||||||
|
auto fill = tvg::LinearGradient::gen();
|
||||||
|
fill->linear(10, 10, 440, 200);
|
||||||
|
|
||||||
|
//Gradient Color Stops
|
||||||
|
tvg::Fill::ColorStop colorStops[2];
|
||||||
|
colorStops[0] = {0, 0, 0, 0, 255};
|
||||||
|
colorStops[1] = {1, 255, 255, 255, 255};
|
||||||
|
|
||||||
|
fill->colorStops(colorStops, 2);
|
||||||
|
|
||||||
|
shape3->fill(move(fill));
|
||||||
|
|
||||||
|
//Create fourth shape, duplicate from third and move position
|
||||||
|
auto shape4 = unique_ptr<tvg::Shape>(static_cast<tvg::Shape*>(shape3->duplicate()));
|
||||||
|
|
||||||
|
//Move shape3 to new postion to don't cover second shape
|
||||||
|
shape4->translate(0, 440);
|
||||||
|
|
||||||
//TODO: test gradient
|
|
||||||
canvas->push(move(shape2));
|
canvas->push(move(shape2));
|
||||||
canvas->push(move(shape3));
|
canvas->push(move(shape3));
|
||||||
|
canvas->push(move(shape4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue