From: Jean-Philippe Bruyère Date: Wed, 25 Apr 2018 16:17:35 +0000 (+0200) Subject: update README and test X-Git-Tag: v0.1-alpha~133^2~2 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=bdd6d2bdb9c18a6dae8049178b98c6a94601e393;p=jp%2Fvkvg.git update README and test --- diff --git a/README.md b/README.md index bb7869d..88803c6 100644 --- a/README.md +++ b/README.md @@ -18,18 +18,20 @@ **vkvg** is a multiplatform **c** library for drawing 2D vector graphics with [Vulkan](https://www.khronos.org/vulkan/). -[Cairo](https://www.cairographics.org/) was missing a Vulkan backend, so I decided to start one myself trying to keep my api as close to Cairo as possible. Maybe vkvg could serve as a starting point for Cairo maintainers to start their Vulkan backend. +[Cairo](https://www.cairographics.org/) was missing a Vulkan backend, so I decided to start one myself trying to keep my api as close to Cairo as possible. ### Current status: -vkvg is in early development stage, and no guarantee is given on the possible roadmap: +**vkvg** is in early development stage, **0.1** beta release is on the road. -- Basic shape fill and stroke functional, using ears clipping. +- Fill (with stencil even-odd technic) and Stroke functional. - Basic painting operation. - Font system with caching operational. -- Context should be thread safe, tests required. -- Image loading with [stb lib](https://github.com/nothings/stb) -- Nice logo. +- Linear Gradients. +- Line caps and joins. +- Context should be thread safe, extensive tests required. +- Image loading and writing with [stb lib](https://github.com/nothings/stb) +- Test includes svg rendering with [nanoSVG](https://github.com/memononen/nanosvg) ### Requirements: @@ -59,7 +61,12 @@ make # Run Make ### Roadmap -- Improve triangulation algorithm. +- Radial gradients. - Offscreen pattern building. -- SVG rendering. +- Avoid line joins inside curves and arc. +- Structured unit testing. +- Perf and memory checks. +- Code clean and comment. +- Documentations. + diff --git a/tests/test1.c b/tests/test1.c index 16ae18e..8ef3f54 100644 --- a/tests/test1.c +++ b/tests/test1.c @@ -714,28 +714,36 @@ void cairo_print_arc (VkvgContext cr) { vkvg_arc (cr, xc, yc, radius, angle1, angle1); vkvg_line_to (cr, xc, yc); vkvg_arc (cr, xc, yc, radius, angle2, angle2); - //vkvg_line_to (cr, xc, yc); vkvg_stroke (cr); } void cairo_tests () { VkvgContext ctx = vkvg_create(surf); vkvg_set_source_rgba(ctx,0.7,0.7,0.7,1); vkvg_paint(ctx); - //cairo_print_arc(ctx); - //cairo_test_clip(ctx); - //vkvg_translate(ctx,200,0); + + cairo_print_arc(ctx); + + vkvg_translate(ctx,200,0); cairo_test_fill_rule(ctx); - //cairo_test_rounded_rect(ctx); - //vkvg_translate(ctx,250,0); - //cairo_test_curves(ctx); -// vkvg_translate(ctx,200,0); -// cairo_test_fill_and_stroke2(ctx); -// vkvg_translate(ctx,-650,300); - //vkvg_translate(ctx,250,0); - //cairo_print_arc_neg(ctx); + vkvg_translate(ctx,250,0); + cairo_test_rounded_rect(ctx); + + vkvg_translate(ctx,250,0); + cairo_test_curves(ctx); + + vkvg_translate(ctx,-700,250); + cairo_test_fill_and_stroke2(ctx); + + vkvg_translate(ctx,250,0); + cairo_print_arc_neg(ctx); + + /*vkvg_translate(ctx,250,0); + cairo_test_clip(ctx); + + vkvg_translate(ctx,250,0); + vkvg_test_fill_and_stroke(ctx);*/ - //vkvg_test_fill_and_stroke(ctx); vkvg_destroy(ctx); } @@ -774,13 +782,18 @@ void test_svg () { vkvg_set_source_rgba(ctx,1.0,1.0,1.0,1); vkvg_paint(ctx); - int cpt = 0; - // Load + vkvg_scale(ctx,0.5,0.5); + vkvg_matrix_t m; + vkvg_get_matrix(ctx, &m); + vkvg_set_matrix(ctx, &m); + NSVGimage* svg; NSVGshape* shape; NSVGpath* path; - svg = nsvgParseFromFile("/mnt/data/images/svg/tiger.svg", "px", 96); + svg = nsvgParseFromFile("/mnt/data/images/svg/tux.svg", "px", 96); + //svg = nsvgParseFromFile("/mnt/data/images/svg/world.svg", "px", 96); + //svg = nsvgParseFromFile("/mnt/data/images/svg/tiger.svg", "px", 96); //svg = nsvgParseFromFile("/mnt/data/images/svg/WMD-biological.svg", "px", 96); //svg = nsvgParseFromFile("/mnt/data/images/svg/Skull_and_crossbones.svg", "px", 96); //svg = nsvgParseFromFile("/mnt/data/images/svg/IconAlerte.svg", "px", 96); @@ -822,16 +835,18 @@ void test_svg () { vkvg_fill_preserve (ctx); } - if (shape->stroke.type == NSVG_PAINT_COLOR){ + if (shape->stroke.type == NSVG_PAINT_COLOR) svg_set_color(ctx, shape->stroke.color, o); - vkvg_stroke(ctx); + else if (shape->stroke.type == NSVG_PAINT_LINEAR_GRADIENT){ + NSVGgradient* g = shape->stroke.gradient; + svg_set_color(ctx, g->stops[0].color, o); } - //vkvg_stroke(ctx); - //cpt++; - //if (cpt>290) - // break; + + vkvg_stroke(ctx); + vkvg_flush(ctx); } + nsvgDelete(svg); vkvg_destroy(ctx); @@ -845,13 +860,13 @@ int main(int argc, char *argv[]) { device = vkvg_device_create(e->phy, e->dev, e->renderer.queue, e->renderer.qFam); surf = vkvg_surface_create (device,1024,800); - test_svg(); + //test_svg(); //multi_test1(); //test_grad_transforms(); - //cairo_tests(); + cairo_tests(); //test_colinear();