]> O.S.I.I.S - jp/vkvg.git/commitdiff
update tests 54/head
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 21 Dec 2021 06:47:29 +0000 (07:47 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 21 Dec 2021 06:47:29 +0000 (07:47 +0100)
tests/inverse_colinear.c
tests/test1.c

index f643d4e203f028c9ae7779f1a02320ed81138e72..be9fc52f01de0952836e83ba435d0eb38808ef7a 100644 (file)
@@ -7,14 +7,21 @@ float lineWidth = 50.0f;
 vkvg_line_join_t lineJoin = VKVG_LINE_JOIN_MITER;
 vkvg_line_cap_t lineCap = VKVG_LINE_CAP_BUTT;
 bool isClosed = false;
+bool startWithArc = false, endWithArc = false;
 
 int ptsCount = 4;
 int initPtsCount = 4;
-vec2 pts[] = {
+/*vec2 pts[] = {
        {150,150},
        {200,300},
        {250,150},
        {280,350},
+};*/
+vec2 pts[] = {
+       {150,150},
+       {250,150},
+       {100,150},
+       {150,200},
 };
 int hoverPt = -1;
 double pointSize = 7;
@@ -35,9 +42,18 @@ void draw (){
        vkvg_set_line_width(ctx,lineWidth);
        vkvg_set_line_join      (ctx, lineJoin);
        vkvg_set_line_cap       (ctx, lineCap);
-       vkvg_move_to(ctx,pts[0].x,pts[0].y);
-       for (int i=1; i<ptsCount; i++)
+
+       if (startWithArc)
+               vkvg_arc(ctx,pts[0].x,pts[0].y,200, 0.3f, M_PIF);
+       else
+               vkvg_move_to(ctx,pts[0].x,pts[0].y);
+       for (int i=1; i<ptsCount-1; i++)
                vkvg_line_to(ctx,pts[i].x,pts[i].y);
+       if (endWithArc)
+               vkvg_arc(ctx,pts[ptsCount-1].x,pts[ptsCount-1].y,200, 0.3f, M_PIF);
+       else
+               vkvg_line_to(ctx,pts[ptsCount-1].x,pts[ptsCount-1].y);
+
        if (isClosed)
                vkvg_close_path(ctx);
 
@@ -68,6 +84,12 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
        case GLFW_KEY_W :
                isClosed ^= true;
                break;
+       case GLFW_KEY_Q :
+               startWithArc ^= true;
+               break;
+       case GLFW_KEY_A :
+               endWithArc ^= true;
+               break;
        case GLFW_KEY_J :
                lineJoin++;
                if (lineJoin > 2)
index 7b6603740541c7648bbc3cffa152beb5ab394ae4..9ffdd747ddd208e5aa93ffbedb80aba09a45a30d 100644 (file)
@@ -101,7 +101,7 @@ void cairo_test_text (VkvgContext cr) {
        vkvg_stroke (cr);
 
        vkvg_move_to (cr, x,y);
-       vkvg_rel_line_to (cr, 0, -ft.descent);
+       vkvg_rel_line_to (cr, 0, ft.descent);
        vkvg_rel_line_to (cr, extents.width, 0);
        vkvg_set_source_rgba (cr, 0.9f, 0.0, 0.0, 0.6f);
 
@@ -238,13 +238,13 @@ void cairo_print_arc_neg (VkvgContext cr){
        float angle2 = 180.0f * (M_PIF/180.0f);  /* in radians           */
 
        vkvg_set_source_rgba(cr, 0, 0, 0, 1);
-       vkvg_set_line_width (cr, 5.0f);
+       vkvg_set_line_width (cr, 10.0f);
        vkvg_arc_negative (cr, xc, yc, radius, angle1, angle2);
        vkvg_stroke (cr);
 
        /* draw helping lines */
        vkvg_set_source_rgba (cr, 1, 0.2f, 0.2f, 0.6f);
-       vkvg_set_line_width (cr, 10.0f);
+       vkvg_set_line_width (cr, 6.0f);
 
        vkvg_arc (cr, xc, yc, 10.0f, 0, 2.f*M_PIF);
        vkvg_fill (cr);