mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
sw_engine stroke: stabilizing line drawing.
Also added StrokeLine test Change-Id: I91143039823d744bf9287534227927556a2f51e1
This commit is contained in:
parent
01b550497c
commit
f335779ce5
6 changed files with 109 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,3 +13,4 @@ testScene
|
|||
testTransform
|
||||
testSceneTransform
|
||||
testStroke
|
||||
testStrokeLine
|
||||
|
|
|
@ -612,7 +612,7 @@ static bool _decomposeOutline(RleWorker& rw)
|
|||
goto close;
|
||||
}
|
||||
}
|
||||
_lineTo(rw, UPSCALE(outline->pts[first]));
|
||||
_lineTo(rw, start);
|
||||
close:
|
||||
first = last + 1;
|
||||
}
|
||||
|
|
|
@ -316,6 +316,7 @@ bool shapeGenOutline(const Shape& shape, SwShape& sdata)
|
|||
auto outline = sdata.outline;
|
||||
if (!outline) outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline)));
|
||||
assert(outline);
|
||||
outline->opened = true;
|
||||
|
||||
_growOutlinePoint(*outline, outlinePtsCnt);
|
||||
_growOutlineContour(*outline, outlineCntrsCnt);
|
||||
|
|
|
@ -635,15 +635,14 @@ static void _addReverseLeft(SwStroke& stroke, bool opened)
|
|||
} else {
|
||||
//switch begin/end tags if necessary
|
||||
auto ttag = dstTag[0] & (SW_STROKE_TAG_BEGIN | SW_STROKE_TAG_END);
|
||||
if (ttag == (SW_STROKE_TAG_BEGIN || SW_STROKE_TAG_END)) {
|
||||
dstTag[0] ^= (SW_STROKE_TAG_BEGIN || SW_STROKE_TAG_END);
|
||||
}
|
||||
if (ttag == SW_STROKE_TAG_BEGIN || ttag == SW_STROKE_TAG_END)
|
||||
dstTag[0] ^= (SW_STROKE_TAG_BEGIN | SW_STROKE_TAG_END);
|
||||
}
|
||||
|
||||
--srcPt;
|
||||
--srcTag;
|
||||
--dstPt;
|
||||
--dstTag;
|
||||
++dstPt;
|
||||
++dstTag;
|
||||
}
|
||||
|
||||
left->ptsCnt = left->start;
|
||||
|
|
|
@ -11,3 +11,4 @@ all:
|
|||
gcc -o testTransform testTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
|
||||
gcc -o testSceneTransform testSceneTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
|
||||
gcc -o testStroke testStroke.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
|
||||
gcc -o testStrokeLine testStrokeLine.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
|
||||
|
|
101
test/testStrokeLine.cpp
Normal file
101
test/testStrokeLine.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
#include <tizenvg.h>
|
||||
#include <Elementary.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define WIDTH 800
|
||||
#define HEIGHT 800
|
||||
|
||||
static uint32_t buffer[WIDTH * HEIGHT];
|
||||
|
||||
void tvgtest()
|
||||
{
|
||||
//Initialize TizenVG Engine
|
||||
tvg::Engine::init();
|
||||
|
||||
//Create a Canvas
|
||||
auto canvas = tvg::SwCanvas::gen();
|
||||
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
auto shape = tvg::Shape::gen();
|
||||
shape->moveTo(50, 50 + (25 * i));
|
||||
shape->lineTo(750, 50 + (25 * i));
|
||||
shape->stroke(255, 255, 255, 255); //color: r, g, b, a
|
||||
shape->stroke(i + 1); //stroke width
|
||||
shape->stroke(tvg::StrokeCap::Round); //default is Square
|
||||
canvas->push(move(shape));
|
||||
}
|
||||
|
||||
auto shape1 = tvg::Shape::gen();
|
||||
shape1->moveTo(20, 350);
|
||||
shape1->lineTo(250, 350);
|
||||
shape1->lineTo(220, 500);
|
||||
shape1->lineTo(70, 470);
|
||||
shape1->lineTo(70, 330);
|
||||
shape1->stroke(255, 0, 0, 255);
|
||||
shape1->stroke(10);
|
||||
shape1->stroke(tvg::StrokeJoin::Round);
|
||||
shape1->stroke(tvg::StrokeCap::Round);
|
||||
canvas->push(move(shape1));
|
||||
|
||||
auto shape2 = tvg::Shape::gen();
|
||||
shape2->moveTo(270, 350);
|
||||
shape2->lineTo(500, 350);
|
||||
shape2->lineTo(470, 500);
|
||||
shape2->lineTo(320, 470);
|
||||
shape2->lineTo(320, 330);
|
||||
shape2->stroke(255, 255, 0, 255);
|
||||
shape2->stroke(10);
|
||||
shape2->stroke(tvg::StrokeJoin::Bevel);
|
||||
shape2->stroke(tvg::StrokeCap::Square);
|
||||
canvas->push(move(shape2));
|
||||
|
||||
auto shape3 = tvg::Shape::gen();
|
||||
shape3->moveTo(520, 350);
|
||||
shape3->lineTo(750, 350);
|
||||
shape3->lineTo(720, 500);
|
||||
shape3->lineTo(570, 470);
|
||||
shape3->lineTo(570, 330);
|
||||
shape3->stroke(0, 255, 0, 255);
|
||||
shape3->stroke(10);
|
||||
shape3->stroke(tvg::StrokeJoin::Miter);
|
||||
shape3->stroke(tvg::StrokeCap::Butt);
|
||||
canvas->push(move(shape3));
|
||||
|
||||
canvas->draw();
|
||||
canvas->sync();
|
||||
|
||||
//Terminate TizenVG Engine
|
||||
tvg::Engine::term();
|
||||
}
|
||||
|
||||
void
|
||||
win_del(void *data, Evas_Object *o, void *ev)
|
||||
{
|
||||
elm_exit();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
tvgtest();
|
||||
|
||||
//Show the result using EFL...
|
||||
elm_init(argc, argv);
|
||||
|
||||
Eo* win = elm_win_util_standard_add(NULL, "TizenVG Test");
|
||||
evas_object_smart_callback_add(win, "delete,request", win_del, 0);
|
||||
|
||||
Eo* img = evas_object_image_filled_add(evas_object_evas_get(win));
|
||||
evas_object_image_size_set(img, WIDTH, HEIGHT);
|
||||
evas_object_image_data_set(img, buffer);
|
||||
evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_show(img);
|
||||
|
||||
elm_win_resize_object_add(win, img);
|
||||
evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
|
||||
evas_object_show(win);
|
||||
|
||||
elm_run();
|
||||
elm_shutdown();
|
||||
}
|
Loading…
Add table
Reference in a new issue