From 20c1cbace2b9f92380531cd72d86b9dbbcdc7eda Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Fri, 22 Nov 2019 05:18:05 +0100 Subject: [PATCH] debug curve test --- README.md | 6 ++---- tests/curve.c | 3 +-- tests/curved_rect.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/fillnstroke.c | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 tests/curved_rect.c create mode 100644 tests/fillnstroke.c diff --git a/README.md b/README.md index 2144d2c..88e8980 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,9 @@ For API documentation and usage, please refer to the [Cairo](https://www.cairogr ### Performances: -Resolution = 512 x 512 -Tiling = Optimal +- Resolution = 512 x 512 +- Tiling = Optimal --------------------------------------------------------------------------------------------- | Test Name | Library | Min | Max | Average | Median | Std Deriv| |-----------------|-----------------|----------|----------|----------|----------|----------| | lines stroke | vkvg | 0.000585 | 0.007052 | 0.001050 | 0.000711 | 0.000924 | @@ -70,7 +69,6 @@ Tiling = Optimal | | cairo xcb | 0.011476 | 0.019959 | 0.015441 | 0.015245 | 0.001388 | | | cairo es3 | 0.009518 | 0.026849 | 0.010171 | 0.009951 | 0.001730 | | | skia | 0.020135 | 0.046562 | 0.023530 | 0.023253 | 0.002584 | --------------------------------------------------------------------------------------------- ### Requirements: diff --git a/tests/curve.c b/tests/curve.c index 38c4620..dd3d4b5 100644 --- a/tests/curve.c +++ b/tests/curve.c @@ -38,8 +38,7 @@ void test(){ //vkvg_stroke(ctx); vkvg_set_source_rgba (ctx, 0.5,0.0,1.0,0.5); - vkvg_move_to(ctx,100,100); - vkvg_line_to(ctx,200,100); + vkvg_move_to(ctx,200,100); vkvg_curve_to(ctx,250,100,300,150,300,200); vkvg_line_to(ctx,300,300); vkvg_curve_to(ctx,300,350,250,400,200,400); diff --git a/tests/curved_rect.c b/tests/curved_rect.c new file mode 100644 index 0000000..e7363d5 --- /dev/null +++ b/tests/curved_rect.c @@ -0,0 +1,39 @@ +#include "test.h" + +void test(){ + VkvgContext ctx = vkvg_create(surf); + + float x = 50, y = 50, width = 150, height = 140, radius = 30; + + vkvg_scale(ctx,2,2); + + vkvg_set_line_width(ctx,15); + vkvg_set_source_rgba(ctx, 0, 0.5f, 0.4f, 1); + + + if ((radius > height / 2) || (radius > width / 2)) + radius = MIN(height / 2, width / 2); + + vkvg_move_to(ctx, x, y + radius); + //vkvg_arc(ctx, x + radius, y + radius, radius, M_PIF, (float)-M_PI_2); + vkvg_line_to(ctx, x + width - radius, y); + //vkvg_arc(ctx, x + width - radius, y + radius, radius, (float)-M_PI_2, 0); + /*vkvg_line_to(ctx, x + width, y + height - radius); + vkvg_arc(ctx, x + width - radius, y + height - radius, radius, 0, (float)M_PI_2); + vkvg_line_to(ctx, x + radius, y + height); + vkvg_arc(ctx, x + radius, y + height - radius, radius, (float)M_PI_2, M_PIF); + vkvg_line_to(ctx, x, y + radius); + vkvg_close_path(ctx); + vkvg_fill_preserve(ctx);*/ + vkvg_set_source_rgba(ctx,0.5,0,0,0.5); + vkvg_stroke(ctx); + + vkvg_destroy(ctx); +} + +int main(int argc, char *argv[]) { + + perform_test (test, 1024, 768); + + return 0; +} diff --git a/tests/fillnstroke.c b/tests/fillnstroke.c new file mode 100644 index 0000000..7d35b29 --- /dev/null +++ b/tests/fillnstroke.c @@ -0,0 +1,40 @@ +#include "test.h" + +void test(){ + VkvgContext ctx = vkvg_create(surf); + + float x = 50, y = 150, dx = 150, dy = 140; + + vkvg_scale(ctx,2,2); + + vkvg_set_line_width(ctx,40); + vkvg_set_source_rgba(ctx,0,1,0,1); + + + vkvg_set_line_join(ctx,VKVG_LINE_JOIN_ROUND); + //vkvg_rectangle(ctx,x,y,dx,dy); + + + vkvg_move_to(ctx,x,y); + vkvg_rel_line_to(ctx,50,-30); + vkvg_rel_line_to(ctx,50,0); + vkvg_rel_line_to(ctx,50,30); + vkvg_rel_line_to(ctx,0,60); + vkvg_rel_line_to(ctx,-50,70); + vkvg_rel_line_to(ctx,-50,0); + vkvg_rel_line_to(ctx,-50,-70); + vkvg_line_to(ctx,x,y); + //vkvg_close_path(ctx); + vkvg_fill_preserve(ctx); + vkvg_set_source_rgba(ctx,0.5,0,0,0.5); + vkvg_stroke(ctx); + + vkvg_destroy(ctx); +} + +int main(int argc, char *argv[]) { + + perform_test (test, 1024, 768); + + return 0; +} -- 2.47.3