]> O.S.I.I.S - jp/vkvg.git/commitdiff
update README and test
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 25 Apr 2018 16:17:35 +0000 (18:17 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 25 Apr 2018 16:17:35 +0000 (18:17 +0200)
README.md
tests/test1.c

index bb7869db1ac8dbaff93376028215c2a1e1356908..88803c6c278b8f8db3753cc5484a9123b69e64fa 100644 (file)
--- a/README.md
+++ b/README.md
 
 **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.
+
 
index 16ae18ee88bcf393cbaf7a571e44a967d6f2b168..8ef3f5433b382ed21a3be9414c7836a554a576ac 100644 (file)
@@ -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();