diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2024-10-27 20:03:31 +0000 |
|---|---|---|
| committer | j-p <jp_bruyere@hotmail.com> | 2025-03-24 19:12:00 +0100 |
| commit | 15ecf40ff47bfbdedddd3161b7d6d9d1418e64bb (patch) | |
| tree | 49001433bd5b102118593642bf1a749494e7ea54 /tests | |
| parent | 7b2f17b8d8f3763d974c52bfbe9a429779aa6f7b (diff) | |
clang format
Diffstat (limited to 'tests')
50 files changed, 8455 insertions, 8482 deletions
diff --git a/tests/arcs.c b/tests/arcs.c index cfeb131..e711b41 100644 --- a/tests/arcs.c +++ b/tests/arcs.c @@ -1,92 +1,92 @@ #include "test.h" -void draw_growing_circles (VkvgContext ctx, float y, int count) { - float x = 2; - for (int i=1; i<count; i++) { - x += 0.5f*i; - //vkvg_set_source_rgb (ctx, 1,0,1); - vkvg_arc(ctx, x + 2, y, 0.5f * i, 0, M_PIF*1.5f); - //vkvg_set_source_rgb (ctx, 0,1,1); - //vkvg_arc_negative(ctx, x + 2, y, 0.5 * i, M_PI/2,0); - x += 0.5f*i + 5; - } +void draw_growing_circles(VkvgContext ctx, float y, int count) { + float x = 2; + for (int i = 1; i < count; i++) { + x += 0.5f * i; + // vkvg_set_source_rgb (ctx, 1,0,1); + vkvg_arc(ctx, x + 2, y, 0.5f * i, 0, M_PIF * 1.5f); + // vkvg_set_source_rgb (ctx, 0,1,1); + // vkvg_arc_negative(ctx, x + 2, y, 0.5 * i, M_PI/2,0); + x += 0.5f * i + 5; + } } void scaled_up() { - VkvgContext ctx = vkvg_create(surf); + VkvgContext ctx = vkvg_create(surf); - vkvg_set_source_rgb (ctx, 1,1,1); - vkvg_paint(ctx); - vkvg_set_source_rgb (ctx, 0,0,0); + vkvg_set_source_rgb(ctx, 1, 1, 1); + vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 0, 0, 0); - vkvg_scale(ctx,10,10); - vkvg_arc(ctx, 20, 20, 2.0f, 0, M_PIF/2.f); - vkvg_stroke(ctx); + vkvg_scale(ctx, 10, 10); + vkvg_arc(ctx, 20, 20, 2.0f, 0, M_PIF / 2.f); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } void sizes() { - VkvgContext ctx = vkvg_create(surf); + VkvgContext ctx = vkvg_create(surf); - vkvg_set_source_rgb (ctx, 1,1,1); - vkvg_paint(ctx); - vkvg_set_source_rgb (ctx, 0,0,0); + vkvg_set_source_rgb(ctx, 1, 1, 1); + vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 0, 0, 0); - draw_growing_circles (ctx, 100, 40); - vkvg_stroke(ctx); + draw_growing_circles(ctx, 100, 40); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void test(){ - VkvgContext ctx = vkvg_create(surf); +void test() { + VkvgContext ctx = vkvg_create(surf); - vkvg_set_source_rgb (ctx, 1,1,1); - vkvg_paint(ctx); - vkvg_set_source_rgb (ctx, 0,0,0); + vkvg_set_source_rgb(ctx, 1, 1, 1); + vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 0, 0, 0); - vkvg_set_source_rgb (ctx, 1,0,1); - vkvg_set_line_width(ctx, 5.0); - vkvg_arc(ctx, 100, 100, 20, 0, M_PIF/2); - vkvg_stroke(ctx); + vkvg_set_source_rgb(ctx, 1, 0, 1); + vkvg_set_line_width(ctx, 5.0); + vkvg_arc(ctx, 100, 100, 20, 0, M_PIF / 2); + vkvg_stroke(ctx); - vkvg_set_source_rgb (ctx, 0,1,1); - vkvg_arc_negative(ctx, 100, 100, 20, 0, M_PIF/2); - vkvg_stroke(ctx); + vkvg_set_source_rgb(ctx, 0, 1, 1); + vkvg_arc_negative(ctx, 100, 100, 20, 0, M_PIF / 2); + vkvg_stroke(ctx); - vkvg_set_source_rgb (ctx, 1,0,1); - vkvg_arc(ctx, 100, 200, 20, M_PIF/2, 0); - vkvg_stroke(ctx); + vkvg_set_source_rgb(ctx, 1, 0, 1); + vkvg_arc(ctx, 100, 200, 20, M_PIF / 2, 0); + vkvg_stroke(ctx); - vkvg_set_source_rgb (ctx, 0,1,1); - vkvg_arc_negative(ctx, 100, 200, 20, M_PIF/2, 0); - vkvg_stroke(ctx); + vkvg_set_source_rgb(ctx, 0, 1, 1); + vkvg_arc_negative(ctx, 100, 200, 20, M_PIF / 2, 0); + vkvg_stroke(ctx); - vkvg_set_source_rgb (ctx, 0,0,1); - vkvg_set_line_width(ctx, 10.0); - vkvg_arc(ctx, 350, 100, 40, 0, M_PIF*2); - vkvg_stroke(ctx); + vkvg_set_source_rgb(ctx, 0, 0, 1); + vkvg_set_line_width(ctx, 10.0); + vkvg_arc(ctx, 350, 100, 40, 0, M_PIF * 2); + vkvg_stroke(ctx); - vkvg_set_source_rgb (ctx, 0,1,0); - vkvg_set_line_width(ctx, 1.0); - vkvg_arc(ctx, 150, 100, 3.5, 0, M_PIF*2); - vkvg_stroke(ctx); - vkvg_arc(ctx, 200, 200, 10, 0, M_PIF*2); - vkvg_fill(ctx); + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_set_line_width(ctx, 1.0); + vkvg_arc(ctx, 150, 100, 3.5, 0, M_PIF * 2); + vkvg_stroke(ctx); + vkvg_arc(ctx, 200, 200, 10, 0, M_PIF * 2); + vkvg_fill(ctx); - vkvg_set_source_rgb (ctx, 1,0,0); - vkvg_scale(ctx,3,3); - vkvg_arc(ctx, 150, 100, 3.5, 0, M_PIF*2); - vkvg_stroke(ctx); - vkvg_arc(ctx, 200, 200, 10, 0, M_PIF*2); - vkvg_fill(ctx); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_scale(ctx, 3, 3); + vkvg_arc(ctx, 150, 100, 3.5, 0, M_PIF * 2); + vkvg_stroke(ctx); + vkvg_arc(ctx, 200, 200, 10, 0, M_PIF * 2); + vkvg_fill(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (sizes, argc, argv); - PERFORM_TEST (scaled_up, argc, argv); - PERFORM_TEST (test, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(sizes, argc, argv); + PERFORM_TEST(scaled_up, argc, argv); + PERFORM_TEST(test, argc, argv); + return 0; } diff --git a/tests/bezier.c b/tests/bezier.c index 0ac57d3..a504722 100644 --- a/tests/bezier.c +++ b/tests/bezier.c @@ -1,230 +1,215 @@ #include "test.h" #include "vectors.h" -vkvg_fill_rule_t fillrule = VKVG_FILL_RULE_NON_ZERO; -static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; -float lineWidth = 10.0f; -vkvg_line_join_t lineJoin = VKVG_LINE_JOIN_MITER; -vkvg_line_cap_t lineCap = VKVG_LINE_CAP_BUTT; -bool isClosed = false, isFilled = false; +vkvg_fill_rule_t fillrule = VKVG_FILL_RULE_NON_ZERO; +static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; +float lineWidth = 10.0f; +vkvg_line_join_t lineJoin = VKVG_LINE_JOIN_MITER; +vkvg_line_cap_t lineCap = VKVG_LINE_CAP_BUTT; +bool isClosed = false, isFilled = false; -int ptsCount = 4; -int initPtsCount = 4; -vec2 pts[] = { - {150,150}, - {500,340}, - {470,150}, - {160,350}, +int ptsCount = 4; +int initPtsCount = 4; +vec2 pts[] = { + {150, 150}, + {500, 340}, + {470, 150}, + {160, 350}, }; /*vec2 pts[] = { - {150,150}, - {250,150}, - {100,150}, - {150,200}, + {150,150}, + {250,150}, + {100,150}, + {150,200}, };*/ -int hoverPt = -1; -double hoverPointSize = 7, - pointSize = 5; +int hoverPt = -1; +double hoverPointSize = 7, pointSize = 5; #ifdef VKVG_WIRED_DEBUG vkvg_wired_debug_mode _wired_debug = vkvg_wired_debug_mode_normal; #endif -void draw (){ +void draw() { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); #ifdef VKVG_WIRED_DEBUG - vkvg_wired_debug = _wired_debug; + vkvg_wired_debug = _wired_debug; #endif - vkvg_set_line_width (ctx,lineWidth); - vkvg_set_line_join (ctx, lineJoin); - vkvg_set_line_cap (ctx, lineCap); + 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); - vkvg_curve_to(ctx, pts[1].x,pts[1].y, pts[2].x,pts[2].y, pts[3].x,pts[3].y); + vkvg_move_to(ctx, pts[0].x, pts[0].y); + vkvg_curve_to(ctx, pts[1].x, pts[1].y, pts[2].x, pts[2].y, pts[3].x, pts[3].y); - if (isClosed) - vkvg_close_path(ctx); + if (isClosed) + vkvg_close_path(ctx); - if (isFilled) { - vkvg_set_source_rgba(ctx,0.4,0.6,0.4,1); - vkvg_fill_preserve (ctx); - } + if (isFilled) { + vkvg_set_source_rgba(ctx, 0.4, 0.6, 0.4, 1); + vkvg_fill_preserve(ctx); + } - vkvg_set_source_rgba(ctx,1,0,0,0.3f); + vkvg_set_source_rgba(ctx, 1, 0, 0, 0.3f); - vkvg_stroke (ctx); - vkvg_flush (ctx); + vkvg_stroke(ctx); + vkvg_flush(ctx); #ifdef VKVG_WIRED_DEBUG - vkvg_wired_debug = vkvg_wired_debug_mode_normal; + vkvg_wired_debug = vkvg_wired_debug_mode_normal; #endif - vkvg_set_line_width(ctx, 1); - vkvg_set_source_rgba(ctx,0.5,0.5,0.5,0.6); - for (int i=0; i<ptsCount; i++) { + vkvg_set_line_width(ctx, 1); + vkvg_set_source_rgba(ctx, 0.5, 0.5, 0.5, 0.6); + for (int i = 0; i < ptsCount; i++) { - if (i == hoverPt) { - vkvg_arc (ctx, pts[i].x, pts[i].y, hoverPointSize, 0, M_PIF*2); - vkvg_set_source_rgba (ctx, 0.5, 0.5, 1.0, 0.6); - vkvg_fill_preserve (ctx); - vkvg_set_source_rgba (ctx, 0.5 ,0.5 ,0.5 ,0.6); - } else { - vkvg_arc (ctx, pts[i].x, pts[i].y, pointSize, 0, M_PIF*2); - vkvg_fill_preserve (ctx); - } - vkvg_stroke (ctx); + if (i == hoverPt) { + vkvg_arc(ctx, pts[i].x, pts[i].y, hoverPointSize, 0, M_PIF * 2); + vkvg_set_source_rgba(ctx, 0.5, 0.5, 1.0, 0.6); + vkvg_fill_preserve(ctx); + vkvg_set_source_rgba(ctx, 0.5, 0.5, 0.5, 0.6); + } else { + vkvg_arc(ctx, pts[i].x, pts[i].y, pointSize, 0, M_PIF * 2); + vkvg_fill_preserve(ctx); + } + vkvg_stroke(ctx); + } + if (hoverPt >= 0) { + vkvg_stroke_preserve(ctx); + vkvg_set_dash(ctx, NULL, 0, 0); + vkvg_set_line_width(ctx, 2); + vkvg_set_source_rgba(ctx, 0, 0, 0, 1); + vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 0.5f, 0.5f, 1.0f, 0.7f); + vkvg_arc(ctx, pts[hoverPt].x, pts[hoverPt].y, pointSize, 0, M_PIF * 2); + vkvg_fill_preserve(ctx); + vkvg_stroke(ctx); + } else + vkvg_stroke(ctx); - } - - if (hoverPt>=0) { - vkvg_stroke_preserve(ctx); - vkvg_set_dash(ctx, NULL, 0, 0); - vkvg_set_line_width(ctx,2); - vkvg_set_source_rgba(ctx,0,0,0,1); - vkvg_stroke(ctx); - vkvg_set_source_rgba(ctx,0.5f,0.5f,1.0f,0.7f); - vkvg_arc (ctx, pts[hoverPt].x, pts[hoverPt].y, pointSize, 0, M_PIF*2); - vkvg_fill_preserve(ctx); - vkvg_stroke(ctx); - } else - vkvg_stroke(ctx); - - //draw_v(ctx, 200, 20, VKVG_LINE_JOIN_BEVEL); - //draw_v(ctx, 300, 80, VKVG_LINE_JOIN_ROUND); - vkvg_destroy(ctx); + // draw_v(ctx, 200, 20, VKVG_LINE_JOIN_BEVEL); + // draw_v(ctx, 300, 80, VKVG_LINE_JOIN_ROUND); + vkvg_destroy(ctx); } -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { - if (action == GLFW_RELEASE) - return; - switch (key) { - case GLFW_KEY_ESCAPE : - glfwSetWindowShouldClose(window, GLFW_TRUE); - break; - case GLFW_KEY_W : - isClosed ^= true; - break; - case GLFW_KEY_F : - isFilled ^= true; - break; - case GLFW_KEY_J : - lineJoin++; - if (lineJoin > 2) - lineJoin = 0; - break; - case GLFW_KEY_C : - lineCap++; - if (lineCap > 2) - lineCap = 0; - break; - case GLFW_KEY_KP_ADD : - lineWidth++; - break; - case GLFW_KEY_KP_SUBTRACT : - if (lineWidth > 1) - lineWidth--; - break; +static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) { + if (action == GLFW_RELEASE) + return; + switch (key) { + case GLFW_KEY_ESCAPE: + glfwSetWindowShouldClose(window, GLFW_TRUE); + break; + case GLFW_KEY_W: + isClosed ^= true; + break; + case GLFW_KEY_F: + isFilled ^= true; + break; + case GLFW_KEY_J: + lineJoin++; + if (lineJoin > 2) + lineJoin = 0; + break; + case GLFW_KEY_C: + lineCap++; + if (lineCap > 2) + lineCap = 0; + break; + case GLFW_KEY_KP_ADD: + lineWidth++; + break; + case GLFW_KEY_KP_SUBTRACT: + if (lineWidth > 1) + lineWidth--; + break; #ifdef VKVG_WIRED_DEBUG - case GLFW_KEY_F1: - _wired_debug ^= (1U << 0); - break; - case GLFW_KEY_F2: - _wired_debug ^= (1U << 1); - break; - case GLFW_KEY_F3: - _wired_debug ^= (1U << 2); - break; + case GLFW_KEY_F1: + _wired_debug ^= (1U << 0); + break; + case GLFW_KEY_F2: + _wired_debug ^= (1U << 1); + break; + case GLFW_KEY_F3: + _wired_debug ^= (1U << 2); + break; #endif - } + } } -static void mouse_move_callback(GLFWwindow* window, double x, double y){ - if (mouseDown) { - if (hoverPt < 0) - return; - pts[hoverPt].x = x; - pts[hoverPt].y = y; - } else { - for (int i=0; i<ptsCount; i++) { - if (x > pts[i].x - hoverPointSize && - x < pts[i].x + hoverPointSize && - y > pts[i].y - hoverPointSize && - y < pts[i].y + hoverPointSize) { - hoverPt = i; - return; - } - } - hoverPt = -1; - } +static void mouse_move_callback(GLFWwindow *window, double x, double y) { + if (mouseDown) { + if (hoverPt < 0) + return; + pts[hoverPt].x = x; + pts[hoverPt].y = y; + } else { + for (int i = 0; i < ptsCount; i++) { + if (x > pts[i].x - hoverPointSize && x < pts[i].x + hoverPointSize && y > pts[i].y - hoverPointSize && + y < pts[i].y + hoverPointSize) { + hoverPt = i; + return; + } + } + hoverPt = -1; + } } -static void scroll_callback(GLFWwindow* window, double x, double y){ - if (y<0.f) - zoom *= 0.5f; - else - zoom *= 2.0f; +static void scroll_callback(GLFWwindow *window, double x, double y) { + if (y < 0.f) + zoom *= 0.5f; + else + zoom *= 2.0f; } -static void mouse_button_callback(GLFWwindow* window, int but, int state, int modif){ - if (but != GLFW_MOUSE_BUTTON_1) - return; - if (state == GLFW_TRUE) - mouseDown = true; - else - mouseDown = false; +static void mouse_button_callback(GLFWwindow *window, int but, int state, int modif) { + if (but != GLFW_MOUSE_BUTTON_1) + return; + if (state == GLFW_TRUE) + mouseDown = true; + else + mouseDown = false; } +int main(int argc, char *argv[]) { + _parse_args(argc, argv); + VkEngine e; + e = vkengine_create(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); -int main(int argc, char* argv[]) { - - _parse_args (argc, argv); - VkEngine e; - e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); - - VkhPresenter r = e->renderer; - vkengine_set_key_callback (e, key_callback); - vkengine_set_mouse_but_callback(e, mouse_button_callback); - vkengine_set_cursor_pos_callback(e, mouse_move_callback); - vkengine_set_scroll_callback(e, scroll_callback); + VkhPresenter r = e->renderer; + vkengine_set_key_callback(e, key_callback); + vkengine_set_mouse_but_callback(e, mouse_button_callback); + vkengine_set_cursor_pos_callback(e, mouse_move_callback); + vkengine_set_scroll_callback(e, scroll_callback); - vkvg_device_create_info_t info = { - samples, - false, - vkh_app_get_inst(e->app), - r->dev->phy, - r->dev->dev, - r->qFam, - 0 - }; - device = vkvg_device_create(&info); + vkvg_device_create_info_t info = {samples, false, vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0}; + device = vkvg_device_create(&info); - surf = vkvg_surface_create(device, test_width, test_height); + surf = vkvg_surface_create(device, test_width, test_height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); - while (!vkengine_should_close (e)) { - glfwPollEvents(); + while (!vkengine_should_close(e)) { + glfwPollEvents(); - draw (); + draw(); - if (!vkh_presenter_draw (r)){ - vkh_presenter_get_size (r, &test_width, &test_height); - vkvg_surface_destroy (surf); - surf = vkvg_surface_create(device, test_width, test_height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); - vkDeviceWaitIdle(r->dev->dev); - continue; - } - } - vkDeviceWaitIdle(e->dev->dev); + if (!vkh_presenter_draw(r)) { + vkh_presenter_get_size(r, &test_width, &test_height); + vkvg_surface_destroy(surf); + surf = vkvg_surface_create(device, test_width, test_height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); + vkDeviceWaitIdle(r->dev->dev); + continue; + } + } + vkDeviceWaitIdle(e->dev->dev); - vkvg_surface_destroy (surf); + vkvg_surface_destroy(surf); - vkvg_device_destroy (device); + vkvg_device_destroy(device); - vkengine_destroy (e); + vkengine_destroy(e); - return 0; + return 0; } diff --git a/tests/circles.c b/tests/circles.c index 3a34d81..e8f88ba 100644 --- a/tests/circles.c +++ b/tests/circles.c @@ -1,63 +1,63 @@ #include "test.h" -void draw_growing_circles (VkvgContext ctx, float y, int count) { - float x = 2; - for (int i=1; i<count; i++) { - x += 0.5f*i; - vkvg_arc(ctx, x + 2, y, 0.5f * i, 0, M_PIF*2.f); - x += 0.5f*i + 5; - } +void draw_growing_circles(VkvgContext ctx, float y, int count) { + float x = 2; + for (int i = 1; i < count; i++) { + x += 0.5f * i; + vkvg_arc(ctx, x + 2, y, 0.5f * i, 0, M_PIF * 2.f); + x += 0.5f * i + 5; + } } void scaled_up() { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - vkvg_set_source_rgb (ctx, 1,1,1); + vkvg_set_source_rgb(ctx, 1, 1, 1); - vkvg_scale(ctx,100,100); - vkvg_arc(ctx, 2, 2, 0.5f, 0, M_PIF*2); - vkvg_stroke(ctx); + vkvg_scale(ctx, 100, 100); + vkvg_arc(ctx, 2, 2, 0.5f, 0, M_PIF * 2); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void fill_and_stroke () { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); - vkvg_set_source_rgba (ctx, 0,0.1f,0.8f, 0.5f); - vkvg_set_line_width(ctx,10); +void fill_and_stroke() { + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); + vkvg_set_source_rgba(ctx, 0, 0.1f, 0.8f, 0.5f); + vkvg_set_line_width(ctx, 10); - vkvg_arc(ctx, 300, 300, 150.f, 0, M_PIF*2); - vkvg_fill_preserve(ctx); - vkvg_stroke(ctx); + vkvg_arc(ctx, 300, 300, 150.f, 0, M_PIF * 2); + vkvg_fill_preserve(ctx); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } void sizes() { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - vkvg_set_source_rgb (ctx, 1,1,1); + vkvg_set_source_rgb(ctx, 1, 1, 1); - draw_growing_circles (ctx, 100, 40); - vkvg_fill (ctx); + draw_growing_circles(ctx, 100, 40); + vkvg_fill(ctx); - draw_growing_circles (ctx, 200, 40); - vkvg_stroke(ctx); + draw_growing_circles(ctx, 200, 40); + vkvg_stroke(ctx); - vkvg_set_source_rgba (ctx, 0,0,1,0.4F); - draw_growing_circles (ctx, 300, 40); - vkvg_fill_preserve (ctx); - vkvg_set_line_width(ctx,5); - vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 0, 0, 1, 0.4F); + draw_growing_circles(ctx, 300, 40); + vkvg_fill_preserve(ctx); + vkvg_set_line_width(ctx, 5); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (fill_and_stroke, argc, argv); - PERFORM_TEST (sizes, argc, argv); - PERFORM_TEST (scaled_up, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(fill_and_stroke, argc, argv); + PERFORM_TEST(sizes, argc, argv); + PERFORM_TEST(scaled_up, argc, argv); + return 0; } diff --git a/tests/clip.c b/tests/clip.c index e5c03a0..5ae8026 100644 --- a/tests/clip.c +++ b/tests/clip.c @@ -1,186 +1,183 @@ #include "test.h" -void clipped_paint_ec () { - VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_paint(ctx); - vkvg_set_source_rgb(ctx,0,1,0); - vkvg_rectangle(ctx, 100,100,300,200); - vkvg_clip(ctx); - vkvg_paint(ctx); - vkvg_destroy(ctx); +void clipped_paint_ec() { + VkvgContext ctx = vkvg_create(surf); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_clip(ctx); + vkvg_paint(ctx); + vkvg_destroy(ctx); } -void clipped_paint_eo () { - VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_paint(ctx); - vkvg_set_source_rgb(ctx,0,1,0); - vkvg_rectangle(ctx, 100,100,300,200); - vkvg_clip(ctx); - vkvg_paint(ctx); +void clipped_paint_eo() { + VkvgContext ctx = vkvg_create(surf); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_clip(ctx); + vkvg_paint(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void clipped_paint2_ec () { - VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_paint(ctx); - vkvg_set_source_rgb(ctx,0,1,0); - vkvg_rectangle(ctx, 100,100,300,200); - vkvg_clip(ctx); - vkvg_paint(ctx); +void clipped_paint2_ec() { + VkvgContext ctx = vkvg_create(surf); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_clip(ctx); + vkvg_paint(ctx); - vkvg_reset_clip(ctx); - vkvg_rectangle(ctx, 200,200,300,200); - vkvg_set_source_rgb(ctx,0,0,1); - vkvg_paint(ctx); + vkvg_reset_clip(ctx); + vkvg_rectangle(ctx, 200, 200, 300, 200); + vkvg_set_source_rgb(ctx, 0, 0, 1); + vkvg_paint(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void clipped_paint2_eo () { - VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_paint(ctx); - vkvg_set_source_rgb(ctx,0,1,0); - vkvg_rectangle(ctx, 100,100,300,200); - vkvg_clip(ctx); - vkvg_paint(ctx); - vkvg_reset_clip(ctx); - vkvg_rectangle(ctx, 200,200,300,200); - vkvg_set_source_rgb(ctx,0,0,1); - vkvg_paint(ctx); +void clipped_paint2_eo() { + VkvgContext ctx = vkvg_create(surf); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_clip(ctx); + vkvg_paint(ctx); + vkvg_reset_clip(ctx); + vkvg_rectangle(ctx, 200, 200, 300, 200); + vkvg_set_source_rgb(ctx, 0, 0, 1); + vkvg_paint(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void clipped_transformed_ec () { - VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_paint(ctx); - vkvg_rotate(ctx,0.2f); - vkvg_set_source_rgb(ctx,0,1,0); - vkvg_rectangle(ctx, 100,100,300,200); - vkvg_clip(ctx); - vkvg_paint(ctx); - vkvg_destroy(ctx); +void clipped_transformed_ec() { + VkvgContext ctx = vkvg_create(surf); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_paint(ctx); + vkvg_rotate(ctx, 0.2f); + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_clip(ctx); + vkvg_paint(ctx); + vkvg_destroy(ctx); } -void clip_transformed_ec () { - VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_paint(ctx); - vkvg_rotate(ctx,0.1f); - vkvg_set_source_rgb(ctx,0,1,0); - vkvg_rectangle(ctx, 100,100,300,200); - vkvg_clip(ctx); - vkvg_paint(ctx); - vkvg_translate (ctx,200,100); - vkvg_set_source_rgb(ctx,0,0,1); - vkvg_paint(ctx); +void clip_transformed_ec() { + VkvgContext ctx = vkvg_create(surf); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_paint(ctx); + vkvg_rotate(ctx, 0.1f); + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_clip(ctx); + vkvg_paint(ctx); + vkvg_translate(ctx, 200, 100); + vkvg_set_source_rgb(ctx, 0, 0, 1); + vkvg_paint(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void clipped_transformed_eo () { - VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_paint(ctx); - vkvg_rotate(ctx,0.2f); - vkvg_set_source_rgb(ctx,0,1,0); - vkvg_rectangle(ctx, 100,100,300,200); - vkvg_clip(ctx); - vkvg_paint(ctx); +void clipped_transformed_eo() { + VkvgContext ctx = vkvg_create(surf); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_paint(ctx); + vkvg_rotate(ctx, 0.2f); + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_clip(ctx); + vkvg_paint(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void test_clip(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); - vkvg_move_to(ctx,10,10); - vkvg_line_to(ctx,400,150); - vkvg_line_to(ctx,900,10); - vkvg_line_to(ctx,700,450); - vkvg_line_to(ctx,900,750); - vkvg_line_to(ctx,500,650); - vkvg_line_to(ctx,100,800); - vkvg_line_to(ctx,150,400); - vkvg_clip_preserve(ctx); - vkvg_set_operator(ctx, VKVG_OPERATOR_CLEAR); - vkvg_fill_preserve(ctx); - vkvg_clip(ctx); - vkvg_set_operator(ctx, VKVG_OPERATOR_OVER); +void test_clip() { + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_move_to(ctx, 10, 10); + vkvg_line_to(ctx, 400, 150); + vkvg_line_to(ctx, 900, 10); + vkvg_line_to(ctx, 700, 450); + vkvg_line_to(ctx, 900, 750); + vkvg_line_to(ctx, 500, 650); + vkvg_line_to(ctx, 100, 800); + vkvg_line_to(ctx, 150, 400); + vkvg_clip_preserve(ctx); + vkvg_set_operator(ctx, VKVG_OPERATOR_CLEAR); + vkvg_fill_preserve(ctx); + vkvg_clip(ctx); + vkvg_set_operator(ctx, VKVG_OPERATOR_OVER); - vkvg_set_source_rgb(ctx,1,0,0); - //vkvg_set_line_width(ctx,10); - //vkvg_stroke(ctx); - vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 1, 0, 0); + // vkvg_set_line_width(ctx,10); + // vkvg_stroke(ctx); + vkvg_paint(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void test_clip2(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); - vkvg_rectangle(ctx, 50,50,500,500); - vkvg_clip(ctx); +void test_clip2() { + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); + vkvg_rectangle(ctx, 50, 50, 500, 500); + vkvg_clip(ctx); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_paint(ctx); - vkvg_save(ctx); - vkvg_rectangle(ctx, 100,100,350,350); - vkvg_clip(ctx); - vkvg_save(ctx); + vkvg_save(ctx); + vkvg_rectangle(ctx, 100, 100, 350, 350); + vkvg_clip(ctx); + vkvg_save(ctx); - vkvg_set_source_rgb(ctx,1,1,0); - vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 1, 1, 0); + vkvg_paint(ctx); - vkvg_rectangle(ctx, 200,200,200,200); - vkvg_clip(ctx); + vkvg_rectangle(ctx, 200, 200, 200, 200); + vkvg_clip(ctx); - vkvg_set_source_rgb(ctx,0,1,0); - vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_paint(ctx); - vkvg_restore(ctx); + vkvg_restore(ctx); - vkvg_rectangle(ctx, 350,350,420,420); - vkvg_set_source_rgb(ctx,0,0,1); - vkvg_fill(ctx); + vkvg_rectangle(ctx, 350, 350, 420, 420); + vkvg_set_source_rgb(ctx, 0, 0, 1); + vkvg_fill(ctx); - vkvg_restore(ctx); + vkvg_restore(ctx); - //vkvg_clip(ctx); - // - /*vkvg_clip_preserve(ctx); - vkvg_set_operator(ctx, VKVG_OPERATOR_CLEAR); - vkvg_fill_preserve(ctx);*/ - //vkvg_clip(ctx); - //vkvg_set_operator(ctx, VKVG_OPERATOR_OVER); - /*vkvg_rectangle(ctx, 200,200,220,220); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_paint(ctx);*/ + // vkvg_clip(ctx); + // + /*vkvg_clip_preserve(ctx); + vkvg_set_operator(ctx, VKVG_OPERATOR_CLEAR); + vkvg_fill_preserve(ctx);*/ + // vkvg_clip(ctx); + // vkvg_set_operator(ctx, VKVG_OPERATOR_OVER); + /*vkvg_rectangle(ctx, 200,200,220,220); + vkvg_set_source_rgb(ctx,1,0,0); + vkvg_paint(ctx);*/ - - - - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (clip_transformed_ec, argc, argv); - PERFORM_TEST (clipped_paint_ec, argc, argv); - PERFORM_TEST (clipped_paint_eo, argc, argv); - PERFORM_TEST (clipped_transformed_ec, argc, argv); - PERFORM_TEST (clipped_transformed_eo, argc, argv); - PERFORM_TEST (clipped_paint2_ec, argc, argv); - PERFORM_TEST (clipped_paint2_eo, argc, argv); - PERFORM_TEST (test_clip, argc, argv); - PERFORM_TEST (test_clip2, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(clip_transformed_ec, argc, argv); + PERFORM_TEST(clipped_paint_ec, argc, argv); + PERFORM_TEST(clipped_paint_eo, argc, argv); + PERFORM_TEST(clipped_transformed_ec, argc, argv); + PERFORM_TEST(clipped_transformed_eo, argc, argv); + PERFORM_TEST(clipped_paint2_ec, argc, argv); + PERFORM_TEST(clipped_paint2_eo, argc, argv); + PERFORM_TEST(test_clip, argc, argv); + PERFORM_TEST(test_clip2, argc, argv); + return 0; } diff --git a/tests/colinear.c b/tests/colinear.c index 9e7d32e..4a569d9 100644 --- a/tests/colinear.c +++ b/tests/colinear.c @@ -1,25 +1,25 @@ #include "test.h" -void test(){ - VkvgContext ctx = vkvg_create(surf); +void test() { + VkvgContext ctx = vkvg_create(surf); - vkvg_set_source_rgba(ctx,0.7f,0.7f,0.7f,1); - vkvg_paint(ctx); + vkvg_set_source_rgba(ctx, 0.7f, 0.7f, 0.7f, 1); + vkvg_paint(ctx); - vkvg_set_source_rgba(ctx,0,1,0,1); - vkvg_set_line_width(ctx,10); + vkvg_set_source_rgba(ctx, 0, 1, 0, 1); + vkvg_set_line_width(ctx, 10); - vkvg_move_to(ctx,100,100); - vkvg_line_to(ctx,100,200); - vkvg_line_to(ctx,100,300); - vkvg_stroke(ctx); + vkvg_move_to(ctx, 100, 100); + vkvg_line_to(ctx, 100, 200); + vkvg_line_to(ctx, 100, 300); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (test, argc, argv); + no_test_size = true; + PERFORM_TEST(test, argc, argv); - return 0; + return 0; } diff --git a/tests/common/nanosvg.h b/tests/common/nanosvg.h index 65ba2a7..3f50d45 100644 --- a/tests/common/nanosvg.h +++ b/tests/common/nanosvg.h @@ -50,125 +50,104 @@ extern "C" { // // If you don't know or care about the units stuff, "px" and 96 should get you going. - /* Example Usage: - // Load - NSVGImage* image; - image = nsvgParseFromFile("test.svg", "px", 96); - printf("size: %f x %f\n", image->width, image->height); - // Use... - for (NSVGshape *shape = image->shapes; shape != NULL; shape = shape->next) { - for (NSVGpath *path = shape->paths; path != NULL; path = path->next) { - for (int i = 0; i < path->npts-1; i += 3) { - float* p = &path->pts[i*2]; - drawCubicBez(p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7]); - } - } - } - // Delete - nsvgDelete(image); + // Load + NSVGImage* image; + image = nsvgParseFromFile("test.svg", "px", 96); + printf("size: %f x %f\n", image->width, image->height); + // Use... + for (NSVGshape *shape = image->shapes; shape != NULL; shape = shape->next) { + for (NSVGpath *path = shape->paths; path != NULL; path = path->next) { + for (int i = 0; i < path->npts-1; i += 3) { + float* p = &path->pts[i*2]; + drawCubicBez(p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7]); + } + } + } + // Delete + nsvgDelete(image); */ enum NSVGpaintType { - NSVG_PAINT_NONE = 0, - NSVG_PAINT_COLOR = 1, - NSVG_PAINT_LINEAR_GRADIENT = 2, - NSVG_PAINT_RADIAL_GRADIENT = 3 + NSVG_PAINT_NONE = 0, + NSVG_PAINT_COLOR = 1, + NSVG_PAINT_LINEAR_GRADIENT = 2, + NSVG_PAINT_RADIAL_GRADIENT = 3 }; -enum NSVGspreadType { - NSVG_SPREAD_PAD = 0, - NSVG_SPREAD_REFLECT = 1, - NSVG_SPREAD_REPEAT = 2 -}; +enum NSVGspreadType { NSVG_SPREAD_PAD = 0, NSVG_SPREAD_REFLECT = 1, NSVG_SPREAD_REPEAT = 2 }; -enum NSVGlineJoin { - NSVG_JOIN_MITER = 0, - NSVG_JOIN_ROUND = 1, - NSVG_JOIN_BEVEL = 2 -}; +enum NSVGlineJoin { NSVG_JOIN_MITER = 0, NSVG_JOIN_ROUND = 1, NSVG_JOIN_BEVEL = 2 }; -enum NSVGlineCap { - NSVG_CAP_BUTT = 0, - NSVG_CAP_ROUND = 1, - NSVG_CAP_SQUARE = 2 -}; +enum NSVGlineCap { NSVG_CAP_BUTT = 0, NSVG_CAP_ROUND = 1, NSVG_CAP_SQUARE = 2 }; -enum NSVGfillRule { - NSVG_FILLRULE_NONZERO = 0, - NSVG_FILLRULE_EVENODD = 1 -}; +enum NSVGfillRule { NSVG_FILLRULE_NONZERO = 0, NSVG_FILLRULE_EVENODD = 1 }; -enum NSVGflags { - NSVG_FLAGS_VISIBLE = 0x01 -}; +enum NSVGflags { NSVG_FLAGS_VISIBLE = 0x01 }; typedef struct NSVGgradientStop { - unsigned int color; - float offset; + unsigned int color; + float offset; } NSVGgradientStop; typedef struct NSVGgradient { - float xform[6]; - char spread; - float fx, fy; - int nstops; - NSVGgradientStop stops[1]; + float xform[6]; + char spread; + float fx, fy; + int nstops; + NSVGgradientStop stops[1]; } NSVGgradient; typedef struct NSVGpaint { - char type; - union { - unsigned int color; - NSVGgradient* gradient; - }; + char type; + union { + unsigned int color; + NSVGgradient *gradient; + }; } NSVGpaint; -typedef struct NSVGpath -{ - float* pts; // Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ... - int npts; // Total number of bezier points. - char closed; // Flag indicating if shapes should be treated as closed. - float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy]. - struct NSVGpath* next; // Pointer to next path, or NULL if last element. +typedef struct NSVGpath { + float *pts; // Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ... + int npts; // Total number of bezier points. + char closed; // Flag indicating if shapes should be treated as closed. + float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy]. + struct NSVGpath *next; // Pointer to next path, or NULL if last element. } NSVGpath; -typedef struct NSVGshape -{ - char id[64]; // Optional 'id' attr of the shape or its group - NSVGpaint fill; // Fill paint - NSVGpaint stroke; // Stroke paint - float opacity; // Opacity of the shape. - float strokeWidth; // Stroke width (scaled). - float strokeDashOffset; // Stroke dash offset (scaled). - float strokeDashArray[8]; // Stroke dash array (scaled). - char strokeDashCount; // Number of dash values in dash array. - char strokeLineJoin; // Stroke join type. - char strokeLineCap; // Stroke cap type. - float miterLimit; // Miter limit - char fillRule; // Fill rule, see NSVGfillRule. - unsigned char flags; // Logical or of NSVG_FLAGS_* flags - float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy]. - NSVGpath* paths; // Linked list of paths in the image. - struct NSVGshape* next; // Pointer to next shape, or NULL if last element. +typedef struct NSVGshape { + char id[64]; // Optional 'id' attr of the shape or its group + NSVGpaint fill; // Fill paint + NSVGpaint stroke; // Stroke paint + float opacity; // Opacity of the shape. + float strokeWidth; // Stroke width (scaled). + float strokeDashOffset; // Stroke dash offset (scaled). + float strokeDashArray[8]; // Stroke dash array (scaled). + char strokeDashCount; // Number of dash values in dash array. + char strokeLineJoin; // Stroke join type. + char strokeLineCap; // Stroke cap type. + float miterLimit; // Miter limit + char fillRule; // Fill rule, see NSVGfillRule. + unsigned char flags; // Logical or of NSVG_FLAGS_* flags + float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy]. + NSVGpath *paths; // Linked list of paths in the image. + struct NSVGshape *next; // Pointer to next shape, or NULL if last element. } NSVGshape; -typedef struct NSVGimage -{ - float width; // Width of the image. - float height; // Height of the image. - NSVGshape* shapes; // Linked list of shapes in the image. +typedef struct NSVGimage { + float width; // Width of the image. + float height; // Height of the image. + NSVGshape *shapes; // Linked list of shapes in the image. } NSVGimage; // Parses SVG file from a file, returns SVG image as paths. -NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi); +NSVGimage *nsvgParseFromFile(const char *filename, const char *units, float dpi); // Parses SVG file from a null terminated string, returns SVG image as paths. // Important note: changes the string. -NSVGimage* nsvgParse(char* input, const char* units, float dpi); +NSVGimage *nsvgParse(char *input, const char *units, float dpi); // Deletes list of paths. -void nsvgDelete(NSVGimage* image); +void nsvgDelete(NSVGimage *image); #ifdef __cplusplus } @@ -182,2744 +161,2747 @@ void nsvgDelete(NSVGimage* image); #include <stdlib.h> #include <math.h> -#define NSVG_PI (3.14159265358979323846264338327f) -#define NSVG_KAPPA90 (0.5522847493f) // Length proportional to radius of a cubic bezier handle for 90deg arcs. +#define NSVG_PI (3.14159265358979323846264338327f) +#define NSVG_KAPPA90 (0.5522847493f) // Length proportional to radius of a cubic bezier handle for 90deg arcs. -#define NSVG_ALIGN_MIN 0 -#define NSVG_ALIGN_MID 1 -#define NSVG_ALIGN_MAX 2 -#define NSVG_ALIGN_NONE 0 -#define NSVG_ALIGN_MEET 1 +#define NSVG_ALIGN_MIN 0 +#define NSVG_ALIGN_MID 1 +#define NSVG_ALIGN_MAX 2 +#define NSVG_ALIGN_NONE 0 +#define NSVG_ALIGN_MEET 1 #define NSVG_ALIGN_SLICE 2 -#define NSVG_NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0) +#define NSVG_NOTUSED(v) \ + do { \ + (void)(1 ? (void)0 : ((void)(v))); \ + } while (0) #define NSVG_RGB(r, g, b) (((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16)) #ifdef _MSC_VER - #pragma warning (disable: 4996) // Switch off security warnings - #pragma warning (disable: 4100) // Switch off unreferenced formal parameter warnings - #ifdef __cplusplus - #define NSVG_INLINE inline - #else - #define NSVG_INLINE - #endif +#pragma warning(disable : 4996) // Switch off security warnings +#pragma warning(disable : 4100) // Switch off unreferenced formal parameter warnings +#ifdef __cplusplus +#define NSVG_INLINE inline #else - #define NSVG_INLINE inline +#define NSVG_INLINE +#endif +#else +#define NSVG_INLINE inline #endif +static int nsvg__isspace(char c) { return strchr(" \t\n\v\f\r", c) != 0; } -static int nsvg__isspace(char c) -{ - return strchr(" \t\n\v\f\r", c) != 0; -} - -static int nsvg__isdigit(char c) -{ - return c >= '0' && c <= '9'; -} +static int nsvg__isdigit(char c) { return c >= '0' && c <= '9'; } -static int nsvg__isnum(char c) -{ - return strchr("0123456789+-.eE", c) != 0; -} +static int nsvg__isnum(char c) { return strchr("0123456789+-.eE", c) != 0; } static NSVG_INLINE float nsvg__minf(float a, float b) { return a < b ? a : b; } static NSVG_INLINE float nsvg__maxf(float a, float b) { return a > b ? a : b; } - // Simple XML parser -#define NSVG_XML_TAG 1 -#define NSVG_XML_CONTENT 2 +#define NSVG_XML_TAG 1 +#define NSVG_XML_CONTENT 2 #define NSVG_XML_MAX_ATTRIBS 256 -static void nsvg__parseContent(char* s, - void (*contentCb)(void* ud, const char* s), - void* ud) -{ - // Trim start white spaces - while (*s && nsvg__isspace(*s)) s++; - if (!*s) return; +static void nsvg__parseContent(char *s, void (*contentCb)(void *ud, const char *s), void *ud) { + // Trim start white spaces + while (*s && nsvg__isspace(*s)) + s++; + if (!*s) + return; - if (contentCb) - (*contentCb)(ud, s); + if (contentCb) + (*contentCb)(ud, s); } -static void nsvg__parseElement(char* s, - void (*startelCb)(void* ud, const char* el, const char** attr), - void (*endelCb)(void* ud, const char* el), - void* ud) -{ - const char* attr[NSVG_XML_MAX_ATTRIBS]; - int nattr = 0; - char* name; - int start = 0; - int end = 0; - char quote; +static void nsvg__parseElement(char *s, void (*startelCb)(void *ud, const char *el, const char **attr), + void (*endelCb)(void *ud, const char *el), void *ud) { + const char *attr[NSVG_XML_MAX_ATTRIBS]; + int nattr = 0; + char *name; + int start = 0; + int end = 0; + char quote; - // Skip white space after the '<' - while (*s && nsvg__isspace(*s)) s++; + // Skip white space after the '<' + while (*s && nsvg__isspace(*s)) + s++; - // Check if the tag is end tag - if (*s == '/') { - s++; - end = 1; - } else { - start = 1; - } + // Check if the tag is end tag + if (*s == '/') { + s++; + end = 1; + } else { + start = 1; + } - // Skip comments, data and preprocessor stuff. - if (!*s || *s == '?' || *s == '!') - return; + // Skip comments, data and preprocessor stuff. + if (!*s || *s == '?' || *s == '!') + return; - // Get tag name - name = s; - while (*s && !nsvg__isspace(*s)) s++; - if (*s) { *s++ = '\0'; } + // Get tag name + name = s; + while (*s && !nsvg__isspace(*s)) + s++; + if (*s) { + *s++ = '\0'; + } - // Get attribs - while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) { - char* name = NULL; - char* value = NULL; + // Get attribs + while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS - 3) { + char *name = NULL; + char *value = NULL; - // Skip white space before the attrib name - while (*s && nsvg__isspace(*s)) s++; - if (!*s) break; - if (*s == '/') { - end = 1; - break; - } - name = s; - // Find end of the attrib name. - while (*s && !nsvg__isspace(*s) && *s != '=') s++; - if (*s) { *s++ = '\0'; } - // Skip until the beginning of the value. - while (*s && *s != '\"' && *s != '\'') s++; - if (!*s) break; - quote = *s; - s++; - // Store value and find the end of it. - value = s; - while (*s && *s != quote) s++; - if (*s) { *s++ = '\0'; } + // Skip white space before the attrib name + while (*s && nsvg__isspace(*s)) + s++; + if (!*s) + break; + if (*s == '/') { + end = 1; + break; + } + name = s; + // Find end of the attrib name. + while (*s && !nsvg__isspace(*s) && *s != '=') + s++; + if (*s) { + *s++ = '\0'; + } + // Skip until the beginning of the value. + while (*s && *s != '\"' && *s != '\'') + s++; + if (!*s) + break; + quote = *s; + s++; + // Store value and find the end of it. + value = s; + while (*s && *s != quote) + s++; + if (*s) { + *s++ = '\0'; + } - // Store only well formed attributes - if (name && value) { - attr[nattr++] = name; - attr[nattr++] = value; - } - } + // Store only well formed attributes + if (name && value) { + attr[nattr++] = name; + attr[nattr++] = value; + } + } - // List terminator - attr[nattr++] = 0; - attr[nattr++] = 0; + // List terminator + attr[nattr++] = 0; + attr[nattr++] = 0; - // Call callbacks. - if (start && startelCb) - (*startelCb)(ud, name, attr); - if (end && endelCb) - (*endelCb)(ud, name); + // Call callbacks. + if (start && startelCb) + (*startelCb)(ud, name, attr); + if (end && endelCb) + (*endelCb)(ud, name); } -int nsvg__parseXML(char* input, - void (*startelCb)(void* ud, const char* el, const char** attr), - void (*endelCb)(void* ud, const char* el), - void (*contentCb)(void* ud, const char* s), - void* ud) -{ - char* s = input; - char* mark = s; - int state = NSVG_XML_CONTENT; - while (*s) { - if (*s == '<' && state == NSVG_XML_CONTENT) { - // Start of a tag - *s++ = '\0'; - nsvg__parseContent(mark, contentCb, ud); - mark = s; - state = NSVG_XML_TAG; - } else if (*s == '>' && state == NSVG_XML_TAG) { - // Start of a content or new tag. - *s++ = '\0'; - nsvg__parseElement(mark, startelCb, endelCb, ud); - mark = s; - state = NSVG_XML_CONTENT; - } else { - s++; - } - } +int nsvg__parseXML(char *input, void (*startelCb)(void *ud, const char *el, const char **attr), + void (*endelCb)(void *ud, const char *el), void (*contentCb)(void *ud, const char *s), void *ud) { + char *s = input; + char *mark = s; + int state = NSVG_XML_CONTENT; + while (*s) { + if (*s == '<' && state == NSVG_XML_CONTENT) { + // Start of a tag + *s++ = '\0'; + nsvg__parseContent(mark, contentCb, ud); + mark = s; + state = NSVG_XML_TAG; + } else if (*s == '>' && state == NSVG_XML_TAG) { + // Start of a content or new tag. + *s++ = '\0'; + nsvg__parseElement(mark, startelCb, endelCb, ud); + mark = s; + state = NSVG_XML_CONTENT; + } else { + s++; + } + } - return 1; + return 1; } - /* Simple SVG parser. */ #define NSVG_MAX_ATTR 128 -enum NSVGgradientUnits { - NSVG_USER_SPACE = 0, - NSVG_OBJECT_SPACE = 1 -}; +enum NSVGgradientUnits { NSVG_USER_SPACE = 0, NSVG_OBJECT_SPACE = 1 }; #define NSVG_MAX_DASHES 8 enum NSVGunits { - NSVG_UNITS_USER, - NSVG_UNITS_PX, - NSVG_UNITS_PT, - NSVG_UNITS_PC, - NSVG_UNITS_MM, - NSVG_UNITS_CM, - NSVG_UNITS_IN, - NSVG_UNITS_PERCENT, - NSVG_UNITS_EM, - NSVG_UNITS_EX + NSVG_UNITS_USER, + NSVG_UNITS_PX, + NSVG_UNITS_PT, + NSVG_UNITS_PC, + NSVG_UNITS_MM, + NSVG_UNITS_CM, + NSVG_UNITS_IN, + NSVG_UNITS_PERCENT, + NSVG_UNITS_EM, + NSVG_UNITS_EX }; typedef struct NSVGcoordinate { - float value; - int units; + float value; + int units; } NSVGcoordinate; typedef struct NSVGlinearData { - NSVGcoordinate x1, y1, x2, y2; + NSVGcoordinate x1, y1, x2, y2; } NSVGlinearData; typedef struct NSVGradialData { - NSVGcoordinate cx, cy, r, fx, fy; + NSVGcoordinate cx, cy, r, fx, fy; } NSVGradialData; -typedef struct NSVGgradientData -{ - char id[64]; - char ref[64]; - char type; - union { - NSVGlinearData linear; - NSVGradialData radial; - }; - char spread; - char units; - float xform[6]; - int nstops; - NSVGgradientStop* stops; - struct NSVGgradientData* next; +typedef struct NSVGgradientData { + char id[64]; + char ref[64]; + char type; + union { + NSVGlinearData linear; + NSVGradialData radial; + }; + char spread; + char units; + float xform[6]; + int nstops; + NSVGgradientStop *stops; + struct NSVGgradientData *next; } NSVGgradientData; -typedef struct NSVGattrib -{ - char id[64]; - float xform[6]; - unsigned int fillColor; - unsigned int strokeColor; - float opacity; - float fillOpacity; - float strokeOpacity; - char fillGradient[64]; - char strokeGradient[64]; - float strokeWidth; - float strokeDashOffset; - float strokeDashArray[NSVG_MAX_DASHES]; - int strokeDashCount; - char strokeLineJoin; - char strokeLineCap; - float miterLimit; - char fillRule; - float fontSize; - unsigned int stopColor; - float stopOpacity; - float stopOffset; - char hasFill; - char hasStroke; - char visible; +typedef struct NSVGattrib { + char id[64]; + float xform[6]; + unsigned int fillColor; + unsigned int strokeColor; + float opacity; + float fillOpacity; + float strokeOpacity; + char fillGradient[64]; + char strokeGradient[64]; + float strokeWidth; + float strokeDashOffset; + float strokeDashArray[NSVG_MAX_DASHES]; + int strokeDashCount; + char strokeLineJoin; + char strokeLineCap; + float miterLimit; + char fillRule; + float fontSize; + unsigned int stopColor; + float stopOpacity; + float stopOffset; + char hasFill; + char hasStroke; + char visible; } NSVGattrib; -typedef struct NSVGparser -{ - NSVGattrib attr[NSVG_MAX_ATTR]; - int attrHead; - float* pts; - int npts; - int cpts; - NSVGpath* plist; - NSVGimage* image; - NSVGgradientData* gradients; - NSVGshape* shapesTail; - float viewMinx, viewMiny, viewWidth, viewHeight; - int alignX, alignY, alignType; - float dpi; - char pathFlag; - char defsFlag; +typedef struct NSVGparser { + NSVGattrib attr[NSVG_MAX_ATTR]; + int attrHead; + float *pts; + int npts; + int cpts; + NSVGpath *plist; + NSVGimage *image; + NSVGgradientData *gradients; + NSVGshape *shapesTail; + float viewMinx, viewMiny, viewWidth, viewHeight; + int alignX, alignY, alignType; + float dpi; + char pathFlag; + char defsFlag; } NSVGparser; -static void nsvg__xformIdentity(float* t) -{ - t[0] = 1.0f; t[1] = 0.0f; - t[2] = 0.0f; t[3] = 1.0f; - t[4] = 0.0f; t[5] = 0.0f; +static void nsvg__xformIdentity(float *t) { + t[0] = 1.0f; + t[1] = 0.0f; + t[2] = 0.0f; + t[3] = 1.0f; + t[4] = 0.0f; + t[5] = 0.0f; } -static void nsvg__xformSetTranslation(float* t, float tx, float ty) -{ - t[0] = 1.0f; t[1] = 0.0f; - t[2] = 0.0f; t[3] = 1.0f; - t[4] = tx; t[5] = ty; +static void nsvg__xformSetTranslation(float *t, float tx, float ty) { + t[0] = 1.0f; + t[1] = 0.0f; + t[2] = 0.0f; + t[3] = 1.0f; + t[4] = tx; + t[5] = ty; } -static void nsvg__xformSetScale(float* t, float sx, float sy) -{ - t[0] = sx; t[1] = 0.0f; - t[2] = 0.0f; t[3] = sy; - t[4] = 0.0f; t[5] = 0.0f; +static void nsvg__xformSetScale(float *t, float sx, float sy) { + t[0] = sx; + t[1] = 0.0f; + t[2] = 0.0f; + t[3] = sy; + t[4] = 0.0f; + t[5] = 0.0f; } -static void nsvg__xformSetSkewX(float* t, float a) -{ - t[0] = 1.0f; t[1] = 0.0f; - t[2] = tanf(a); t[3] = 1.0f; - t[4] = 0.0f; t[5] = 0.0f; +static void nsvg__xformSetSkewX(float *t, float a) { + t[0] = 1.0f; + t[1] = 0.0f; + t[2] = tanf(a); + t[3] = 1.0f; + t[4] = 0.0f; + t[5] = 0.0f; } -static void nsvg__xformSetSkewY(float* t, float a) -{ - t[0] = 1.0f; t[1] = tanf(a); - t[2] = 0.0f; t[3] = 1.0f; - t[4] = 0.0f; t[5] = 0.0f; +static void nsvg__xformSetSkewY(float *t, float a) { + t[0] = 1.0f; + t[1] = tanf(a); + t[2] = 0.0f; + t[3] = 1.0f; + t[4] = 0.0f; + t[5] = 0.0f; } -static void nsvg__xformSetRotation(float* t, float a) -{ - float cs = cosf(a), sn = sinf(a); - t[0] = cs; t[1] = sn; - t[2] = -sn; t[3] = cs; - t[4] = 0.0f; t[5] = 0.0f; +static void nsvg__xformSetRotation(float *t, float a) { + float cs = cosf(a), sn = sinf(a); + t[0] = cs; + t[1] = sn; + t[2] = -sn; + t[3] = cs; + t[4] = 0.0f; + t[5] = 0.0f; } -static void nsvg__xformMultiply(float* t, float* s) -{ - float t0 = t[0] * s[0] + t[1] * s[2]; - float t2 = t[2] * s[0] + t[3] * s[2]; - float t4 = t[4] * s[0] + t[5] * s[2] + s[4]; - t[1] = t[0] * s[1] + t[1] * s[3]; - t[3] = t[2] * s[1] + t[3] * s[3]; - t[5] = t[4] * s[1] + t[5] * s[3] + s[5]; - t[0] = t0; - t[2] = t2; - t[4] = t4; +static void nsvg__xformMultiply(float *t, float *s) { + float t0 = t[0] * s[0] + t[1] * s[2]; + float t2 = t[2] * s[0] + t[3] * s[2]; + float t4 = t[4] * s[0] + t[5] * s[2] + s[4]; + t[1] = t[0] * s[1] + t[1] * s[3]; + t[3] = t[2] * s[1] + t[3] * s[3]; + t[5] = t[4] * s[1] + t[5] * s[3] + s[5]; + t[0] = t0; + t[2] = t2; + t[4] = t4; } -static void nsvg__xformInverse(float* inv, float* t) -{ - double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1]; - if (det > -1e-6 && det < 1e-6) { - nsvg__xformIdentity(t); - return; - } - invdet = 1.0 / det; - inv[0] = (float)(t[3] * invdet); - inv[2] = (float)(-t[2] * invdet); - inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet); - inv[1] = (float)(-t[1] * invdet); - inv[3] = (float)(t[0] * invdet); - inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet); +static void nsvg__xformInverse(float *inv, float *t) { + double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1]; + if (det > -1e-6 && det < 1e-6) { + nsvg__xformIdentity(t); + return; + } + invdet = 1.0 / det; + inv[0] = (float)(t[3] * invdet); + inv[2] = (float)(-t[2] * invdet); + inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet); + inv[1] = (float)(-t[1] * invdet); + inv[3] = (float)(t[0] * invdet); + inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet); } -static void nsvg__xformPremultiply(float* t, float* s) -{ - float s2[6]; - memcpy(s2, s, sizeof(float)*6); - nsvg__xformMultiply(s2, t); - memcpy(t, s2, sizeof(float)*6); +static void nsvg__xformPremultiply(float *t, float *s) { + float s2[6]; + memcpy(s2, s, sizeof(float) * 6); + nsvg__xformMultiply(s2, t); + memcpy(t, s2, sizeof(float) * 6); } -static void nsvg__xformPoint(float* dx, float* dy, float x, float y, float* t) -{ - *dx = x*t[0] + y*t[2] + t[4]; - *dy = x*t[1] + y*t[3] + t[5]; +static void nsvg__xformPoint(float *dx, float *dy, float x, float y, float *t) { + *dx = x * t[0] + y * t[2] + t[4]; + *dy = x * t[1] + y * t[3] + t[5]; } -static void nsvg__xformVec(float* dx, float* dy, float x, float y, float* t) -{ - *dx = x*t[0] + y*t[2]; - *dy = x*t[1] + y*t[3]; +static void nsvg__xformVec(float *dx, float *dy, float x, float y, float *t) { + *dx = x * t[0] + y * t[2]; + *dy = x * t[1] + y * t[3]; } #define NSVG_EPSILON (1e-12) -static int nsvg__ptInBounds(float* pt, float* bounds) -{ - return pt[0] >= bounds[0] && pt[0] <= bounds[2] && pt[1] >= bounds[1] && pt[1] <= bounds[3]; +static int nsvg__ptInBounds(float *pt, float *bounds) { + return pt[0] >= bounds[0] && pt[0] <= bounds[2] && pt[1] >= bounds[1] && pt[1] <= bounds[3]; } - -static double nsvg__evalBezier(double t, double p0, double p1, double p2, double p3) -{ - double it = 1.0-t; - return it*it*it*p0 + 3.0*it*it*t*p1 + 3.0*it*t*t*p2 + t*t*t*p3; +static double nsvg__evalBezier(double t, double p0, double p1, double p2, double p3) { + double it = 1.0 - t; + return it * it * it * p0 + 3.0 * it * it * t * p1 + 3.0 * it * t * t * p2 + t * t * t * p3; } -static void nsvg__curveBounds(float* bounds, float* curve) -{ - int i, j, count; - double roots[2], a, b, c, b2ac, t, v; - float* v0 = &curve[0]; - float* v1 = &curve[2]; - float* v2 = &curve[4]; - float* v3 = &curve[6]; +static void nsvg__curveBounds(float *bounds, float *curve) { + int i, j, count; + double roots[2], a, b, c, b2ac, t, v; + float *v0 = &curve[0]; + float *v1 = &curve[2]; + float *v2 = &curve[4]; + float *v3 = &curve[6]; - // Start the bounding box by end points - bounds[0] = nsvg__minf(v0[0], v3[0]); - bounds[1] = nsvg__minf(v0[1], v3[1]); - bounds[2] = nsvg__maxf(v0[0], v3[0]); - bounds[3] = nsvg__maxf(v0[1], v3[1]); + // Start the bounding box by end points + bounds[0] = nsvg__minf(v0[0], v3[0]); + bounds[1] = nsvg__minf(v0[1], v3[1]); + bounds[2] = nsvg__maxf(v0[0], v3[0]); + bounds[3] = nsvg__maxf(v0[1], v3[1]); - // Bezier curve fits inside the convex hull of it's control points. - // If control points are inside the bounds, we're done. - if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds)) - return; + // Bezier curve fits inside the convex hull of it's control points. + // If control points are inside the bounds, we're done. + if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds)) + return; - // Add bezier curve inflection points in X and Y. - for (i = 0; i < 2; i++) { - a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i]; - b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i]; - c = 3.0 * v1[i] - 3.0 * v0[i]; - count = 0; - if (fabs(a) < NSVG_EPSILON) { - if (fabs(b) > NSVG_EPSILON) { - t = -c / b; - if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON) - roots[count++] = t; - } - } else { - b2ac = b*b - 4.0*c*a; - if (b2ac > NSVG_EPSILON) { - t = (-b + sqrt(b2ac)) / (2.0 * a); - if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON) - roots[count++] = t; - t = (-b - sqrt(b2ac)) / (2.0 * a); - if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON) - roots[count++] = t; - } - } - for (j = 0; j < count; j++) { - v = nsvg__evalBezier(roots[j], v0[i], v1[i], v2[i], v3[i]); - bounds[0+i] = nsvg__minf(bounds[0+i], (float)v); - bounds[2+i] = nsvg__maxf(bounds[2+i], (float)v); - } - } + // Add bezier curve inflection points in X and Y. + for (i = 0; i < 2; i++) { + a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i]; + b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i]; + c = 3.0 * v1[i] - 3.0 * v0[i]; + count = 0; + if (fabs(a) < NSVG_EPSILON) { + if (fabs(b) > NSVG_EPSILON) { + t = -c / b; + if (t > NSVG_EPSILON && t < 1.0 - NSVG_EPSILON) + roots[count++] = t; + } + } else { + b2ac = b * b - 4.0 * c * a; + if (b2ac > NSVG_EPSILON) { + t = (-b + sqrt(b2ac)) / (2.0 * a); + if (t > NSVG_EPSILON && t < 1.0 - NSVG_EPSILON) + roots[count++] = t; + t = (-b - sqrt(b2ac)) / (2.0 * a); + if (t > NSVG_EPSILON && t < 1.0 - NSVG_EPSILON) + roots[count++] = t; + } + } + for (j = 0; j < count; j++) { + v = nsvg__evalBezier(roots[j], v0[i], v1[i], v2[i], v3[i]); + bounds[0 + i] = nsvg__minf(bounds[0 + i], (float)v); + bounds[2 + i] = nsvg__maxf(bounds[2 + i], (float)v); + } + } } -static NSVGparser* nsvg__createParser() -{ - NSVGparser* p; - p = (NSVGparser*)malloc(sizeof(NSVGparser)); - if (p == NULL) goto error; - memset(p, 0, sizeof(NSVGparser)); +static NSVGparser *nsvg__createParser() { + NSVGparser *p; + p = (NSVGparser *)malloc(sizeof(NSVGparser)); + if (p == NULL) + goto error; + memset(p, 0, sizeof(NSVGparser)); - p->image = (NSVGimage*)malloc(sizeof(NSVGimage)); - if (p->image == NULL) goto error; - memset(p->image, 0, sizeof(NSVGimage)); + p->image = (NSVGimage *)malloc(sizeof(NSVGimage)); + if (p->image == NULL) + goto error; + memset(p->image, 0, sizeof(NSVGimage)); - // Init style - nsvg__xformIdentity(p->attr[0].xform); - memset(p->attr[0].id, 0, sizeof p->attr[0].id); - p->attr[0].fillColor = NSVG_RGB(0,0,0); - p->attr[0].strokeColor = NSVG_RGB(0,0,0); - p->attr[0].opacity = 1; - p->attr[0].fillOpacity = 1; - p->attr[0].strokeOpacity = 1; - p->attr[0].stopOpacity = 1; - p->attr[0].strokeWidth = 1; - p->attr[0].strokeLineJoin = NSVG_JOIN_MITER; - p->attr[0].strokeLineCap = NSVG_CAP_BUTT; - p->attr[0].miterLimit = 4; - p->attr[0].fillRule = NSVG_FILLRULE_NONZERO; - p->attr[0].hasFill = 1; - p->attr[0].visible = 1; + // Init style + nsvg__xformIdentity(p->attr[0].xform); + memset(p->attr[0].id, 0, sizeof p->attr[0].id); + p->attr[0].fillColor = NSVG_RGB(0, 0, 0); + p->attr[0].strokeColor = NSVG_RGB(0, 0, 0); + p->attr[0].opacity = 1; + p->attr[0].fillOpacity = 1; + p->attr[0].strokeOpacity = 1; + p->attr[0].stopOpacity = 1; + p->attr[0].strokeWidth = 1; + p->attr[0].strokeLineJoin = NSVG_JOIN_MITER; + p->attr[0].strokeLineCap = NSVG_CAP_BUTT; + p->attr[0].miterLimit = 4; + p->attr[0].fillRule = NSVG_FILLRULE_NONZERO; + p->attr[0].hasFill = 1; + p->attr[0].visible = 1; - return p; + return p; error: - if (p) { - if (p->image) free(p->image); - free(p); - } - return NULL; + if (p) { + if (p->image) + free(p->image); + free(p); + } + return NULL; } -static void nsvg__deletePaths(NSVGpath* path) -{ - while (path) { - NSVGpath *next = path->next; - if (path->pts != NULL) - free(path->pts); - free(path); - path = next; - } +static void nsvg__deletePaths(NSVGpath *path) { + while (path) { + NSVGpath *next = path->next; + if (path->pts != NULL) + free(path->pts); + free(path); + path = next; + } } -static void nsvg__deletePaint(NSVGpaint* paint) -{ - if (paint->type == NSVG_PAINT_LINEAR_GRADIENT || paint->type == NSVG_PAINT_RADIAL_GRADIENT) - free(paint->gradient); +static void nsvg__deletePaint(NSVGpaint *paint) { + if (paint->type == NSVG_PAINT_LINEAR_GRADIENT || paint->type == NSVG_PAINT_RADIAL_GRADIENT) + free(paint->gradient); } -static void nsvg__deleteGradientData(NSVGgradientData* grad) -{ - NSVGgradientData* next; - while (grad != NULL) { - next = grad->next; - free(grad->stops); - free(grad); - grad = next; - } +static void nsvg__deleteGradientData(NSVGgradientData *grad) { + NSVGgradientData *next; + while (grad != NULL) { + next = grad->next; + free(grad->stops); + free(grad); + grad = next; + } } -static void nsvg__deleteParser(NSVGparser* p) -{ - if (p != NULL) { - nsvg__deletePaths(p->plist); - nsvg__deleteGradientData(p->gradients); - nsvgDelete(p->image); - free(p->pts); - free(p); - } +static void nsvg__deleteParser(NSVGparser *p) { + if (p != NULL) { + nsvg__deletePaths(p->plist); + nsvg__deleteGradientData(p->gradients); + nsvgDelete(p->image); + free(p->pts); + free(p); + } } -static void nsvg__resetPath(NSVGparser* p) -{ - p->npts = 0; -} +static void nsvg__resetPath(NSVGparser *p) { p->npts = 0; } -static void nsvg__addPoint(NSVGparser* p, float x, float y) -{ - if (p->npts+1 > p->cpts) { - p->cpts = p->cpts ? p->cpts*2 : 8; - p->pts = (float*)realloc(p->pts, p->cpts*2*sizeof(float)); - if (!p->pts) return; - } - p->pts[p->npts*2+0] = x; - p->pts[p->npts*2+1] = y; - p->npts++; +static void nsvg__addPoint(NSVGparser *p, float x, float y) { + if (p->npts + 1 > p->cpts) { + p->cpts = p->cpts ? p->cpts * 2 : 8; + p->pts = (float *)realloc(p->pts, p->cpts * 2 * sizeof(float)); + if (!p->pts) + return; + } + p->pts[p->npts * 2 + 0] = x; + p->pts[p->npts * 2 + 1] = y; + p->npts++; } -static void nsvg__moveTo(NSVGparser* p, float x, float y) -{ - if (p->npts > 0) { - p->pts[(p->npts-1)*2+0] = x; - p->pts[(p->npts-1)*2+1] = y; - } else { - nsvg__addPoint(p, x, y); - } +static void nsvg__moveTo(NSVGparser *p, float x, float y) { + if (p->npts > 0) { + p->pts[(p->npts - 1) * 2 + 0] = x; + p->pts[(p->npts - 1) * 2 + 1] = y; + } else { + nsvg__addPoint(p, x, y); + } } -static void nsvg__lineTo(NSVGparser* p, float x, float y) -{ - float px,py, dx,dy; - if (p->npts > 0) { - px = p->pts[(p->npts-1)*2+0]; - py = p->pts[(p->npts-1)*2+1]; - dx = x - px; - dy = y - py; - nsvg__addPoint(p, px + dx/3.0f, py + dy/3.0f); - nsvg__addPoint(p, x - dx/3.0f, y - dy/3.0f); - nsvg__addPoint(p, x, y); - } +static void nsvg__lineTo(NSVGparser *p, float x, float y) { + float px, py, dx, dy; + if (p->npts > 0) { + px = p->pts[(p->npts - 1) * 2 + 0]; + py = p->pts[(p->npts - 1) * 2 + 1]; + dx = x - px; + dy = y - py; + nsvg__addPoint(p, px + dx / 3.0f, py + dy / 3.0f); + nsvg__addPoint(p, x - dx / 3.0f, y - dy / 3.0f); + nsvg__addPoint(p, x, y); + } } -static void nsvg__cubicBezTo(NSVGparser* p, float cpx1, float cpy1, float cpx2, float cpy2, float x, float y) -{ - nsvg__addPoint(p, cpx1, cpy1); - nsvg__addPoint(p, cpx2, cpy2); - nsvg__addPoint(p, x, y); +static void nsvg__cubicBezTo(NSVGparser *p, float cpx1, float cpy1, float cpx2, float cpy2, float x, float y) { + nsvg__addPoint(p, cpx1, cpy1); + nsvg__addPoint(p, cpx2, cpy2); + nsvg__addPoint(p, x, y); } -static NSVGattrib* nsvg__getAttr(NSVGparser* p) -{ - return &p->attr[p->attrHead]; -} +static NSVGattrib *nsvg__getAttr(NSVGparser *p) { return &p->attr[p->attrHead]; } -static void nsvg__pushAttr(NSVGparser* p) -{ - if (p->attrHead < NSVG_MAX_ATTR-1) { - p->attrHead++; - memcpy(&p->attr[p->attrHead], &p->attr[p->attrHead-1], sizeof(NSVGattrib)); - } +static void nsvg__pushAttr(NSVGparser *p) { + if (p->attrHead < NSVG_MAX_ATTR - 1) { + p->attrHead++; + memcpy(&p->attr[p->attrHead], &p->attr[p->attrHead - 1], sizeof(NSVGattrib)); + } } -static void nsvg__popAttr(NSVGparser* p) -{ - if (p->attrHead > 0) - p->attrHead--; +static void nsvg__popAttr(NSVGparser *p) { + if (p->attrHead > 0) + p->attrHead--; } -static float nsvg__actualOrigX(NSVGparser* p) -{ - return p->viewMinx; -} +static float nsvg__actualOrigX(NSVGparser *p) { return p->viewMinx; } -static float nsvg__actualOrigY(NSVGparser* p) -{ - return p->viewMiny; -} +static float nsvg__actualOrigY(NSVGparser *p) { return p->viewMiny; } -static float nsvg__actualWidth(NSVGparser* p) -{ - return p->viewWidth; -} +static float nsvg__actualWidth(NSVGparser *p) { return p->viewWidth; } -static float nsvg__actualHeight(NSVGparser* p) -{ - return p->viewHeight; -} +static float nsvg__actualHeight(NSVGparser *p) { return p->viewHeight; } -static float nsvg__actualLength(NSVGparser* p) -{ - float w = nsvg__actualWidth(p), h = nsvg__actualHeight(p); - return sqrtf(w*w + h*h) / sqrtf(2.0f); +static float nsvg__actualLength(NSVGparser *p) { + float w = nsvg__actualWidth(p), h = nsvg__actualHeight(p); + return sqrtf(w * w + h * h) / sqrtf(2.0f); } -static float nsvg__convertToPixels(NSVGparser* p, NSVGcoordinate c, float orig, float length) -{ - NSVGattrib* attr = nsvg__getAttr(p); - switch (c.units) { - case NSVG_UNITS_USER: return c.value; - case NSVG_UNITS_PX: return c.value; - case NSVG_UNITS_PT: return c.value / 72.0f * p->dpi; - case NSVG_UNITS_PC: return c.value / 6.0f * p->dpi; - case NSVG_UNITS_MM: return c.value / 25.4f * p->dpi; - case NSVG_UNITS_CM: return c.value / 2.54f * p->dpi; - case NSVG_UNITS_IN: return c.value * p->dpi; - case NSVG_UNITS_EM: return c.value * attr->fontSize; - case NSVG_UNITS_EX: return c.value * attr->fontSize * 0.52f; // x-height of Helvetica. - case NSVG_UNITS_PERCENT: return orig + c.value / 100.0f * length; - default: return c.value; - } - return c.value; +static float nsvg__convertToPixels(NSVGparser *p, NSVGcoordinate c, float orig, float length) { + NSVGattrib *attr = nsvg__getAttr(p); + switch (c.units) { + case NSVG_UNITS_USER: + return c.value; + case NSVG_UNITS_PX: + return c.value; + case NSVG_UNITS_PT: + return c.value / 72.0f * p->dpi; + case NSVG_UNITS_PC: + return c.value / 6.0f * p->dpi; + case NSVG_UNITS_MM: + return c.value / 25.4f * p->dpi; + case NSVG_UNITS_CM: + return c.value / 2.54f * p->dpi; + case NSVG_UNITS_IN: + return c.value * p->dpi; + case NSVG_UNITS_EM: + return c.value * attr->fontSize; + case NSVG_UNITS_EX: + return c.value * attr->fontSize * 0.52f; // x-height of Helvetica. + case NSVG_UNITS_PERCENT: + return orig + c.value / 100.0f * length; + default: + return c.value; + } + return c.value; } -static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id) -{ - NSVGgradientData* grad = p->gradients; - while (grad) { - if (strcmp(grad->id, id) == 0) - return grad; - grad = grad->next; - } - return NULL; +static NSVGgradientData *nsvg__findGradientData(NSVGparser *p, const char *id) { + NSVGgradientData *grad = p->gradients; + while (grad) { + if (strcmp(grad->id, id) == 0) + return grad; + grad = grad->next; + } + return NULL; } -static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const float* localBounds, char* paintType) -{ - NSVGattrib* attr = nsvg__getAttr(p); - NSVGgradientData* data = NULL; - NSVGgradientData* ref = NULL; - NSVGgradientStop* stops = NULL; - NSVGgradient* grad; - float ox, oy, sw, sh, sl; - int nstops = 0; +static NSVGgradient *nsvg__createGradient(NSVGparser *p, const char *id, const float *localBounds, char *paintType) { + NSVGattrib *attr = nsvg__getAttr(p); + NSVGgradientData *data = NULL; + NSVGgradientData *ref = NULL; + NSVGgradientStop *stops = NULL; + NSVGgradient *grad; + float ox, oy, sw, sh, sl; + int nstops = 0; - data = nsvg__findGradientData(p, id); - if (data == NULL) return NULL; + data = nsvg__findGradientData(p, id); + if (data == NULL) + return NULL; - // TODO: use ref to fill in all unset values too. - ref = data; - while (ref != NULL) { - if (stops == NULL && ref->stops != NULL) { - stops = ref->stops; - nstops = ref->nstops; - break; - } - ref = nsvg__findGradientData(p, ref->ref); - } - if (stops == NULL) return NULL; + // TODO: use ref to fill in all unset values too. + ref = data; + while (ref != NULL) { + if (stops == NULL && ref->stops != NULL) { + stops = ref->stops; + nstops = ref->nstops; + break; + } + ref = nsvg__findGradientData(p, ref->ref); + } + if (stops == NULL) + return NULL; - grad = (NSVGgradient*)malloc(sizeof(NSVGgradient) + sizeof(NSVGgradientStop)*(nstops-1)); - if (grad == NULL) return NULL; + grad = (NSVGgradient *)malloc(sizeof(NSVGgradient) + sizeof(NSVGgradientStop) * (nstops - 1)); + if (grad == NULL) + return NULL; - // The shape width and height. - if (data->units == NSVG_OBJECT_SPACE) { - ox = localBounds[0]; - oy = localBounds[1]; - sw = localBounds[2] - localBounds[0]; - sh = localBounds[3] - localBounds[1]; - } else { - ox = nsvg__actualOrigX(p); - oy = nsvg__actualOrigY(p); - sw = nsvg__actualWidth(p); - sh = nsvg__actualHeight(p); - } - sl = sqrtf(sw*sw + sh*sh) / sqrtf(2.0f); + // The shape width and height. + if (data->units == NSVG_OBJECT_SPACE) { + ox = localBounds[0]; + oy = localBounds[1]; + sw = localBounds[2] - localBounds[0]; + sh = localBounds[3] - localBounds[1]; + } else { + ox = nsvg__actualOrigX(p); + oy = nsvg__actualOrigY(p); + sw = nsvg__actualWidth(p); + sh = nsvg__actualHeight(p); + } + sl = sqrtf(sw * sw + sh * sh) / sqrtf(2.0f); - if (data->type == NSVG_PAINT_LINEAR_GRADIENT) { - float x1, y1, x2, y2, dx, dy; - x1 = nsvg__convertToPixels(p, data->linear.x1, ox, sw); - y1 = nsvg__convertToPixels(p, data->linear.y1, oy, sh); - x2 = nsvg__convertToPixels(p, data->linear.x2, ox, sw); - y2 = nsvg__convertToPixels(p, data->linear.y2, oy, sh); - // Calculate transform aligned to the line - dx = x2 - x1; - dy = y2 - y1; - grad->xform[0] = dy; grad->xform[1] = -dx; - grad->xform[2] = dx; grad->xform[3] = dy; - grad->xform[4] = x1; grad->xform[5] = y1; - } else { - float cx, cy, fx, fy, r; - cx = nsvg__convertToPixels(p, data->radial.cx, ox, sw); - cy = nsvg__convertToPixels(p, data->radial.cy, oy, sh); - fx = nsvg__convertToPixels(p, data->radial.fx, ox, sw); - fy = nsvg__convertToPixels(p, data->radial.fy, oy, sh); - r = nsvg__convertToPixels(p, data->radial.r, 0, sl); - // Calculate transform aligned to the circle - grad->xform[0] = r; grad->xform[1] = 0; - grad->xform[2] = 0; grad->xform[3] = r; - grad->xform[4] = cx; grad->xform[5] = cy; - grad->fx = fx / r; - grad->fy = fy / r; - } + if (data->type == NSVG_PAINT_LINEAR_GRADIENT) { + float x1, y1, x2, y2, dx, dy; + x1 = nsvg__convertToPixels(p, data->linear.x1, ox, sw); + y1 = nsvg__convertToPixels(p, data->linear.y1, oy, sh); + x2 = nsvg__convertToPixels(p, data->linear.x2, ox, sw); + y2 = nsvg__convertToPixels(p, data->linear.y2, oy, sh); + // Calculate transform aligned to the line + dx = x2 - x1; + dy = y2 - y1; + grad->xform[0] = dy; + grad->xform[1] = -dx; + grad->xform[2] = dx; + grad->xform[3] = dy; + grad->xform[4] = x1; + grad->xform[5] = y1; + } else { + float cx, cy, fx, fy, r; + cx = nsvg__convertToPixels(p, data->radial.cx, ox, sw); + cy = nsvg__convertToPixels(p, data->radial.cy, oy, sh); + fx = nsvg__convertToPixels(p, data->radial.fx, ox, sw); + fy = nsvg__convertToPixels(p, data->radial.fy, oy, sh); + r = nsvg__convertToPixels(p, data->radial.r, 0, sl); + // Calculate transform aligned to the circle + grad->xform[0] = r; + grad->xform[1] = 0; + grad->xform[2] = 0; + grad->xform[3] = r; + grad->xform[4] = cx; + grad->xform[5] = cy; + grad->fx = fx / r; + grad->fy = fy / r; + } - nsvg__xformMultiply(grad->xform, data->xform); - nsvg__xformMultiply(grad->xform, attr->xform); + nsvg__xformMultiply(grad->xform, data->xform); + nsvg__xformMultiply(grad->xform, attr->xform); - grad->spread = data->spread; - memcpy(grad->stops, stops, nstops*sizeof(NSVGgradientStop)); - grad->nstops = nstops; + grad->spread = data->spread; + memcpy(grad->stops, stops, nstops * sizeof(NSVGgradientStop)); + grad->nstops = nstops; - *paintType = data->type; + *paintType = data->type; - return grad; + return grad; } -static float nsvg__getAverageScale(float* t) -{ - float sx = sqrtf(t[0]*t[0] + t[2]*t[2]); - float sy = sqrtf(t[1]*t[1] + t[3]*t[3]); - return (sx + sy) * 0.5f; +static float nsvg__getAverageScale(float *t) { + float sx = sqrtf(t[0] * t[0] + t[2] * t[2]); + float sy = sqrtf(t[1] * t[1] + t[3] * t[3]); + return (sx + sy) * 0.5f; } -static void nsvg__getLocalBounds(float* bounds, NSVGshape *shape, float* xform) -{ - NSVGpath* path; - float curve[4*2], curveBounds[4]; - int i, first = 1; - for (path = shape->paths; path != NULL; path = path->next) { - nsvg__xformPoint(&curve[0], &curve[1], path->pts[0], path->pts[1], xform); - for (i = 0; i < path->npts-1; i += 3) { - nsvg__xformPoint(&curve[2], &curve[3], path->pts[(i+1)*2], path->pts[(i+1)*2+1], xform); - nsvg__xformPoint(&curve[4], &curve[5], path->pts[(i+2)*2], path->pts[(i+2)*2+1], xform); - nsvg__xformPoint(&curve[6], &curve[7], path->pts[(i+3)*2], path->pts[(i+3)*2+1], xform); - nsvg__curveBounds(curveBounds, curve); - if (first) { - bounds[0] = curveBounds[0]; - bounds[1] = curveBounds[1]; - bounds[2] = curveBounds[2]; - bounds[3] = curveBounds[3]; - first = 0; - } else { - bounds[0] = nsvg__minf(bounds[0], curveBounds[0]); - bounds[1] = nsvg__minf(bounds[1], curveBounds[1]); - bounds[2] = nsvg__maxf(bounds[2], curveBounds[2]); - bounds[3] = nsvg__maxf(bounds[3], curveBounds[3]); - } - curve[0] = curve[6]; - curve[1] = curve[7]; - } - } +static void nsvg__getLocalBounds(float *bounds, NSVGshape *shape, float *xform) { + NSVGpath *path; + float curve[4 * 2], curveBounds[4]; + int i, first = 1; + for (path = shape->paths; path != NULL; path = path->next) { + nsvg__xformPoint(&curve[0], &curve[1], path->pts[0], path->pts[1], xform); + for (i = 0; i < path->npts - 1; i += 3) { + nsvg__xformPoint(&curve[2], &curve[3], path->pts[(i + 1) * 2], path->pts[(i + 1) * 2 + 1], xform); + nsvg__xformPoint(&curve[4], &curve[5], path->pts[(i + 2) * 2], path->pts[(i + 2) * 2 + 1], xform); + nsvg__xformPoint(&curve[6], &curve[7], path->pts[(i + 3) * 2], path->pts[(i + 3) * 2 + 1], xform); + nsvg__curveBounds(curveBounds, curve); + if (first) { + bounds[0] = curveBounds[0]; + bounds[1] = curveBounds[1]; + bounds[2] = curveBounds[2]; + bounds[3] = curveBounds[3]; + first = 0; + } else { + bounds[0] = nsvg__minf(bounds[0], curveBounds[0]); + bounds[1] = nsvg__minf(bounds[1], curveBounds[1]); + bounds[2] = nsvg__maxf(bounds[2], curveBounds[2]); + bounds[3] = nsvg__maxf(bounds[3], curveBounds[3]); + } + curve[0] = curve[6]; + curve[1] = curve[7]; + } + } } -static void nsvg__addShape(NSVGparser* p) -{ - NSVGattrib* attr = nsvg__getAttr(p); - float scale = 1.0f; - NSVGshape* shape; - NSVGpath* path; - int i; +static void nsvg__addShape(NSVGparser *p) { + NSVGattrib *attr = nsvg__getAttr(p); + float scale = 1.0f; + NSVGshape *shape; + NSVGpath *path; + int i; - if (p->plist == NULL) - return; + if (p->plist == NULL) + return; - shape = (NSVGshape*)malloc(sizeof(NSVGshape)); - if (shape == NULL) goto error; - memset(shape, 0, sizeof(NSVGshape)); + shape = (NSVGshape *)malloc(sizeof(NSVGshape)); + if (shape == NULL) + goto error; + memset(shape, 0, sizeof(NSVGshape)); - memcpy(shape->id, attr->id, sizeof shape->id); - scale = nsvg__getAverageScale(attr->xform); - shape->strokeWidth = attr->strokeWidth * scale; - shape->strokeDashOffset = attr->strokeDashOffset * scale; - shape->strokeDashCount = (char)attr->strokeDashCount; - for (i = 0; i < attr->strokeDashCount; i++) - shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale; - shape->strokeLineJoin = attr->strokeLineJoin; - shape->strokeLineCap = attr->strokeLineCap; - shape->miterLimit = attr->miterLimit; - shape->fillRule = attr->fillRule; - shape->opacity = attr->opacity; + memcpy(shape->id, attr->id, sizeof shape->id); + scale = nsvg__getAverageScale(attr->xform); + shape->strokeWidth = attr->strokeWidth * scale; + shape->strokeDashOffset = attr->strokeDashOffset * scale; + shape->strokeDashCount = (char)attr->strokeDashCount; + for (i = 0; i < attr->strokeDashCount; i++) + shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale; + shape->strokeLineJoin = attr->strokeLineJoin; + shape->strokeLineCap = attr->strokeLineCap; + shape->miterLimit = attr->miterLimit; + shape->fillRule = attr->fillRule; + shape->opacity = attr->opacity; - shape->paths = p->plist; - p->plist = NULL; + shape->paths = p->plist; + p->plist = NULL; - // Calculate shape bounds - shape->bounds[0] = shape->paths->bounds[0]; - shape->bounds[1] = shape->paths->bounds[1]; - shape->bounds[2] = shape->paths->bounds[2]; - shape->bounds[3] = shape->paths->bounds[3]; - for (path = shape->paths->next; path != NULL; path = path->next) { - shape->bounds[0] = nsvg__minf(shape->bounds[0], path->bounds[0]); - shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]); - shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]); - shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]); - } + // Calculate shape bounds + shape->bounds[0] = shape->paths->bounds[0]; + shape->bounds[1] = shape->paths->bounds[1]; + shape->bounds[2] = shape->paths->bounds[2]; + shape->bounds[3] = shape->paths->bounds[3]; + for (path = shape->paths->next; path != NULL; path = path->next) { + shape->bounds[0] = nsvg__minf(shape->bounds[0], path->bounds[0]); + shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]); + shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]); + shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]); + } - // Set fill - if (attr->hasFill == 0) { - shape->fill.type = NSVG_PAINT_NONE; - } else if (attr->hasFill == 1) { - shape->fill.type = NSVG_PAINT_COLOR; - shape->fill.color = attr->fillColor; - shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24; - } else if (attr->hasFill == 2) { - float inv[6], localBounds[4]; - nsvg__xformInverse(inv, attr->xform); - nsvg__getLocalBounds(localBounds, shape, inv); - shape->fill.gradient = nsvg__createGradient(p, attr->fillGradient, localBounds, &shape->fill.type); - if (shape->fill.gradient == NULL) { - shape->fill.type = NSVG_PAINT_NONE; - } - } + // Set fill + if (attr->hasFill == 0) { + shape->fill.type = NSVG_PAINT_NONE; + } else if (attr->hasFill == 1) { + shape->fill.type = NSVG_PAINT_COLOR; + shape->fill.color = attr->fillColor; + shape->fill.color |= (unsigned int)(attr->fillOpacity * 255) << 24; + } else if (attr->hasFill == 2) { + float inv[6], localBounds[4]; + nsvg__xformInverse(inv, attr->xform); + nsvg__getLocalBounds(localBounds, shape, inv); + shape->fill.gradient = nsvg__createGradient(p, attr->fillGradient, localBounds, &shape->fill.type); + if (shape->fill.gradient == NULL) { + shape->fill.type = NSVG_PAINT_NONE; + } + } - // Set stroke - if (attr->hasStroke == 0) { - shape->stroke.type = NSVG_PAINT_NONE; - } else if (attr->hasStroke == 1) { - shape->stroke.type = NSVG_PAINT_COLOR; - shape->stroke.color = attr->strokeColor; - shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24; - } else if (attr->hasStroke == 2) { - float inv[6], localBounds[4]; - nsvg__xformInverse(inv, attr->xform); - nsvg__getLocalBounds(localBounds, shape, inv); - shape->stroke.gradient = nsvg__createGradient(p, attr->strokeGradient, localBounds, &shape->stroke.type); - if (shape->stroke.gradient == NULL) - shape->stroke.type = NSVG_PAINT_NONE; - } + // Set stroke + if (attr->hasStroke == 0) { + shape->stroke.type = NSVG_PAINT_NONE; + } else if (attr->hasStroke == 1) { + shape->stroke.type = NSVG_PAINT_COLOR; + shape->stroke.color = attr->strokeColor; + shape->stroke.color |= (unsigned int)(attr->strokeOpacity * 255) << 24; + } else if (attr->hasStroke == 2) { + float inv[6], localBounds[4]; + nsvg__xformInverse(inv, attr->xform); + nsvg__getLocalBounds(localBounds, shape, inv); + shape->stroke.gradient = nsvg__createGradient(p, attr->strokeGradient, localBounds, &shape->stroke.type); + if (shape->stroke.gradient == NULL) + shape->stroke.type = NSVG_PAINT_NONE; + } - // Set flags - shape->flags = (attr->visible ? NSVG_FLAGS_VISIBLE : 0x00); + // Set flags + shape->flags = (attr->visible ? NSVG_FLAGS_VISIBLE : 0x00); - // Add to tail - if (p->image->shapes == NULL) - p->image->shapes = shape; - else - p->shapesTail->next = shape; - p->shapesTail = shape; + // Add to tail + if (p->image->shapes == NULL) + p->image->shapes = shape; + else + p->shapesTail->next = shape; + p->shapesTail = shape; - return; + return; error: - if (shape) free(shape); + if (shape) + free(shape); } -static void nsvg__addPath(NSVGparser* p, char closed) -{ - NSVGattrib* attr = nsvg__getAttr(p); - NSVGpath* path = NULL; - float bounds[4]; - float* curve; - int i; +static void nsvg__addPath(NSVGparser *p, char closed) { + NSVGattrib *attr = nsvg__getAttr(p); + NSVGpath *path = NULL; + float bounds[4]; + float *curve; + int i; - if (p->npts < 4) - return; + if (p->npts < 4) + return; - if (closed) - nsvg__lineTo(p, p->pts[0], p->pts[1]); + if (closed) + nsvg__lineTo(p, p->pts[0], p->pts[1]); - path = (NSVGpath*)malloc(sizeof(NSVGpath)); - if (path == NULL) goto error; - memset(path, 0, sizeof(NSVGpath)); + path = (NSVGpath *)malloc(sizeof(NSVGpath)); + if (path == NULL) + goto error; + memset(path, 0, sizeof(NSVGpath)); - path->pts = (float*)malloc(p->npts*2*sizeof(float)); - if (path->pts == NULL) goto error; - path->closed = closed; - path->npts = p->npts; + path->pts = (float *)malloc(p->npts * 2 * sizeof(float)); + if (path->pts == NULL) + goto error; + path->closed = closed; + path->npts = p->npts; - // Transform path. - for (i = 0; i < p->npts; ++i) - nsvg__xformPoint(&path->pts[i*2], &path->pts[i*2+1], p->pts[i*2], p->pts[i*2+1], attr->xform); + // Transform path. + for (i = 0; i < p->npts; ++i) + nsvg__xformPoint(&path->pts[i * 2], &path->pts[i * 2 + 1], p->pts[i * 2], p->pts[i * 2 + 1], attr->xform); - // Find bounds - for (i = 0; i < path->npts-1; i += 3) { - curve = &path->pts[i*2]; - nsvg__curveBounds(bounds, curve); - if (i == 0) { - path->bounds[0] = bounds[0]; - path->bounds[1] = bounds[1]; - path->bounds[2] = bounds[2]; - path->bounds[3] = bounds[3]; - } else { - path->bounds[0] = nsvg__minf(path->bounds[0], bounds[0]); - path->bounds[1] = nsvg__minf(path->bounds[1], bounds[1]); - path->bounds[2] = nsvg__maxf(path->bounds[2], bounds[2]); - path->bounds[3] = nsvg__maxf(path->bounds[3], bounds[3]); - } - } + // Find bounds + for (i = 0; i < path->npts - 1; i += 3) { + curve = &path->pts[i * 2]; + nsvg__curveBounds(bounds, curve); + if (i == 0) { + path->bounds[0] = bounds[0]; + path->bounds[1] = bounds[1]; + path->bounds[2] = bounds[2]; + path->bounds[3] = bounds[3]; + } else { + path->bounds[0] = nsvg__minf(path->bounds[0], bounds[0]); + path->bounds[1] = nsvg__minf(path->bounds[1], bounds[1]); + path->bounds[2] = nsvg__maxf(path->bounds[2], bounds[2]); + path->bounds[3] = nsvg__maxf(path->bounds[3], bounds[3]); + } + } - path->next = p->plist; - p->plist = path; + path->next = p->plist; + p->plist = path; - return; + return; error: - if (path != NULL) { - if (path->pts != NULL) free(path->pts); - free(path); - } + if (path != NULL) { + if (path->pts != NULL) + free(path->pts); + free(path); + } } // We roll our own string to float because the std library one uses locale and messes things up. -static double nsvg__atof(const char* s) -{ - char* cur = (char*)s; - char* end = NULL; - double res = 0.0, sign = 1.0; - long long intPart = 0, fracPart = 0; - char hasIntPart = 0, hasFracPart = 0; +static double nsvg__atof(const char *s) { + char *cur = (char *)s; + char *end = NULL; + double res = 0.0, sign = 1.0; + long long intPart = 0, fracPart = 0; + char hasIntPart = 0, hasFracPart = 0; - // Parse optional sign - if (*cur == '+') { - cur++; - } else if (*cur == '-') { - sign = -1; - cur++; - } + // Parse optional sign + if (*cur == '+') { + cur++; + } else if (*cur == '-') { + sign = -1; + cur++; + } - // Parse integer part - if (nsvg__isdigit(*cur)) { - // Parse digit sequence - intPart = (double)strtoll(cur, &end, 10); - if (cur != end) { - res = (double)intPart; - hasIntPart = 1; - cur = end; - } - } + // Parse integer part + if (nsvg__isdigit(*cur)) { + // Parse digit sequence + intPart = (double)strtoll(cur, &end, 10); + if (cur != end) { + res = (double)intPart; + hasIntPart = 1; + cur = end; + } + } - // Parse fractional part. - if (*cur == '.') { - cur++; // Skip '.' - if (nsvg__isdigit(*cur)) { - // Parse digit sequence - fracPart = strtoll(cur, &end, 10); - if (cur != end) { - res += (double)fracPart / pow(10.0, (double)(end - cur)); - hasFracPart = 1; - cur = end; - } - } - } + // Parse fractional part. + if (*cur == '.') { + cur++; // Skip '.' + if (nsvg__isdigit(*cur)) { + // Parse digit sequence + fracPart = strtoll(cur, &end, 10); + if (cur != end) { + res += (double)fracPart / pow(10.0, (double)(end - cur)); + hasFracPart = 1; + cur = end; + } + } + } - // A valid number should have integer or fractional part. - if (!hasIntPart && !hasFracPart) - return 0.0; + // A valid number should have integer or fractional part. + if (!hasIntPart && !hasFracPart) + return 0.0; - // Parse optional exponent - if (*cur == 'e' || *cur == 'E') { - int expPart = 0; - cur++; // skip 'E' - expPart = strtol(cur, &end, 10); // Parse digit sequence with sign - if (cur != end) { - res *= pow(10.0, (double)expPart); - } - } + // Parse optional exponent + if (*cur == 'e' || *cur == 'E') { + int expPart = 0; + cur++; // skip 'E' + expPart = strtol(cur, &end, 10); // Parse digit sequence with sign + if (cur != end) { + res *= pow(10.0, (double)expPart); + } + } - return res * sign; + return res * sign; } +static const char *nsvg__parseNumber(const char *s, char *it, const int size) { + const int last = size - 1; + int i = 0; -static const char* nsvg__parseNumber(const char* s, char* it, const int size) -{ - const int last = size-1; - int i = 0; - - // sign - if (*s == '-' || *s == '+') { - if (i < last) it[i++] = *s; - s++; - } - // integer part - while (*s && nsvg__isdigit(*s)) { - if (i < last) it[i++] = *s; - s++; - } - if (*s == '.') { - // decimal point - if (i < last) it[i++] = *s; - s++; - // fraction part - while (*s && nsvg__isdigit(*s)) { - if (i < last) it[i++] = *s; - s++; - } - } - // exponent - if (*s == 'e' || *s == 'E') { - if (i < last) it[i++] = *s; - s++; - if (*s == '-' || *s == '+') { - if (i < last) it[i++] = *s; - s++; - } - while (*s && nsvg__isdigit(*s)) { - if (i < last) it[i++] = *s; - s++; - } - } - it[i] = '\0'; + // sign + if (*s == '-' || *s == '+') { + if (i < last) + it[i++] = *s; + s++; + } + // integer part + while (*s && nsvg__isdigit(*s)) { + if (i < last) + it[i++] = *s; + s++; + } + if (*s == '.') { + // decimal point + if (i < last) + it[i++] = *s; + s++; + // fraction part + while (*s && nsvg__isdigit(*s)) { + if (i < last) + it[i++] = *s; + s++; + } + } + // exponent + if (*s == 'e' || *s == 'E') { + if (i < last) + it[i++] = *s; + s++; + if (*s == '-' || *s == '+') { + if (i < last) + it[i++] = *s; + s++; + } + while (*s && nsvg__isdigit(*s)) { + if (i < last) + it[i++] = *s; + s++; + } + } + it[i] = '\0'; - return s; + return s; } -static const char* nsvg__getNextPathItem(const char* s, char* it) -{ - it[0] = '\0'; - // Skip white spaces and commas - while (*s && (nsvg__isspace(*s) || *s == ',')) s++; - if (!*s) return s; - if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) { - s = nsvg__parseNumber(s, it, 64); - } else { - // Parse command - it[0] = *s++; - it[1] = '\0'; - return s; - } +static const char *nsvg__getNextPathItem(const char *s, char *it) { + it[0] = '\0'; + // Skip white spaces and commas + while (*s && (nsvg__isspace(*s) || *s == ',')) + s++; + if (!*s) + return s; + if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) { + s = nsvg__parseNumber(s, it, 64); + } else { + // Parse command + it[0] = *s++; + it[1] = '\0'; + return s; + } - return s; + return s; } -static unsigned int nsvg__parseColorHex(const char* str) -{ - unsigned int c = 0, r = 0, g = 0, b = 0; - int n = 0; - str++; // skip # - // Calculate number of characters. - while(str[n] && !nsvg__isspace(str[n])) - n++; - if (n == 6) { - sscanf(str, "%x", &c); - } else if (n == 3) { - sscanf(str, "%x", &c); - c = (c&0xf) | ((c&0xf0) << 4) | ((c&0xf00) << 8); - c |= c<<4; - } - r = (c >> 16) & 0xff; - g = (c >> 8) & 0xff; - b = c & 0xff; - return NSVG_RGB(r,g,b); +static unsigned int nsvg__parseColorHex(const char *str) { + unsigned int c = 0, r = 0, g = 0, b = 0; + int n = 0; + str++; // skip # + // Calculate number of characters. + while (str[n] && !nsvg__isspace(str[n])) + n++; + if (n == 6) { + sscanf(str, "%x", &c); + } else if (n == 3) { + sscanf(str, "%x", &c); + c = (c & 0xf) | ((c & 0xf0) << 4) | ((c & 0xf00) << 8); + c |= c << 4; + } + r = (c >> 16) & 0xff; + g = (c >> 8) & 0xff; + b = c & 0xff; + return NSVG_RGB(r, g, b); } -static unsigned int nsvg__parseColorRGB(const char* str) -{ - int r = -1, g = -1, b = -1; - char s1[32]="", s2[32]=""; - sscanf(str + 4, "%d%[%%, \t]%d%[%%, \t]%d", &r, s1, &g, s2, &b); - if (strchr(s1, '%')) { - return NSVG_RGB((r*255)/100,(g*255)/100,(b*255)/100); - } else { - return NSVG_RGB(r,g,b); - } +static unsigned int nsvg__parseColorRGB(const char *str) { + int r = -1, g = -1, b = -1; + char s1[32] = "", s2[32] = ""; + sscanf(str + 4, "%d%[%%, \t]%d%[%%, \t]%d", &r, s1, &g, s2, &b); + if (strchr(s1, '%')) { + return NSVG_RGB((r * 255) / 100, (g * 255) / 100, (b * 255) / 100); + } else { + return NSVG_RGB(r, g, b); + } } typedef struct NSVGNamedColor { - const char* name; - unsigned int color; + const char *name; + unsigned int color; } NSVGNamedColor; NSVGNamedColor nsvg__colors[] = { - { "red", NSVG_RGB(255, 0, 0) }, - { "green", NSVG_RGB( 0, 128, 0) }, - { "blue", NSVG_RGB( 0, 0, 255) }, - { "yellow", NSVG_RGB(255, 255, 0) }, - { "cyan", NSVG_RGB( 0, 255, 255) }, - { "magenta", NSVG_RGB(255, 0, 255) }, - { "black", NSVG_RGB( 0, 0, 0) }, - { "grey", NSVG_RGB(128, 128, 128) }, - { "gray", NSVG_RGB(128, 128, 128) }, - { "white", NSVG_RGB(255, 255, 255) }, + {"red", NSVG_RGB(255, 0, 0)}, + {"green", NSVG_RGB(0, 128, 0)}, + {"blue", NSVG_RGB(0, 0, 255)}, + {"yellow", NSVG_RGB(255, 255, 0)}, + {"cyan", NSVG_RGB(0, 255, 255)}, + {"magenta", NSVG_RGB(255, 0, 255)}, + {"black", NSVG_RGB(0, 0, 0)}, + {"grey", NSVG_RGB(128, 128, 128)}, + {"gray", NSVG_RGB(128, 128, 128)}, + {"white", NSVG_RGB(255, 255, 255)}, #ifdef NANOSVG_ALL_COLOR_KEYWORDS - { "aliceblue", NSVG_RGB(240, 248, 255) }, - { "antiquewhite", NSVG_RGB(250, 235, 215) }, - { "aqua", NSVG_RGB( 0, 255, 255) }, - { "aquamarine", NSVG_RGB(127, 255, 212) }, - { "azure", NSVG_RGB(240, 255, 255) }, - { "beige", NSVG_RGB(245, 245, 220) }, - { "bisque", NSVG_RGB(255, 228, 196) }, - { "blanchedalmond", NSVG_RGB(255, 235, 205) }, - { "blueviolet", NSVG_RGB(138, 43, 226) }, - { "brown", NSVG_RGB(165, 42, 42) }, - { "burlywood", NSVG_RGB(222, 184, 135) }, - { "cadetblue", NSVG_RGB( 95, 158, 160) }, - { "chartreuse", NSVG_RGB(127, 255, 0) }, - { "chocolate", NSVG_RGB(210, 105, 30) }, - { "coral", NSVG_RGB(255, 127, 80) }, - { "cornflowerblue", NSVG_RGB(100, 149, 237) }, - { "cornsilk", NSVG_RGB(255, 248, 220) }, - { "crimson", NSVG_RGB(220, 20, 60) }, - { "darkblue", NSVG_RGB( 0, 0, 139) }, - { "darkcyan", NSVG_RGB( 0, 139, 139) }, - { "darkgoldenrod", NSVG_RGB(184, 134, 11) }, - { "darkgray", NSVG_RGB(169, 169, 169) }, - { "darkgreen", NSVG_RGB( 0, 100, 0) }, - { "darkgrey", NSVG_RGB(169, 169, 169) }, - { "darkkhaki", NSVG_RGB(189, 183, 107) }, - { "darkmagenta", NSVG_RGB(139, 0, 139) }, - { "darkolivegreen", NSVG_RGB( 85, 107, 47) }, - { "darkorange", NSVG_RGB(255, 140, 0) }, - { "darkorchid", NSVG_RGB(153, 50, 204) }, - { "darkred", NSVG_RGB(139, 0, 0) }, - { "darksalmon", NSVG_RGB(233, 150, 122) }, - { "darkseagreen", NSVG_RGB(143, 188, 143) }, - { "darkslateblue", NSVG_RGB( 72, 61, 139) }, - { "darkslategray", NSVG_RGB( 47, 79, 79) }, - { "darkslategrey", NSVG_RGB( 47, 79, 79) }, - { "darkturquoise", NSVG_RGB( 0, 206, 209) }, - { "darkviolet", NSVG_RGB(148, 0, 211) }, - { "deeppink", NSVG_RGB(255, 20, 147) }, - { "deepskyblue", NSVG_RGB( 0, 191, 255) }, - { "dimgray", NSVG_RGB(105, 105, 105) }, - { "dimgrey", NSVG_RGB(105, 105, 105) }, - { "dodgerblue", NSVG_RGB( 30, 144, 255) }, - { "firebrick", NSVG_RGB(178, 34, 34) }, - { "floralwhite", NSVG_RGB(255, 250, 240) }, - { "forestgreen", NSVG_RGB( 34, 139, 34) }, - { "fuchsia", NSVG_RGB(255, 0, 255) }, - { "gainsboro", NSVG_RGB(220, 220, 220) }, - { "ghostwhite", NSVG_RGB(248, 248, 255) }, - { "gold", NSVG_RGB(255, 215, 0) }, - { "goldenrod", NSVG_RGB(218, 165, 32) }, - { "greenyellow", NSVG_RGB(173, 255, 47) }, - { "honeydew", NSVG_RGB(240, 255, 240) }, - { "hotpink", NSVG_RGB(255, 105, 180) }, - { "indianred", NSVG_RGB(205, 92, 92) }, - { "indigo", NSVG_RGB( 75, 0, 130) }, - { "ivory", NSVG_RGB(255, 255, 240) }, - { "khaki", NSVG_RGB(240, 230, 140) }, - { "lavender", NSVG_RGB(230, 230, 250) }, - { "lavenderblush", NSVG_RGB(255, 240, 245) }, - { "lawngreen", NSVG_RGB(124, 252, 0) }, - { "lemonchiffon", NSVG_RGB(255, 250, 205) }, - { "lightblue", NSVG_RGB(173, 216, 230) }, - { "lightcoral", NSVG_RGB(240, 128, 128) }, - { "lightcyan", NSVG_RGB(224, 255, 255) }, - { "lightgoldenrodyellow", NSVG_RGB(250, 250, 210) }, - { "lightgray", NSVG_RGB(211, 211, 211) }, - { "lightgreen", NSVG_RGB(144, 238, 144) }, - { "lightgrey", NSVG_RGB(211, 211, 211) }, - { "lightpink", NSVG_RGB(255, 182, 193) }, - { "lightsalmon", NSVG_RGB(255, 160, 122) }, - { "lightseagreen", NSVG_RGB( 32, 178, 170) }, - { "lightskyblue", NSVG_RGB(135, 206, 250) }, - { "lightslategray", NSVG_RGB(119, 136, 153) }, - { "lightslategrey", NSVG_RGB(119, 136, 153) }, - { "lightsteelblue", NSVG_RGB(176, 196, 222) }, - { "lightyellow", NSVG_RGB(255, 255, 224) }, - { "lime", NSVG_RGB( 0, 255, 0) }, - { "limegreen", NSVG_RGB( 50, 205, 50) }, - { "linen", NSVG_RGB(250, 240, 230) }, - { "maroon", NSVG_RGB(128, 0, 0) }, - { "mediumaquamarine", NSVG_RGB(102, 205, 170) }, - { "mediumblue", NSVG_RGB( 0, 0, 205) }, - { "mediumorchid", NSVG_RGB(186, 85, 211) }, - { "mediumpurple", NSVG_RGB(147, 112, 219) }, - { "mediumseagreen", NSVG_RGB( 60, 179, 113) }, - { "mediumslateblue", NSVG_RGB(123, 104, 238) }, - { "mediumspringgreen", NSVG_RGB( 0, 250, 154) }, - { "mediumturquoise", NSVG_RGB( 72, 209, 204) }, - { "mediumvioletred", NSVG_RGB(199, 21, 133) }, - { "midnightblue", NSVG_RGB( 25, 25, 112) }, - { "mintcream", NSVG_RGB(245, 255, 250) }, - { "mistyrose", NSVG_RGB(255, 228, 225) }, - { "moccasin", NSVG_RGB(255, 228, 181) }, - { "navajowhite", NSVG_RGB(255, 222, 173) }, - { "navy", NSVG_RGB( 0, 0, 128) }, - { "oldlace", NSVG_RGB(253, 245, 230) }, - { "olive", NSVG_RGB(128, 128, 0) }, - { "olivedrab", NSVG_RGB(107, 142, 35) }, - { "orange", NSVG_RGB(255, 165, 0) }, - { "orangered", NSVG_RGB(255, 69, 0) }, - { "orchid", NSVG_RGB(218, 112, 214) }, - { "palegoldenrod", NSVG_RGB(238, 232, 170) }, - { "palegreen", NSVG_RGB(152, 251, 152) }, - { "paleturquoise", NSVG_RGB(175, 238, 238) }, - { "palevioletred", NSVG_RGB(219, 112, 147) }, - { "papayawhip", NSVG_RGB(255, 239, 213) }, - { "peachpuff", NSVG_RGB(255, 218, 185) }, - { "peru", NSVG_RGB(205, 133, 63) }, - { "pink", NSVG_RGB(255, 192, 203) }, - { "plum", NSVG_RGB(221, 160, 221) }, - { "powderblue", NSVG_RGB(176, 224, 230) }, - { "purple", NSVG_RGB(128, 0, 128) }, - { "rosybrown", NSVG_RGB(188, 143, 143) }, - { "royalblue", NSVG_RGB( 65, 105, 225) }, - { "saddlebrown", NSVG_RGB(139, 69, 19) }, - { "salmon", NSVG_RGB(250, 128, 114) }, - { "sandybrown", NSVG_RGB(244, 164, 96) }, - { "seagreen", NSVG_RGB( 46, 139, 87) }, - { "seashell", NSVG_RGB(255, 245, 238) }, - { "sienna", NSVG_RGB(160, 82, 45) }, - { "silver", NSVG_RGB(192, 192, 192) }, - { "skyblue", NSVG_RGB(135, 206, 235) }, - { "slateblue", NSVG_RGB(106, 90, 205) }, - { "slategray", NSVG_RGB(112, 128, 144) }, - { "slategrey", NSVG_RGB(112, 128, 144) }, - { "snow", NSVG_RGB(255, 250, 250) }, - { "springgreen", NSVG_RGB( 0, 255, 127) }, - { "steelblue", NSVG_RGB( 70, 130, 180) }, - { "tan", NSVG_RGB(210, 180, 140) }, - { "teal", NSVG_RGB( 0, 128, 128) }, - { "thistle", NSVG_RGB(216, 191, 216) }, - { "tomato", NSVG_RGB(255, 99, 71) }, - { "turquoise", NSVG_RGB( 64, 224, 208) }, - { "violet", NSVG_RGB(238, 130, 238) }, - { "wheat", NSVG_RGB(245, 222, 179) }, - { "whitesmoke", NSVG_RGB(245, 245, 245) }, - { "yellowgreen", NSVG_RGB(154, 205, 50) }, + {"aliceblue", NSVG_RGB(240, 248, 255)}, + {"antiquewhite", NSVG_RGB(250, 235, 215)}, + {"aqua", NSVG_RGB(0, 255, 255)}, + {"aquamarine", NSVG_RGB(127, 255, 212)}, + {"azure", NSVG_RGB(240, 255, 255)}, + {"beige", NSVG_RGB(245, 245, 220)}, + {"bisque", NSVG_RGB(255, 228, 196)}, + {"blanchedalmond", NSVG_RGB(255, 235, 205)}, + {"blueviolet", NSVG_RGB(138, 43, 226)}, + {"brown", NSVG_RGB(165, 42, 42)}, + {"burlywood", NSVG_RGB(222, 184, 135)}, + {"cadetblue", NSVG_RGB(95, 158, 160)}, + {"chartreuse", NSVG_RGB(127, 255, 0)}, + {"chocolate", NSVG_RGB(210, 105, 30)}, + {"coral", NSVG_RGB(255, 127, 80)}, + {"cornflowerblue", NSVG_RGB(100, 149, 237)}, + {"cornsilk", NSVG_RGB(255, 248, 220)}, + {"crimson", NSVG_RGB(220, 20, 60)}, + {"darkblue", NSVG_RGB(0, 0, 139)}, + {"darkcyan", NSVG_RGB(0, 139, 139)}, + {"darkgoldenrod", NSVG_RGB(184, 134, 11)}, + {"darkgray", NSVG_RGB(169, 169, 169)}, + {"darkgreen", NSVG_RGB(0, 100, 0)}, + {"darkgrey", NSVG_RGB(169, 169, 169)}, + {"darkkhaki", NSVG_RGB(189, 183, 107)}, + {"darkmagenta", NSVG_RGB(139, 0, 139)}, + {"darkolivegreen", NSVG_RGB(85, 107, 47)}, + {"darkorange", NSVG_RGB(255, 140, 0)}, + {"darkorchid", NSVG_RGB(153, 50, 204)}, + {"darkred", NSVG_RGB(139, 0, 0)}, + {"darksalmon", NSVG_RGB(233, 150, 122)}, + {"darkseagreen", NSVG_RGB(143, 188, 143)}, + {"darkslateblue", NSVG_RGB(72, 61, 139)}, + {"darkslategray", NSVG_RGB(47, 79, 79)}, + {"darkslategrey", NSVG_RGB(47, 79, 79)}, + {"darkturquoise", NSVG_RGB(0, 206, 209)}, + {"darkviolet", NSVG_RGB(148, 0, 211)}, + {"deeppink", NSVG_RGB(255, 20, 147)}, + {"deepskyblue", NSVG_RGB(0, 191, 255)}, + {"dimgray", NSVG_RGB(105, 105, 105)}, + {"dimgrey", NSVG_RGB(105, 105, 105)}, + {"dodgerblue", NSVG_RGB(30, 144, 255)}, + {"firebrick", NSVG_RGB(178, 34, 34)}, + {"floralwhite", NSVG_RGB(255, 250, 240)}, + {"forestgreen", NSVG_RGB(34, 139, 34)}, + {"fuchsia", NSVG_RGB(255, 0, 255)}, + {"gainsboro", NSVG_RGB(220, 220, 220)}, + {"ghostwhite", NSVG_RGB(248, 248, 255)}, + {"gold", NSVG_RGB(255, 215, 0)}, + {"goldenrod", NSVG_RGB(218, 165, 32)}, + {"greenyellow", NSVG_RGB(173, 255, 47)}, + {"honeydew", NSVG_RGB(240, 255, 240)}, + {"hotpink", NSVG_RGB(255, 105, 180)}, + {"indianred", NSVG_RGB(205, 92, 92)}, + {"indigo", NSVG_RGB(75, 0, 130)}, + {"ivory", NSVG_RGB(255, 255, 240)}, + {"khaki", NSVG_RGB(240, 230, 140)}, + {"lavender", NSVG_RGB(230, 230, 250)}, + {"lavenderblush", NSVG_RGB(255, 240, 245)}, + {"lawngreen", NSVG_RGB(124, 252, 0)}, + {"lemonchiffon", NSVG_RGB(255, 250, 205)}, + {"lightblue", NSVG_RGB(173, 216, 230)}, + {"lightcoral", NSVG_RGB(240, 128, 128)}, + {"lightcyan", NSVG_RGB(224, 255, 255)}, + {"lightgoldenrodyellow", NSVG_RGB(250, 250, 210)}, + {"lightgray", NSVG_RGB(211, 211, 211)}, + {"lightgreen", NSVG_RGB(144, 238, 144)}, + {"lightgrey", NSVG_RGB(211, 211, 211)}, + {"lightpink", NSVG_RGB(255, 182, 193)}, + {"lightsalmon", NSVG_RGB(255, 160, 122)}, + {"lightseagreen", NSVG_RGB(32, 178, 170)}, + {"lightskyblue", NSVG_RGB(135, 206, 250)}, + {"lightslategray", NSVG_RGB(119, 136, 153)}, + {"lightslategrey", NSVG_RGB(119, 136, 153)}, + {"lightsteelblue", NSVG_RGB(176, 196, 222)}, + {"lightyellow", NSVG_RGB(255, 255, 224)}, + {"lime", NSVG_RGB(0, 255, 0)}, + {"limegreen", NSVG_RGB(50, 205, 50)}, + {"linen", NSVG_RGB(250, 240, 230)}, + {"maroon", NSVG_RGB(128, 0, 0)}, + {"mediumaquamarine", NSVG_RGB(102, 205, 170)}, + {"mediumblue", NSVG_RGB(0, 0, 205)}, + {"mediumorchid", NSVG_RGB(186, 85, 211)}, + {"mediumpurple", NSVG_RGB(147, 112, 219)}, + {"mediumseagreen", NSVG_RGB(60, 179, 113)}, + {"mediumslateblue", NSVG_RGB(123, 104, 238)}, + {"mediumspringgreen", NSVG_RGB(0, 250, 154)}, + {"mediumturquoise", NSVG_RGB(72, 209, 204)}, + {"mediumvioletred", NSVG_RGB(199, 21, 133)}, + {"midnightblue", NSVG_RGB(25, 25, 112)}, + {"mintcream", NSVG_RGB(245, 255, 250)}, + {"mistyrose", NSVG_RGB(255, 228, 225)}, + {"moccasin", NSVG_RGB(255, 228, 181)}, + {"navajowhite", NSVG_RGB(255, 222, 173)}, + {"navy", NSVG_RGB(0, 0, 128)}, + {"oldlace", NSVG_RGB(253, 245, 230)}, + {"olive", NSVG_RGB(128, 128, 0)}, + {"olivedrab", NSVG_RGB(107, 142, 35)}, + {"orange", NSVG_RGB(255, 165, 0)}, + {"orangered", NSVG_RGB(255, 69, 0)}, + {"orchid", NSVG_RGB(218, 112, 214)}, + {"palegoldenrod", NSVG_RGB(238, 232, 170)}, + {"palegreen", NSVG_RGB(152, 251, 152)}, + {"paleturquoise", NSVG_RGB(175, 238, 238)}, + {"palevioletred", NSVG_RGB(219, 112, 147)}, + {"papayawhip", NSVG_RGB(255, 239, 213)}, + {"peachpuff", NSVG_RGB(255, 218, 185)}, + {"peru", NSVG_RGB(205, 133, 63)}, + {"pink", NSVG_RGB(255, 192, 203)}, + {"plum", NSVG_RGB(221, 160, 221)}, + {"powderblue", NSVG_RGB(176, 224, 230)}, + {"purple", NSVG_RGB(128, 0, 128)}, + {"rosybrown", NSVG_RGB(188, 143, 143)}, + {"royalblue", NSVG_RGB(65, 105, 225)}, + {"saddlebrown", NSVG_RGB(139, 69, 19)}, + {"salmon", NSVG_RGB(250, 128, 114)}, + {"sandybrown", NSVG_RGB(244, 164, 96)}, + {"seagreen", NSVG_RGB(46, 139, 87)}, + {"seashell", NSVG_RGB(255, 245, 238)}, + {"sienna", NSVG_RGB(160, 82, 45)}, + {"silver", NSVG_RGB(192, 192, 192)}, + {"skyblue", NSVG_RGB(135, 206, 235)}, + {"slateblue", NSVG_RGB(106, 90, 205)}, + {"slategray", NSVG_RGB(112, 128, 144)}, + {"slategrey", NSVG_RGB(112, 128, 144)}, + {"snow", NSVG_RGB(255, 250, 250)}, + {"springgreen", NSVG_RGB(0, 255, 127)}, + {"steelblue", NSVG_RGB(70, 130, 180)}, + {"tan", NSVG_RGB(210, 180, 140)}, + {"teal", NSVG_RGB(0, 128, 128)}, + {"thistle", NSVG_RGB(216, 191, 216)}, + {"tomato", NSVG_RGB(255, 99, 71)}, + {"turquoise", NSVG_RGB(64, 224, 208)}, + {"violet", NSVG_RGB(238, 130, 238)}, + {"wheat", NSVG_RGB(245, 222, 179)}, + {"whitesmoke", NSVG_RGB(245, 245, 245)}, + {"yellowgreen", NSVG_RGB(154, 205, 50)}, #endif }; -static unsigned int nsvg__parseColorName(const char* str) -{ - int i, ncolors = sizeof(nsvg__colors) / sizeof(NSVGNamedColor); +static unsigned int nsvg__parseColorName(const char *str) { + int i, ncolors = sizeof(nsvg__colors) / sizeof(NSVGNamedColor); - for (i = 0; i < ncolors; i++) { - if (strcmp(nsvg__colors[i].name, str) == 0) { - return nsvg__colors[i].color; - } - } + for (i = 0; i < ncolors; i++) { + if (strcmp(nsvg__colors[i].name, str) == 0) { + return nsvg__colors[i].color; + } + } - return NSVG_RGB(128, 128, 128); + return NSVG_RGB(128, 128, 128); } -static unsigned int nsvg__parseColor(const char* str) -{ - size_t len = 0; - while(*str == ' ') ++str; - len = strlen(str); - if (len >= 1 && *str == '#') - return nsvg__parseColorHex(str); - else if (len >= 4 && str[0] == 'r' && str[1] == 'g' && str[2] == 'b' && str[3] == '(') - return nsvg__parseColorRGB(str); - return nsvg__parseColorName(str); +static unsigned int nsvg__parseColor(const char *str) { + size_t len = 0; + while (*str == ' ') + ++str; + len = strlen(str); + if (len >= 1 && *str == '#') + return nsvg__parseColorHex(str); + else if (len >= 4 && str[0] == 'r' && str[1] == 'g' && str[2] == 'b' && str[3] == '(') + return nsvg__parseColorRGB(str); + return nsvg__parseColorName(str); } -static float nsvg__parseOpacity(const char* str) -{ - float val = 0; - sscanf(str, "%f", &val); - if (val < 0.0f) val = 0.0f; - if (val > 1.0f) val = 1.0f; - return val; +static float nsvg__parseOpacity(const char *str) { + float val = 0; + sscanf(str, "%f", &val); + if (val < 0.0f) + val = 0.0f; + if (val > 1.0f) + val = 1.0f; + return val; } -static float nsvg__parseMiterLimit(const char* str) -{ - float val = 0; - sscanf(str, "%f", &val); - if (val < 0.0f) val = 0.0f; - return val; +static float nsvg__parseMiterLimit(const char *str) { + float val = 0; + sscanf(str, "%f", &val); + if (val < 0.0f) + val = 0.0f; + return val; } -static int nsvg__parseUnits(const char* units) -{ - if (units[0] == 'p' && units[1] == 'x') - return NSVG_UNITS_PX; - else if (units[0] == 'p' && units[1] == 't') - return NSVG_UNITS_PT; - else if (units[0] == 'p' && units[1] == 'c') - return NSVG_UNITS_PC; - else if (units[0] == 'm' && units[1] == 'm') - return NSVG_UNITS_MM; - else if (units[0] == 'c' && units[1] == 'm') - return NSVG_UNITS_CM; - else if (units[0] == 'i' && units[1] == 'n') - return NSVG_UNITS_IN; - else if (units[0] == '%') - return NSVG_UNITS_PERCENT; - else if (units[0] == 'e' && units[1] == 'm') - return NSVG_UNITS_EM; - else if (units[0] == 'e' && units[1] == 'x') - return NSVG_UNITS_EX; - return NSVG_UNITS_USER; +static int nsvg__parseUnits(const char *units) { + if (units[0] == 'p' && units[1] == 'x') + return NSVG_UNITS_PX; + else if (units[0] == 'p' && units[1] == 't') + return NSVG_UNITS_PT; + else if (units[0] == 'p' && units[1] == 'c') + return NSVG_UNITS_PC; + else if (units[0] == 'm' && units[1] == 'm') + return NSVG_UNITS_MM; + else if (units[0] == 'c' && units[1] == 'm') + return NSVG_UNITS_CM; + else if (units[0] == 'i' && units[1] == 'n') + return NSVG_UNITS_IN; + else if (units[0] == '%') + return NSVG_UNITS_PERCENT; + else if (units[0] == 'e' && units[1] == 'm') + return NSVG_UNITS_EM; + else if (units[0] == 'e' && units[1] == 'x') + return NSVG_UNITS_EX; + return NSVG_UNITS_USER; } -static NSVGcoordinate nsvg__parseCoordinateRaw(const char* str) -{ - NSVGcoordinate coord = {0, NSVG_UNITS_USER}; - char units[32]=""; - sscanf(str, "%f%31s", &coord.value, units); - coord.units = nsvg__parseUnits(units); - return coord; +static NSVGcoordinate nsvg__parseCoordinateRaw(const char *str) { + NSVGcoordinate coord = {0, NSVG_UNITS_USER}; + char units[32] = ""; + sscanf(str, "%f%31s", &coord.value, units); + coord.units = nsvg__parseUnits(units); + return coord; } -static NSVGcoordinate nsvg__coord(float v, int units) -{ - NSVGcoordinate coord = {v, units}; - return coord; +static NSVGcoordinate nsvg__coord(float v, int units) { + NSVGcoordinate coord = {v, units}; + return coord; } -static float nsvg__parseCoordinate(NSVGparser* p, const char* str, float orig, float length) -{ - NSVGcoordinate coord = nsvg__parseCoordinateRaw(str); - return nsvg__convertToPixels(p, coord, orig, length); +static float nsvg__parseCoordinate(NSVGparser *p, const char *str, float orig, float length) { + NSVGcoordinate coord = nsvg__parseCoordinateRaw(str); + return nsvg__convertToPixels(p, coord, orig, length); } -static int nsvg__parseTransformArgs(const char* str, float* args, int maxNa, int* na) -{ - const char* end; - const char* ptr; - char it[64]; +static int nsvg__parseTransformArgs(const char *str, float *args, int maxNa, int *na) { + const char *end; + const char *ptr; + char it[64]; - *na = 0; - ptr = str; - while (*ptr && *ptr != '(') ++ptr; - if (*ptr == 0) - return 1; - end = ptr; - while (*end && *end != ')') ++end; - if (*end == 0) - return 1; + *na = 0; + ptr = str; + while (*ptr && *ptr != '(') + ++ptr; + if (*ptr == 0) + return 1; + end = ptr; + while (*end && *end != ')') + ++end; + if (*end == 0) + return 1; - while (ptr < end) { - if (*ptr == '-' || *ptr == '+' || *ptr == '.' || nsvg__isdigit(*ptr)) { - if (*na >= maxNa) return 0; - ptr = nsvg__parseNumber(ptr, it, 64); - args[(*na)++] = (float)nsvg__atof(it); - } else { - ++ptr; - } - } - return (int)(end - str); + while (ptr < end) { + if (*ptr == '-' || *ptr == '+' || *ptr == '.' || nsvg__isdigit(*ptr)) { + if (*na >= maxNa) + return 0; + ptr = nsvg__parseNumber(ptr, it, 64); + args[(*na)++] = (float)nsvg__atof(it); + } else { + ++ptr; + } + } + return (int)(end - str); } - -static int nsvg__parseMatrix(float* xform, const char* str) -{ - float t[6]; - int na = 0; - int len = nsvg__parseTransformArgs(str, t, 6, &na); - if (na != 6) return len; - memcpy(xform, t, sizeof(float)*6); - return len; +static int nsvg__parseMatrix(float *xform, const char *str) { + float t[6]; + int na = 0; + int len = nsvg__parseTransformArgs(str, t, 6, &na); + if (na != 6) + return len; + memcpy(xform, t, sizeof(float) * 6); + return len; } -static int nsvg__parseTranslate(float* xform, const char* str) -{ - float args[2]; - float t[6]; - int na = 0; - int len = nsvg__parseTransformArgs(str, args, 2, &na); - if (na == 1) args[1] = 0.0; +static int nsvg__parseTranslate(float *xform, const char *str) { + float args[2]; + float t[6]; + int na = 0; + int len = nsvg__parseTransformArgs(str, args, 2, &na); + if (na == 1) + args[1] = 0.0; - nsvg__xformSetTranslation(t, args[0], args[1]); - memcpy(xform, t, sizeof(float)*6); - return len; + nsvg__xformSetTranslation(t, args[0], args[1]); + memcpy(xform, t, sizeof(float) * 6); + return len; } -static int nsvg__parseScale(float* xform, const char* str) -{ - float args[2]; - int na = 0; - float t[6]; - int len = nsvg__parseTransformArgs(str, args, 2, &na); - if (na == 1) args[1] = args[0]; - nsvg__xformSetScale(t, args[0], args[1]); - memcpy(xform, t, sizeof(float)*6); - return len; +static int nsvg__parseScale(float *xform, const char *str) { + float args[2]; + int na = 0; + float t[6]; + int len = nsvg__parseTransformArgs(str, args, 2, &na); + if (na == 1) + args[1] = args[0]; + nsvg__xformSetScale(t, args[0], args[1]); + memcpy(xform, t, sizeof(float) * 6); + return len; } -static int nsvg__parseSkewX(float* xform, const char* str) -{ - float args[1]; - int na = 0; - float t[6]; - int len = nsvg__parseTransformArgs(str, args, 1, &na); - nsvg__xformSetSkewX(t, args[0]/180.0f*NSVG_PI); - memcpy(xform, t, sizeof(float)*6); - return len; +static int nsvg__parseSkewX(float *xform, const char *str) { + float args[1]; + int na = 0; + float t[6]; + int len = nsvg__parseTransformArgs(str, args, 1, &na); + nsvg__xformSetSkewX(t, args[0] / 180.0f * NSVG_PI); + memcpy(xform, t, sizeof(float) * 6); + return len; } -static int nsvg__parseSkewY(float* xform, const char* str) -{ - float args[1]; - int na = 0; - float t[6]; - int len = nsvg__parseTransformArgs(str, args, 1, &na); - nsvg__xformSetSkewY(t, args[0]/180.0f*NSVG_PI); - memcpy(xform, t, sizeof(float)*6); - return len; +static int nsvg__parseSkewY(float *xform, const char *str) { + float args[1]; + int na = 0; + float t[6]; + int len = nsvg__parseTransformArgs(str, args, 1, &na); + nsvg__xformSetSkewY(t, args[0] / 180.0f * NSVG_PI); + memcpy(xform, t, sizeof(float) * 6); + return len; } -static int nsvg__parseRotate(float* xform, const char* str) -{ - float args[3]; - int na = 0; - float m[6]; - float t[6]; - int len = nsvg__parseTransformArgs(str, args, 3, &na); - if (na == 1) - args[1] = args[2] = 0.0f; - nsvg__xformIdentity(m); +static int nsvg__parseRotate(float *xform, const char *str) { + float args[3]; + int na = 0; + float m[6]; + float t[6]; + int len = nsvg__parseTransformArgs(str, args, 3, &na); + if (na == 1) + args[1] = args[2] = 0.0f; + nsvg__xformIdentity(m); - if (na > 1) { - nsvg__xformSetTranslation(t, -args[1], -args[2]); - nsvg__xformMultiply(m, t); - } + if (na > 1) { + nsvg__xformSetTranslation(t, -args[1], -args[2]); + nsvg__xformMultiply(m, t); + } - nsvg__xformSetRotation(t, args[0]/180.0f*NSVG_PI); - nsvg__xformMultiply(m, t); + nsvg__xformSetRotation(t, args[0] / 180.0f * NSVG_PI); + nsvg__xformMultiply(m, t); - if (na > 1) { - nsvg__xformSetTranslation(t, args[1], args[2]); - nsvg__xformMultiply(m, t); - } + if (na > 1) { + nsvg__xformSetTranslation(t, args[1], args[2]); + nsvg__xformMultiply(m, t); + } - memcpy(xform, m, sizeof(float)*6); + memcpy(xform, m, sizeof(float) * 6); - return len; + return len; } -static void nsvg__parseTransform(float* xform, const char* str) -{ - float t[6]; - nsvg__xformIdentity(xform); - while (*str) - { - if (strncmp(str, "matrix", 6) == 0) - str += nsvg__parseMatrix(t, str); - else if (strncmp(str, "translate", 9) == 0) - str += nsvg__parseTranslate(t, str); - else if (strncmp(str, "scale", 5) == 0) - str += nsvg__parseScale(t, str); - else if (strncmp(str, "rotate", 6) == 0) - str += nsvg__parseRotate(t, str); - else if (strncmp(str, "skewX", 5) == 0) - str += nsvg__parseSkewX(t, str); - else if (strncmp(str, "skewY", 5) == 0) - str += nsvg__parseSkewY(t, str); - else{ - ++str; - continue; - } +static void nsvg__parseTransform(float *xform, const char *str) { + float t[6]; + nsvg__xformIdentity(xform); + while (*str) { + if (strncmp(str, "matrix", 6) == 0) + str += nsvg__parseMatrix(t, str); + else if (strncmp(str, "translate", 9) == 0) + str += nsvg__parseTranslate(t, str); + else if (strncmp(str, "scale", 5) == 0) + str += nsvg__parseScale(t, str); + else if (strncmp(str, "rotate", 6) == 0) + str += nsvg__parseRotate(t, str); + else if (strncmp(str, "skewX", 5) == 0) + str += nsvg__parseSkewX(t, str); + else if (strncmp(str, "skewY", 5) == 0) + str += nsvg__parseSkewY(t, str); + else { + ++str; + continue; + } - nsvg__xformPremultiply(xform, t); - } + nsvg__xformPremultiply(xform, t); + } } -static void nsvg__parseUrl(char* id, const char* str) -{ - int i = 0; - str += 4; // "url("; - if (*str == '#') - str++; - while (i < 63 && *str != ')') { - id[i] = *str++; - i++; - } - id[i] = '\0'; +static void nsvg__parseUrl(char *id, const char *str) { + int i = 0; + str += 4; // "url("; + if (*str == '#') + str++; + while (i < 63 && *str != ')') { + id[i] = *str++; + i++; + } + id[i] = '\0'; } -static char nsvg__parseLineCap(const char* str) -{ - if (strcmp(str, "butt") == 0) - return NSVG_CAP_BUTT; - else if (strcmp(str, "round") == 0) - return NSVG_CAP_ROUND; - else if (strcmp(str, "square") == 0) - return NSVG_CAP_SQUARE; - // TODO: handle inherit. - return NSVG_CAP_BUTT; +static char nsvg__parseLineCap(const char *str) { + if (strcmp(str, "butt") == 0) + return NSVG_CAP_BUTT; + else if (strcmp(str, "round") == 0) + return NSVG_CAP_ROUND; + else if (strcmp(str, "square") == 0) + return NSVG_CAP_SQUARE; + // TODO: handle inherit. + return NSVG_CAP_BUTT; } -static char nsvg__parseLineJoin(const char* str) -{ - if (strcmp(str, "miter") == 0) - return NSVG_JOIN_MITER; - else if (strcmp(str, "round") == 0) - return NSVG_JOIN_ROUND; - else if (strcmp(str, "bevel") == 0) - return NSVG_JOIN_BEVEL; - // TODO: handle inherit. - return NSVG_JOIN_MITER; +static char nsvg__parseLineJoin(const char *str) { + if (strcmp(str, "miter") == 0) + return NSVG_JOIN_MITER; + else if (strcmp(str, "round") == 0) + return NSVG_JOIN_ROUND; + else if (strcmp(str, "bevel") == 0) + return NSVG_JOIN_BEVEL; + // TODO: handle inherit. + return NSVG_JOIN_MITER; } -static char nsvg__parseFillRule(const char* str) -{ - if (strcmp(str, "nonzero") == 0) - return NSVG_FILLRULE_NONZERO; - else if (strcmp(str, "evenodd") == 0) - return NSVG_FILLRULE_EVENODD; - // TODO: handle inherit. - return NSVG_FILLRULE_NONZERO; +static char nsvg__parseFillRule(const char *str) { + if (strcmp(str, "nonzero") == 0) + return NSVG_FILLRULE_NONZERO; + else if (strcmp(str, "evenodd") == 0) + return NSVG_FILLRULE_EVENODD; + // TODO: handle inherit. + return NSVG_FILLRULE_NONZERO; } -static const char* nsvg__getNextDashItem(const char* s, char* it) -{ - int n = 0; - it[0] = '\0'; - // Skip white spaces and commas - while (*s && (nsvg__isspace(*s) || *s == ',')) s++; - // Advance until whitespace, comma or end. - while (*s && (!nsvg__isspace(*s) && *s != ',')) { - if (n < 63) - it[n++] = *s; - s++; - } - it[n++] = '\0'; - return s; +static const char *nsvg__getNextDashItem(const char *s, char *it) { + int n = 0; + it[0] = '\0'; + // Skip white spaces and commas + while (*s && (nsvg__isspace(*s) || *s == ',')) + s++; + // Advance until whitespace, comma or end. + while (*s && (!nsvg__isspace(*s) && *s != ',')) { + if (n < 63) + it[n++] = *s; + s++; + } + it[n++] = '\0'; + return s; } -static int nsvg__parseStrokeDashArray(NSVGparser* p, const char* str, float* strokeDashArray) -{ - char item[64]; - int count = 0, i; - float sum = 0.0f; +static int nsvg__parseStrokeDashArray(NSVGparser *p, const char *str, float *strokeDashArray) { + char item[64]; + int count = 0, i; + float sum = 0.0f; - // Handle "none" - if (str[0] == 'n') - return 0; + // Handle "none" + if (str[0] == 'n') + return 0; - // Parse dashes - while (*str) { - str = nsvg__getNextDashItem(str, item); - if (!*item) break; - if (count < NSVG_MAX_DASHES) - strokeDashArray[count++] = fabsf(nsvg__parseCoordinate(p, item, 0.0f, nsvg__actualLength(p))); - } + // Parse dashes + while (*str) { + str = nsvg__getNextDashItem(str, item); + if (!*item) + break; + if (count < NSVG_MAX_DASHES) + strokeDashArray[count++] = fabsf(nsvg__parseCoordinate(p, item, 0.0f, nsvg__actualLength(p))); + } - for (i = 0; i < count; i++) - sum += strokeDashArray[i]; - if (sum <= 1e-6f) - count = 0; + for (i = 0; i < count; i++) + sum += strokeDashArray[i]; + if (sum <= 1e-6f) + count = 0; - return count; + return count; } -static void nsvg__parseStyle(NSVGparser* p, const char* str); +static void nsvg__parseStyle(NSVGparser *p, const char *str); -static int nsvg__parseAttr(NSVGparser* p, const char* name, const char* value) -{ - float xform[6]; - NSVGattrib* attr = nsvg__getAttr(p); - if (!attr) return 0; +static int nsvg__parseAttr(NSVGparser *p, const char *name, const char *value) { + float xform[6]; + NSVGattrib *attr = nsvg__getAttr(p); + if (!attr) + return 0; - if (strcmp(name, "style") == 0) { - nsvg__parseStyle(p, value); - } else if (strcmp(name, "display") == 0) { - if (strcmp(value, "none") == 0) - attr->visible = 0; - // Don't reset ->visible on display:inline, one display:none hides the whole subtree + if (strcmp(name, "style") == 0) { + nsvg__parseStyle(p, value); + } else if (strcmp(name, "display") == 0) { + if (strcmp(value, "none") == 0) + attr->visible = 0; + // Don't reset ->visible on display:inline, one display:none hides the whole subtree - } else if (strcmp(name, "fill") == 0) { - if (strcmp(value, "none") == 0) { - attr->hasFill = 0; - } else if (strncmp(value, "url(", 4) == 0) { - attr->hasFill = 2; - nsvg__parseUrl(attr->fillGradient, value); - } else { - attr->hasFill = 1; - attr->fillColor = nsvg__parseColor(value); - } - } else if (strcmp(name, "opacity") == 0) { - attr->opacity = nsvg__parseOpacity(value); - } else if (strcmp(name, "fill-opacity") == 0) { - attr->fillOpacity = nsvg__parseOpacity(value); - } else if (strcmp(name, "stroke") == 0) { - if (strcmp(value, "none") == 0) { - attr->hasStroke = 0; - } else if (strncmp(value, "url(", 4) == 0) { - attr->hasStroke = 2; - nsvg__parseUrl(attr->strokeGradient, value); - } else { - attr->hasStroke = 1; - attr->strokeColor = nsvg__parseColor(value); - } - } else if (strcmp(name, "stroke-width") == 0) { - attr->strokeWidth = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p)); - } else if (strcmp(name, "stroke-dasharray") == 0) { - attr->strokeDashCount = nsvg__parseStrokeDashArray(p, value, attr->strokeDashArray); - } else if (strcmp(name, "stroke-dashoffset") == 0) { - attr->strokeDashOffset = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p)); - } else if (strcmp(name, "stroke-opacity") == 0) { - attr->strokeOpacity = nsvg__parseOpacity(value); - } else if (strcmp(name, "stroke-linecap") == 0) { - attr->strokeLineCap = nsvg__parseLineCap(value); - } else if (strcmp(name, "stroke-linejoin") == 0) { - attr->strokeLineJoin = nsvg__parseLineJoin(value); - } else if (strcmp(name, "stroke-miterlimit") == 0) { - attr->miterLimit = nsvg__parseMiterLimit(value); - } else if (strcmp(name, "fill-rule") == 0) { - attr->fillRule = nsvg__parseFillRule(value); - } else if (strcmp(name, "font-size") == 0) { - attr->fontSize = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p)); - } else if (strcmp(name, "transform") == 0) { - nsvg__parseTransform(xform, value); - nsvg__xformPremultiply(attr->xform, xform); - } else if (strcmp(name, "stop-color") == 0) { - attr->stopColor = nsvg__parseColor(value); - } else if (strcmp(name, "stop-opacity") == 0) { - attr->stopOpacity = nsvg__parseOpacity(value); - } else if (strcmp(name, "offset") == 0) { - attr->stopOffset = nsvg__parseCoordinate(p, value, 0.0f, 1.0f); - } else if (strcmp(name, "id") == 0) { - strncpy(attr->id, value, 63); - attr->id[63] = '\0'; - } else { - return 0; - } - return 1; + } else if (strcmp(name, "fill") == 0) { + if (strcmp(value, "none") == 0) { + attr->hasFill = 0; + } else if (strncmp(value, "url(", 4) == 0) { + attr->hasFill = 2; + nsvg__parseUrl(attr->fillGradient, value); + } else { + attr->hasFill = 1; + attr->fillColor = nsvg__parseColor(value); + } + } else if (strcmp(name, "opacity") == 0) { + attr->opacity = nsvg__parseOpacity(value); + } else if (strcmp(name, "fill-opacity") == 0) { + attr->fillOpacity = nsvg__parseOpacity(value); + } else if (strcmp(name, "stroke") == 0) { + if (strcmp(value, "none") == 0) { + attr->hasStroke = 0; + } else if (strncmp(value, "url(", 4) == 0) { + attr->hasStroke = 2; + nsvg__parseUrl(attr->strokeGradient, value); + } else { + attr->hasStroke = 1; + attr->strokeColor = nsvg__parseColor(value); + } + } else if (strcmp(name, "stroke-width") == 0) { + attr->strokeWidth = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p)); + } else if (strcmp(name, "stroke-dasharray") == 0) { + attr->strokeDashCount = nsvg__parseStrokeDashArray(p, value, attr->strokeDashArray); + } else if (strcmp(name, "stroke-dashoffset") == 0) { + attr->strokeDashOffset = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p)); + } else if (strcmp(name, "stroke-opacity") == 0) { + attr->strokeOpacity = nsvg__parseOpacity(value); + } else if (strcmp(name, "stroke-linecap") == 0) { + attr->strokeLineCap = nsvg__parseLineCap(value); + } else if (strcmp(name, "stroke-linejoin") == 0) { + attr->strokeLineJoin = nsvg__parseLineJoin(value); + } else if (strcmp(name, "stroke-miterlimit") == 0) { + attr->miterLimit = nsvg__parseMiterLimit(value); + } else if (strcmp(name, "fill-rule") == 0) { + attr->fillRule = nsvg__parseFillRule(value); + } else if (strcmp(name, "font-size") == 0) { + attr->fontSize = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p)); + } else if (strcmp(name, "transform") == 0) { + nsvg__parseTransform(xform, value); + nsvg__xformPremultiply(attr->xform, xform); + } else if (strcmp(name, "stop-color") == 0) { + attr->stopColor = nsvg__parseColor(value); + } else if (strcmp(name, "stop-opacity") == 0) { + attr->stopOpacity = nsvg__parseOpacity(value); + } else if (strcmp(name, "offset") == 0) { + attr->stopOffset = nsvg__parseCoordinate(p, value, 0.0f, 1.0f); + } else if (strcmp(name, "id") == 0) { + strncpy(attr->id, value, 63); + attr->id[63] = '\0'; + } else { + return 0; + } + return 1; } -static int nsvg__parseNameValue(NSVGparser* p, const char* start, const char* end) -{ - const char* str; - const char* val; - char name[512]; - char value[512]; - int n; +static int nsvg__parseNameValue(NSVGparser *p, const char *start, const char *end) { + const char *str; + const char *val; + char name[512]; + char value[512]; + int n; - str = start; - while (str < end && *str != ':') ++str; + str = start; + while (str < end && *str != ':') + ++str; - val = str; + val = str; - // Right Trim - while (str > start && (*str == ':' || nsvg__isspace(*str))) --str; - ++str; + // Right Trim + while (str > start && (*str == ':' || nsvg__isspace(*str))) + --str; + ++str; - n = (int)(str - start); - if (n > 511) n = 511; - if (n) memcpy(name, start, n); - name[n] = 0; + n = (int)(str - start); + if (n > 511) + n = 511; + if (n) + memcpy(name, start, n); + name[n] = 0; - while (val < end && (*val == ':' || nsvg__isspace(*val))) ++val; + while (val < end && (*val == ':' || nsvg__isspace(*val))) + ++val; - n = (int)(end - val); - if (n > 511) n = 511; - if (n) memcpy(value, val, n); - value[n] = 0; + n = (int)(end - val); + if (n > 511) + n = 511; + if (n) + memcpy(value, val, n); + value[n] = 0; - return nsvg__parseAttr(p, name, value); + return nsvg__parseAttr(p, name, value); } -static void nsvg__parseStyle(NSVGparser* p, const char* str) -{ - const char* start; - const char* end; +static void nsvg__parseStyle(NSVGparser *p, const char *str) { + const char *start; + const char *end; - while (*str) { - // Left Trim - while(*str && nsvg__isspace(*str)) ++str; - start = str; - while(*str && *str != ';') ++str; - end = str; + while (*str) { + // Left Trim + while (*str && nsvg__isspace(*str)) + ++str; + start = str; + while (*str && *str != ';') + ++str; + end = str; - // Right Trim - while (end > start && (*end == ';' || nsvg__isspace(*end))) --end; - ++end; + // Right Trim + while (end > start && (*end == ';' || nsvg__isspace(*end))) + --end; + ++end; - nsvg__parseNameValue(p, start, end); - if (*str) ++str; - } + nsvg__parseNameValue(p, start, end); + if (*str) + ++str; + } } -static void nsvg__parseAttribs(NSVGparser* p, const char** attr) -{ - int i; - for (i = 0; attr[i]; i += 2) - { - if (strcmp(attr[i], "style") == 0) - nsvg__parseStyle(p, attr[i + 1]); - else - nsvg__parseAttr(p, attr[i], attr[i + 1]); - } +static void nsvg__parseAttribs(NSVGparser *p, const char **attr) { + int i; + for (i = 0; attr[i]; i += 2) { + if (strcmp(attr[i], "style") == 0) + nsvg__parseStyle(p, attr[i + 1]); + else + nsvg__parseAttr(p, attr[i], attr[i + 1]); + } } -static int nsvg__getArgsPerElement(char cmd) -{ - switch (cmd) { - case 'v': - case 'V': - case 'h': - case 'H': - return 1; - case 'm': - case 'M': - case 'l': - case 'L': - case 't': - case 'T': - return 2; - case 'q': - case 'Q': - case 's': - case 'S': - return 4; - case 'c': - case 'C': - return 6; - case 'a': - case 'A': - return 7; - } - return 0; +static int nsvg__getArgsPerElement(char cmd) { + switch (cmd) { + case 'v': + case 'V': + case 'h': + case 'H': + return 1; + case 'm': + case 'M': + case 'l': + case 'L': + case 't': + case 'T': + return 2; + case 'q': + case 'Q': + case 's': + case 'S': + return 4; + case 'c': + case 'C': + return 6; + case 'a': + case 'A': + return 7; + } + return 0; } -static void nsvg__pathMoveTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel) -{ - if (rel) { - *cpx += args[0]; - *cpy += args[1]; - } else { - *cpx = args[0]; - *cpy = args[1]; - } - nsvg__moveTo(p, *cpx, *cpy); +static void nsvg__pathMoveTo(NSVGparser *p, float *cpx, float *cpy, float *args, int rel) { + if (rel) { + *cpx += args[0]; + *cpy += args[1]; + } else { + *cpx = args[0]; + *cpy = args[1]; + } + nsvg__moveTo(p, *cpx, *cpy); } -static void nsvg__pathLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel) -{ - if (rel) { - *cpx += args[0]; - *cpy += args[1]; - } else { - *cpx = args[0]; - *cpy = args[1]; - } - nsvg__lineTo(p, *cpx, *cpy); +static void nsvg__pathLineTo(NSVGparser *p, float *cpx, float *cpy, float *args, int rel) { + if (rel) { + *cpx += args[0]; + *cpy += args[1]; + } else { + *cpx = args[0]; + *cpy = args[1]; + } + nsvg__lineTo(p, *cpx, *cpy); } -static void nsvg__pathHLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel) -{ - if (rel) - *cpx += args[0]; - else - *cpx = args[0]; - nsvg__lineTo(p, *cpx, *cpy); +static void nsvg__pathHLineTo(NSVGparser *p, float *cpx, float *cpy, float *args, int rel) { + if (rel) + *cpx += args[0]; + else + *cpx = args[0]; + nsvg__lineTo(p, *cpx, *cpy); } -static void nsvg__pathVLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel) -{ - if (rel) - *cpy += args[0]; - else - *cpy = args[0]; - nsvg__lineTo(p, *cpx, *cpy); +static void nsvg__pathVLineTo(NSVGparser *p, float *cpx, float *cpy, float *args, int rel) { + if (rel) + *cpy += args[0]; + else + *cpy = args[0]; + nsvg__lineTo(p, *cpx, *cpy); } -static void nsvg__pathCubicBezTo(NSVGparser* p, float* cpx, float* cpy, - float* cpx2, float* cpy2, float* args, int rel) -{ - float x2, y2, cx1, cy1, cx2, cy2; +static void nsvg__pathCubicBezTo(NSVGparser *p, float *cpx, float *cpy, float *cpx2, float *cpy2, float *args, + int rel) { + float x2, y2, cx1, cy1, cx2, cy2; - if (rel) { - cx1 = *cpx + args[0]; - cy1 = *cpy + args[1]; - cx2 = *cpx + args[2]; - cy2 = *cpy + args[3]; - x2 = *cpx + args[4]; - y2 = *cpy + args[5]; - } else { - cx1 = args[0]; - cy1 = args[1]; - cx2 = args[2]; - cy2 = args[3]; - x2 = args[4]; - y2 = args[5]; - } + if (rel) { + cx1 = *cpx + args[0]; + cy1 = *cpy + args[1]; + cx2 = *cpx + args[2]; + cy2 = *cpy + args[3]; + x2 = *cpx + args[4]; + y2 = *cpy + args[5]; + } else { + cx1 = args[0]; + cy1 = args[1]; + cx2 = args[2]; + cy2 = args[3]; + x2 = args[4]; + y2 = args[5]; + } - nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2); + nsvg__cubicBezTo(p, cx1, cy1, cx2, cy2, x2, y2); - *cpx2 = cx2; - *cpy2 = cy2; - *cpx = x2; - *cpy = y2; + *cpx2 = cx2; + *cpy2 = cy2; + *cpx = x2; + *cpy = y2; } -static void nsvg__pathCubicBezShortTo(NSVGparser* p, float* cpx, float* cpy, - float* cpx2, float* cpy2, float* args, int rel) -{ - float x1, y1, x2, y2, cx1, cy1, cx2, cy2; +static void nsvg__pathCubicBezShortTo(NSVGparser *p, float *cpx, float *cpy, float *cpx2, float *cpy2, float *args, + int rel) { + float x1, y1, x2, y2, cx1, cy1, cx2, cy2; - x1 = *cpx; - y1 = *cpy; - if (rel) { - cx2 = *cpx + args[0]; - cy2 = *cpy + args[1]; - x2 = *cpx + args[2]; - y2 = *cpy + args[3]; - } else { - cx2 = args[0]; - cy2 = args[1]; - x2 = args[2]; - y2 = args[3]; - } + x1 = *cpx; + y1 = *cpy; + if (rel) { + cx2 = *cpx + args[0]; + cy2 = *cpy + args[1]; + x2 = *cpx + args[2]; + y2 = *cpy + args[3]; + } else { + cx2 = args[0]; + cy2 = args[1]; + x2 = args[2]; + y2 = args[3]; + } - cx1 = 2*x1 - *cpx2; - cy1 = 2*y1 - *cpy2; + cx1 = 2 * x1 - *cpx2; + cy1 = 2 * y1 - *cpy2; - nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2); + nsvg__cubicBezTo(p, cx1, cy1, cx2, cy2, x2, y2); - *cpx2 = cx2; - *cpy2 = cy2; - *cpx = x2; - *cpy = y2; + *cpx2 = cx2; + *cpy2 = cy2; + *cpx = x2; + *cpy = y2; } -static void nsvg__pathQuadBezTo(NSVGparser* p, float* cpx, float* cpy, - float* cpx2, float* cpy2, float* args, int rel) -{ - float x1, y1, x2, y2, cx, cy; - float cx1, cy1, cx2, cy2; +static void nsvg__pathQuadBezTo(NSVGparser *p, float *cpx, float *cpy, float *cpx2, float *cpy2, float *args, int rel) { + float x1, y1, x2, y2, cx, cy; + float cx1, cy1, cx2, cy2; - x1 = *cpx; - y1 = *cpy; - if (rel) { - cx = *cpx + args[0]; - cy = *cpy + args[1]; - x2 = *cpx + args[2]; - y2 = *cpy + args[3]; - } else { - cx = args[0]; - cy = args[1]; - x2 = args[2]; - y2 = args[3]; - } + x1 = *cpx; + y1 = *cpy; + if (rel) { + cx = *cpx + args[0]; + cy = *cpy + args[1]; + x2 = *cpx + args[2]; + y2 = *cpy + args[3]; + } else { + cx = args[0]; + cy = args[1]; + x2 = args[2]; + y2 = args[3]; + } - // Convert to cubic bezier - cx1 = x1 + 2.0f/3.0f*(cx - x1); - cy1 = y1 + 2.0f/3.0f*(cy - y1); - cx2 = x2 + 2.0f/3.0f*(cx - x2); - cy2 = y2 + 2.0f/3.0f*(cy - y2); + // Convert to cubic bezier + cx1 = x1 + 2.0f / 3.0f * (cx - x1); + cy1 = y1 + 2.0f / 3.0f * (cy - y1); + cx2 = x2 + 2.0f / 3.0f * (cx - x2); + cy2 = y2 + 2.0f / 3.0f * (cy - y2); - nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2); + nsvg__cubicBezTo(p, cx1, cy1, cx2, cy2, x2, y2); - *cpx2 = cx; - *cpy2 = cy; - *cpx = x2; - *cpy = y2; + *cpx2 = cx; + *cpy2 = cy; + *cpx = x2; + *cpy = y2; } -static void nsvg__pathQuadBezShortTo(NSVGparser* p, float* cpx, float* cpy, - float* cpx2, float* cpy2, float* args, int rel) -{ - float x1, y1, x2, y2, cx, cy; - float cx1, cy1, cx2, cy2; +static void nsvg__pathQuadBezShortTo(NSVGparser *p, float *cpx, float *cpy, float *cpx2, float *cpy2, float *args, + int rel) { + float x1, y1, x2, y2, cx, cy; + float cx1, cy1, cx2, cy2; - x1 = *cpx; - y1 = *cpy; - if (rel) { - x2 = *cpx + args[0]; - y2 = *cpy + args[1]; - } else { - x2 = args[0]; - y2 = args[1]; - } + x1 = *cpx; + y1 = *cpy; + if (rel) { + x2 = *cpx + args[0]; + y2 = *cpy + args[1]; + } else { + x2 = args[0]; + y2 = args[1]; + } - cx = 2*x1 - *cpx2; - cy = 2*y1 - *cpy2; + cx = 2 * x1 - *cpx2; + cy = 2 * y1 - *cpy2; - // Convert to cubix bezier - cx1 = x1 + 2.0f/3.0f*(cx - x1); - cy1 = y1 + 2.0f/3.0f*(cy - y1); - cx2 = x2 + 2.0f/3.0f*(cx - x2); - cy2 = y2 + 2.0f/3.0f*(cy - y2); + // Convert to cubix bezier + cx1 = x1 + 2.0f / 3.0f * (cx - x1); + cy1 = y1 + 2.0f / 3.0f * (cy - y1); + cx2 = x2 + 2.0f / 3.0f * (cx - x2); + cy2 = y2 + 2.0f / 3.0f * (cy - y2); - nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2); + nsvg__cubicBezTo(p, cx1, cy1, cx2, cy2, x2, y2); - *cpx2 = cx; - *cpy2 = cy; - *cpx = x2; - *cpy = y2; + *cpx2 = cx; + *cpy2 = cy; + *cpx = x2; + *cpy = y2; } -static float nsvg__sqr(float x) { return x*x; } -static float nsvg__vmag(float x, float y) { return sqrtf(x*x + y*y); } +static float nsvg__sqr(float x) { return x * x; } +static float nsvg__vmag(float x, float y) { return sqrtf(x * x + y * y); } -static float nsvg__vecrat(float ux, float uy, float vx, float vy) -{ - return (ux*vx + uy*vy) / (nsvg__vmag(ux,uy) * nsvg__vmag(vx,vy)); +static float nsvg__vecrat(float ux, float uy, float vx, float vy) { + return (ux * vx + uy * vy) / (nsvg__vmag(ux, uy) * nsvg__vmag(vx, vy)); } -static float nsvg__vecang(float ux, float uy, float vx, float vy) -{ - float r = nsvg__vecrat(ux,uy, vx,vy); - if (r < -1.0f) r = -1.0f; - if (r > 1.0f) r = 1.0f; - return ((ux*vy < uy*vx) ? -1.0f : 1.0f) * acosf(r); +static float nsvg__vecang(float ux, float uy, float vx, float vy) { + float r = nsvg__vecrat(ux, uy, vx, vy); + if (r < -1.0f) + r = -1.0f; + if (r > 1.0f) + r = 1.0f; + return ((ux * vy < uy * vx) ? -1.0f : 1.0f) * acosf(r); } -static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel) -{ - // Ported from canvg (https://code.google.com/p/canvg/) - float rx, ry, rotx; - float x1, y1, x2, y2, cx, cy, dx, dy, d; - float x1p, y1p, cxp, cyp, s, sa, sb; - float ux, uy, vx, vy, a1, da; - float x, y, tanx, tany, a, px = 0, py = 0, ptanx = 0, ptany = 0, t[6]; - float sinrx, cosrx; - int fa, fs; - int i, ndivs; - float hda, kappa; +static void nsvg__pathArcTo(NSVGparser *p, float *cpx, float *cpy, float *args, int rel) { + // Ported from canvg (https://code.google.com/p/canvg/) + float rx, ry, rotx; + float x1, y1, x2, y2, cx, cy, dx, dy, d; + float x1p, y1p, cxp, cyp, s, sa, sb; + float ux, uy, vx, vy, a1, da; + float x, y, tanx, tany, a, px = 0, py = 0, ptanx = 0, ptany = 0, t[6]; + float sinrx, cosrx; + int fa, fs; + int i, ndivs; + float hda, kappa; - rx = fabsf(args[0]); // y radius - ry = fabsf(args[1]); // x radius - rotx = args[2] / 180.0f * NSVG_PI; // x rotation angle - fa = fabsf(args[3]) > 1e-6 ? 1 : 0; // Large arc - fs = fabsf(args[4]) > 1e-6 ? 1 : 0; // Sweep direction - x1 = *cpx; // start point - y1 = *cpy; - if (rel) { // end point - x2 = *cpx + args[5]; - y2 = *cpy + args[6]; - } else { - x2 = args[5]; - y2 = args[6]; - } + rx = fabsf(args[0]); // y radius + ry = fabsf(args[1]); // x radius + rotx = args[2] / 180.0f * NSVG_PI; // x rotation angle + fa = fabsf(args[3]) > 1e-6 ? 1 : 0; // Large arc + fs = fabsf(args[4]) > 1e-6 ? 1 : 0; // Sweep direction + x1 = *cpx; // start point + y1 = *cpy; + if (rel) { // end point + x2 = *cpx + args[5]; + y2 = *cpy + args[6]; + } else { + x2 = args[5]; + y2 = args[6]; + } - dx = x1 - x2; - dy = y1 - y2; - d = sqrtf(dx*dx + dy*dy); - if (d < 1e-6f || rx < 1e-6f || ry < 1e-6f) { - // The arc degenerates to a line - nsvg__lineTo(p, x2, y2); - *cpx = x2; - *cpy = y2; - return; - } + dx = x1 - x2; + dy = y1 - y2; + d = sqrtf(dx * dx + dy * dy); + if (d < 1e-6f || rx < 1e-6f || ry < 1e-6f) { + // The arc degenerates to a line + nsvg__lineTo(p, x2, y2); + *cpx = x2; + *cpy = y2; + return; + } - sinrx = sinf(rotx); - cosrx = cosf(rotx); + sinrx = sinf(rotx); + cosrx = cosf(rotx); - // Convert to center point parameterization. - // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes - // 1) Compute x1', y1' - x1p = cosrx * dx / 2.0f + sinrx * dy / 2.0f; - y1p = -sinrx * dx / 2.0f + cosrx * dy / 2.0f; - d = nsvg__sqr(x1p)/nsvg__sqr(rx) + nsvg__sqr(y1p)/nsvg__sqr(ry); - if (d > 1) { - d = sqrtf(d); - rx *= d; - ry *= d; - } - // 2) Compute cx', cy' - s = 0.0f; - sa = nsvg__sqr(rx)*nsvg__sqr(ry) - nsvg__sqr(rx)*nsvg__sqr(y1p) - nsvg__sqr(ry)*nsvg__sqr(x1p); - sb = nsvg__sqr(rx)*nsvg__sqr(y1p) + nsvg__sqr(ry)*nsvg__sqr(x1p); - if (sa < 0.0f) sa = 0.0f; - if (sb > 0.0f) - s = sqrtf(sa / sb); - if (fa == fs) - s = -s; - cxp = s * rx * y1p / ry; - cyp = s * -ry * x1p / rx; + // Convert to center point parameterization. + // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes + // 1) Compute x1', y1' + x1p = cosrx * dx / 2.0f + sinrx * dy / 2.0f; + y1p = -sinrx * dx / 2.0f + cosrx * dy / 2.0f; + d = nsvg__sqr(x1p) / nsvg__sqr(rx) + nsvg__sqr(y1p) / nsvg__sqr(ry); + if (d > 1) { + d = sqrtf(d); + rx *= d; + ry *= d; + } + // 2) Compute cx', cy' + s = 0.0f; + sa = nsvg__sqr(rx) * nsvg__sqr(ry) - nsvg__sqr(rx) * nsvg__sqr(y1p) - nsvg__sqr(ry) * nsvg__sqr(x1p); + sb = nsvg__sqr(rx) * nsvg__sqr(y1p) + nsvg__sqr(ry) * nsvg__sqr(x1p); + if (sa < 0.0f) + sa = 0.0f; + if (sb > 0.0f) + s = sqrtf(sa / sb); + if (fa == fs) + s = -s; + cxp = s * rx * y1p / ry; + cyp = s * -ry * x1p / rx; - // 3) Compute cx,cy from cx',cy' - cx = (x1 + x2)/2.0f + cosrx*cxp - sinrx*cyp; - cy = (y1 + y2)/2.0f + sinrx*cxp + cosrx*cyp; + // 3) Compute cx,cy from cx',cy' + cx = (x1 + x2) / 2.0f + cosrx * cxp - sinrx * cyp; + cy = (y1 + y2) / 2.0f + sinrx * cxp + cosrx * cyp; - // 4) Calculate theta1, and delta theta. - ux = (x1p - cxp) / rx; - uy = (y1p - cyp) / ry; - vx = (-x1p - cxp) / rx; - vy = (-y1p - cyp) / ry; - a1 = nsvg__vecang(1.0f,0.0f, ux,uy); // Initial angle - da = nsvg__vecang(ux,uy, vx,vy); // Delta angle + // 4) Calculate theta1, and delta theta. + ux = (x1p - cxp) / rx; + uy = (y1p - cyp) / ry; + vx = (-x1p - cxp) / rx; + vy = (-y1p - cyp) / ry; + a1 = nsvg__vecang(1.0f, 0.0f, ux, uy); // Initial angle + da = nsvg__vecang(ux, uy, vx, vy); // Delta angle -// if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI; -// if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0; + // if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI; + // if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0; - if (fs == 0 && da > 0) - da -= 2 * NSVG_PI; - else if (fs == 1 && da < 0) - da += 2 * NSVG_PI; + if (fs == 0 && da > 0) + da -= 2 * NSVG_PI; + else if (fs == 1 && da < 0) + da += 2 * NSVG_PI; - // Approximate the arc using cubic spline segments. - t[0] = cosrx; t[1] = sinrx; - t[2] = -sinrx; t[3] = cosrx; - t[4] = cx; t[5] = cy; + // Approximate the arc using cubic spline segments. + t[0] = cosrx; + t[1] = sinrx; + t[2] = -sinrx; + t[3] = cosrx; + t[4] = cx; + t[5] = cy; - // Split arc into max 90 degree segments. - // The loop assumes an iteration per end point (including start and end), this +1. - ndivs = (int)(fabsf(da) / (NSVG_PI*0.5f) + 1.0f); - hda = (da / (float)ndivs) / 2.0f; - kappa = fabsf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda)); - if (da < 0.0f) - kappa = -kappa; + // Split arc into max 90 degree segments. + // The loop assumes an iteration per end point (including start and end), this +1. + ndivs = (int)(fabsf(da) / (NSVG_PI * 0.5f) + 1.0f); + hda = (da / (float)ndivs) / 2.0f; + kappa = fabsf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda)); + if (da < 0.0f) + kappa = -kappa; - for (i = 0; i <= ndivs; i++) { - a = a1 + da * ((float)i/(float)ndivs); - dx = cosf(a); - dy = sinf(a); - nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position - nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); // tangent - if (i > 0) - nsvg__cubicBezTo(p, px+ptanx,py+ptany, x-tanx, y-tany, x, y); - px = x; - py = y; - ptanx = tanx; - ptany = tany; - } + for (i = 0; i <= ndivs; i++) { + a = a1 + da * ((float)i / (float)ndivs); + dx = cosf(a); + dy = sinf(a); + nsvg__xformPoint(&x, &y, dx * rx, dy * ry, t); // position + nsvg__xformVec(&tanx, &tany, -dy * rx * kappa, dx * ry * kappa, t); // tangent + if (i > 0) + nsvg__cubicBezTo(p, px + ptanx, py + ptany, x - tanx, y - tany, x, y); + px = x; + py = y; + ptanx = tanx; + ptany = tany; + } - *cpx = x2; - *cpy = y2; + *cpx = x2; + *cpy = y2; } -static void nsvg__parsePath(NSVGparser* p, const char** attr) -{ - const char* s = NULL; - char cmd = '\0'; - float args[10]; - int nargs; - int rargs = 0; - float cpx, cpy, cpx2, cpy2; - const char* tmp[4]; - char closedFlag; - int i; - char item[64]; +static void nsvg__parsePath(NSVGparser *p, const char **attr) { + const char *s = NULL; + char cmd = '\0'; + float args[10]; + int nargs; + int rargs = 0; + float cpx, cpy, cpx2, cpy2; + const char *tmp[4]; + char closedFlag; + int i; + char item[64]; - for (i = 0; attr[i]; i += 2) { - if (strcmp(attr[i], "d") == 0) { - s = attr[i + 1]; - } else { - tmp[0] = attr[i]; - tmp[1] = attr[i + 1]; - tmp[2] = 0; - tmp[3] = 0; - nsvg__parseAttribs(p, tmp); - } - } + for (i = 0; attr[i]; i += 2) { + if (strcmp(attr[i], "d") == 0) { + s = attr[i + 1]; + } else { + tmp[0] = attr[i]; + tmp[1] = attr[i + 1]; + tmp[2] = 0; + tmp[3] = 0; + nsvg__parseAttribs(p, tmp); + } + } - if (s) { - nsvg__resetPath(p); - cpx = 0; cpy = 0; - cpx2 = 0; cpy2 = 0; - closedFlag = 0; - nargs = 0; + if (s) { + nsvg__resetPath(p); + cpx = 0; + cpy = 0; + cpx2 = 0; + cpy2 = 0; + closedFlag = 0; + nargs = 0; - while (*s) { - s = nsvg__getNextPathItem(s, item); - if (!*item) break; - if (nsvg__isnum(item[0])) { - if (nargs < 10) - args[nargs++] = (float)nsvg__atof(item); - if (nargs >= rargs) { - switch (cmd) { - case 'm': - case 'M': - nsvg__pathMoveTo(p, &cpx, &cpy, args, cmd == 'm' ? 1 : 0); - // Moveto can be followed by multiple coordinate pairs, - // which should be treated as linetos. - cmd = (cmd == 'm') ? 'l' : 'L'; - rargs = nsvg__getArgsPerElement(cmd); - cpx2 = cpx; cpy2 = cpy; - break; - case 'l': - case 'L': - nsvg__pathLineTo(p, &cpx, &cpy, args, cmd == 'l' ? 1 : 0); - cpx2 = cpx; cpy2 = cpy; - break; - case 'H': - case 'h': - nsvg__pathHLineTo(p, &cpx, &cpy, args, cmd == 'h' ? 1 : 0); - cpx2 = cpx; cpy2 = cpy; - break; - case 'V': - case 'v': - nsvg__pathVLineTo(p, &cpx, &cpy, args, cmd == 'v' ? 1 : 0); - cpx2 = cpx; cpy2 = cpy; - break; - case 'C': - case 'c': - nsvg__pathCubicBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'c' ? 1 : 0); - break; - case 'S': - case 's': - nsvg__pathCubicBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 's' ? 1 : 0); - break; - case 'Q': - case 'q': - nsvg__pathQuadBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'q' ? 1 : 0); - break; - case 'T': - case 't': - nsvg__pathQuadBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 't' ? 1 : 0); - break; - case 'A': - case 'a': - nsvg__pathArcTo(p, &cpx, &cpy, args, cmd == 'a' ? 1 : 0); - cpx2 = cpx; cpy2 = cpy; - break; - default: - if (nargs >= 2) { - cpx = args[nargs-2]; - cpy = args[nargs-1]; - cpx2 = cpx; cpy2 = cpy; - } - break; - } - nargs = 0; - } - } else { - cmd = item[0]; - rargs = nsvg__getArgsPerElement(cmd); - if (cmd == 'M' || cmd == 'm') { - // Commit path. - if (p->npts > 0) - nsvg__addPath(p, closedFlag); - // Start new subpath. - nsvg__resetPath(p); - closedFlag = 0; - nargs = 0; - } else if (cmd == 'Z' || cmd == 'z') { - closedFlag = 1; - // Commit path. - if (p->npts > 0) { - // Move current point to first point - cpx = p->pts[0]; - cpy = p->pts[1]; - cpx2 = cpx; cpy2 = cpy; - nsvg__addPath(p, closedFlag); - } - // Start new subpath. - nsvg__resetPath(p); - nsvg__moveTo(p, cpx, cpy); - closedFlag = 0; - nargs = 0; - } - } - } - // Commit path. - if (p->npts) - nsvg__addPath(p, closedFlag); - } + while (*s) { + s = nsvg__getNextPathItem(s, item); + if (!*item) + break; + if (nsvg__isnum(item[0])) { + if (nargs < 10) + args[nargs++] = (float)nsvg__atof(item); + if (nargs >= rargs) { + switch (cmd) { + case 'm': + case 'M': + nsvg__pathMoveTo(p, &cpx, &cpy, args, cmd == 'm' ? 1 : 0); + // Moveto can be followed by multiple coordinate pairs, + // which should be treated as linetos. + cmd = (cmd == 'm') ? 'l' : 'L'; + rargs = nsvg__getArgsPerElement(cmd); + cpx2 = cpx; + cpy2 = cpy; + break; + case 'l': + case 'L': + nsvg__pathLineTo(p, &cpx, &cpy, args, cmd == 'l' ? 1 : 0); + cpx2 = cpx; + cpy2 = cpy; + break; + case 'H': + case 'h': + nsvg__pathHLineTo(p, &cpx, &cpy, args, cmd == 'h' ? 1 : 0); + cpx2 = cpx; + cpy2 = cpy; + break; + case 'V': + case 'v': + nsvg__pathVLineTo(p, &cpx, &cpy, args, cmd == 'v' ? 1 : 0); + cpx2 = cpx; + cpy2 = cpy; + break; + case 'C': + case 'c': + nsvg__pathCubicBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'c' ? 1 : 0); + break; + case 'S': + case 's': + nsvg__pathCubicBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 's' ? 1 : 0); + break; + case 'Q': + case 'q': + nsvg__pathQuadBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'q' ? 1 : 0); + break; + case 'T': + case 't': + nsvg__pathQuadBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 't' ? 1 : 0); + break; + case 'A': + case 'a': + nsvg__pathArcTo(p, &cpx, &cpy, args, cmd == 'a' ? 1 : 0); + cpx2 = cpx; + cpy2 = cpy; + break; + default: + if (nargs >= 2) { + cpx = args[nargs - 2]; + cpy = args[nargs - 1]; + cpx2 = cpx; + cpy2 = cpy; + } + break; + } + nargs = 0; + } + } else { + cmd = item[0]; + rargs = nsvg__getArgsPerElement(cmd); + if (cmd == 'M' || cmd == 'm') { + // Commit path. + if (p->npts > 0) + nsvg__addPath(p, closedFlag); + // Start new subpath. + nsvg__resetPath(p); + closedFlag = 0; + nargs = 0; + } else if (cmd == 'Z' || cmd == 'z') { + closedFlag = 1; + // Commit path. + if (p->npts > 0) { + // Move current point to first point + cpx = p->pts[0]; + cpy = p->pts[1]; + cpx2 = cpx; + cpy2 = cpy; + nsvg__addPath(p, closedFlag); + } + // Start new subpath. + nsvg__resetPath(p); + nsvg__moveTo(p, cpx, cpy); + closedFlag = 0; + nargs = 0; + } + } + } + // Commit path. + if (p->npts) + nsvg__addPath(p, closedFlag); + } - nsvg__addShape(p); + nsvg__addShape(p); } -static void nsvg__parseRect(NSVGparser* p, const char** attr) -{ - float x = 0.0f; - float y = 0.0f; - float w = 0.0f; - float h = 0.0f; - float rx = -1.0f; // marks not set - float ry = -1.0f; - int i; +static void nsvg__parseRect(NSVGparser *p, const char **attr) { + float x = 0.0f; + float y = 0.0f; + float w = 0.0f; + float h = 0.0f; + float rx = -1.0f; // marks not set + float ry = -1.0f; + int i; - for (i = 0; attr[i]; i += 2) { - if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { - if (strcmp(attr[i], "x") == 0) x = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); - if (strcmp(attr[i], "y") == 0) y = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); - if (strcmp(attr[i], "width") == 0) w = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)); - if (strcmp(attr[i], "height") == 0) h = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)); - if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p))); - if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p))); - } - } + for (i = 0; attr[i]; i += 2) { + if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { + if (strcmp(attr[i], "x") == 0) + x = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); + if (strcmp(attr[i], "y") == 0) + y = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); + if (strcmp(attr[i], "width") == 0) + w = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, nsvg__actualWidth(p)); + if (strcmp(attr[i], "height") == 0) + h = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, nsvg__actualHeight(p)); + if (strcmp(attr[i], "rx") == 0) + rx = fabsf(nsvg__parseCoordinate(p, attr[i + 1], 0.0f, nsvg__actualWidth(p))); + if (strcmp(attr[i], "ry") == 0) + ry = fabsf(nsvg__parseCoordinate(p, attr[i + 1], 0.0f, nsvg__actualHeight(p))); + } + } - if (rx < 0.0f && ry > 0.0f) rx = ry; - if (ry < 0.0f && rx > 0.0f) ry = rx; - if (rx < 0.0f) rx = 0.0f; - if (ry < 0.0f) ry = 0.0f; - if (rx > w/2.0f) rx = w/2.0f; - if (ry > h/2.0f) ry = h/2.0f; + if (rx < 0.0f && ry > 0.0f) + rx = ry; + if (ry < 0.0f && rx > 0.0f) + ry = rx; + if (rx < 0.0f) + rx = 0.0f; + if (ry < 0.0f) + ry = 0.0f; + if (rx > w / 2.0f) + rx = w / 2.0f; + if (ry > h / 2.0f) + ry = h / 2.0f; - if (w != 0.0f && h != 0.0f) { - nsvg__resetPath(p); + if (w != 0.0f && h != 0.0f) { + nsvg__resetPath(p); - if (rx < 0.00001f || ry < 0.0001f) { - nsvg__moveTo(p, x, y); - nsvg__lineTo(p, x+w, y); - nsvg__lineTo(p, x+w, y+h); - nsvg__lineTo(p, x, y+h); - } else { - // Rounded rectangle - nsvg__moveTo(p, x+rx, y); - nsvg__lineTo(p, x+w-rx, y); - nsvg__cubicBezTo(p, x+w-rx*(1-NSVG_KAPPA90), y, x+w, y+ry*(1-NSVG_KAPPA90), x+w, y+ry); - nsvg__lineTo(p, x+w, y+h-ry); - nsvg__cubicBezTo(p, x+w, y+h-ry*(1-NSVG_KAPPA90), x+w-rx*(1-NSVG_KAPPA90), y+h, x+w-rx, y+h); - nsvg__lineTo(p, x+rx, y+h); - nsvg__cubicBezTo(p, x+rx*(1-NSVG_KAPPA90), y+h, x, y+h-ry*(1-NSVG_KAPPA90), x, y+h-ry); - nsvg__lineTo(p, x, y+ry); - nsvg__cubicBezTo(p, x, y+ry*(1-NSVG_KAPPA90), x+rx*(1-NSVG_KAPPA90), y, x+rx, y); - } + if (rx < 0.00001f || ry < 0.0001f) { + nsvg__moveTo(p, x, y); + nsvg__lineTo(p, x + w, y); + nsvg__lineTo(p, x + w, y + h); + nsvg__lineTo(p, x, y + h); + } else { + // Rounded rectangle + nsvg__moveTo(p, x + rx, y); + nsvg__lineTo(p, x + w - rx, y); + nsvg__cubicBezTo(p, x + w - rx * (1 - NSVG_KAPPA90), y, x + w, y + ry * (1 - NSVG_KAPPA90), x + w, y + ry); + nsvg__lineTo(p, x + w, y + h - ry); + nsvg__cubicBezTo(p, x + w, y + h - ry * (1 - NSVG_KAPPA90), x + w - rx * (1 - NSVG_KAPPA90), y + h, + x + w - rx, y + h); + nsvg__lineTo(p, x + rx, y + h); + nsvg__cubicBezTo(p, x + rx * (1 - NSVG_KAPPA90), y + h, x, y + h - ry * (1 - NSVG_KAPPA90), x, y + h - ry); + nsvg__lineTo(p, x, y + ry); + nsvg__cubicBezTo(p, x, y + ry * (1 - NSVG_KAPPA90), x + rx * (1 - NSVG_KAPPA90), y, x + rx, y); + } - nsvg__addPath(p, 1); + nsvg__addPath(p, 1); - nsvg__addShape(p); - } + nsvg__addShape(p); + } } -static void nsvg__parseCircle(NSVGparser* p, const char** attr) -{ - float cx = 0.0f; - float cy = 0.0f; - float r = 0.0f; - int i; +static void nsvg__parseCircle(NSVGparser *p, const char **attr) { + float cx = 0.0f; + float cy = 0.0f; + float r = 0.0f; + int i; - for (i = 0; attr[i]; i += 2) { - if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { - if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); - if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); - if (strcmp(attr[i], "r") == 0) r = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualLength(p))); - } - } + for (i = 0; attr[i]; i += 2) { + if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { + if (strcmp(attr[i], "cx") == 0) + cx = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); + if (strcmp(attr[i], "cy") == 0) + cy = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); + if (strcmp(attr[i], "r") == 0) + r = fabsf(nsvg__parseCoordinate(p, attr[i + 1], 0.0f, nsvg__actualLength(p))); + } + } - if (r > 0.0f) { - nsvg__resetPath(p); + if (r > 0.0f) { + nsvg__resetPath(p); - nsvg__moveTo(p, cx+r, cy); - nsvg__cubicBezTo(p, cx+r, cy+r*NSVG_KAPPA90, cx+r*NSVG_KAPPA90, cy+r, cx, cy+r); - nsvg__cubicBezTo(p, cx-r*NSVG_KAPPA90, cy+r, cx-r, cy+r*NSVG_KAPPA90, cx-r, cy); - nsvg__cubicBezTo(p, cx-r, cy-r*NSVG_KAPPA90, cx-r*NSVG_KAPPA90, cy-r, cx, cy-r); - nsvg__cubicBezTo(p, cx+r*NSVG_KAPPA90, cy-r, cx+r, cy-r*NSVG_KAPPA90, cx+r, cy); + nsvg__moveTo(p, cx + r, cy); + nsvg__cubicBezTo(p, cx + r, cy + r * NSVG_KAPPA90, cx + r * NSVG_KAPPA90, cy + r, cx, cy + r); + nsvg__cubicBezTo(p, cx - r * NSVG_KAPPA90, cy + r, cx - r, cy + r * NSVG_KAPPA90, cx - r, cy); + nsvg__cubicBezTo(p, cx - r, cy - r * NSVG_KAPPA90, cx - r * NSVG_KAPPA90, cy - r, cx, cy - r); + nsvg__cubicBezTo(p, cx + r * NSVG_KAPPA90, cy - r, cx + r, cy - r * NSVG_KAPPA90, cx + r, cy); - nsvg__addPath(p, 1); + nsvg__addPath(p, 1); - nsvg__addShape(p); - } + nsvg__addShape(p); + } } -static void nsvg__parseEllipse(NSVGparser* p, const char** attr) -{ - float cx = 0.0f; - float cy = 0.0f; - float rx = 0.0f; - float ry = 0.0f; - int i; +static void nsvg__parseEllipse(NSVGparser *p, const char **attr) { + float cx = 0.0f; + float cy = 0.0f; + float rx = 0.0f; + float ry = 0.0f; + int i; - for (i = 0; attr[i]; i += 2) { - if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { - if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); - if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); - if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p))); - if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p))); - } - } + for (i = 0; attr[i]; i += 2) { + if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { + if (strcmp(attr[i], "cx") == 0) + cx = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); + if (strcmp(attr[i], "cy") == 0) + cy = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); + if (strcmp(attr[i], "rx") == 0) + rx = fabsf(nsvg__parseCoordinate(p, attr[i + 1], 0.0f, nsvg__actualWidth(p))); + if (strcmp(attr[i], "ry") == 0) + ry = fabsf(nsvg__parseCoordinate(p, attr[i + 1], 0.0f, nsvg__actualHeight(p))); + } + } - if (rx > 0.0f && ry > 0.0f) { + if (rx > 0.0f && ry > 0.0f) { - nsvg__resetPath(p); + nsvg__resetPath(p); - nsvg__moveTo(p, cx+rx, cy); - nsvg__cubicBezTo(p, cx+rx, cy+ry*NSVG_KAPPA90, cx+rx*NSVG_KAPPA90, cy+ry, cx, cy+ry); - nsvg__cubicBezTo(p, cx-rx*NSVG_KAPPA90, cy+ry, cx-rx, cy+ry*NSVG_KAPPA90, cx-rx, cy); - nsvg__cubicBezTo(p, cx-rx, cy-ry*NSVG_KAPPA90, cx-rx*NSVG_KAPPA90, cy-ry, cx, cy-ry); - nsvg__cubicBezTo(p, cx+rx*NSVG_KAPPA90, cy-ry, cx+rx, cy-ry*NSVG_KAPPA90, cx+rx, cy); + nsvg__moveTo(p, cx + rx, cy); + nsvg__cubicBezTo(p, cx + rx, cy + ry * NSVG_KAPPA90, cx + rx * NSVG_KAPPA90, cy + ry, cx, cy + ry); + nsvg__cubicBezTo(p, cx - rx * NSVG_KAPPA90, cy + ry, cx - rx, cy + ry * NSVG_KAPPA90, cx - rx, cy); + nsvg__cubicBezTo(p, cx - rx, cy - ry * NSVG_KAPPA90, cx - rx * NSVG_KAPPA90, cy - ry, cx, cy - ry); + nsvg__cubicBezTo(p, cx + rx * NSVG_KAPPA90, cy - ry, cx + rx, cy - ry * NSVG_KAPPA90, cx + rx, cy); - nsvg__addPath(p, 1); + nsvg__addPath(p, 1); - nsvg__addShape(p); - } + nsvg__addShape(p); + } } -static void nsvg__parseLine(NSVGparser* p, const char** attr) -{ - float x1 = 0.0; - float y1 = 0.0; - float x2 = 0.0; - float y2 = 0.0; - int i; +static void nsvg__parseLine(NSVGparser *p, const char **attr) { + float x1 = 0.0; + float y1 = 0.0; + float x2 = 0.0; + float y2 = 0.0; + int i; - for (i = 0; attr[i]; i += 2) { - if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { - if (strcmp(attr[i], "x1") == 0) x1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); - if (strcmp(attr[i], "y1") == 0) y1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); - if (strcmp(attr[i], "x2") == 0) x2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); - if (strcmp(attr[i], "y2") == 0) y2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); - } - } + for (i = 0; attr[i]; i += 2) { + if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { + if (strcmp(attr[i], "x1") == 0) + x1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); + if (strcmp(attr[i], "y1") == 0) + y1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); + if (strcmp(attr[i], "x2") == 0) + x2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); + if (strcmp(attr[i], "y2") == 0) + y2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); + } + } - nsvg__resetPath(p); + nsvg__resetPath(p); - nsvg__moveTo(p, x1, y1); - nsvg__lineTo(p, x2, y2); + nsvg__moveTo(p, x1, y1); + nsvg__lineTo(p, x2, y2); - nsvg__addPath(p, 0); + nsvg__addPath(p, 0); - nsvg__addShape(p); + nsvg__addShape(p); } -static void nsvg__parsePoly(NSVGparser* p, const char** attr, int closeFlag) -{ - int i; - const char* s; - float args[2]; - int nargs, npts = 0; - char item[64]; +static void nsvg__parsePoly(NSVGparser *p, const char **attr, int closeFlag) { + int i; + const char *s; + float args[2]; + int nargs, npts = 0; + char item[64]; - nsvg__resetPath(p); + nsvg__resetPath(p); - for (i = 0; attr[i]; i += 2) { - if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { - if (strcmp(attr[i], "points") == 0) { - s = attr[i + 1]; - nargs = 0; - while (*s) { - s = nsvg__getNextPathItem(s, item); - args[nargs++] = (float)nsvg__atof(item); - if (nargs >= 2) { - if (npts == 0) - nsvg__moveTo(p, args[0], args[1]); - else - nsvg__lineTo(p, args[0], args[1]); - nargs = 0; - npts++; - } - } - } - } - } + for (i = 0; attr[i]; i += 2) { + if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { + if (strcmp(attr[i], "points") == 0) { + s = attr[i + 1]; + nargs = 0; + while (*s) { + s = nsvg__getNextPathItem(s, item); + args[nargs++] = (float)nsvg__atof(item); + if (nargs >= 2) { + if (npts == 0) + nsvg__moveTo(p, args[0], args[1]); + else + nsvg__lineTo(p, args[0], args[1]); + nargs = 0; + npts++; + } + } + } + } + } - nsvg__addPath(p, (char)closeFlag); + nsvg__addPath(p, (char)closeFlag); - nsvg__addShape(p); + nsvg__addShape(p); } -static void nsvg__parseSVG(NSVGparser* p, const char** attr) -{ - int i; - for (i = 0; attr[i]; i += 2) { - if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { - if (strcmp(attr[i], "width") == 0) { - p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f); - } else if (strcmp(attr[i], "height") == 0) { - p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f); - } else if (strcmp(attr[i], "viewBox") == 0) { - sscanf(attr[i + 1], "%f%*[%%, \t]%f%*[%%, \t]%f%*[%%, \t]%f", &p->viewMinx, &p->viewMiny, &p->viewWidth, &p->viewHeight); - } else if (strcmp(attr[i], "preserveAspectRatio") == 0) { - if (strstr(attr[i + 1], "none") != 0) { - // No uniform scaling - p->alignType = NSVG_ALIGN_NONE; - } else { - // Parse X align - if (strstr(attr[i + 1], "xMin") != 0) - p->alignX = NSVG_ALIGN_MIN; - else if (strstr(attr[i + 1], "xMid") != 0) - p->alignX = NSVG_ALIGN_MID; - else if (strstr(attr[i + 1], "xMax") != 0) - p->alignX = NSVG_ALIGN_MAX; - // Parse X align - if (strstr(attr[i + 1], "yMin") != 0) - p->alignY = NSVG_ALIGN_MIN; - else if (strstr(attr[i + 1], "yMid") != 0) - p->alignY = NSVG_ALIGN_MID; - else if (strstr(attr[i + 1], "yMax") != 0) - p->alignY = NSVG_ALIGN_MAX; - // Parse meet/slice - p->alignType = NSVG_ALIGN_MEET; - if (strstr(attr[i + 1], "slice") != 0) - p->alignType = NSVG_ALIGN_SLICE; - } - } - } - } +static void nsvg__parseSVG(NSVGparser *p, const char **attr) { + int i; + for (i = 0; attr[i]; i += 2) { + if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { + if (strcmp(attr[i], "width") == 0) { + p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f); + } else if (strcmp(attr[i], "height") == 0) { + p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f); + } else if (strcmp(attr[i], "viewBox") == 0) { + sscanf(attr[i + 1], "%f%*[%%, \t]%f%*[%%, \t]%f%*[%%, \t]%f", &p->viewMinx, &p->viewMiny, &p->viewWidth, + &p->viewHeight); + } else if (strcmp(attr[i], "preserveAspectRatio") == 0) { + if (strstr(attr[i + 1], "none") != 0) { + // No uniform scaling + p->alignType = NSVG_ALIGN_NONE; + } else { + // Parse X align + if (strstr(attr[i + 1], "xMin") != 0) + p->alignX = NSVG_ALIGN_MIN; + else if (strstr(attr[i + 1], "xMid") != 0) + p->alignX = NSVG_ALIGN_MID; + else if (strstr(attr[i + 1], "xMax") != 0) + p->alignX = NSVG_ALIGN_MAX; + // Parse X align + if (strstr(attr[i + 1], "yMin") != 0) + p->alignY = NSVG_ALIGN_MIN; + else if (strstr(attr[i + 1], "yMid") != 0) + p->alignY = NSVG_ALIGN_MID; + else if (strstr(attr[i + 1], "yMax") != 0) + p->alignY = NSVG_ALIGN_MAX; + // Parse meet/slice + p->alignType = NSVG_ALIGN_MEET; + if (strstr(attr[i + 1], "slice") != 0) + p->alignType = NSVG_ALIGN_SLICE; + } + } + } + } } -static void nsvg__parseGradient(NSVGparser* p, const char** attr, char type) -{ - int i; - NSVGgradientData* grad = (NSVGgradientData*)malloc(sizeof(NSVGgradientData)); - if (grad == NULL) return; - memset(grad, 0, sizeof(NSVGgradientData)); - grad->units = NSVG_OBJECT_SPACE; - grad->type = type; - if (grad->type == NSVG_PAINT_LINEAR_GRADIENT) { - grad->linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); - grad->linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); - grad->linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT); - grad->linear.y2 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); - } else if (grad->type == NSVG_PAINT_RADIAL_GRADIENT) { - grad->radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); - grad->radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); - grad->radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); - } +static void nsvg__parseGradient(NSVGparser *p, const char **attr, char type) { + int i; + NSVGgradientData *grad = (NSVGgradientData *)malloc(sizeof(NSVGgradientData)); + if (grad == NULL) + return; + memset(grad, 0, sizeof(NSVGgradientData)); + grad->units = NSVG_OBJECT_SPACE; + grad->type = type; + if (grad->type == NSVG_PAINT_LINEAR_GRADIENT) { + grad->linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); + grad->linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); + grad->linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT); + grad->linear.y2 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); + } else if (grad->type == NSVG_PAINT_RADIAL_GRADIENT) { + grad->radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); + grad->radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); + grad->radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); + } - nsvg__xformIdentity(grad->xform); + nsvg__xformIdentity(grad->xform); - for (i = 0; attr[i]; i += 2) { - if (strcmp(attr[i], "id") == 0) { - strncpy(grad->id, attr[i+1], 63); - grad->id[63] = '\0'; - } else if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { - if (strcmp(attr[i], "gradientUnits") == 0) { - if (strcmp(attr[i+1], "objectBoundingBox") == 0) - grad->units = NSVG_OBJECT_SPACE; - else - grad->units = NSVG_USER_SPACE; - } else if (strcmp(attr[i], "gradientTransform") == 0) { - nsvg__parseTransform(grad->xform, attr[i + 1]); - } else if (strcmp(attr[i], "cx") == 0) { - grad->radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]); - } else if (strcmp(attr[i], "cy") == 0) { - grad->radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]); - } else if (strcmp(attr[i], "r") == 0) { - grad->radial.r = nsvg__parseCoordinateRaw(attr[i + 1]); - } else if (strcmp(attr[i], "fx") == 0) { - grad->radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]); - } else if (strcmp(attr[i], "fy") == 0) { - grad->radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]); - } else if (strcmp(attr[i], "x1") == 0) { - grad->linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]); - } else if (strcmp(attr[i], "y1") == 0) { - grad->linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]); - } else if (strcmp(attr[i], "x2") == 0) { - grad->linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]); - } else if (strcmp(attr[i], "y2") == 0) { - grad->linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]); - } else if (strcmp(attr[i], "spreadMethod") == 0) { - if (strcmp(attr[i+1], "pad") == 0) - grad->spread = NSVG_SPREAD_PAD; - else if (strcmp(attr[i+1], "reflect") == 0) - grad->spread = NSVG_SPREAD_REFLECT; - else if (strcmp(attr[i+1], "repeat") == 0) - grad->spread = NSVG_SPREAD_REPEAT; - } else if (strcmp(attr[i], "xlink:href") == 0) { - const char *href = attr[i+1]; - strncpy(grad->ref, href+1, 62); - grad->ref[62] = '\0'; - } - } - } + for (i = 0; attr[i]; i += 2) { + if (strcmp(attr[i], "id") == 0) { + strncpy(grad->id, attr[i + 1], 63); + grad->id[63] = '\0'; + } else if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) { + if (strcmp(attr[i], "gradientUnits") == 0) { + if (strcmp(attr[i + 1], "objectBoundingBox") == 0) + grad->units = NSVG_OBJECT_SPACE; + else + grad->units = NSVG_USER_SPACE; + } else if (strcmp(attr[i], "gradientTransform") == 0) { + nsvg__parseTransform(grad->xform, attr[i + 1]); + } else if (strcmp(attr[i], "cx") == 0) { + grad->radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]); + } else if (strcmp(attr[i], "cy") == 0) { + grad->radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]); + } else if (strcmp(attr[i], "r") == 0) { + grad->radial.r = nsvg__parseCoordinateRaw(attr[i + 1]); + } else if (strcmp(attr[i], "fx") == 0) { + grad->radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]); + } else if (strcmp(attr[i], "fy") == 0) { + grad->radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]); + } else if (strcmp(attr[i], "x1") == 0) { + grad->linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]); + } else if (strcmp(attr[i], "y1") == 0) { + grad->linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]); + } else if (strcmp(attr[i], "x2") == 0) { + grad->linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]); + } else if (strcmp(attr[i], "y2") == 0) { + grad->linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]); + } else if (strcmp(attr[i], "spreadMethod") == 0) { + if (strcmp(attr[i + 1], "pad") == 0) + grad->spread = NSVG_SPREAD_PAD; + else if (strcmp(attr[i + 1], "reflect") == 0) + grad->spread = NSVG_SPREAD_REFLECT; + else if (strcmp(attr[i + 1], "repeat") == 0) + grad->spread = NSVG_SPREAD_REPEAT; + } else if (strcmp(attr[i], "xlink:href") == 0) { + const char *href = attr[i + 1]; + strncpy(grad->ref, href + 1, 62); + grad->ref[62] = '\0'; + } + } + } - grad->next = p->gradients; - p->gradients = grad; + grad->next = p->gradients; + p->gradients = grad; } -static void nsvg__parseGradientStop(NSVGparser* p, const char** attr) -{ - NSVGattrib* curAttr = nsvg__getAttr(p); - NSVGgradientData* grad; - NSVGgradientStop* stop; - int i, idx; +static void nsvg__parseGradientStop(NSVGparser *p, const char **attr) { + NSVGattrib *curAttr = nsvg__getAttr(p); + NSVGgradientData *grad; + NSVGgradientStop *stop; + int i, idx; - curAttr->stopOffset = 0; - curAttr->stopColor = 0; - curAttr->stopOpacity = 1.0f; + curAttr->stopOffset = 0; + curAttr->stopColor = 0; + curAttr->stopOpacity = 1.0f; - for (i = 0; attr[i]; i += 2) { - nsvg__parseAttr(p, attr[i], attr[i + 1]); - } + for (i = 0; attr[i]; i += 2) { + nsvg__parseAttr(p, attr[i], attr[i + 1]); + } - // Add stop to the last gradient. - grad = p->gradients; - if (grad == NULL) return; + // Add stop to the last gradient. + grad = p->gradients; + if (grad == NULL) + return; - grad->nstops++; - grad->stops = (NSVGgradientStop*)realloc(grad->stops, sizeof(NSVGgradientStop)*grad->nstops); - if (grad->stops == NULL) return; + grad->nstops++; + grad->stops = (NSVGgradientStop *)realloc(grad->stops, sizeof(NSVGgradientStop) * grad->nstops); + if (grad->stops == NULL) + return; - // Insert - idx = grad->nstops-1; - for (i = 0; i < grad->nstops-1; i++) { - if (curAttr->stopOffset < grad->stops[i].offset) { - idx = i; - break; - } - } - if (idx != grad->nstops-1) { - for (i = grad->nstops-1; i > idx; i--) - grad->stops[i] = grad->stops[i-1]; - } + // Insert + idx = grad->nstops - 1; + for (i = 0; i < grad->nstops - 1; i++) { + if (curAttr->stopOffset < grad->stops[i].offset) { + idx = i; + break; + } + } + if (idx != grad->nstops - 1) { + for (i = grad->nstops - 1; i > idx; i--) + grad->stops[i] = grad->stops[i - 1]; + } - stop = &grad->stops[idx]; - stop->color = curAttr->stopColor; - stop->color |= (unsigned int)(curAttr->stopOpacity*255) << 24; - stop->offset = curAttr->stopOffset; + stop = &grad->stops[idx]; + stop->color = curAttr->stopColor; + stop->color |= (unsigned int)(curAttr->stopOpacity * 255) << 24; + stop->offset = curAttr->stopOffset; } -static void nsvg__startElement(void* ud, const char* el, const char** attr) -{ - NSVGparser* p = (NSVGparser*)ud; +static void nsvg__startElement(void *ud, const char *el, const char **attr) { + NSVGparser *p = (NSVGparser *)ud; - if (p->defsFlag) { - // Skip everything but gradients in defs - if (strcmp(el, "linearGradient") == 0) { - nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT); - } else if (strcmp(el, "radialGradient") == 0) { - nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT); - } else if (strcmp(el, "stop") == 0) { - nsvg__parseGradientStop(p, attr); - } - return; - } + if (p->defsFlag) { + // Skip everything but gradients in defs + if (strcmp(el, "linearGradient") == 0) { + nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT); + } else if (strcmp(el, "radialGradient") == 0) { + nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT); + } else if (strcmp(el, "stop") == 0) { + nsvg__parseGradientStop(p, attr); + } + return; + } - if (strcmp(el, "g") == 0) { - nsvg__pushAttr(p); - nsvg__parseAttribs(p, attr); - } else if (strcmp(el, "path") == 0) { - if (p->pathFlag) // Do not allow nested paths. - return; - nsvg__pushAttr(p); - nsvg__parsePath(p, attr); - nsvg__popAttr(p); - } else if (strcmp(el, "rect") == 0) { - nsvg__pushAttr(p); - nsvg__parseRect(p, attr); - nsvg__popAttr(p); - } else if (strcmp(el, "circle") == 0) { - nsvg__pushAttr(p); - nsvg__parseCircle(p, attr); - nsvg__popAttr(p); - } else if (strcmp(el, "ellipse") == 0) { - nsvg__pushAttr(p); - nsvg__parseEllipse(p, attr); - nsvg__popAttr(p); - } else if (strcmp(el, "line") == 0) { - nsvg__pushAttr(p); - nsvg__parseLine(p, attr); - nsvg__popAttr(p); - } else if (strcmp(el, "polyline") == 0) { - nsvg__pushAttr(p); - nsvg__parsePoly(p, attr, 0); - nsvg__popAttr(p); - } else if (strcmp(el, "polygon") == 0) { - nsvg__pushAttr(p); - nsvg__parsePoly(p, attr, 1); - nsvg__popAttr(p); - } else if (strcmp(el, "linearGradient") == 0) { - nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT); - } else if (strcmp(el, "radialGradient") == 0) { - nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT); - } else if (strcmp(el, "stop") == 0) { - nsvg__parseGradientStop(p, attr); - } else if (strcmp(el, "defs") == 0) { - p->defsFlag = 1; - } else if (strcmp(el, "svg") == 0) { - nsvg__parseSVG(p, attr); - } + if (strcmp(el, "g") == 0) { + nsvg__pushAttr(p); + nsvg__parseAttribs(p, attr); + } else if (strcmp(el, "path") == 0) { + if (p->pathFlag) // Do not allow nested paths. + return; + nsvg__pushAttr(p); + nsvg__parsePath(p, attr); + nsvg__popAttr(p); + } else if (strcmp(el, "rect") == 0) { + nsvg__pushAttr(p); + nsvg__parseRect(p, attr); + nsvg__popAttr(p); + } else if (strcmp(el, "circle") == 0) { + nsvg__pushAttr(p); + nsvg__parseCircle(p, attr); + nsvg__popAttr(p); + } else if (strcmp(el, "ellipse") == 0) { + nsvg__pushAttr(p); + nsvg__parseEllipse(p, attr); + nsvg__popAttr(p); + } else if (strcmp(el, "line") == 0) { + nsvg__pushAttr(p); + nsvg__parseLine(p, attr); + nsvg__popAttr(p); + } else if (strcmp(el, "polyline") == 0) { + nsvg__pushAttr(p); + nsvg__parsePoly(p, attr, 0); + nsvg__popAttr(p); + } else if (strcmp(el, "polygon") == 0) { + nsvg__pushAttr(p); + nsvg__parsePoly(p, attr, 1); + nsvg__popAttr(p); + } else if (strcmp(el, "linearGradient") == 0) { + nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT); + } else if (strcmp(el, "radialGradient") == 0) { + nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT); + } else if (strcmp(el, "stop") == 0) { + nsvg__parseGradientStop(p, attr); + } else if (strcmp(el, "defs") == 0) { + p->defsFlag = 1; + } else if (strcmp(el, "svg") == 0) { + nsvg__parseSVG(p, attr); + } } -static void nsvg__endElement(void* ud, const char* el) -{ - NSVGparser* p = (NSVGparser*)ud; +static void nsvg__endElement(void *ud, const char *el) { + NSVGparser *p = (NSVGparser *)ud; - if (strcmp(el, "g") == 0) { - nsvg__popAttr(p); - } else if (strcmp(el, "path") == 0) { - p->pathFlag = 0; - } else if (strcmp(el, "defs") == 0) { - p->defsFlag = 0; - } + if (strcmp(el, "g") == 0) { + nsvg__popAttr(p); + } else if (strcmp(el, "path") == 0) { + p->pathFlag = 0; + } else if (strcmp(el, "defs") == 0) { + p->defsFlag = 0; + } } -static void nsvg__content(void* ud, const char* s) -{ - NSVG_NOTUSED(ud); - NSVG_NOTUSED(s); - // empty +static void nsvg__content(void *ud, const char *s) { + NSVG_NOTUSED(ud); + NSVG_NOTUSED(s); + // empty } -static void nsvg__imageBounds(NSVGparser* p, float* bounds) -{ - NSVGshape* shape; - shape = p->image->shapes; - if (shape == NULL) { - bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0; - return; - } - bounds[0] = shape->bounds[0]; - bounds[1] = shape->bounds[1]; - bounds[2] = shape->bounds[2]; - bounds[3] = shape->bounds[3]; - for (shape = shape->next; shape != NULL; shape = shape->next) { - bounds[0] = nsvg__minf(bounds[0], shape->bounds[0]); - bounds[1] = nsvg__minf(bounds[1], shape->bounds[1]); - bounds[2] = nsvg__maxf(bounds[2], shape->bounds[2]); - bounds[3] = nsvg__maxf(bounds[3], shape->bounds[3]); - } +static void nsvg__imageBounds(NSVGparser *p, float *bounds) { + NSVGshape *shape; + shape = p->image->shapes; + if (shape == NULL) { + bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0; + return; + } + bounds[0] = shape->bounds[0]; + bounds[1] = shape->bounds[1]; + bounds[2] = shape->bounds[2]; + bounds[3] = shape->bounds[3]; + for (shape = shape->next; shape != NULL; shape = shape->next) { + bounds[0] = nsvg__minf(bounds[0], shape->bounds[0]); + bounds[1] = nsvg__minf(bounds[1], shape->bounds[1]); + bounds[2] = nsvg__maxf(bounds[2], shape->bounds[2]); + bounds[3] = nsvg__maxf(bounds[3], shape->bounds[3]); + } } -static float nsvg__viewAlign(float content, float container, int type) -{ - if (type == NSVG_ALIGN_MIN) - return 0; - else if (type == NSVG_ALIGN_MAX) - return container - content; - // mid - return (container - content) * 0.5f; +static float nsvg__viewAlign(float content, float container, int type) { + if (type == NSVG_ALIGN_MIN) + return 0; + else if (type == NSVG_ALIGN_MAX) + return container - content; + // mid + return (container - content) * 0.5f; } -static void nsvg__scaleGradient(NSVGgradient* grad, float tx, float ty, float sx, float sy) -{ - float t[6]; - nsvg__xformSetTranslation(t, tx, ty); - nsvg__xformMultiply (grad->xform, t); +static void nsvg__scaleGradient(NSVGgradient *grad, float tx, float ty, float sx, float sy) { + float t[6]; + nsvg__xformSetTranslation(t, tx, ty); + nsvg__xformMultiply(grad->xform, t); - nsvg__xformSetScale(t, sx, sy); - nsvg__xformMultiply (grad->xform, t); + nsvg__xformSetScale(t, sx, sy); + nsvg__xformMultiply(grad->xform, t); } -static void nsvg__scaleToViewbox(NSVGparser* p, const char* units) -{ - NSVGshape* shape; - NSVGpath* path; - float tx, ty, sx, sy, us, bounds[4], t[6], avgs; - int i; - float* pt; +static void nsvg__scaleToViewbox(NSVGparser *p, const char *units) { + NSVGshape *shape; + NSVGpath *path; + float tx, ty, sx, sy, us, bounds[4], t[6], avgs; + int i; + float *pt; - // Guess image size if not set completely. - nsvg__imageBounds(p, bounds); + // Guess image size if not set completely. + nsvg__imageBounds(p, bounds); - if (p->viewWidth == 0) { - if (p->image->width > 0) { - p->viewWidth = p->image->width; - } else { - p->viewMinx = bounds[0]; - p->viewWidth = bounds[2] - bounds[0]; - } - } - if (p->viewHeight == 0) { - if (p->image->height > 0) { - p->viewHeight = p->image->height; - } else { - p->viewMiny = bounds[1]; - p->viewHeight = bounds[3] - bounds[1]; - } - } - if (p->image->width == 0) - p->image->width = p->viewWidth; - if (p->image->height == 0) - p->image->height = p->viewHeight; + if (p->viewWidth == 0) { + if (p->image->width > 0) { + p->viewWidth = p->image->width; + } else { + p->viewMinx = bounds[0]; + p->viewWidth = bounds[2] - bounds[0]; + } + } + if (p->viewHeight == 0) { + if (p->image->height > 0) { + p->viewHeight = p->image->height; + } else { + p->viewMiny = bounds[1]; + p->viewHeight = bounds[3] - bounds[1]; + } + } + if (p->image->width == 0) + p->image->width = p->viewWidth; + if (p->image->height == 0) + p->image->height = p->viewHeight; - tx = -p->viewMinx; - ty = -p->viewMiny; - sx = p->viewWidth > 0 ? p->image->width / p->viewWidth : 0; - sy = p->viewHeight > 0 ? p->image->height / p->viewHeight : 0; - // Unit scaling - us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f); + tx = -p->viewMinx; + ty = -p->viewMiny; + sx = p->viewWidth > 0 ? p->image->width / p->viewWidth : 0; + sy = p->viewHeight > 0 ? p->image->height / p->viewHeight : 0; + // Unit scaling + us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f); - // Fix aspect ratio - if (p->alignType == NSVG_ALIGN_MEET) { - // fit whole image into viewbox - sx = sy = nsvg__minf(sx, sy); - tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx; - ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy; - } else if (p->alignType == NSVG_ALIGN_SLICE) { - // fill whole viewbox with image - sx = sy = nsvg__maxf(sx, sy); - tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx; - ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy; - } + // Fix aspect ratio + if (p->alignType == NSVG_ALIGN_MEET) { + // fit whole image into viewbox + sx = sy = nsvg__minf(sx, sy); + tx += nsvg__viewAlign(p->viewWidth * sx, p->image->width, p->alignX) / sx; + ty += nsvg__viewAlign(p->viewHeight * sy, p->image->height, p->alignY) / sy; + } else if (p->alignType == NSVG_ALIGN_SLICE) { + // fill whole viewbox with image + sx = sy = nsvg__maxf(sx, sy); + tx += nsvg__viewAlign(p->viewWidth * sx, p->image->width, p->alignX) / sx; + ty += nsvg__viewAlign(p->viewHeight * sy, p->image->height, p->alignY) / sy; + } - // Transform - sx *= us; - sy *= us; - avgs = (sx+sy) / 2.0f; - for (shape = p->image->shapes; shape != NULL; shape = shape->next) { - shape->bounds[0] = (shape->bounds[0] + tx) * sx; - shape->bounds[1] = (shape->bounds[1] + ty) * sy; - shape->bounds[2] = (shape->bounds[2] + tx) * sx; - shape->bounds[3] = (shape->bounds[3] + ty) * sy; - for (path = shape->paths; path != NULL; path = path->next) { - path->bounds[0] = (path->bounds[0] + tx) * sx; - path->bounds[1] = (path->bounds[1] + ty) * sy; - path->bounds[2] = (path->bounds[2] + tx) * sx; - path->bounds[3] = (path->bounds[3] + ty) * sy; - for (i =0; i < path->npts; i++) { - pt = &path->pts[i*2]; - pt[0] = (pt[0] + tx) * sx; - pt[1] = (pt[1] + ty) * sy; - } - } + // Transform + sx *= us; + sy *= us; + avgs = (sx + sy) / 2.0f; + for (shape = p->image->shapes; shape != NULL; shape = shape->next) { + shape->bounds[0] = (shape->bounds[0] + tx) * sx; + shape->bounds[1] = (shape->bounds[1] + ty) * sy; + shape->bounds[2] = (shape->bounds[2] + tx) * sx; + shape->bounds[3] = (shape->bounds[3] + ty) * sy; + for (path = shape->paths; path != NULL; path = path->next) { + path->bounds[0] = (path->bounds[0] + tx) * sx; + path->bounds[1] = (path->bounds[1] + ty) * sy; + path->bounds[2] = (path->bounds[2] + tx) * sx; + path->bounds[3] = (path->bounds[3] + ty) * sy; + for (i = 0; i < path->npts; i++) { + pt = &path->pts[i * 2]; + pt[0] = (pt[0] + tx) * sx; + pt[1] = (pt[1] + ty) * sy; + } + } - if (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT || shape->fill.type == NSVG_PAINT_RADIAL_GRADIENT) { - nsvg__scaleGradient(shape->fill.gradient, tx,ty, sx,sy); - memcpy(t, shape->fill.gradient->xform, sizeof(float)*6); - nsvg__xformInverse(shape->fill.gradient->xform, t); - } - if (shape->stroke.type == NSVG_PAINT_LINEAR_GRADIENT || shape->stroke.type == NSVG_PAINT_RADIAL_GRADIENT) { - nsvg__scaleGradient(shape->stroke.gradient, tx,ty, sx,sy); - memcpy(t, shape->stroke.gradient->xform, sizeof(float)*6); - nsvg__xformInverse(shape->stroke.gradient->xform, t); - } + if (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT || shape->fill.type == NSVG_PAINT_RADIAL_GRADIENT) { + nsvg__scaleGradient(shape->fill.gradient, tx, ty, sx, sy); + memcpy(t, shape->fill.gradient->xform, sizeof(float) * 6); + nsvg__xformInverse(shape->fill.gradient->xform, t); + } + if (shape->stroke.type == NSVG_PAINT_LINEAR_GRADIENT || shape->stroke.type == NSVG_PAINT_RADIAL_GRADIENT) { + nsvg__scaleGradient(shape->stroke.gradient, tx, ty, sx, sy); + memcpy(t, shape->stroke.gradient->xform, sizeof(float) * 6); + nsvg__xformInverse(shape->stroke.gradient->xform, t); + } - shape->strokeWidth *= avgs; - shape->strokeDashOffset *= avgs; - for (i = 0; i < shape->strokeDashCount; i++) - shape->strokeDashArray[i] *= avgs; - } + shape->strokeWidth *= avgs; + shape->strokeDashOffset *= avgs; + for (i = 0; i < shape->strokeDashCount; i++) + shape->strokeDashArray[i] *= avgs; + } } -NSVGimage* nsvgParse(char* input, const char* units, float dpi) -{ - NSVGparser* p; - NSVGimage* ret = 0; +NSVGimage *nsvgParse(char *input, const char *units, float dpi) { + NSVGparser *p; + NSVGimage *ret = 0; - p = nsvg__createParser(); - if (p == NULL) { - return NULL; - } - p->dpi = dpi; + p = nsvg__createParser(); + if (p == NULL) { + return NULL; + } + p->dpi = dpi; - nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p); + nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p); - // Scale to viewBox - nsvg__scaleToViewbox(p, units); + // Scale to viewBox + nsvg__scaleToViewbox(p, units); - ret = p->image; - p->image = NULL; + ret = p->image; + p->image = NULL; - nsvg__deleteParser(p); + nsvg__deleteParser(p); - return ret; + return ret; } -NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi) -{ - FILE* fp = NULL; - size_t size; - char* data = NULL; - NSVGimage* image = NULL; +NSVGimage *nsvgParseFromFile(const char *filename, const char *units, float dpi) { + FILE *fp = NULL; + size_t size; + char *data = NULL; + NSVGimage *image = NULL; - fp = fopen(filename, "rb"); - if (!fp) goto error; - fseek(fp, 0, SEEK_END); - size = ftell(fp); - fseek(fp, 0, SEEK_SET); - data = (char*)malloc(size+1); - if (data == NULL) goto error; - if (fread(data, 1, size, fp) != size) goto error; - data[size] = '\0'; // Must be null terminated. - fclose(fp); - image = nsvgParse(data, units, dpi); - free(data); + fp = fopen(filename, "rb"); + if (!fp) + goto error; + fseek(fp, 0, SEEK_END); + size = ftell(fp); + fseek(fp, 0, SEEK_SET); + data = (char *)malloc(size + 1); + if (data == NULL) + goto error; + if (fread(data, 1, size, fp) != size) + goto error; + data[size] = '\0'; // Must be null terminated. + fclose(fp); + image = nsvgParse(data, units, dpi); + free(data); - return image; + return image; error: - if (fp) fclose(fp); - if (data) free(data); - if (image) nsvgDelete(image); - return NULL; + if (fp) + fclose(fp); + if (data) + free(data); + if (image) + nsvgDelete(image); + return NULL; } -void nsvgDelete(NSVGimage* image) -{ - NSVGshape *snext, *shape; - if (image == NULL) return; - shape = image->shapes; - while (shape != NULL) { - snext = shape->next; - nsvg__deletePaths(shape->paths); - nsvg__deletePaint(&shape->fill); - nsvg__deletePaint(&shape->stroke); - free(shape); - shape = snext; - } - free(image); +void nsvgDelete(NSVGimage *image) { + NSVGshape *snext, *shape; + if (image == NULL) + return; + shape = image->shapes; + while (shape != NULL) { + snext = shape->next; + nsvg__deletePaths(shape->paths); + nsvg__deletePaint(&shape->fill); + nsvg__deletePaint(&shape->stroke); + free(shape); + shape = snext; + } + free(image); } #endif diff --git a/tests/common/rnd.c b/tests/common/rnd.c index 410a1ed..448bd0e 100644 --- a/tests/common/rnd.c +++ b/tests/common/rnd.c @@ -1,1009 +1,1259 @@ -static int _rnd_count = 9999; -static float _rnd[] = { 0.39540747, -0.841546, 0.52073574, 0.80399257, 0.95868486, 0.46164507, 0.5644759, 0.50258803, 0.1953517, 0.40522006, 0.7953865, -0.7795385, 0.6009604, 0.03921096, 0.56872225, 0.93369347, 0.7019503, 0.5392296, 0.2671585, 0.87286836, 0.28110227, -0.41505373, 0.8609184, 0.65234584, 0.18079561, 0.1345461, 0.26905555, 0.97823226, 0.9349287, 0.37662244, 0.47883937, -0.1831086, 0.63446456, 0.2549137, 0.8205819, 0.44705132, 0.7044422, 0.36040744, 0.29616997, 0.60375917, 0.21973382, -0.094351165, 0.3769042, 0.9975177, 0.6133292, 0.3379986, 0.88620085, 0.83456165, 0.16677794, 0.2749627, 0.28938183, -0.6274365, 0.058304083, 0.97233975, 0.48520145, 0.9803537, 0.9806276, 0.8683899, 0.62319696, 0.82413876, 0.19258952, -0.5862436, 0.5676593, 0.8187293, 0.9263807, 0.6122779, 0.14507395, 0.34604672, 0.21862903, 0.121670924, 0.22925124, -0.34154287, 0.2430596, 0.66339934, 0.6531345, 0.1867511, 0.038149532, 0.8634007, 0.039016694, 0.84279704, 0.24834526, -0.4344939, 0.8114543, 0.65996605, 0.08724063, 0.8514029, 0.12480451, 0.6621248, 0.76971227, 0.8402282, 0.46642372, -0.83605236, 0.73721045, 0.47203118, 0.41116965, 0.6334902, 0.52669185, 0.55817497, 0.07113702, 0.0010512439, 0.19292463, -0.5401541, 0.61593264, 0.045107026, 0.04571145, 0.94783896, 0.3843769, 0.39490476, 0.3192052, 0.29845035, 0.9422042, -0.11722695, 0.8293732, 0.7804, 0.5757935, 0.7580956, 0.7747893, 0.90769327, 0.73148865, 0.074977815, 0.4874734, -0.48294914, 0.5763345, 0.37840083, 0.6552472, 0.39319888, 0.6043324, 0.77102846, 0.25222966, 0.019644327, 0.6600592, -0.4799746, 0.7922636, 0.03796545, 0.64987236, 0.70819116, 0.81856126, 0.7663473, 0.6142546, 0.13940167, 0.46702597, -0.72989976, 0.34291962, 0.47126192, 0.89802396, 0.34919676, 0.0066791615, 0.95681053, 0.8962376, 0.653074, 0.85870093, -0.6189986, 0.8266863, 0.9961592, 0.5135778, 0.7099755, 0.9638197, 0.2375318, 0.3898598, 0.65251255, 0.34350657, -0.6133485, 0.14267509, 0.29956087, 0.6383911, 0.4622296, 0.3249633, 0.79140776, 0.13052759, 0.8676024, 0.93953437, -0.008441999, 0.2934387, 0.592087, 0.6079518, 0.75757366, 0.14002953, 0.10507256, 0.48037684, 0.30605045, 0.38651973, -0.64752185, 0.8747908, 0.59915566, 0.1609434, 0.04106063, 0.65328825, 0.79610443, 0.5243876, 0.9398969, 0.7443715, -0.5810295, 0.3764875, 0.961742, 0.7958951, 0.8536775, 0.58722466, 0.043358732, 0.8328708, 0.43579438, 0.024233455, -0.21527143, 0.8262829, 0.028635254, 0.71353966, 0.85025895, 0.3255599, 0.23459937, 0.38820738, 0.7560042, 0.569946, -0.8587471, 0.75715494, 0.083809346, 0.26599285, 0.6959847, 0.73855764, 0.54351944, 0.13861747, 0.59733045, 0.80894136, -0.52885884, 0.26702014, 0.1906307, 0.123230904, 0.35850486, 0.6319545, 0.3316967, 0.7961919, 0.7542743, 0.17034897, -0.0966708, 0.27220175, 0.04458247, 0.28181702, 0.1712483, 0.82123893, 0.8461555, 0.88561594, 0.3106845, 0.7155007, -0.4186889, 0.40789708, 0.76838344, 0.36995092, 0.8856244, 0.82387453, 0.29267815, 0.69574916, 0.099910386, 0.11511985, -0.04370523, 0.9047413, 0.23554033, 0.62685305, 0.4953746, 0.9482513, 0.63565224, 0.9054043, 0.3550348, 0.21830441, -0.9938632, 0.4384075, 0.633933, 0.5856552, 0.47327515, 0.58654535, 0.71257246, 0.80199236, 0.09474454, 0.8747458, -0.8924021, 0.6579035, 0.82793295, 0.88182974, 0.39025244, 0.12096177, 0.4986367, 0.8206798, 0.23760653, 0.53463036, -0.33927637, 0.6359475, 0.6962815, 0.6391545, 0.12664375, 0.19192953, 0.036661416, 0.41772944, 0.7864424, 0.222997, -0.18558672, 0.9407512, 0.5305812, 0.092380084, 0.7216375, 0.9802814, 0.77396405, 0.18272822, 0.89667577, 0.29907903, -0.11130205, 0.4906858, 0.60100466, 0.22516462, 0.22271773, 0.38580173, 0.07680829, 0.3537106, 0.23660058, 0.37441283, -0.4496146, 0.81497246, 0.6677978, 0.82040447, 0.879028, 0.35791573, 0.742126, 0.9947786, 0.45901147, 0.28134564, -0.54988396, 0.29484302, 0.015549939, 0.87174755, 0.68915904, 0.9516509, 0.12732233, 0.7355529, 0.16019227, 0.40997103, -0.34699774, 0.31590846, 0.924004, 0.93852746, 0.4233283, 0.84859055, 0.034942873, 0.47111684, 0.41643673, 0.740842, -0.115121245, 0.68295085, 0.18112887, 0.41202956, 0.77338237, 0.3706143, 0.27295336, 0.7101767, 0.21335205, 0.36372176, -0.2381554, 0.7791855, 0.72371674, 0.6153301, 0.7491951, 0.816459, 0.47513586, 0.7292571, 0.5360056, 0.2710668, -0.25847942, 0.3412554, 0.19351831, 0.8266295, 0.0274151, 0.13370614, 0.8909684, 0.72927034, 0.39707616, 0.030437447, -0.32297286, 0.27100918, 0.57834184, 0.71816945, 0.16622439, 0.8669331, 0.11371415, 0.6035204, 0.09836516, 0.31854475, -0.6786976, 0.41714564, 0.5222008, 0.7964705, 0.17181565, 0.56781226, 0.5921917, 0.30867395, 0.1893324, 0.6068693, -0.37345472, 0.3056858, 0.9351113, 0.14536993, 0.4823626, 0.7738658, 0.4894325, 0.35449934, 0.38461447, 0.6396763, -0.4796459, 0.54368305, 0.31310055, 0.18291461, 0.040748898, 0.9671462, 0.20084366, 0.0055472897, 0.4491057, 0.882262, -0.7027449, 0.87161547, 0.6308919, 0.21746083, 0.59236926, 0.8413338, 0.81905454, 0.3970478, 0.6548139, 0.45960286, -0.5415144, 0.58229446, 0.539938, 0.7902069, 0.6569827, 0.017287076, 0.33589792, 0.4329719, 0.23580688, 0.39235854, -0.3775006, 0.7592148, 0.2189059, 0.45868888, 0.83889884, 0.13501453, 0.10404509, 0.3392862, 0.7557216, 0.20466943, -0.36696857, 0.5866444, 0.85956824, 0.3070704, 0.9041244, 0.5018392, 0.67479384, 0.7176504, 0.5530007, 0.6410288, -0.9548113, 0.092384726, 0.69968545, 0.92501163, 0.09816185, 0.89735144, 0.0037450776, 0.52289367, 0.5259319, 0.023461822, -0.6312483, 0.7678718, 0.7697404, 0.05674718, 0.5047614, 0.9435301, 0.6527096, 0.17220303, 0.37856197, 0.45735472, -0.7372887, 0.47976837, 0.6413262, 0.45014447, 0.09263428, 0.95487, 0.7227262, 0.23286755, 0.8860825, 0.15514348, -0.34249324, 0.61824745, 0.8799712, 0.59477806, 0.43754727, 0.28511587, 0.059529364, 0.2938943, 0.36052704, 0.9415474, -0.13126945, 0.5811514, 0.8133543, 0.7322598, 0.5734211, 0.5990968, 0.816904, 0.80282104, 0.802309, 0.96059436, -0.8491296, 0.50259084, 0.33908847, 0.09564596, 0.9037401, 0.4750429, 0.45105854, 0.24954097, 0.8323773, 0.14329186, -0.17462522, 0.77087754, 0.63681114, 0.3707884, 0.6809686, 0.013000839, 0.8879006, 0.17496233, 0.61919993, 0.21964556, -0.8840007, 0.3588153, 0.81167597, 0.43701455, 0.32608527, 0.15613726, 0.666414, 0.9090664, 0.87672335, 0.4935375, -0.13796596, 0.9199052, 0.43055856, 0.9254882, 0.30601385, 0.8399024, 0.279159, 0.78432524, 0.69103795, 0.9625043, -0.83405733, 0.8099884, 0.46151695, 0.2172352, 0.7669222, 0.3603919, 0.9443403, 0.44256592, 0.0512912, 0.5604203, -0.7111962, 0.64194167, 0.18362112, 0.5826634, 0.07659364, 0.49031433, 0.6909148, 0.9020739, 0.7695607, 0.7476028, -0.80862886, 0.5419922, 0.3728176, 0.33883983, 0.005325912, 0.25472003, 0.34031895, 0.711323, 0.064774565, 0.8410662, -0.73384184, 0.10357534, 0.48392436, 0.65669554, 0.38558826, 0.07401231, 0.8972984, 0.5944408, 0.67009234, 0.96569335, -0.21179698, 0.22384812, 0.8577752, 0.31630307, 0.7823413, 0.49602425, 0.7362841, 0.84789515, 0.84889454, 0.8156995, -0.14898759, 0.3770851, 0.01476456, 0.94343513, 0.15387547, 0.29206514, 0.43717077, 0.12267711, 0.21190928, 0.5122022, -0.020072967, 0.23301727, 0.37779135, 0.21022503, 0.82657844, 0.60762084, 0.15801735, 0.52692556, 0.19707517, 0.0025813282, -0.59301597, 0.09647403, 0.23198159, 0.80386734, 0.5358059, 0.58478075, 0.684217, 0.056514528, 0.5564985, 0.50930166, -0.51843596, 0.4924238, 0.8624285, 0.24907504, 0.6920786, 0.35675675, 0.08881078, 0.5404892, 0.5028201, 0.0935231, -0.63684154, 0.77462125, 0.38253152, 0.15789017, 0.94562036, 0.97877973, 0.84605676, 0.64755017, 0.48972467, 0.17472044, -0.3380069, 0.2093585, 0.65081996, 0.8463132, 0.22268358, 0.052513562, 0.1451035, 0.21089722, 0.40762928, 0.5690947, -0.60784817, 0.38065624, 0.56617856, 0.70260763, 0.99376625, 0.52764916, 0.37058878, 0.1287163, 0.51814646, 0.4698217, -0.5188101, 0.61752814, 0.024105478, 0.103552066, 0.3657398, 0.81839466, 0.7139425, 0.07409142, 0.858247, 0.55702615, -0.738724, 0.03666682, 0.56678987, 0.38177812, 0.17129473, 0.30907747, 0.8416038, 0.016115308, 0.02639147, 0.639565, -0.21165326, 0.87791353, 0.13285992, 0.9337254, 0.48567492, 0.2561853, 0.20844269, 0.6799239, 0.16412394, 0.41797122, -0.60819095, 0.71734047, 0.12940371, 0.019902974, 0.6559104, 0.7204788, 0.18525302, 0.5472679, 0.4805734, 0.4042889, -0.33857107, 0.07101207, 0.35265025, 0.85060316, 0.8303707, 0.57118136, 0.8138664, 0.18440045, 0.5313129, 0.68468875, -0.68604535, 0.35447347, 0.10232483, 0.8785814, 0.25816843, 0.6408965, 0.48466823, 0.09038009, 0.6178771, 0.10955451, -0.609952, 0.034018606, 0.9099675, 0.44027576, 0.9488352, 0.021383535, 0.9072631, 0.5468869, 0.72586775, 0.45081598, -0.12382444, 0.29433593, 0.5355419, 0.62210256, 0.30099395, 0.14064118, 0.5252633, 0.28225678, 0.10335469, 0.91449356, -0.44231892, 0.024042243, 0.14861101, 0.47943518, 0.7319259, 0.2537175, 0.6150156, 0.25082228, 0.76173455, 0.01501382, -0.23581055, 0.09487294, 0.9293908, 0.3710189, 0.7943369, 0.30455244, 0.1610446, 0.9123745, 0.90176797, 0.80898714, -0.66391826, 0.2669795, 0.4585327, 0.08049692, 0.5608643, 0.3917094, 0.8189315, 0.48022225, 0.5775875, 0.11752723, -0.11563321, 0.20241146, 0.9870254, 0.70338356, 0.6672356, 0.5859097, 0.88540757, 0.4305323, 0.7083498, 0.69511765, -0.4063679, 0.6564408, 0.7851523, 0.71085393, 0.21500541, 0.028951503, 0.36494514, 0.16452302, 0.8277657, 0.9964415, -0.9795966, 0.6128888, 0.38048878, 0.29436752, 0.25057533, 0.17533945, 0.56550956, 0.06811409, 0.9185709, 0.3402165, -0.43478596, 0.13479339, 0.6732348, 0.64420736, 0.8993806, 0.033399098, 0.10784754, 0.22600721, 0.7037833, 0.20842715, -0.41914487, 0.7305123, 0.20402466, 0.2066503, 0.40261927, 0.007477421, 0.48182714, 0.74767876, 0.8654915, 0.5319128, -0.026764244, 0.6544085, 0.6524566, 0.58114594, 0.13793063, 0.50274444, 0.82192266, 0.6926579, 0.45280823, 0.49189615, -0.020400187, 0.8172935, 0.51196146, 0.36813334, 0.26033172, 0.27157453, 0.983206, 0.140945, 0.81147337, 0.18160632, -0.92110395, 0.13893794, 0.46073973, 0.6193385, 0.5772967, 0.2490843, 0.40886414, 0.1738385, 0.89174825, 0.24309792, -0.6935123, 0.8178308, 0.20262258, 0.38665804, 0.31345224, 0.78037745, 0.48233682, 0.09208888, 0.50627667, 0.3966362, -0.21147643, 0.41518968, 0.77319896, 0.21188715, 0.18802696, 0.60185134, 0.21855086, 0.8358913, 0.94631857, 0.13104475, -0.024271427, 0.34088212, 0.9362054, 0.6838852, 0.61080885, 0.8878263, 0.1936688, 0.03311803, 0.0038492912, 0.88884634, -0.09388026, 0.64808416, 0.8009096, 0.2097103, 0.79838383, 0.20256937, 0.61467093, 0.1253034, 0.054681093, 0.47995427, -0.7892377, 0.8911171, 0.6346683, 0.41483715, 0.9701299, 0.5059143, 0.36573896, 0.24885257, 0.43131158, 0.97544533, -0.03053343, 0.57297283, 0.2275199, 0.7607035, 0.21882649, 0.3526302, 0.8816254, 0.5187374, 0.77584916, 0.42562595, -0.58670866, 0.44921878, 0.08823959, 0.6174303, 0.30275592, 0.5633923, 0.61428005, 0.56348866, 0.41350332, 0.9854576, -0.9871804, 0.093247466, 0.7812102, 0.4663643, 0.34180707, 0.13315432, 0.70621383, 0.52136827, 0.7137553, 0.10489457, -0.52208734, 0.94481623, 0.60180646, 0.028403986, 0.8583129, 0.5209074, 0.42056426, 0.04020609, 0.9908838, 0.44575363, -0.32094392, 0.09593353, 0.34945422, 0.62905514, 0.89324564, 0.3400189, 0.80287755, 0.017237967, 0.112081215, 0.40673763, -0.8916342, 0.80225027, 0.83534926, 0.44585398, 0.98826486, 0.93728596, 0.79176265, 0.7611556, 0.41889647, 0.08567218, -0.64641637, 0.3602572, 0.80498207, 0.6709546, 0.9035386, 0.64189243, 0.84741235, 0.0598356, 0.7591174, 0.7818485, -0.142828, 0.574074, 0.5726049, 0.96774966, 0.6645137, 0.8912469, 0.74379325, 0.15215507, 0.5731187, 0.0017881524, -0.3302768, 0.6889758, 0.40928704, 0.30701768, 0.21326037, 0.71983707, 0.10946698, 0.1559525, 0.040139113, 0.92102695, -0.7291448, 0.6594087, 0.62130964, 0.9052116, 0.79933727, 0.9606867, 0.29095143, 0.6784996, 0.72551656, 0.2513532, -0.49260658, 0.74304193, 0.25812054, 0.33023268, 0.2639096, 0.31756023, 0.22964539, 0.86759955, 0.7813403, 0.097017966, -0.19349271, 0.63960755, 0.18803692, 0.4171083, 0.7553954, 0.95744056, 0.9509702, 0.4979644, 0.45769426, 0.18370152, -0.53242546, 0.69145983, 0.019696489, 0.8380905, 0.052703734, 0.48341933, 0.95276433, 0.6673932, 0.16841243, 0.70382696, -0.6002955, 0.06529366, 0.42663854, 0.32176548, 0.50918156, 0.58723485, 0.4308553, 0.079054326, 0.04310807, 0.89570016, -0.4901917, 0.24186741, 0.3746122, 0.94312114, 0.72753423, 0.08953723, 0.47137174, 0.20420133, 0.14981624, 0.8418967, -0.009716521, 0.79298705, 0.22080535, 0.541815, 0.71892774, 0.80114675, 0.72334546, 0.42003006, 0.27752897, 0.7804903, -0.36479586, 0.56225216, 0.69918716, 0.07751329, 0.4967225, 0.12819904, 0.212969, 0.86627144, 0.90792674, 0.16816054, -0.5265852, 0.8719159, 0.45485634, 0.56199414, 0.6935098, 0.29055804, 0.31684762, 0.07657534, 0.11055623, 0.9631665, -0.012047576, 0.74856305, 0.517577, 0.32651573, 0.69411045, 0.80730844, 0.8444883, 0.88482356, 0.60283774, 0.7080349, -0.8638894, 0.010825248, 0.80152535, 0.26261777, 0.53090423, 0.92793953, 0.54268026, 0.29709893, 0.44639865, 0.5993352, -0.8765682, 0.6051003, 0.2962746, 0.9816557, 0.31531146, 0.13780066, 0.3381307, 0.6588112, 0.84830517, 0.4283697, -0.48429912, 0.6467701, 0.30947384, 0.31436247, 0.7684427, 0.6162329, 0.044675153, 0.3726714, 0.38340282, 0.689414, -0.28371072, 0.32814547, 0.26343372, 0.19989188, 0.30427113, 0.51576, 0.07039049, 0.19223855, 0.031089857, 0.7655703, -0.7478778, 0.019748688, 0.63017666, 0.511221, 0.08659828, 0.40694728, 0.45228842, 0.53592134, 0.011204251, 0.5563098, -0.46917772, 0.18567711, 0.036518365, 0.17446801, 0.22373573, 0.21711932, 0.7013514, 0.48716292, 0.49417505, 0.9146714, -0.88326436, 0.17000887, 0.9136961, 0.7569846, 0.3156245, 0.54842275, 0.34166658, 0.09638273, 0.67738456, 0.7995515, -0.06741016, 0.14589214, 0.62772137, 0.08273488, 0.680492, 0.46455044, 0.016593413, 0.7982528, 0.22776419, 0.36149544, -0.16394442, 0.50875384, 0.36146715, 0.827093, 0.22023632, 0.098033614, 0.2916271, 0.088965714, 0.9761561, 0.08715181, -0.8144086, 0.5832276, 0.6980635, 0.11641844, 0.8823059, 0.5778689, 0.106052585, 0.8731921, 0.19559653, 0.5381755, -0.06528069, 0.3559057, 0.8585367, 0.21165277, 0.48889965, 0.32328558, 0.55795574, 0.95378345, 0.49397606, 0.7591853, -0.20052591, 0.9030986, 0.25939873, 0.13267961, 0.750727, 0.37451053, 0.8085417, 0.086603075, 0.5367483, 0.21759088, -0.25679567, 0.25270087, 0.120226584, 0.59023273, 0.9851429, 0.48418257, 0.44782865, 0.51130295, 0.20042898, 0.102623075, -0.35849786, 0.14340132, 0.6026563, 0.68958867, 0.29621476, 0.8080387, 0.6502171, 0.14981438, 0.3381934, 0.8969507, -0.54007787, 0.33784363, 0.59498966, 0.21697083, 0.8866259, 0.91130996, 0.32382888, 0.5653839, 0.36569145, 0.5077954, -0.76932716, 0.01944951, 0.3364438, 0.97800565, 0.28137985, 0.8125798, 0.2356791, 0.268304, 0.22650987, 0.00471706, -0.8754569, 0.04665282, 0.7533545, 0.39135298, 0.40068746, 0.05712457, 0.3004423, 0.56981003, 0.8364648, 0.9426883, -0.7242934, 0.65872735, 0.7484097, 0.63979757, 0.677513, 0.91895205, 0.6577112, 0.90325576, 0.70360684, 0.07383294, -0.1603537, 0.88244474, 0.14561148, 0.6926336, 0.3332959, 0.33904833, 0.80695754, 0.62465066, 0.40820882, 0.48363495, -0.5723596, 0.38191313, 0.9233045, 0.33347633, 0.021493766, 0.49342504, 0.5844891, 0.20363668, 0.81628335, 0.82950133, -0.6108677, 0.75401884, 0.728919, 0.42300317, 0.7835019, 0.11059984, 0.2710398, 0.6966462, 0.30049264, 0.3624278, -0.1548686, 0.33242336, 0.56469715, 0.15267694, 0.84436333, 0.9930122, 0.9010413, 0.06072089, 0.058057077, 0.061639126, -0.25016704, 0.6757917, 0.16160122, 0.3528299, 0.37032866, 0.34238032, 0.7354228, 0.41493335, 0.6183038, 0.18408795, -0.3344629, 0.45407453, 0.08697238, 0.8741055, 0.46296528, 0.40633488, 0.1535257, 0.7226083, 0.90913165, 0.22269607, -0.068008505, 0.1103113, 0.32415798, 0.045781024, 0.32876635, 0.23993625, 0.817216, 0.77062756, 0.48911297, 0.028481547, -0.5923837, 0.52376825, 0.14557959, 0.7546443, 0.5793343, 0.935076, 0.5924176, 0.37608913, 0.05267449, 0.44112164, -0.37517703, 0.85610646, 0.078342445, 0.11640469, 0.02796489, 0.70079404, 0.24545097, 0.69059163, 0.68971163, 0.43802848, -0.83948654, 0.17843302, 0.15158923, 0.835361, 0.99363065, 0.13985574, 0.3516337, 0.115820184, 0.02406358, 0.13039242, -0.5251643, 0.96479523, 0.92582035, 0.58982223, 0.59170425, 0.8106947, 0.30849496, 0.33232814, 0.2947712, 0.5278893, -0.8139172, 0.77743655, 0.6699338, 0.46801004, 0.84751904, 0.21190204, 0.031968854, 0.2077533, 0.017816134, 0.62797225, -0.99448526, 0.12662433, 0.080915935, 0.05108449, 0.18899502, 0.41395068, 0.372179, 0.3102186, 0.7610136, 0.43947858, -0.5834423, 0.47659743, 0.35202554, 0.9222821, 0.9159573, 0.4103818, 0.9302861, 0.4885202, 0.52470046, 0.21727021, -0.39229912, 0.91312283, 0.39582044, 0.16182233, 0.62411124, 0.062049974, 0.5084992, 0.6835792, 0.98784196, 0.78172857, -0.10788689, 0.1438804, 0.09800406, 0.3960913, 0.13590716, 0.39854, 0.8838793, 0.8747359, 0.40082723, 0.17775355, -0.43851566, 0.99827635, 0.5713145, 0.8552926, 0.94444704, 0.33731982, 0.42541102, 0.74765176, 0.55205274, 0.43713725, -0.28161594, 0.5434486, 0.68305284, 0.80054593, 0.23567316, 0.08136242, 0.7308039, 0.9190936, 0.42697325, 0.12694505, -0.9054515, 0.6885998, 0.32237664, 0.97928506, 0.33159167, 0.43956187, 0.3785934, 0.9559342, 0.7863749, 0.5174173, -0.5265025, 0.05555021, 0.08769297, 0.3469469, 0.77875453, 0.39402276, 0.34180835, 0.5405278, 0.21737531, 0.2867914, -0.636639, 0.76084745, 0.13152646, 0.5507047, 0.50011265, 0.5644382, 0.46082756, 0.29745814, 0.16041815, 0.054544732, -0.6677361, 0.9647857, 0.44776264, 0.27388218, 0.27230206, 0.74991584, 0.67589974, 0.59202945, 0.52370095, 0.50488514, -0.9587264, 0.46947676, 0.9612768, 0.034635436, 0.91063476, 0.22606573, 0.45575568, 0.33610594, 0.02179139, 0.8416504, -0.7395541, 0.19027609, 0.7017183, 0.14018182, 0.49030608, 0.14460404, 0.55707335, 0.7716719, 0.47917238, 0.76715344, -0.9787343, 0.08113525, 0.7955161, 0.7318302, 0.8496812, 0.5617168, 0.60778755, 0.81381077, 0.07464484, 0.028838681, -0.718123, 0.74977887, 0.016826851, 0.71249014, 0.32806498, 0.16716221, 0.7995706, 0.096891016, 0.64007, 0.27404693, -0.10868255, 0.12472161, 0.27566674, 0.31876773, 0.31499064, 0.47746003, 0.2630674, 0.30758083, 0.78357613, 0.12769802, -0.1928425, 0.90422785, 0.112857096, 0.7565475, 0.5261508, 0.8775912, 0.6739607, 0.22944665, 0.18495426, 0.3489179, -0.61827815, 0.6419449, 0.2614611, 0.9929527, 0.12352738, 0.98977524, 0.17344923, 0.9892281, 0.81211686, 0.32314387, -0.34503344, 0.46018234, 0.13160191, 0.20512545, 0.65847087, 0.8540127, 0.8054685, 0.47674835, 0.41683954, 0.37222117, -0.29864943, 0.30020675, 0.03023468, 0.94694686, 0.8359962, 0.8138952, 0.63692176, 0.26027933, 0.18633933, 0.45047382, -0.49320155, 0.570124, 0.91193676, 0.2911521, 0.65576875, 0.46673766, 0.8632605, 0.28271404, 0.19524036, 0.32521543, -0.30401078, 0.27383924, 0.495464, 0.46043226, 0.7826646, 0.7326602, 0.7726259, 0.90773165, 0.09807661, 0.6721381, -0.07212267, 0.1972123, 0.8126071, 0.8127331, 0.05026847, 0.3180714, 0.6117102, 0.31451428, 0.15695652, 0.30963218, -0.35285345, 0.9131699, 0.8028888, 0.36164302, 0.8299423, 0.7749095, 0.54824555, 0.8404498, 0.5493567, 0.19173324, -0.9907522, 0.5227545, 0.281508, 0.091624096, 0.06821037, 0.024810186, 0.80474275, 0.5698024, 0.16428226, 0.10333604, -0.04126928, 0.7291901, 0.16220273, 0.5142012, 0.37835112, 0.29598927, 0.75751686, 0.09920368, 0.24088362, 0.33769736, -0.85502744, 0.5487462, 0.12575752, 0.8856082, 0.972362, 0.3908409, 0.47095042, 0.13382097, 0.63048995, 0.007755094, -0.18441458, 0.9321761, 0.35837498, 0.9063434, 0.6813859, 0.5493682, 0.9157043, 0.720983, 0.7445227, 0.025458287, -0.5133287, 0.041907787, 0.15023202, 0.053620476, 0.2683629, 0.6236633, 0.75096714, 0.28868756, 0.98329186, 0.5339531, -0.017392641, 0.4490419, 0.5995662, 0.21165931, 0.3367058, 0.44200596, 0.39699697, 0.39589983, 0.11926211, 0.6773695, -0.5538598, 0.6709218, 0.93931246, 0.15652716, 0.9189215, 0.10909318, 0.37081516, 0.25585935, 0.83281535, 0.82898295, -0.38028497, 0.03653382, 0.35468096, 0.21542533, 0.8243687, 0.81311965, 0.39851424, 0.07213704, 0.61724526, 0.34869868, -0.63987374, 0.18226288, 0.15052907, 0.096536905, 0.99036247, 0.73537266, 0.3326099, 0.14671567, 0.5696376, 0.2393799, -0.15237123, 0.5198045, 0.6017209, 0.067153245, 0.47159854, 0.84240687, 0.1025953, 0.99370486, 0.134699, 0.15926972, -0.25284818, 0.4951078, 0.45587218, 0.15430894, 0.15366808, 0.9808588, 0.094360925, 0.38414088, 0.3872906, 0.52358615, -0.043491747, 0.32485992, 0.7786546, 0.7705634, 0.037495736, 0.37159687, 0.5203927, 0.8427756, 0.16616471, 0.18354878, -0.7764833, 0.22409947, 0.6862218, 0.59343547, 0.6766117, 0.8604805, 0.4348129, 0.2875277, 0.7438268, 0.9819619, -0.7105244, 0.4048094, 0.937438, 0.45797554, 0.09585048, 0.14476593, 0.7263907, 0.9962201, 0.9428688, 0.009503636, -0.6410118, 0.94846904, 0.7594251, 0.04605143, 0.19588815, 0.8275113, 0.7411499, 0.83115745, 0.02965751, 0.10000168, -0.32201412, 0.25981972, 0.82754016, 0.95115024, 0.38278645, 0.02874871, 0.808886, 0.8624367, 0.47769725, 0.29318756, -0.5460459, 0.8068332, 0.6403141, 0.4053287, 0.8130618, 0.63868237, 0.3874219, 0.320679, 0.67471296, 0.8927298, -0.64520615, 0.5241726, 0.89990675, 0.15666108, 0.54253703, 0.82801425, 0.46467438, 0.64017034, 0.39754733, 0.8491004, -0.11933059, 0.60365546, 0.25787023, 0.6438251, 0.65994775, 0.45070463, 0.57726926, 0.98628783, 0.075189106, 0.06710178, -0.33587992, 0.863954, 0.51852286, 0.64968127, 0.46345773, 0.83417857, 0.30815494, 0.35409638, 0.23298964, 0.5572058, -0.4400894, 0.4204709, 0.1564445, 0.13692771, 0.4547955, 0.7978415, 0.35991296, 0.67087907, 0.4086132, 0.5547722, -0.56407434, 0.16871567, 0.46488938, 0.62859684, 0.17385697, 0.94239044, 0.548963, 0.996489, 0.74538094, 0.36235714, -0.061413143, 0.40113407, 0.24548991, 0.6076112, 0.5568499, 0.78125215, 0.005649717, 0.2502255, 0.69320333, 0.70835847, -0.5198593, 0.110578, 0.4071807, 0.84034157, 0.40901098, 0.6988597, 0.44721094, 0.12094251, 0.1890296, 0.86210626, -0.09079167, 0.90639013, 0.5776746, 0.5204169, 0.50302744, 0.16716424, 0.39906463, 0.8899261, 0.47582427, 0.52106726, -0.2852156, 0.31166598, 0.6087155, 0.87063247, 0.49579263, 0.03895533, 0.174981, 0.5488333, 0.5800778, 0.67354333, -0.7921918, 0.10968746, 0.97767574, 0.70025474, 0.034912895, 0.45349634, 0.761535, 0.6245478, 0.21958585, 0.47499728, -0.4951795, 0.42802048, 0.80745935, 0.8832747, 0.27156547, 0.15502298, 0.8234595, 0.725073, 0.10458374, 0.38968566, -0.38218752, 0.11572367, 0.77440125, 0.17213607, 0.42314288, 0.2081933, 0.5018625, 0.5365482, 0.3445489, 0.37005565, -0.5238787, 0.8983776, 0.5408647, 0.51548624, 0.06991447, 0.9811042, 0.9287144, 0.8774199, 0.48550403, 0.04953112, -0.40562928, 0.7745168, 0.6703402, 0.00082698837, 0.025887761, 0.8571951, 0.5042066, 0.7254408, 0.59906703, 0.34076965, -0.21549584, 0.449908, 0.44424957, 0.19039217, 0.29135585, 0.67646813, 0.33528623, 0.80553967, 0.27711186, 0.8267196, -0.95163375, 0.22498675, 0.2799989, 0.8495302, 0.9511186, 0.5968019, 0.8871558, 0.2919731, 0.8133602, 0.29046127, -0.22630857, 0.9460396, 0.23956898, 0.05505262, 0.98405635, 0.60767066, 0.4453835, 0.77357423, 0.14624831, 0.5659478, -0.7039867, 0.7764218, 0.9374812, 0.0037792725, 0.1545598, 0.073970705, 0.45412806, 0.35047254, 0.2241304, 0.39344636, -0.645818, 0.12317476, 0.600308, 0.65878445, 0.09789734, 0.18064253, 0.49451795, 0.82080996, 0.049708407, 0.42908588, -0.9700393, 0.2122335, 0.9120806, 0.30860576, 0.11446109, 0.26945624, 0.21033902, 0.38919696, 0.20633578, 0.6836851, -0.23108464, 0.56171197, 0.6592914, 0.7111641, 0.122732915, 0.175212, 0.28750554, 0.2762196, 0.69497037, 0.87714785, -0.14267384, 0.53668326, 0.06784272, 0.41991386, 0.6446433, 0.10313381, 0.34573162, 0.58078456, 0.9571553, 0.8034138, -0.11315275, 0.62457347, 0.7238658, 0.71716243, 0.59590846, 0.4917532, 0.8643412, 0.62887543, 0.88931817, 0.8851036, -0.86363167, 0.064931095, 0.14413676, 0.54044527, 0.16236171, 0.084106006, 0.4638834, 0.8891439, 0.5360515, 0.9226853, -0.893137, 0.21829833, 0.12583959, 0.17256053, 0.28641203, 0.4333561, 0.14439079, 0.49216673, 0.6639625, 0.011327274, -0.9237246, 0.62955445, 0.43204167, 0.40292194, 0.5705324, 0.6065112, 0.83784616, 0.94212896, 0.115255654, 0.6309797, -0.3108708, 0.6586301, 0.38690144, 0.8098668, 0.013516203, 0.07774274, 0.39254647, 0.52739745, 0.25755215, 0.5605373, -0.6392504, 0.4565877, 0.044733036, 0.034469932, 0.91027683, 0.8948544, 0.4987339, 0.5513053, 0.4307504, 0.16255233, -0.3473624, 0.3721745, 0.96491295, 0.8779909, 0.961379, 0.2340772, 0.6328894, 0.7412148, 0.9699129, 0.55585057, -0.24625985, 0.52175444, 0.77388823, 0.9050718, 0.61181456, 0.23450689, 0.8313969, 0.31597278, 0.15904433, 0.20866929, -0.04080962, 0.6169933, 0.23461457, 0.1034252, 0.37207687, 0.4671369, 0.58482146, 0.39757174, 0.4926451, 0.67567796, -0.107777245, 0.28654084, 0.5113785, 0.9527033, 0.28361735, 0.9386963, 0.6937171, 0.50891054, 0.84848785, 0.779439, -0.44485334, 0.65133166, 0.55748457, 0.7017016, 0.3142774, 0.11749596, 0.68269944, 0.13966125, 0.42265537, 0.6757699, -0.06345752, 0.18276113, 0.39226097, 0.2220811, 0.12174272, 0.7303691, 0.13755992, 0.8614878, 0.50591403, 0.4942421, -0.64925575, 0.23531766, 0.24856968, 0.29423487, 0.44807333, 0.959719, 0.010375906, 0.82118493, 0.6214544, 0.67311823, -0.5407898, 0.3224864, 0.46748495, 0.37960532, 0.76381594, 0.38947794, 0.05950873, 0.53291297, 0.7891478, 0.2545809, -0.7844374, 0.44516018, 0.97491634, 0.81687516, 0.61222047, 0.9250161, 0.89427984, 0.28929746, 0.83096063, 0.5532483, -0.8011364, 0.8322293, 0.0029964554, 0.35424575, 0.13018323, 0.20953566, 0.402762, 0.2632497, 0.25362825, 0.3545584, -0.10712006, 0.8615145, 0.51820683, 0.7495371, 0.13498017, 0.74097115, 0.7152762, 0.0126556605, 0.45826513, 0.73226476, -0.67086035, 0.6046469, 0.07234, 0.25133318, 0.70980465, 0.20409557, 0.2604013, 0.43169454, 0.6820144, 0.5230572, -0.065439165, 0.72107846, 0.99022436, 0.06820616, 0.87198186, 0.70856047, 0.31948993, 0.11323921, 0.24942209, 0.5542803, -0.9867159, 0.79625905, 0.27928472, 0.4345894, 0.14746083, 0.9229229, 0.9269534, 0.22537923, 0.681895, 0.8712493, -0.20973994, 0.8816242, 0.83103234, 0.098695815, 0.88238794, 0.19648944, 0.75988936, 0.75166327, 0.64444107, 0.9260877, -0.94913435, 0.9710675, 0.5812353, 0.7305711, 0.28911924, 0.3860416, 0.87129015, 0.45000067, 0.87755525, 0.42641973, -0.4214812, 0.60203695, 0.7632336, 0.90398484, 0.74554884, 0.8746013, 0.32536224, 0.6377506, 0.10387234, 0.7868817, -0.2771422, 0.035022065, 0.74979955, 0.8107651, 0.31331727, 0.18381497, 0.8900461, 0.89152855, 0.18581823, 0.6754924, -0.9486711, 0.5678266, 0.4687981, 0.32333443, 0.60514593, 0.015648454, 0.21502374, 0.5487136, 0.14547014, 0.76141924, -0.05163277, 0.4769527, 0.34782398, 0.25547525, 0.44976813, 0.607703, 0.11839061, 0.9270475, 0.35314697, 0.007786621, -0.8711272, 0.12213872, 0.64779097, 0.8575594, 0.64894545, 0.9141123, 0.22126794, 0.77047014, 0.4172538, 0.10530428, -0.4959955, 0.97976166, 0.26418245, 0.20206283, 0.47774863, 0.85365456, 0.13323887, 0.43989918, 0.29883888, 0.7299004, -0.65957755, 0.7766486, 0.49228048, 0.34245312, 0.7352489, 0.8001895, 0.6871981, 0.49432427, 0.360997, 0.70561427, -0.06542435, 0.96299857, 0.5383816, 0.1780316, 0.8043652, 0.82653236, 0.92003566, 0.6112387, 0.67438895, 0.6910336, -0.79438055, 0.44455358, 0.13145985, 0.04016586, 0.26542372, 0.07187113, 0.21277027, 0.14576113, 0.77772665, 0.59611356, -0.47446412, 0.6784915, 0.62820864, 0.62324655, 0.34820905, 0.094478644, 0.62985826, 0.30533785, 0.122310445, 0.84875596, -0.22691421, 0.7269437, 0.40947318, 0.7116395, 0.039879926, 0.5329969, 0.44138008, 0.08615084, 0.39769763, 0.65121627, -0.93361884, 0.52200013, 0.7655102, 0.60780525, 0.9355199, 0.21502401, 0.64518875, 0.45211464, 0.0770294, 0.6633778, -0.5874192, 0.541437, 0.7165977, 0.7648834, 0.2311502, 0.3869329, 0.33478996, 0.915135, 0.82982254, 0.70988655, -0.19667415, 0.6146979, 0.4889283, 0.825633, 0.46411943, 0.067436874, 0.035080392, 0.41982034, 0.0002859342, 0.7324268, -0.630491, 0.12661943, 0.7480635, 0.12651038, 0.6624947, 0.952464, 0.9129812, 0.020403363, 0.6877267, 0.13318504, -0.44928992, 0.1777436, 0.22830844, 0.45893264, 0.2613367, 0.68547726, 0.010346001, 0.6445898, 0.4804893, 0.652947, -0.19820693, 0.52624506, 0.25632828, 0.687811, 0.4545421, 0.31892103, 0.033071853, 0.9398772, 0.14368583, 0.868083, -0.17994362, 0.2253684, 0.4518287, 0.34460258, 0.032886766, 0.4607998, 0.7933734, 0.59008723, 0.10238874, 0.27868623, -0.47395167, 0.3143866, 0.22740832, 0.6966375, 0.26059666, 0.018930554, 0.3863894, 0.029995646, 0.5642963, 0.7786422, -0.05709087, 0.39049065, 0.939331, 0.3473389, 0.53421986, 0.10424597, 0.8702912, 0.060252476, 0.6719683, 0.34357366, -0.9193921, 0.97310406, 0.8767175, 0.8196437, 0.9532414, 0.22392152, 0.7259149, 0.88370585, 0.42604586, 0.80053693, -0.8921038, 0.42025873, 0.54220104, 0.2018031, 0.17899537, 0.8838203, 0.29883677, 0.5596908, 0.42721438, 0.43561155, -0.9325316, 0.0030762074, 0.37558094, 0.36504367, 0.8109921, 0.78945297, 0.2860374, 0.10448979, 0.8103827, 0.9286408, -0.59050864, 0.733121, 0.91811895, 0.75881505, 0.35929412, 0.50084764, 0.4376691, 0.40776464, 0.7433961, 0.036675144, -0.29301566, 0.5026836, 0.6039498, 0.7637594, 0.8865383, 0.6368321, 0.8482896, 0.7375279, 0.16834354, 0.65039957, -0.8054092, 0.31060037, 0.6330381, 0.23635677, 0.41104206, 0.9163159, 0.5975231, 0.51167387, 0.008651535, 0.16378845, -0.93788415, 0.62142515, 0.07332315, 0.49740508, 0.21002825, 0.15898286, 0.5021398, 0.78338593, 0.842509, 0.67814773, -0.44615123, 0.8910721, 0.81629467, 0.39053923, 0.14259589, 0.42984807, 0.39912644, 0.61182153, 0.47850534, 0.17416, -0.94116336, 0.5485095, 0.93614626, 0.15998314, 0.12323159, 0.27990827, 0.10008287, 0.6817622, 0.34777302, 0.4429782, -0.9033245, 0.92599523, 0.39911312, 0.57960767, 0.09879101, 0.6715905, 0.4293604, 0.1065447, 0.55373114, 0.72755545, -0.13469236, 0.06490368, 0.89501894, 0.4901958, 0.20424834, 0.9143371, 0.4943057, 0.24249884, 0.093760885, 0.98119396, -0.5171895, 0.98570156, 0.03316852, 0.83449155, 0.22262509, 0.38937467, 0.6852789, 0.91334003, 0.3741735, 0.93012, -0.05889999, 0.8203776, 0.43561292, 0.3995308, 0.77482325, 0.52015597, 0.491959, 0.23668702, 0.29174823, 0.47100535, -0.0004876647, 0.29258174, 0.058090426, 0.75094986, 0.039467655, 0.8762597, 0.65349054, 0.44595045, 0.9557348, 0.20889449, -0.78560257, 0.857584, 0.5880013, 0.36657903, 0.9257887, 0.917623, 0.89282674, 0.56462157, 0.35698256, 0.70941633, -0.9863116, 0.51602036, 0.7323712, 0.62361115, 0.6686555, 0.31431475, 0.62929076, 0.4954881, 0.71537256, 0.68409234, -0.4223781, 0.2576187, 0.9507506, 0.6227555, 0.98070633, 0.22460775, 0.9276111, 0.28221866, 0.79502386, 0.34636542, -0.73588413, 0.23932843, 0.95760524, 0.165279, 0.1445174, 0.20131597, 0.23237628, 0.069033906, 0.47374207, 0.85720026, -0.62732923, 0.9273374, 0.8797045, 0.5823319, 0.48469374, 0.48446727, 0.5602105, 0.43447927, 0.08229436, 0.7251529, -0.24696892, 0.15800244, 0.7305779, 0.27164242, 0.78651637, 0.52798384, 0.9068334, 0.9652458, 0.3858727, 0.701181, -0.9900118, 0.61060804, 0.7695977, 0.010617126, 0.97353226, 0.74698323, 0.5584152, 0.56709224, 0.47909376, 0.46733952, -0.08193848, 0.56025684, 0.021746036, 0.8581723, 0.056763105, 0.49504068, 0.37791422, 0.36841872, 0.13806179, 0.49623904, -0.66439724, 0.49313185, 0.19992432, 0.06987098, 0.09939649, 0.5778817, 0.50875056, 0.6859628, 0.3787626, 0.6165335, -0.29448256, 0.2671305, 0.6831612, 0.77256113, 0.86718845, 0.016721206, 0.1577397, 0.86908734, 0.60879964, 0.73771054, -0.9260521, 0.9931183, 0.9553855, 0.6149548, 0.6432144, 0.6867121, 0.1362564, 0.8724056, 0.21487932, 0.2914757, -0.15006965, 0.53841466, 0.827184, 0.88963366, 0.03678374, 0.49687997, 0.41068372, 0.69972676, 0.9112206, 0.39565054, -0.23823264, 0.8724524, 0.18832962, 0.8625602, 0.17285694, 0.814808, 0.87709564, 0.24918492, 0.99098384, 0.0400419, -0.337301, 0.50882685, 0.7596191, 0.4003513, 0.5701869, 0.67127895, 0.5377463, 0.58496946, 0.42665657, 0.4126844, -0.4416253, 0.63634497, 0.47108346, 0.08728689, 0.4664639, 0.75606793, 0.4399465, 0.79352754, 0.7357774, 0.3703085, -0.6060375, 0.45801297, 0.9578667, 0.2131491, 0.49947786, 0.05359975, 0.8047887, 0.092825316, 0.4420979, 0.82840645, -0.80961645, 0.8870715, 0.88142174, 0.17483743, 0.95417476, 0.6412428, 0.7787956, 0.4268327, 0.31944674, 0.3655048, -0.9591336, 0.82571423, 0.2730702, 0.49853623, 0.95402527, 0.6018877, 0.4013689, 0.10104273, 0.39609635, 0.41678905, -0.37486148, 0.083568096, 0.5134075, 0.6206753, 0.43400443, 0.879288, 0.5509602, 0.54647, 0.9008734, 0.5165872, -0.86649024, 0.44492102, 0.14287159, 0.59825015, 0.60306793, 0.5545538, 0.7549232, 0.29624605, 0.13311216, 0.8252211, -0.97727233, 0.013113789, 0.4740808, 0.37027258, 0.41117483, 0.7803232, 0.18494278, 0.45933047, 0.25912383, 0.89759016, -0.65223086, 0.70374596, 0.696729, 0.02530885, 0.45354494, 0.72604835, 0.37366393, 0.2607464, 0.740833, 0.07488672, -0.09028263, 0.23232558, 0.5259593, 0.80285954, 0.49901456, 0.5142126, 0.6828427, 0.67482007, 0.8954683, 0.39947143, -0.8469645, 0.10512285, 0.96793056, 0.5708752, 0.43951672, 0.3617477, 0.6094873, 0.14313498, 0.2095005, 0.6536812, -0.69434524, 0.09162968, 0.28734615, 0.0032832306, 0.86435634, 0.1627443, 0.748192, 0.11756273, 0.14470519, 0.8770196, -0.1808899, 0.49417683, 0.55541307, 0.05822544, 0.73493844, 0.7449467, 0.48715448, 0.67122126, 0.871258, 0.8969622, -0.097480536, 0.5101227, 0.5638622, 0.8596524, 0.050625734, 0.547108, 0.7358154, 0.12585375, 0.5857921, 0.09179724, -0.11656108, 0.23052894, 0.051245883, 0.08715177, 0.38054147, 0.99865294, 0.9449794, 0.52267605, 0.93850327, 0.33627024, -0.7660206, 0.56527996, 0.5301148, 0.018448701, 0.21858154, 0.3527876, 0.5497098, 0.90970516, 0.8359368, 0.69457, -0.8745932, 0.93826604, 0.27187696, 0.3125383, 0.5562007, 0.1842225, 0.5277675, 0.42769375, 0.9526575, 0.3172483, -0.42692894, 0.6223383, 0.5317706, 0.05290796, 0.7604585, 0.95036095, 0.44293094, 0.46826127, 0.67768395, 0.7362855, -0.7999673, 0.96447843, 0.732718, 0.53498775, 0.13094164, 0.5322006, 0.9800079, 0.5454135, 0.64107084, 0.6978381, -0.9973982, 0.82611024, 0.28991696, 0.8912221, 0.21720403, 0.17829505, 0.95865196, 0.7387076, 0.5309511, 0.19631897, -0.47088546, 0.5172857, 0.5700186, 0.6212549, 0.90934134, 0.14368229, 0.033509336, 0.4772069, 0.25799018, 0.26822057, -0.9098567, 0.08144851, 0.23202117, 0.09965124, 0.8946027, 0.91011477, 0.20554802, 0.7368892, 0.18159665, 0.024000084, -0.20421462, 0.982354, 0.7866229, 0.2548194, 0.31985012, 0.6008187, 0.33242133, 0.64054847, 0.8357039, 0.58216345, -0.991709, 0.70422333, 0.93731016, 0.481365, 0.26540005, 0.2826816, 0.39445987, 0.1114631, 0.6256465, 0.9872593, -0.49869126, 0.502801, 0.2874233, 0.37285027, 0.78798145, 0.9159497, 0.5940891, 0.19026573, 0.99661946, 0.30708927, -0.972747, 0.22176278, 0.55711097, 0.50695103, 0.99210435, 0.48853147, 0.73066276, 0.31519917, 0.3014048, 0.30852264, -0.81126094, 0.39296088, 0.641503, 0.6758267, 0.27651158, 0.20563333, 0.14413832, 0.7506562, 0.83425117, 0.6119211, -0.5156549, 0.094084926, 0.111242734, 0.1943373, 0.52530885, 0.70141363, 0.6949307, 0.41377264, 0.46683794, 0.4039004, -0.006729609, 0.14215559, 0.643929, 0.52861464, 0.6094164, 0.7699462, 0.1471124, 0.43035918, 0.4892606, 0.7768686, -0.5520188, 0.07926069, 0.8100583, 0.31712383, 0.17599839, 0.105730385, 0.861298, 0.6115966, 0.096338674, 0.5823481, -0.77181137, 0.8434329, 0.35601455, 0.38469836, 0.79143435, 0.8786621, 0.11052005, 0.36277366, 0.9816422, 0.29069075, -0.7936008, 0.31689015, 0.84836125, 0.8975044, 0.30179304, 0.66910535, 0.7490319, 0.1128883, 0.06641029, 0.5065654, -0.058520928, 0.71377915, 0.26139554, 0.057382602, 0.059902266, 0.4363942, 0.28402662, 0.7941189, 0.018338913, 0.41957843, -0.84011555, 0.083334126, 0.31743395, 0.88448983, 0.632089, 0.16329671, 0.78614104, 0.2592306, 0.7371803, 0.7307543, -0.65942615, 0.7843387, 0.448717, 0.19856988, 0.9832678, 0.23512867, 0.23089947, 0.9125539, 0.015330798, 0.50689304, -0.3566985, 0.74840975, 0.5451863, 0.5897733, 0.5238272, 0.05803223, 0.5820373, 0.29863194, 0.3247961, 0.35504016, -0.5946355, 0.31640115, 0.34443474, 0.56206375, 0.45057517, 0.71026665, 0.99945617, 0.9638714, 0.26541534, 0.13849631, -0.8829643, 0.48980126, 0.375708, 0.33565596, 0.84713924, 0.2741822, 0.26506215, 0.06282568, 0.07411481, 0.8247736, -0.20549475, 0.37147272, 0.7787881, 0.5114459, 0.06287994, 0.09170583, 0.53814787, 0.72766066, 0.36066267, 0.5740568, -0.58125937, 0.4875091, 0.93443453, 0.38214013, 0.13611887, 0.343025, 0.439904, 0.88665324, 0.7479947, 0.27300113, -0.23567249, 0.26702806, 0.64713854, 0.8768345, 0.62392867, 0.8668972, 0.37270173, 0.20953032, 0.74263406, 0.249645, -0.79297006, 0.51921165, 0.22451714, 0.50002253, 0.14954542, 0.22316273, 0.53761303, 0.83298886, 0.4991838, 0.35886934, -0.17211881, 0.2717955, 0.6032087, 0.6913585, 0.5572369, 0.3954552, 0.55536675, 0.9935679, 0.19953707, 0.5041142, -0.83427817, 0.3784089, 0.314831, 0.80111367, 0.58910114, 0.93846667, 0.7243342, 0.90195364, 0.8875172, 0.19598271, -0.7190041, 0.3286175, 0.9850266, 0.11101766, 0.78108674, 0.06204771, 0.26299196, 0.434412, 0.23259473, 0.9129562, -0.805412, 0.6069152, 0.38746944, 0.38912535, 0.10088234, 0.96387696, 0.6638193, 0.95578, 0.31959754, 0.22847345, -0.3115305, 0.37913388, 0.009993258, 0.23851983, 0.4153668, 0.41456118, 0.20438069, 0.42340347, 0.9109214, 0.21107873, -0.49882856, 0.6356594, 0.94547164, 0.3032011, 0.6398653, 0.84350127, 0.28676888, 0.49219108, 0.91027176, 0.49518922, -0.13246326, 0.120954745, 0.76097316, 0.28658092, 0.6987022, 0.22736304, 0.99093944, 0.9257056, 0.7002313, 0.6252242, -0.27464733, 0.76855415, 0.5823561, 0.6590438, 0.8844522, 0.3398702, 0.31862426, 0.7465068, 0.6956509, 0.36652556, -0.857667, 0.8395885, 0.5234906, 0.021515984, 0.4141276, 0.16975257, 0.66144353, 0.084268354, 0.74926007, 0.25738105, -0.67710805, 0.17162827, 0.045508236, 0.8244083, 0.0960102, 0.19057575, 0.6181607, 0.72341233, 0.5398176, 0.18800376, -0.4236217, 0.27867505, 0.7231721, 0.28569725, 0.9364314, 0.73027444, 0.05330333, 0.28642786, 0.4187489, 0.29999506, -0.524877, 0.5402621, 0.7965402, 0.54374623, 0.6375222, 0.29287475, 0.59746414, 0.73945713, 0.87245333, 0.5289497, -0.56591946, 0.9066711, 0.17644554, 0.4428503, 0.94811606, 0.10301907, 0.7230459, 0.75794774, 0.5630336, 0.69387645, -0.7217095, 0.5952119, 0.20668921, 0.5076471, 0.9429038, 0.57899195, 0.116416365, 0.23779334, 0.08508458, 0.6838532, -0.11644924, 0.3750157, 0.6655195, 0.44926503, 0.73250407, 0.13684598, 0.37508807, 0.50176203, 0.1868861, 0.80313545, -0.59311163, 0.8787036, 0.850959, 0.0108679095, 0.62208426, 0.5169506, 0.10222952, 0.28032187, 0.3375812, 0.83341235, -0.0072284974, 0.2953556, 0.7233943, 0.7248724, 0.5782856, 0.9296651, 0.3335729, 0.28889313, 0.6008424, 0.05853025, -0.17645839, 0.3596708, 0.6543726, 0.18860014, 0.41250044, 0.19090378, 0.24115163, 0.7271805, 0.7103462, 0.8112701, -0.727931, 0.22128391, 0.5710617, 0.7598981, 0.10076484, 0.8430059, 0.7442529, 0.1958213, 0.8855628, 0.4259532, -0.47676244, 0.8360945, 0.90021217, 0.25167224, 0.67662466, 0.8210937, 0.6516214, 0.940647, 0.8709795, 0.802839, -0.8032731, 0.08619493, 0.9009196, 0.12835586, 0.62667704, 0.2334408, 0.224331, 0.6623589, 0.59836745, 0.4311805, -0.27579898, 0.37504902, 0.5699756, 0.5263111, 0.10548131, 0.7859446, 0.72429395, 0.96349615, 0.6241076, 0.7352797, -0.18541217, 0.13775158, 0.40333033, 0.17488916, 0.5817678, 0.34036386, 0.45945865, 0.40270033, 0.51197547, 0.59140676, -0.5392824, 0.3005046, 0.85620105, 0.9075073, 0.007996995, 0.6417361, 0.3203643, 0.44270578, 0.13322107, 0.86732405, -0.6186749, 0.08189404, 0.59745383, 0.4543823, 0.15015423, 0.10171343, 0.2661189, 0.37390104, 0.14619094, 0.8906801, -0.096799746, 0.68812525, 0.31653944, 0.13569976, 0.6174268, 0.6655215, 0.6828646, 0.72603047, 0.54658806, 0.28631318, -0.77398217, 0.8216307, 0.15038341, 0.0069607063, 0.8918981, 0.97529435, 0.518848, 0.6624684, 0.5183141, 0.46374524, -0.4655803, 0.28158814, 0.83027506, 0.75678355, 0.11660483, 0.10351813, 0.54029775, 0.948948, 0.024734931, 0.48005438, -0.074244976, 0.0855576, 0.2565094, 0.62129533, 0.49460703, 0.85115707, 0.98396516, 0.7205013, 0.2900805, 0.34247547, -0.9588715, 0.5943338, 0.89611775, 0.8469079, 0.09334188, 0.79704416, 0.9315106, 0.59049314, 0.5624842, 0.17485987, -0.5828654, 0.60365057, 0.85558695, 0.6824457, 0.4250998, 0.8152116, 0.8578502, 0.55975586, 0.01909494, 0.5139087, -0.12522376, 0.73391664, 0.7012955, 0.06653367, 0.2120682, 0.6884245, 0.5651213, 0.5290881, 0.51235366, 0.040741026, -0.9913292, 0.7983467, 0.3723879, 0.17583862, 0.50487375, 0.87124646, 0.3854704, 0.9833672, 0.66344166, 0.31956065, -0.1720075, 0.94980466, 0.38646382, 0.8498751, 0.89718896, 0.4705944, 0.22997065, 0.57406366, 0.19619557, 0.67939544, -0.9933069, 0.4242093, 0.70140636, 0.7761718, 0.21725173, 0.22495484, 0.89303833, 0.82958406, 0.6348397, 0.40491733, -0.23192288, 0.40242258, 0.07813944, 0.5217432, 0.18353066, 0.7845187, 0.23126268, 0.6797483, 0.17757194, 0.55385333, -0.42974123, 0.874483, 0.8963142, 0.6995343, 0.34190118, 0.17541912, 0.34745282, 0.85142046, 0.16934472, 0.7414738, -0.4584539, 0.99105763, 0.33289248, 0.8329583, 0.04743413, 0.5671199, 0.09694037, 0.5962161, 0.9585869, 0.2799189, -0.9782081, 0.5558863, 0.3485275, 0.25852436, 0.08763776, 0.76958495, 0.8716652, 0.86472064, 0.6663444, 0.1126702, -0.23933174, 0.55022234, 0.39649174, 0.64234227, 0.24965419, 0.118823886, 0.5278951, 0.0018720366, 0.43427062, 0.04183261, -0.877502, 0.04161787, 0.66023934, 0.8933659, 0.9464634, 0.24086526, 0.069530085, 0.24518117, 0.47430903, 0.61641073, -0.6875784, 0.6350466, 0.7211614, 0.89765304, 0.5756452, 0.87385494, 0.5259555, 0.63778985, 0.6118965, 0.5723162, -0.3037539, 0.48273215, 0.18507604, 0.05667453, 0.5021421, 0.90823156, 0.59456587, 0.69055027, 0.5833041, 0.92861027, -0.039224792, 0.095068336, 0.16194543, 0.9167543, 0.40241688, 0.93659025, 0.895647, 0.4551616, 0.31206095, 0.8467725, -0.7000548, 0.62648404, 0.39041162, 0.049933646, 0.42509183, 0.6042851, 0.8290609, 0.49883872, 0.06669706, 0.37579927, -0.5928684, 0.89010525, 0.3899755, 0.8619544, 0.7380787, 0.39476988, 0.8565418, 0.6035648, 0.39122385, 0.038231853, -0.64629936, 0.37897983, 0.6618771, 0.54569876, 0.577186, 0.59251004, 0.47310117, 0.8044071, 0.49523613, 0.6390549, -0.97820795, 0.07079393, 0.3257289, 0.765124, 0.8722614, 0.6772699, 0.092320524, 0.1351424, 0.6315827, 0.89785695, -0.07917066, 0.09572715, 0.6238532, 0.20750481, 0.33574188, 0.14911953, 0.70509285, 0.29999104, 0.1786756, 0.0076469877, -0.08004845, 0.29208216, 0.063937746, 0.27382907, 0.20047311, 0.32107502, 0.96460694, 0.84471285, 0.47274768, 0.8325818, -0.13118395, 0.024653764, 0.0036025788, 0.42764217, 0.39759132, 0.52207446, 0.56437635, 0.62485147, 0.989693, 0.060808785, -0.30244938, 0.7213994, 0.9719821, 0.49336693, 0.9590612, 0.5505722, 0.75512666, 0.4543723, 0.2099569, 0.42806646, -0.8874172, 0.17311013, 0.6257315, 0.48758915, 0.55900645, 0.68612576, 0.0068561803, 0.051899806, 0.56465095, 0.5511864, -0.71266294, 0.2476077, 0.6623947, 0.7990009, 0.76667297, 0.054516893, 0.092124574, 0.19621104, 0.80991346, 0.8136675, -0.58474314, 0.08024137, 0.31029803, 0.117866814, 0.70519763, 0.35864902, 0.32010004, 0.5705708, 0.3147679, 0.64990085, -0.56594837, 0.51023465, 0.6347559, 0.044681232, 0.94516456, 0.9580738, 0.39892223, 0.51601344, 0.8686357, 0.71146554, -0.51521826, 0.51247656, 0.06020054, 0.43850663, 0.3481458, 0.054841675, 0.059004717, 0.1729812, 0.7266939, 0.9045443, -0.45844766, 0.5589156, 0.6444588, 0.39628944, 0.8433233, 0.8071758, 0.8628121, 0.5078647, 0.78239155, 0.20035744, -0.36602575, 0.43628535, 0.7371319, 0.91475004, 0.985238, 0.20242831, 0.61285174, 0.6177135, 0.8538363, 0.8085992, -0.65559465, 0.57611114, 0.32757533, 0.09844793, 0.2984492, 0.07226656, 0.020040827, 0.87179136, 0.769721, 0.65035594, -0.2996443, 0.14711884, 0.8438769, 0.4102236, 0.1914532, 0.007032739, 0.8657759, 0.23846649, 0.20135792, 0.13798875, -0.09526171, 0.8910575, 0.7336219, 0.6682783, 0.34543982, 0.078932896, 0.77534467, 0.14545049, 0.45326862, 0.14571752, -0.44198993, 0.44129124, 0.31914487, 0.9180948, 0.24894963, 0.8823365, 0.23134027, 0.54601085, 0.09784024, 0.7710568, -0.787135, 0.99102074, 0.73814374, 0.13203558, 0.90071315, 0.2189069, 0.5924085, 0.32690832, 0.7232968, 0.97820526, -0.33665246, 0.37438527, 0.41635555, 0.71584755, 0.7133375, 0.76453716, 0.84248924, 0.6592971, 0.7530081, 0.2195163, -0.29692188, 0.87459034, 0.41852275, 0.62400347, 0.20836602, 0.8583531, 0.82797396, 0.9257821, 0.16127396, 0.3091167, -0.77569246, 0.31976497, 0.14062625, 0.43030116, 0.35085374, 0.104240976, 0.15291376, 0.6015863, 0.76756513, 0.12653293, -0.48652443, 0.44843635, 0.42215365, 0.47506335, 0.80906504, 0.06760467, 0.02493567, 0.6032973, 0.20475733, 0.48441246, -0.039847255, 0.5720432, 0.7930028, 0.8783239, 0.47413486, 0.91254467, 0.57249796, 0.11414025, 0.9236696, 0.042360075, -0.39093295, 0.6666264, 0.16563436, 0.41418016, 0.20251282, 0.016887465, 0.23375902, 0.9860544, 0.36499384, 0.60909647, -0.6116234, 0.24090295, 0.891732, 0.6264752, 0.7329919, 0.8484855, 0.45243672, 0.9434594, 0.8149384, 0.14076136, -0.8334174, 0.22467664, 0.72102475, 0.6768615, 0.26926944, 0.20364925, 0.52676225, 0.2623023, 0.95616627, 0.43830907, -0.531743, 0.03877351, 0.67791677, 0.72520506, 0.7356, 0.81989807, 0.282802, 0.007973485, 0.27255052, 0.7921776, -0.8338457, 0.038881265, 0.23830348, 0.59566087, 0.872789, 0.7989443, 0.68031126, 0.16652757, 0.14533207, 0.62564933, -0.46010798, 0.6290386, 0.29920182, 0.7829082, 0.20894268, 0.16625631, 0.94560164, 0.48877287, 0.14491072, 0.9988636, -0.49012524, 0.9714567, 0.029888112, 0.92668474, 0.07735347, 0.5728499, 0.5629862, 0.16652691, 0.8908752, 0.91309386, -0.56568354, 0.44446322, 0.67090887, 0.022760825, 0.3069157, 0.7945361, 0.9863731, 0.12536389, 0.80407244, 0.47032514, -0.523338, 0.36023465, 0.11697024, 0.33051696, 0.9782011, 0.9027044, 0.7395717, 0.89500856, 0.51626235, 0.5693437, -0.8742964, 0.7940291, 0.86306274, 0.27368698, 0.30205235, 0.86238897, 0.008993154, 0.31161872, 0.5183074, 0.29993913, -0.2359581, 0.51378435, 0.27565238, 0.23223823, 0.059965752, 0.01564475, 0.9581297, 0.276441, 0.4759925, 0.41440654, -0.17988315, 0.82023776, 0.68470037, 0.6745856, 0.47552556, 0.12989059, 0.85448647, 0.69937116, 0.94848365, 0.17464903, -0.83327824, 0.6679777, 0.65026456, 0.32153153, 0.038797423, 0.7716544, 0.58140045, 0.3972219, 0.7207085, 0.44452676, -0.78554296, 0.67475444, 0.6070565, 0.50413334, 0.23436703, 0.009553685, 0.08458229, 0.884732, 0.27055123, 0.96255636, -0.9445748, 0.46313068, 0.41901603, 0.10185582, 0.38946053, 0.05405868, 0.10932874, 0.18847717, 0.79816145, 0.17216177, -0.007902476, 0.30962202, 0.36313507, 0.34365836, 0.46666092, 0.5679804, 0.8635198, 0.9541208, 0.19344081, 0.2883113, -0.4342443, 0.5609078, 0.55573255, 0.03146575, 0.6288636, 0.50512874, 0.21318124, 0.18056706, 0.44021857, 0.46597186, -0.045308296, 0.96975446, 0.42881992, 0.9859273, 0.23007429, 0.37014756, 0.24896163, 0.54840875, 0.932071, 0.98473877, -0.6623257, 0.39292327, 0.5990605, 0.5485467, 0.4366243, 0.47592095, 0.31161934, 0.26339814, 0.037472416, 0.6663866, -0.1460339, 0.13046144, 0.6912912, 0.9822399, 0.528312, 0.38366696, 0.90739816, 0.3875503, 0.47299224, 0.88433176, -0.8408774, 0.92876166, 0.7482586, 0.33218956, 0.12685347, 0.038148023, 0.8808021, 0.37720776, 0.11358407, 0.09651337, -0.3190188, 0.31511107, 0.022049852, 0.20870206, 0.6259856, 0.041321024, 0.9618473, 0.007185834, 0.5948415, 0.15294261, -0.19350938, 0.9497831, 0.14309464, 0.77383196, 0.31993797, 0.91484684, 0.27846324, 0.44658, 0.45761526, 0.8464073, -0.46274942, 0.86141133, 0.075416476, 0.0477392, 0.14386131, 0.733564, 0.64466465, 0.26687092, 0.42169324, 0.39847627, -0.5951189, 0.9344116, 0.14981407, 0.94095904, 0.3473678, 0.83092284, 0.108411595, 0.48258916, 0.3562543, 0.48699102, -0.42181966, 0.9002123, 0.7927088, 0.32004964, 0.6908224, 0.8910943, 0.78566706, 0.9744266, 0.012251603, 0.21200661, -0.7596848, 0.4342221, 0.9195925, 0.26717675, 0.63376397, 0.45760745, 0.2396946, 0.97431064, 0.06484076, 0.8924216, -0.39665636, 0.6949764, 0.5854926, 0.1963652, 0.5578238, 0.2590978, 0.799969, 0.2021356, 0.42646417, 0.48901513, -0.8064353, 0.7958741, 0.0903257, 0.9706242, 0.42458767, 0.56253713, 0.068702534, 0.75536686, 0.3569168, 0.25276697, -0.94789696, 0.670238, 0.2546193, 0.2096866, 0.6387915, 0.16089676, 0.01481907, 0.8826373, 0.3071951, 0.8897603, -0.59122825, 0.13410094, 0.4177484, 0.4638327, 0.09033466, 0.72684324, 0.3147197, 0.5963436, 0.76222587, 0.43172458, -0.091125324, 0.58353144, 0.5479625, 0.52323645, 0.40557137, 0.9638107, 0.3438964, 0.9489683, 0.8425891, 0.07122685, -0.38890493, 0.48432773, 0.61739385, 0.8120738, 0.9445246, 0.7264184, 0.4403571, 0.375806, 0.55757374, 0.396927, -0.24427874, 0.9173317, 0.8949405, 0.5367038, 0.8977869, 0.6723343, 0.3781257, 0.626493, 0.88028955, 0.6977444, -0.24781741, 0.4723589, 0.993141, 0.9251922, 0.16164163, 0.36436552, 0.12227554, 0.73138285, 0.80411524, 0.6749808, -0.8170004, 0.06585078, 0.040048227, 0.23596825, 0.5008554, 0.10690048, 0.51670706, 0.6056746, 0.5193081, 0.3639163, -0.28648618, 0.9389137, 0.03876988, 0.36529887, 0.18744585, 0.17379361, 0.68859094, 0.011258623, 0.62544954, 0.733237, -0.585685, 0.7174034, 0.06867873, 0.14484468, 0.82340944, 0.916546, 0.49118677, 0.6922017, 0.65043217, 0.58015907, -0.60414284, 0.70897424, 0.57169074, 0.8825929, 0.5799266, 0.17842796, 0.8772835, 0.65897226, 0.03584844, 0.7908864, -0.15562724, 0.7724511, 0.10718488, 0.5163733, 0.41125825, 0.3089037, 0.43358904, 0.62784207, 0.73774636, 0.98784804, -0.6757746, 0.111016914, 0.10593328, 0.07087821, 0.08929581, 0.09959695, 0.99717206, 0.89520353, 0.4125588, 0.5843094, -0.6157137, 0.82450545, 0.95524246, 0.939149, 0.7597735, 0.5775119, 0.36722296, 0.15617695, 0.78537226, 0.009017896, -0.29651013, 0.029618707, 0.97541016, 0.83456314, 0.5776098, 0.8132339, 0.6102185, 0.55230546, 0.73358643, 0.51450574, -0.48295695, 0.86334467, 0.9544553, 0.6625841, 0.90438455, 0.49312592, 0.603041, 0.50081253, 0.7932971, 0.4803297, -0.1812559, 0.9820799, 0.24641345, 0.45153904, 0.1751727, 0.3311218, 0.81720865, 0.16803588, 0.7565998, 0.8337463, -0.9416807, 0.2774121, 0.8424698, 0.7287285, 0.6913379, 0.64615583, 0.13560674, 0.27137014, 0.4932684, 0.27606192, -0.48937842, 0.4448666, 0.16161712, 0.89805305, 0.10135246, 0.75236905, 0.87005013, 0.29265827, 0.034764472, 0.26664755, -0.9744709, 0.86641043, 0.3628798, 0.30504256, 0.827762, 0.31443018, 0.7832053, 0.5238711, 0.65939045, 0.246488, -0.9960252, 0.44218266, 0.7957057, 0.8998401, 0.572825, 0.20554484, 0.020874852, 0.22572684, 0.97124624, 0.2582287, -0.35751918, 0.33167085, 0.007544129, 0.5172352, 0.99095124, 0.73638934, 0.8204628, 0.34836042, 0.3501866, 0.4228037, -0.46107167, 0.5245504, 0.1332714, 0.48995224, 0.8592754, 0.07527029, 0.91453224, 0.53742725, 0.90096647, 0.3769077, -0.8629506, 0.6117356, 0.61197966, 0.2467804, 0.2800367, 0.047195755, 0.6491609, 0.261777, 0.32522804, 0.8958076, -0.7314942, 0.6443233, 0.32141203, 0.7765358, 0.90912837, 0.6428001, 0.85886633, 0.8456446, 0.31409132, 0.09137268, -0.49396735, 0.43484485, 0.17368458, 0.23658675, 0.78541636, 0.47147486, 0.30891126, 0.30575344, 0.040564716, 0.49755472, -0.2910126, 0.48344758, 0.32476038, 0.59433854, 0.39527807, 0.7457836, 0.71969116, 0.76076376, 0.23719852, 0.9437555, -0.087228395, 0.55868584, 0.023132376, 0.45437896, 0.6913095, 0.8167484, 0.20313835, 0.35673562, 0.58082384, 0.2164753, -0.21640398, 0.06888765, 0.22333595, 0.8095938, 0.88294035, 0.42810574, 0.43805102, 0.37539294, 0.46136406, 0.80856186, -0.7382845, 0.34340748, 0.2212123, 0.8276733, 0.60479504, 0.24804658, 0.3195629, 0.7270735, 0.3812577, 0.16334477, -0.92310894, 0.09810257, 0.6084461, 0.37033582, 0.004144284, 0.9352815, 0.41171247, 0.71930563, 0.54527724, 0.968668, -0.2683365, 0.9521756, 0.7249296, 0.8240894, 0.28115076, 0.22212493, 0.26011166, 0.5151666, 0.71139824, 0.9671723, -0.3077326, 0.3442982, 0.29939967, 0.42863667, 0.20547101, 0.7438209, 0.33747354, 0.19545908, 0.8495839, 0.44326293, -0.49718547, 0.4760649, 0.97547793, 0.4174791, 0.29336637, 0.11830141, 0.46044156, 0.85300016, 0.8054495, 0.9476588, -0.016393282, 0.7187454, 0.8301157, 0.49269608, 0.5402253, 0.78610885, 0.6184779, 0.39712286, 0.54652256, 0.3826701, -0.98793495, 0.80439633, 0.015675247, 0.4140854, 0.85561216, 0.5788107, 0.7987029, 0.17980942, 0.16486481, 0.26032335, -0.597808, 0.2162534, 0.86972165, 0.102014296, 0.47148252, 0.7922716, 0.97669774, 0.3074505, 0.53072304, 0.16284934, -0.7616834, 0.40711153, 0.7097171, 0.7637394, 0.950779, 0.58898723, 0.5141825, 0.8067036, 0.88841134, 0.41936216, -0.12534304, 0.94035065, 0.6489365, 0.46691382, 0.45532802, 0.69278914, 0.46038964, 0.56139255, 0.56186694, 0.7145557, -0.31959853, 0.28063214, 0.6881353, 0.54512614, 0.3498508, 0.8001399, 0.8490237, 0.7281014, 0.021213572, 0.7479538, -0.8094111, 0.31102738, 0.8663998, 0.38367322, 0.6209867, 0.5808234, 0.09467922, 0.25193584, 0.46330634, 0.26662496, -0.06462818, 0.99199927, 0.29139808, 0.74550265, 0.13498032, 0.65745735, 0.5673169, 0.40280786, 0.64668626, 0.7786934, -0.33188194, 0.4153052, 0.7455836, 0.8161674, 0.8432508, 0.48105124, 0.7189762, 0.16459095, 0.41388863, 0.15063916, -0.73996353, 0.78608114, 0.78549004, 0.14045759, 0.609951, 0.8143157, 0.07395084, 0.26526332, 0.8459271, 0.8745046, -0.5981099, 0.20845382, 0.098086186, 0.29524195, 0.6499275, 0.32759923, 0.98923403, 0.9426327, 0.41014582, 0.6923934, -0.23282301, 0.44621587, 0.08141512, 0.24252021, 0.4160718, 0.3941059, 0.5654438, 0.050232418, 0.5404224, 0.13993548, -0.8618472, 0.9300883, 0.8380472, 0.31266716, 0.52666146, 0.27854705, 0.20650926, 0.1509405, 0.13555165, 0.32066464, -0.5835065, 0.30205357, 0.5568808, 0.7721817, 0.18058343, 0.123428136, 0.31721902, 0.45034164, 0.16623993, 0.5156516, -0.4918172, 0.7763435, 0.75444514, 0.7214952, 0.91781616, 0.29374766, 0.704666, 0.5429698, 0.7243858, 0.21584511, -0.24887188, 0.02371842, 0.7248409, 0.7059916, 0.012657363, 0.6680217, 0.37040663, 0.785419, 0.7685805, 0.37138042, -0.12108998, 0.83829355, 0.80708104, 0.08948117, 0.108886935, 0.93076944, 0.8893351, 0.30923343, 0.061936773, 0.29264367, -0.07688689, 0.11510216, 0.8839925, 0.02477082, 0.64811826, 0.08550372, 0.17564313, 0.11655201, 0.39485103, 0.23291379, -0.57388103, 0.6635394, 0.42655468, 0.9197065, 0.071792774, 0.5597881, 0.57721263, 0.8508891, 0.75952435, 0.5125618, -0.75302154, 0.53180003, 0.6817611, 0.79485947, 0.3945616, 0.6535236, 0.9692625, 0.66496396, 0.61260825, 0.98704666, -0.40441254, 0.3954326, 0.48103306, 0.43174213, 0.13895822, 0.13376972, 0.13972592, 0.7000701, 0.05787335, 0.92715365, -0.49237853, 0.2538546, 0.390568, 0.5356667, 0.7974994, 0.45755056, 0.41173887, 0.8873745, 0.017688395, 0.54909885, -0.3535568, 0.038445998, 0.54970914, 0.549375, 0.5396221, 0.54508686, 0.43334106, 0.089132994, 0.6302092, 0.99459463, -0.11624123, 0.5106792, 0.50394374, 0.40780434, 0.8285013, 0.17844845, 0.18250638, 0.99481255, 0.7807483, 0.93802303, -0.42006215, 0.87714255, 0.7930158, 0.8323707, 0.020183232, 0.4991669, 0.14123203, 0.1460944, 0.9973601, 0.93701106, -0.24178477, 0.081888, 0.64727557, 0.06350941, 0.6334899, 0.36596653, 0.84572345, 0.931658, 0.89212, 0.59387136, -0.70042866, 0.050592937, 0.06986087, 0.063278705, 0.81091243, 0.98169935, 0.74991083, 0.98276365, 0.7071655, 0.6190509, -0.27504414, 0.41692632, 0.106626175, 0.07966534, 0.12903668, 0.47641423, 0.24543023, 0.71733844, 0.5291918, 0.040455237, -0.40385485, 0.28724664, 0.091772884, 0.69319814, 0.7528099, 0.034353238, 0.8634036, 0.44043434, 0.77431446, 0.46253473, -0.332725, 0.25084835, 0.10269255, 0.18687698, 0.23759438, 0.36946923, 0.8072817, 0.72973704, 0.021458272, 0.038483858, -0.7492561, 0.1584684, 0.43892893, 0.37830916, 0.6619669, 0.8248584, 0.9752618, 0.5676102, 0.93447274, 0.15707563, -0.120536305, 0.12838502, 0.40246627, 0.8516648, 0.19001648, 0.41318202, 0.95882004, 0.3766627, 0.31046882, 0.7765592, -0.11829578, 0.3094765, 0.20844917, 0.24463072, 0.28632593, 0.024195805, 0.31423378, 0.9197492, 0.84207094, 0.75956744, -0.66913253, 0.5156932, 0.6958802, 0.4907079, 0.29119918, 0.24538647, 0.8483177, 0.7134637, 0.031231258, 0.92795146, -0.059091415, 0.29579335, 0.5059616, 0.6172388, 0.34199843, 0.20433997, 0.84838206, 0.2510278, 0.9968605, 0.82441235, -0.41064918, 0.43061897, 0.41926822, 0.2448991, 0.92018807, 0.43977955, 0.95001924, 0.19429821, 0.09198324, 0.63777107, -0.51062465, 0.055512622, 0.72553927, 0.17490527, 0.48794308, 0.60484314, 0.43250486, 0.91175836, 0.5604656, 0.94463, -0.56486434, 0.24535634, 0.34543145, 0.38251737, 0.7174677, 0.82250243, 0.8035149, 0.59121037, 0.9026323, 0.081985965, -0.17581372, 0.06320599, 0.9228887, 0.017658591, 0.3489183, 0.23851357, 0.096424945, 0.45098105, 0.57051986, 0.8514196, -0.29536724, 0.6540195, 0.62148046, 0.39346015, 0.41732678, 0.0035787956, 0.5702541, 0.33105636, 0.12929575, 0.7371553, -0.7718351, 0.93662375, 0.6905622, 0.052230474, 0.25954804, 0.16529284, 0.08518753, 0.03675085, 0.52743137, 0.097685665, -0.6362647, 0.35880888, 0.2916659, 0.009997273, 0.46195737, 0.4474187, 0.13262391, 0.7078807, 0.825987, 0.24942951, -0.5084182, 0.9815238, 0.3412385, 0.70904595, 0.6492628, 0.9108448, 0.62387586, 0.9519713, 0.9651906, 0.71388894, -0.25224832, 0.4724585, 0.4619146, 0.16547702, 0.31015086, 0.23919, 0.37264377, 0.8706582, 0.7581105, 0.18362544, -0.15332605, 0.05967409, 0.9235497, 0.47283417, 0.21515496, 0.93655837, 0.3623536, 0.6114832, 0.93150276, 0.9699081, -0.8709549, 0.8623734, 0.5050694, 0.87986624, 0.2287371, 0.7903113, 0.5953852, 0.98151624, 0.40296772, 0.34870324, -0.541417, 0.13321623, 0.07156025, 0.81354237, 0.84543735, 0.16380614, 0.8968943, 0.12618889, 0.6998464, 0.22276738, -0.07477489, 0.2619657, 0.94977015, 0.6423615, 0.09610346, 0.4487441, 0.05797409, 0.8684043, 0.49389097, 0.7127044, -0.54849124, 0.012392659, 0.020468513, 0.99528253, 0.8429341, 0.3898749, 0.96738917, 0.58204836, 0.9367399, 0.5198395, -0.6438048, 0.39112753, 0.46769053, 0.40940732, 0.64220846, 0.02010981, 0.9881138, 0.11000732, 0.6273968, 0.051348828, -0.039664086, 0.2361647, 0.91163677, 0.7087354, 0.8951332, 0.6089892, 0.91260326, 0.86270785, 0.7837628, 0.779993, -0.73233724, 0.72698087, 0.48762527, 0.69026333, 0.800212, 0.5290243, 0.11274772, 0.07627774, 0.9706083, 0.45556244, -0.19641699, 0.31484595, 0.18944897, 0.18000686, 0.5789626, 0.6836474, 0.79427516, 0.54036283, 0.00015307916, 0.07599365, -0.46063024, 0.94796675, 0.24100749, 0.44254217, 0.67304033, 0.31232652, 0.10075587, 0.31173313, 0.100149296, 0.23394488, -0.47727165, 0.10468131, 0.79828554, 0.1567469, 0.78750235, 0.9168239, 0.9035022, 0.7774272, 0.6091953, 0.11318414, -0.9073621, 0.9118361, 0.139399, 0.17183441, 0.85493183, 0.7248181, 0.04671574, 0.7316299, 0.1297728, 0.21148583, -0.814714, 0.37224042, 0.8625547, 0.70776916, 0.31936276, 0.7843705, 0.4859734, 0.04508312, 0.017223012, 0.4878855, -0.42826846, 0.8010146, 0.97612846, 0.73666346, 0.9782908, 0.09173568, 0.51656044, 0.032702066, 0.3925045, 0.6621387, -0.7801451, 0.01684795, 0.93116754, 0.886969, 0.16863157, 0.54879415, 0.80856776, 0.06917309, 0.5876103, 0.94822216, -0.26561078, 0.36912593, 0.18196031, 0.8886635, 0.41923082, 0.1050312, 0.24212655, 0.09051639, 0.8373841, 0.0031318855, -0.4308505, 0.8584191, 0.7602042, 0.121309794, 0.68491566, 0.10634747, 0.9357077, 0.4027356, 0.19354361, 0.7631962, -0.2082577, 0.014013676, 0.3391254, 0.46763408, 0.43134072, 0.7978661, 0.44107288, 0.9755858, 0.5391376, 0.7705686, -0.9758027, 0.4168003, 0.4574728, 0.06900084, 0.22227472, 0.059142508, 0.6190543, 0.08746498, 0.3174326, 0.8732596, -0.84960914, 0.42604402, 0.19531794, 0.38937265, 0.2312882, 0.921726, 0.25664374, 0.8098577, 0.20205325, 0.06228409, -0.61308646, 0.40583217, 0.8756295, 0.8244142, 0.7399645, 0.2515971, 0.030000538, 0.7143262, 0.45732272, 0.6213647, -0.6639583, 0.26654074, 0.5513788, 0.0668155, 0.02732918, 0.014050223, 0.40094635, 0.69120336, 0.8990351, 0.6257732, -0.48729318, 0.8482427, 0.08530297, 0.320284, 0.91358703, 0.7822137, 0.8186957, 0.94975275, 0.2363459, 0.50961477, -0.54122233, 0.63121516, 0.77353257, 0.4768535, 0.15748215, 0.56997055, 0.54117084, 0.6330586, 0.32903638, 0.9706776, -0.02914197, 0.90472806, 0.6301423, 0.69606787, 0.20930128, 0.5830684, 0.8746652, 0.12850243, 0.36204344, 0.21723796, -0.5207796, 0.5654404, 0.9108227, 0.57628006, 0.5749909, 0.7648438, 0.3205292, 0.5553455, 0.91082716, 0.9577508, -0.43290135, 0.08024777, 0.47798032, 0.94770795, 0.0801424, 0.03274318, 0.49300817, 0.07452531, 0.90933335, 0.45735866, -0.4728794, 0.7678877, 0.362167, 0.9283575, 0.5966312, 0.5825651, 0.21810043, 0.3892351, 0.11098274, 0.33051863, -0.9075484, 0.6901933, 0.5877093, 0.019107932, 0.9888351, 0.9757819, 0.72039247, 0.19725248, 0.90186256, 0.39263836, -0.24944134, 0.98582536, 0.72223145, 0.3712856, 0.5377763, 0.9488942, 0.42674774, 0.68243426, 0.6159255, 0.1765581, -0.09006023, 0.8001399, 0.21916907, 0.9046848, 0.74435854, 0.7528919, 0.20327342, 0.9824652, 0.9796489, 0.9924258, -0.5467434, 0.9312941, 0.44436273, 0.58030856, 0.05020233, 0.742708, 0.49253845, 0.4588724, 0.95887285, 0.10436046, -0.31235072, 0.29575568, 0.17266272, 0.516695, 0.20791732, 0.48705408, 0.045656245, 0.9908814, 0.3905812, 0.647737, -0.15581739, 0.5356661, 0.77330965, 0.93442464, 0.2404584, 0.10740854, 0.47102425, 0.6830245, 0.27474937, 0.2359432, -0.7725085, 0.73792726, 0.21760361, 0.9094368, 0.845895, 0.31814724, 0.5414626, 0.14192294, 0.32108325, 0.7950682, -0.45635575, 0.96787536, 0.72356147, 0.511565, 0.8642074, 0.79430455, 0.62747717, 0.70247406, 0.6967675, 0.2573045, -0.7072357, 0.212392, 0.591884, 0.33191186, 0.8366084, 0.01107724, 0.15798447, 0.5099381, 0.33985013, 0.9427938, -0.27168378, 0.8095139, 0.18412302, 0.72292966, 0.33185193, 0.5744235, 0.078152075, 0.2632259, 0.67080003, 0.8897701, -0.94559145, 0.9037333, 0.66979814, 0.595513, 0.19138126, 0.18794204, 0.8121047, 0.26174462, 0.07021725, 0.44615385, -0.47993135, 0.76855016, 0.986257, 0.017444894, 0.5287075, 0.5601165, 0.1460432, 0.88569176, 0.07282839, 0.8348177, -0.16016278, 0.031524524, 0.80207276, 0.37828946, 0.52338445, 0.6468418, 0.7837523, 0.00063179433, 0.17971309, 0.2897839, -0.7161524, 0.3642513, 0.031674027, 0.8069974, 0.31171304, 0.8035024, 0.54259384, 0.9963711, 0.14053062, 0.6486664, -0.19897254, 0.8962398, 0.43972084, 0.8936963, 0.46286246, 0.5031336, 0.8232569, 0.16667813, 0.19422211, 0.7717354, -0.42838028, 0.19246033, 0.19039753, 0.8359823, 0.7296073, 0.9140669, 0.10166052, 0.29150867, 0.07212853, 0.54453945, -0.40418974, 0.8114729, 0.08203155, 0.78043336, 0.7300014, 0.11568007, 0.73687613, 0.1792596, 0.70573187, 0.7252052, -0.017522655, 0.14967212, 0.7451611, 0.42416203, 0.6358452, 0.26392296, 0.59180367, 0.9083765, 0.915427, 0.020250821, -0.8235849, 0.6170742, 0.80640966, 0.40797767, 0.86140364, 0.52369213, 0.17385374, 0.19569172, 0.07739012, 0.3976461, -0.70184183, 0.2510852, 0.92424256, 0.59599113, 0.24447663, 0.38749963, 0.81420827, 0.6592875, 0.16369487, 0.34718236, -0.76625746, 0.6439973, 0.46094626, 0.46901694, 0.75421274, 0.27870816, 0.44729918, 0.76623553, 0.20013711, 0.46568435, -0.32226324, 0.193284, 0.37608168, 0.051877704, 0.72095454, 0.7871155, 0.0050632227, 0.6740539, 0.9190297, 0.20630927, -0.94182634, 0.5411844, 0.10186948, 0.30808574, 0.023363324, 0.7664375, 0.22542956, 0.14916998, 0.17968538, 0.24834555, -0.44971466, 0.93251616, 0.74468166, 0.56824464, 0.25399336, 0.17958756, 0.15612793, 0.33739275, 0.6537649, 0.5826955, -0.07639295, 0.40761822, 0.9955546, 0.6117058, 0.07538286, 0.50855786, 0.8750035, 0.8723649, 0.8750366, 0.4573611, -0.38243642, 0.1401544, 0.7402578, 0.9573856, 0.40535605, 0.22507304, 0.54212785, 0.1528605, 0.44565362, 0.98777527, -0.05327858, 0.2981292, 0.5865501, 0.9517916, 0.015969688, 0.38974705, 0.44860238, 0.807837, 0.79788435, 0.541367, -0.6309876, 0.6676705, 0.02028897, 0.33633423, 0.12991633, 0.5342081, 0.5456298, 0.4901637, 0.2327029, 0.5148055, -0.89143395, 0.35306472, 0.27413338, 0.7223243, 0.86590916, 0.30956024, 0.1922584, 0.787296, 0.1628886, 0.02892033, -0.6374597, 0.0032674163, 0.89173913, 0.66598964, 0.5294169, 0.77826375, 0.8210681, 0.043763056, 0.5957361, 0.6856358, -0.05995547, 0.06716649, 0.07448051, 0.3336696, 0.8263735, 0.7147659, 0.11986544, 0.40392354, 0.8274693, 0.87114793, -0.67944324, 0.051964145, 0.9201576, 0.9308481, 0.096341334, 0.70021385, 0.02399584, 0.8642258, 0.08588241, 0.70640945, -0.19748867, 0.6613063, 0.6449484, 0.768964, 0.9039073, 0.6277202, 0.77593136, 0.35429934, 0.8069173, 0.3516526, -0.71314, 0.50186676, 0.8944276, 0.5470671, 0.45485002, 0.82426745, 0.2785842, 0.9404638, 0.8959508, 0.15114321, -0.18969482, 0.78833485, 0.9598267, 0.29174066, 0.3494771, 0.5854956, 0.0831098, 0.960891, 0.56964827, 0.829203, -0.7542679, 0.9568423, 0.9578806, 0.88932663, 0.48814714, 0.39864913, 0.42221805, 0.3055165, 0.42976233, 0.19865331, -0.93883455, 0.7655661, 0.5970062, 0.4758167, 0.15800795, 0.17757647, 0.15753652, 0.3730905, 0.47599813, 0.27207386, -0.42162967, 0.08353208, 0.96827507, 0.9347392, 0.51671463, 0.40915382, 0.7014796, 0.35320777, 0.4194869, 0.3184117, -0.5446104, 0.81504035, 0.78465104, 0.9777143, 0.5973847, 0.7562977, 0.54398614, 0.0051009622, 0.05891997, 0.05620089, -0.4020494, 0.9730677, 0.5107014, 0.69729745, 0.21230865, 0.4241287, 0.19132863, 0.48401004, 0.1337327, 0.17190064, -0.42795905, 0.7100193, 0.48489287, 0.29757443, 0.40757337, 0.67073584, 0.98856723, 0.023141444, 0.37261203, 0.07899332, -0.6971695, 0.06901029, 0.8860296, 0.11135061, 0.65404296, 0.12379419, 0.98091507, 0.6192919, 0.878432, 0.40171024, -0.63359034, 0.15243557, 0.31417054, 0.41979724, 0.87002444, 0.44856197, 0.5728306, 0.2709776, 0.7224305, 0.09258589, -0.21782517, 0.21746957, 0.21947508, 0.24758625, 0.8904527, 0.8345911, 0.3301475, 0.48707664, 0.57014096, 0.92664886, -0.7677305, 0.5208447, 0.6324889, 0.97992665, 0.35903138, 0.3330391, 0.0870381, 0.39935082, 0.043254532, 0.08851445, -0.44321367, 0.57203674, 0.60557806, 0.73202246, 0.5383103, 0.27552348, 0.39584875, 0.06509563, 0.42754996, 0.95901144, -0.09790518, 0.7175897, 0.3007109, 0.28002614, 0.86116815, 0.47969994, 0.8495352, 0.63844335, 0.22089794, 0.8194518, -0.7936467, 0.4938384, 0.049150985, 0.9517831, 0.6339798, 0.11274567, 0.51994663, 0.3342439, 0.060765848, 0.53698534, -0.36152387, 0.17347981, 0.22772305, 0.6339161, 0.6493722, 0.64578843, 0.6118915, 0.48745263, 0.70927596, 0.6149292, -0.43874234, 0.26505187, 0.05952667, 0.6111295, 0.8287437, 0.050140806, 0.22013378, 0.35246277, 0.1187585, 0.87933147, -0.4835039, 0.44859475, 0.1784529, 0.2238027, 0.29486778, 0.9493753, 0.52288574, 0.65379494, 0.09804267, 0.42556462, -0.75557685, 0.061604857, 0.0043297815, 0.8905646, 0.59748757, 0.92442536, 0.4898666, 0.6667948, 0.6306539, 0.21537969, -0.8678084, 0.3620826, 0.9291674, 0.6059688, 0.3807095, 0.5285948, 0.43431175, 0.43802148, 0.123039424, 0.583839, -0.8926119, 0.16748385, 0.2154854, 0.18143441, 0.05348144, 0.9129291, 0.99502695, 0.003920352, 0.33904833, 0.69999695, -0.12290272, 0.9580966, 0.38940993, 0.2837113, 0.85935235, 0.37713748, 0.2607221, 0.16896206, 0.013641968, 0.90431833, -0.5602742, 0.553339, 0.72180885, 0.9033788, 0.011523027, 0.1214213, 0.51942736, 0.57248414, 0.8430932, 0.76627296, -0.5150635, 0.084864266, 0.5307555, 0.51420367, 0.5329527, 0.588093, 0.84611946, 0.82289535, 0.83708316, 0.68455845, -0.9293985, 0.48594627, 0.32774645, 0.930657, 0.092476964, 0.9097118, 0.97267264, 0.6454561, 0.74661636, 0.003572011, -0.2678727, 0.2653497, 0.4243795, 0.2187211, 0.023564778, 0.3392729, 0.44567502, 0.31210658, 0.16991138, 0.9320601, -0.39350176, 0.42254278, 0.16082714, 0.57277536, 0.18493341, 0.03803846, 0.4273411, 0.87520623, 0.7507586, 0.27125937, -0.531018, 0.43782672, 0.33187887, 0.32908353, 0.97491986, 0.07432794, 0.22559255, 0.7911518, 0.8109018, 0.10181122, -0.14874865, 0.8739713, 0.8258678, 0.83952117, 0.49840027, 0.24971384, 0.6604848, 0.3120344, 0.4906389, 0.19367984, -0.14241797, 0.5340129, 0.65298396, 0.90502304, 0.2910567, 0.50685567, 0.3251191, 0.7549711, 0.7457236, 0.054438505, -0.4823707, 0.09746641, 0.8946975, 0.47535703, 0.472554, 0.83004594, 0.9334708, 0.09529597, 0.24380124, 0.9492368, -0.11368034, 0.6545232, 0.5012047, 0.06810016, 0.7833115, 0.5195305, 0.59667504, 0.32130596, 0.07437508, 0.9352196, -0.3775537, 0.11530671, 0.38456735, 0.5570788, 0.12884142, 0.9970051, 0.7848427, 0.42685586, 0.03802683, 0.4680642, -0.7492088, 0.47062147, 0.045428254, 0.75646335, 0.6194405, 0.05128224, 0.9792738, 0.35051075, 0.3669672, 0.66835433, -0.31624305, 0.56518877, 0.06823316, 0.5414021, 0.0799995, 0.4878948, 0.032808155, 0.5848838, 0.12171154, 0.7715262, -0.9101807, 0.0038131434, 0.680596, 0.810504, 0.67688483, 0.36706397, 0.7128991, 0.3376187, 0.3465156, 0.47554886, -0.04520323, 0.5066149, 0.05726915, 0.77573705, 0.200028, 0.6430589, 0.6090949, 0.7447414, 0.44865963, 0.73202926, -0.5402566, 0.24616429, 0.9543388, 0.40602076, 0.61897653, 0.8123649, 0.047073558, 0.8431653, 0.47707924, 0.6409466, -0.964197, 0.1999589, 0.3051443, 0.2665006, 0.5578835, 0.7453957, 0.7900255, 0.23492423, 0.07957853, 0.25237653, -0.33838317, 0.6416551, 0.0039951354, 0.89141834, 0.62315106, 0.80962807, 0.50791967, 0.29249611, 0.34137407, 0.4369406, -0.8787999, 0.28806677, 0.1362242, 0.3896823, 0.23126958, 0.66401637, 0.049474377, 0.27457523, 0.19152752, 0.8645199, -0.31999043, 0.8697338, 0.8605395, 0.70556897, 0.5113519, 0.84524435, 0.20147063, 0.79076856, 0.21785353, 0.4546323, -0.8530334, 0.3741707, 0.66516286, 0.1962831, 0.3936461, 0.89860153, 0.24216916, 0.062920436, 0.7828697, 0.8093484, -0.30444527, 0.75457746, 0.5017912, 0.040138636, 0.7621467, 0.6761302, 0.06373471, 0.915462, 0.035231, 0.89386714, -0.6959213, 0.51545024, 0.04339671, 0.21505861, 0.9323861, 0.46864936, 0.7811156, 0.29842615, 0.38006642, 0.7779068, -0.60815746, 0.7171511, 0.07464257, 0.88674176, 0.5839072, 0.5046292, 0.6229039, 0.9399411, 0.9960362, 0.33266804, -0.42184722, 0.9865539, 0.49170554, 0.38217908, 0.5600747, 0.565413, 0.36794263, 0.82040083, 0.94342226, 0.8352217, -0.78150964, 0.2860086, 0.75553757, 0.32398638, 0.758711, 0.3375832, 0.33077398, 0.45010427, 0.26389697, 0.92499673, -0.11748593, 0.943743, 0.682854, 0.004962936, 0.20119096, 0.58729416, 0.67993486, 0.6150494, 0.45623145, 0.25751752, -0.053226303, 0.12379362, 0.91942585, 0.702563, 0.47201994, 0.7093674, 0.023744669, 0.66121763, 0.65498394, 0.36697313, -0.10070673, 0.96071476, 0.3550039, 0.54484475, 0.99639714, 0.32214886, 0.96161354, 0.7506562, 0.12803078, 0.24632397, -0.17385522, 0.17279965, 0.6760441, 0.071039446, 0.2151821, 0.4781042, 0.30369994, 0.48674262, 0.18098812, 0.97278047, -0.8854781, 0.7528932, 0.3641694, 0.68590474, 0.7819954, 0.657716, 0.36658275, 0.05297459, 0.85196644, 0.049343612, -0.31383854, 0.6695563, 0.7951203, 0.89692384, 0.82429004, 0.15677115, 0.5887391, 0.13800927, 0.0085657975, 0.8790421, -0.6256806, 0.9292787, 0.48701864, 0.20990747, 0.083662316, 0.88042665, 0.4477495, 0.8483864, 0.48738086, 0.99391574, -0.40566745, 0.537002, 0.4802295, 0.6822035, 0.48149505, 0.34781352, 0.5965454, 0.66909915, 0.76284933, 0.33868113, -0.9555661, 0.90863895, 0.89868975, 0.07868716, 0.93248546, 0.50429887, 0.37767935, 0.77912027, 0.24674945, 0.05841095, -0.8893651, 0.16569066, 0.4781768, 0.301946, 0.34709984, 0.9561994, 0.26587456, 0.15426192, 0.6022424, 0.9015687, -0.20996648, 0.51819634, 0.5655937, 0.8580507, 0.64367616, 0.7768365, 0.18932684, 0.11291685, 0.4154288, 0.4764765, -0.5602257, 0.91964, 0.37515992, 0.6698847, 0.923476, 0.7170417, 0.030588947, 0.40833148, 0.27742204, 0.57936347, -0.5027473, 0.6686292, 0.60163695, 0.42896992, 0.10455062, 0.2399768, 0.058825243, 0.17828348, 0.3351036, 0.5252956, -0.08193896, 0.44228348, 0.06685673, 0.8612806, 0.12871465, 0.43736976, 0.34304523, 0.040639006, 0.435011, 0.15564895, -0.314972, 0.2647625, 0.36369145, 0.770273, 0.4981852, 0.96972513, 0.79053074, 0.80829215, 0.37847006, 0.63005817, -0.9256105, 0.85754305, 0.8768399, 0.022878975, 0.3988214, 0.54133725, 0.9165594, 0.1366238, 0.7535001, 0.40369937, -0.71801126, 0.011043364, 0.77781326, 0.89013314, 0.39453754, 0.11794228, 0.85278326, 0.5138793, 0.54117, 0.4861062, -0.37399647, 0.98994994, 0.9733205, 0.12177309, 0.26439142, 0.23798482, 0.30493778, 0.83136404, 0.9307847, 0.13482551, -0.44944605, 0.25053307, 0.7998134, 0.70504546, 0.5996852, 0.22439589, 0.5654436, 0.043977752, 0.4624592, 0.5873774, -0.52081037, 0.20642142, 0.2871389, 0.031311635, 0.43763772, 0.30392867, 0.48694924, 0.4735583, 0.37573543, 0.3802429, -0.11694187, 0.27665144, 0.26712215, 0.89236385, 0.25606167, 0.93566054, 0.8842226, 0.7550668, 0.7584876, 0.16083659, -0.23639946, 0.08519537, 0.20583908, 0.6186746, 0.9542533, 0.46747816, 0.21122995, 0.07276781, 0.29044798, 0.17014165, -0.5524987, 0.8088055, 0.0514201, 0.9537926, 0.9652958, 0.16757506, 0.70281106, 0.94200885, 0.6841354, 0.96046275, -0.7510356, 0.8313795, 0.45562857, 0.5505418, 0.017883644, 0.17279461, 0.9834109, 0.90744954, 0.44898376, 0.66402465, -0.34017327, 0.81037676, 0.28549019, 0.3016226, 0.35097796, 0.43561503, 0.00058234343, 0.6684643, 0.07705832, 0.97015953, -0.092698716, 0.41418144, 0.18311031, 0.20559378, 0.82774425, 0.30813637, 0.22523133, 0.31332958, 0.92706805, 0.08848662, -0.23284948, 0.9422138, 0.07093142, 0.7980248, 0.409801, 0.40501997, 0.6295668, 0.6552973, 0.600791, 0.7814587, -0.48406723, 0.3037804, 0.62378407, 0.62642336, 0.82996833, 0.7421219, 0.5233153, 0.74979746, 0.6028146, 0.5296808, -0.16699271, 0.03434674, 0.86495054, 0.71397585, 0.86776406, 0.33685416, 0.6482692, 0.2500348, 0.7227976, 0.70974725, -0.9475633, 0.6700813, 0.9803815, 0.36049715, 0.43117517, 0.39795953, 0.7394454, 0.4874654, 0.8918216, 0.94595796, -0.8060482, 0.3452851, 0.06767335, 0.29559964, 0.4860923, 0.7889183, 0.7903974, 0.556687, 0.3756254, 0.08562232, -0.7848211, 0.47543386, 0.71051496, 0.3973873, 0.9214939, 0.19850273, 0.07726323, 0.3569556, 0.9302608, 0.072946854, -0.7567508, 0.37953198, 0.9324997, 0.89104366, 0.8338954, 0.8139859, 0.32339892, 0.2632869, 0.19524816, 0.43200883, -0.002676534, 0.035849903, 0.8579759, 0.65685666, 0.7236325, 0.82170767, 0.9666734, 0.5693509, 0.22788355, 0.07884572, -0.54645675, 0.09158218, 0.8744094, 0.63717526, 0.9249262, 0.47212943, 0.9595664, 0.58299416, 0.43900326, 0.23267244, -0.3206963, 0.3824898, 0.55720466, 0.8188748, 0.18920717, 0.42651626, 0.41278538, 0.17662966, 0.46170422, 0.6721064, -0.4655194, 0.5271105, 0.3614388, 0.94361657, 0.08294579, 0.74897116, 0.617458, 0.053658314, 0.67375475, 0.09978627, -0.23182935, 0.50791234, 0.12907204, 0.85141504, 0.5264901, 0.66516864, 0.50512254, 0.29532441, 0.9661175, 0.36176598, -0.8544195, 0.7404047, 0.82428366, 0.96257573, 0.11131253, 0.62018675, 0.47864527, 0.039101128, 0.46764946, 0.29711628, -0.40892226, 0.7900437, 0.10764668, 0.55577713, 0.6133263, 0.019346252, 0.73014337, 0.9307928, 0.5542295, 0.17595504, -0.8546715, 0.90590805, 0.9092394, 0.33921698, 0.0008430821, 0.81278396, 0.25341776, 0.7057896, 0.29238465, 0.52403855, -0.9213937, 0.11746097, 0.21051219, 0.09993823, 0.8176869, 0.72511464, 0.70282686, 0.3988631, 0.83230406, 0.46275905, -0.2703259, 0.57835686, 0.58600885, 0.3766385, 0.690864, 0.44178563, 0.40026566, 0.5732949, 0.23808873, 0.50714386, -0.9350253, 0.57432973, 0.74109495, 0.79016244, 0.5070945, 0.9485114, 0.8311653, 0.48506665, 0.9617326, 0.29852858, -0.366769, 0.77285564, 0.74671644, 0.94361097, 0.3757226, 0.29146126, 0.57953155, 0.007708449, 0.7380902, 0.88821167, -0.31651938, 0.33128026, 0.09848877, 0.09147043, 0.90562916, 0.27631462, 0.31989923, 0.53260094, 0.648353, 0.5590575, -0.4125183, 0.68012285, 0.4677009, 0.7852408, 0.5890133, 0.34706393, 0.37636602, 0.42034975, 0.5928437, 0.86917543, -0.89394933, 0.21776019, 0.43713045, 0.5337755, 0.09599007, 0.49747026, 0.83164036, 0.6423979, 0.00091591524, 0.39940274, -0.8622541, 0.3925572, 0.83520466, 0.3498771, 0.19062445, 0.603745, 0.475841, 0.6496245, 0.8845333, 0.2307799, -0.6286122, 0.29856437, 0.83671373, 0.40267518, 0.8860103, 0.6866461, 0.30515477, 0.9614757, 0.3545977, 0.028658632, -0.9150952, 0.15918177, 0.41486475, 0.8689148, 0.9942623, 0.0987592, 0.8941498, 0.5647133, 0.99548036, 0.40815887, -0.44467425, 0.6775013, 0.531685, 0.24895021, 0.69680333, 0.019961093, 0.8449182, 0.1178238, 0.59461635, 0.98526824, -0.871223, 0.7267415, 0.53581643, 0.3620638, 0.24056326, 0.59538496, 0.38104647, 0.034455262, 0.6477652, 0.40934396, -0.19231549, 0.8701647, 0.28780022, 0.97225726, 0.48430753, 0.7030723, 0.9776925, 0.9662899, 0.3556148, 0.09186526, -0.7095952, 0.9111277, 0.65414417, 0.47637445, 0.78610563, 0.9511109, 0.7668794, 0.5877635, 0.7058718, 0.8660492, -0.8417279, 0.18733096, 0.3668593, 0.36932942, 0.15743567, 0.18835372, 0.62336534, 0.05280094, 0.6283515, 0.3988773, -0.7177127, 0.85969454, 0.9169481, 0.5861364, 0.21584338, 0.5745095, 0.3897011, 0.55942774, 0.7646427, 0.993731, -0.042268623, 0.8786283, 0.762209, 0.5027511, 0.27567303, 0.9600953, 0.072597355, 0.059442017, 0.57595813, 0.2894524, -0.82850564, 0.793283, 0.32858342, 0.78171605, 0.56761605, 0.0049845274, 0.50330544, 0.9184708, 0.8148216, 0.29595378, -0.07970701, 0.92489153, 0.33793837, 0.9567375, 0.37415254, 0.84990066, 0.9941796, 0.06800775, 0.26053104, 0.21159613, -0.5614098, 0.20745164, 0.8231208, 0.7121408, 0.82378054, 0.9630996, 0.42512196, 0.8641082, 0.09365638, 0.19734041, -0.11575636, 0.5639233, 0.4768428, 0.33889914, 0.5703717, 0.9244297, 0.5311111, 0.13523202, 0.01852037, 0.21085885, -0.071204096, 0.4712303, 0.74460614, 0.4686889, 0.914024, 0.117377095, 0.54068995, 0.80547154, 0.12859856, 0.4257724, -0.9659156, 0.0045896024, 0.798911, 0.36436203, 0.7280426, 0.621054, 0.9701622, 0.6164426, 0.9579355, 0.6045164, -0.5798626, 0.63919723, 0.82481444, 0.61748123, 0.18019743, 0.5157837, 0.44804874, 0.99903923, 0.3863658, 0.44972283, -0.31878954, 0.85894763, 0.049487386, 0.04967219, 0.14039204, 0.09017946, 0.4628455, 0.3544319, 0.7981168, 0.70640343, -0.42240968, 0.6196504, 0.73550963, 0.667884, 0.23142478, 0.11116676, 0.7650123, 0.112480775, 0.6108565, 0.9493177, -0.9542675, 0.9146685, 0.17729652, 0.41400397, 0.6309963, 0.43200687, 0.6464159, 0.12712492, 0.2884915, 0.3982403, -0.66932833, 0.54165065, 0.4191057, 0.67887574, 0.10698286, 0.10696802, 0.9551022, 0.7492388, 0.22396998, 0.63786316, -0.15820846, 0.6157303, 0.8183258, 0.25153205, 0.18210672, 0.9602121, 0.9036876, 0.15693043, 0.38605642, 0.06903067, -0.7507714, 0.33556795, 0.38818276, 0.43704808, 0.4954553, 0.40412104, 0.6816511, 0.63548344, 0.4186759, 0.70838517, -0.44376358, 0.3357206, 0.06594042, 0.39987648, 0.037075095, 0.88075906, 0.20054473, 0.05663389, 0.5609011, 0.124456756, -0.15606454, 0.015773552, 0.88851076, 0.9729933, 0.79110926, 0.33853722, 0.09634267, 0.9257645, 0.23189723, 0.6707842, -0.52831924, 0.48948547, 0.7410685, 0.2194608, 0.6474689, 0.3337604, 0.15346791, 0.98205763, 0.18342042, 0.70286185, -0.42531693, 0.3196188, 0.3305629, 0.5155848, 0.19409959, 0.82248783, 0.5497899, 0.41844934, 0.21445695, 0.3013477, -0.7596674, 0.8470537, 0.5960293, 0.26159966, 0.91296613, 0.7349978, 0.44705716, 0.41518942, 0.6459388, 0.1569181, -0.30777836, 0.7558866, 0.4035862, 0.7478917, 0.18006596, 0.9542781, 0.5946521, 0.8464796, 0.75240755, 0.7033147, -0.7272911, 0.2184871, 0.87321347, 0.8580393, 0.69913983, 0.83644575, 0.68521065, 0.372926, 0.77889377, 0.96862143, -0.7887473, 0.67789334, 0.7113075, 0.93054956, 0.9111168, 0.6812655, 0.89345616, 0.47946882, 0.30649468, 0.9124711, -0.88670325, 0.7382785, 0.33611885, 0.026502334, 0.39508346, 0.6694303, 0.9160326, 0.5826711, 0.33551884, 0.23982148, -0.22783574, 0.70331025, 0.6660418, 0.51114225, 0.57405657, 0.5411803, 0.9738403, 0.73799, 0.5624598, 0.07652036, -0.04978715, 0.07413118, 0.6362957, 0.6773174, 0.36817077, 0.629885, 0.044579085, 0.47303665, 0.836775, 0.49880046, -0.06082195, 0.115183294, 0.53998494, 0.83993644, 0.81661147, 0.98901266, 0.88236827, 0.84671116, 0.46295583, 0.029709496, -0.9204132, 0.10253954, 0.03740714, 0.5390723, 0.74078566, 0.08543706, 0.011851499, 0.20016527, 0.356493, 0.36993647, -0.70742524, 0.15546617, 0.917009, 0.22997431, 0.86268395, 0.81257206, 0.1019828, 0.65880144, 0.6583316, 0.7651984, -0.6248512, 0.44299594, 0.74589616, 0.8367184, 0.17899951, 0.11265245, 0.16332534, 0.8261054, 0.6945308, 0.5850439, -0.65881205, 0.12712914, 0.27503416, 0.53275037, 0.15610719, 0.9472476, 0.036724042, 0.0972234, 0.9365317, 0.2827337, -0.6180335, 0.8444138, 0.116543666, 0.46683854, 0.7913752, 0.9053558, 0.19817433, 0.3100106, 0.9772525, 0.0040394296, -0.8870298, 0.22356682, 0.18837956, 0.6977574, 0.40485826, 0.47741726, 0.35664338, 0.20068875, 0.36007276, 0.62813324, -0.92211175, 0.1857461, 0.5056345, 0.7714491, 0.7111244, 0.5802961, 0.880432, 0.3842586, 0.07386713, 0.9154364, -0.775848, 0.0047594067, 0.7222697, 0.37559786, 0.14716488, 0.7804374, 0.32645226, 0.27905762, 0.04534316, 0.27364373, -0.9144781, 0.8533147, 0.84885293, 0.6904914, 0.6980141, 0.43524522, 0.93874955, 0.57727677, 0.1278921, 0.67868996, -0.5906042, 0.8360353, 0.73715067, 0.30839851, 0.360622, 0.43228745, 0.33877933, 0.3450946, 0.7557141, 0.21107915, -0.024923787, 0.8139157, 0.23614348, 0.061816096, 0.22819144, 0.88227046, 0.5012971, 0.8127817, 0.55059254, 0.6244208, -0.15096499, 0.07758577, 0.15534559, 0.08642902, 0.7136551, 0.068797, 0.33689317, 0.8151431, 0.073435, 0.27587917, -0.6415465, 0.30315524, 0.25636652, 0.3951772, 0.32483214, 0.9398127, 0.26760876, 0.41387123, 0.014975904, 0.7148774, -0.4416581, 0.9813577, 0.5233435, 0.83426404, 0.24871995, 0.100562416, 0.6171712, 0.78703684, 0.4622999, 0.8157436, -0.93394816, 0.1259679, 0.026684225, 0.50347126, 0.527725, 0.5130184, 0.6806897, 0.6507216, 0.59474343, 0.29182497, -0.09539426, 0.52363616, 0.27165958, 0.47983494, 0.56953263, 0.72176856, 0.5575492, 0.8409663, 0.73698395, 0.28837872, -0.6146617, 0.08742587, 0.7978058, 0.8357151, 0.18276273, 0.16960731, 0.55424225, 0.32108158, 0.83770907, 0.61309266, -0.45162576, 0.54985636, 0.35284323, 0.25769138, 0.34193105, 0.5155786, 0.27647102, 0.75289524, 0.86745226, 0.8118137, -0.259123, 0.61688715, 0.8191278, 0.7231509, 0.6194832, 0.9180219, 0.7096981, 0.043508567, 0.26473138, 0.5269514, -0.5430132, 0.77620494, 0.05005288, 0.1739212, 0.20108196, 0.8465223, 0.32816213, 0.19096912, 0.32070854, 0.35811764, -0.9587762, 0.3596081, 0.81301254, 0.9816507, 0.84019923, 0.54553795, 0.17079297, 0.013968218, 0.13790388, 0.053954035, -0.44529754, 0.80465394, 0.9735141, 0.92517024, 0.029255724, 0.99777454, 0.26829806, 0.07465485, 0.21623193, 0.2647408, -0.45990923, 0.5107337, 0.056350194, 0.31075767, 0.07007945, 0.6754208, 0.49980345, 0.17892201, 0.056609415, 0.4954088, -0.18741646, 0.08550189, 0.4321867, 0.5093346, 0.85303754, 0.89951485, 0.8038746, 0.8374771, 0.88295174, 0.073945254, -0.7472289, 0.69572985, 0.90560466, 0.21077734, 0.08165387, 0.7383593, 0.80269086, 0.12488264, 0.14466548, 0.20330743, -0.5782242, 0.2535073, 0.9747372, 0.055967752, 0.8982084, 0.44804245, 0.30325794, 0.50225484, 0.91157126, 0.16477837, -0.045734458, 0.99187094, 0.9573588, 0.6424951, 0.8665376, 0.35979563, 0.37246728, 0.46417946, 0.0721327, 0.12974085, -0.19389993, 0.430821, 0.19170313, 0.14228667, 0.51751184, 0.76417935, 0.605129, 0.8455728, 0.2291038, 0.3317202, -0.87272996, 0.37492082, 0.034256544, 0.853302, 0.9171846, 0.9339092, 0.11076469, 0.37621894, 0.6111262, 0.40499508, -0.5962569, 0.30161974, 0.92590576, 0.7181733, 0.028210793, 0.755358, 0.7383711, 0.2631096, 0.34423977, 0.7218582, -0.365892, 0.3385114, 0.05274994, 0.014924624, 0.0094075035, 0.1474032, 0.061804168, 0.8324505, 0.5384559, 0.13402902, -0.84291345, 0.45768508, 0.27315107, 0.5798511, 0.29204842, 0.6708136, 0.9576144, 0.10405682, 0.7253105, 0.9326284, -0.24903095, 0.99624836, 0.8530533, 0.6671376, 0.5334839, 0.8922802, 0.50491524, 0.47352976, 0.114075884, 0.76215386, -0.025808325, 0.34201944, 0.50133306, 0.5072456, 0.9658282, 0.53421855, 0.32217088, 0.019331919, 0.8438945, 0.7697814, -0.872105, 0.27831417, 0.837763, 0.47709718, 0.56208163, 0.13857186, 0.028468672, 0.34605467, 0.42612493, 0.35739717, -0.79774356, 0.63431424, 0.5377991, 0.4116114, 0.4728273, 0.36964366, 0.48545814, 0.3856123, 0.48144072, 0.11712731, -0.64248794, 0.5882744, 0.71837467, 0.77630204, 0.1082207, 0.500894, 0.956352, 0.7659055, 0.6140229, 0.75782984, -0.34864277, 0.9382825, 0.26016235, 0.9555291, 0.06052337, 0.9707168, 0.15848531, 0.3759561, 0.10505597, 0.39491206, -0.86381155, 0.15886053, 0.047404833, 0.7566787, 0.96441025, 0.3914941, 0.8042203, 0.08972167, 0.0344183, 0.59618455, -0.0487604, 0.93655854, 0.5378912, 0.7267672, 0.12729345, 0.2838306, 0.5599395, 0.06146098, 0.3688765, 0.061187647, -0.18221985, 0.2625632, 0.7320318, 0.6682951, 0.008754399, 0.85946107, 0.3741519, 0.58227, 0.35108802, 0.5021105, -0.21115834, 0.10950206, 0.28055635, 0.08652866, 0.25331578, 0.48362744, 0.5408696, 0.9616959, 0.8118918, 0.7167266, -0.6966737, 0.8666303, 0.73148715, 0.017838325, 0.7090695, 0.4120842, 0.40039128, 0.5333952, 0.8282356, 0.77669275, -0.41077727, 0.09702433, 0.007079605, 0.043868326, 0.21269222, 0.6012483, 0.42682874, 0.37910977, 0.7479243, 0.10494917, -0.01734221, 0.22195028, 0.73863363, 0.5323078, 0.38502622, 0.93925834, 0.6560022, 0.45136255, 0.47345138, 0.643666, -0.74296105, 0.5982436, 0.24956919, 0.65214986, 0.36451396, 0.31558952, 0.531076, 0.71419346, 0.9592256, 0.5966702, -0.45906982, 0.8407567, 0.7540344, 0.5743953, 0.09133322, 0.114134, 0.10242245, 0.23668802, 0.87383646, 0.6520674, -0.056798704, 0.16175981, 0.2137716, 0.7069426, 0.6993844, 0.4747234, 0.1279967, 0.19917937, 0.6328121, 0.76981115, -0.756082, 0.94902873, 0.059943788, 0.1845696, 0.03373171, 0.8125337, 0.84745514, 0.35492972, 0.67935437, 0.8971027, -0.07017233, 0.7126353, 0.41988418, 0.15125412, 0.6458793, 0.1765855, 0.46791586, 0.16423836, 0.4409746, 0.27089223, -0.83683586, 0.4193142, 0.5775261, 0.82138395, 0.58686733, 0.58120126, 0.384472, 0.54262656, 0.95276546, 0.8897906, -0.1875928, 0.33189663, 0.08138137, 0.18941447, 0.8405882, 0.51004106, 0.7808129, 0.5694648, 0.54066354, 0.27879953, -0.26667887, 0.74749273, 0.55733365, 0.97673374, 0.5818951, 0.34416345, 0.74187565, 0.06251747, 0.061063267, 0.5227989, -0.0068075284, 0.96375835, 0.75820476, 0.36191988, 0.93297523, 0.3367678, 0.37150264, 0.23855984, 0.5977023, 0.45253047, -0.42806166, 0.30482855, 0.40216422, 0.7895638, 0.7095099, 0.7382757, 0.6312539, 0.23046969, 0.3106659, 0.13583827, -0.39577258, 0.89845103, 0.6235748, 0.16217506, 0.004213362, 0.08934315, 0.86198056, 0.60079235, 0.23948883, 0.24270387, -0.8393256, 0.32195452, 0.4815633, 0.4299666, 0.8829831, 0.22383447, 0.57369184, 0.7194615, 0.2564392, 0.5038204, -0.13853844, 0.5422531, 0.97176254, 0.0881331, 0.85073787, 0.9618503, 0.3453285, 0.76776993, 0.26722383, 0.8436194, -0.7129096, 0.51140594, 0.75185156, 0.925225, 0.1270263, 0.10835649, 0.34018353, 0.5960297, 0.35770652, 0.8436321, -0.47478724, 0.7707103, 0.999071, 0.35499844, 0.6132049, 0.106107146, 0.82326525, 0.97219765, 0.9065807, 0.48567542, -0.16458383, 0.9117924, 0.9740305, 0.8068454, 0.99729985, 0.8535195, 0.9266885, 0.5354417, 0.3114372, 0.04236306, -0.7440147, 0.09421062, 0.3335685, 0.3958694, 0.52979434, 0.32791966, 0.57010293, 0.5563383, 0.30294028, 0.77462655, -0.88365096, 0.97766215, 0.36175498, 0.41280714, 0.029033197, 0.36782816, 0.5431821, 0.61676407, 0.47492823, 0.7446307, -0.13858505, 0.37313086, 0.86118925, 0.7815484, 0.6790356, 0.8011172, 0.53737545, 0.94500613, 0.92792517, 0.27350682, -0.18166798, 0.8047418, 0.2845925, 0.31534344, 0.09961744, 0.38057664, 0.43714178, 0.6032016, 0.82520413, 0.28528523, -0.5360042, 0.26692694, 0.66925734, 0.13195412, 0.6020245, 0.18692169, 0.5500374, 0.5612233, 0.77781224, 0.62947166, -0.31033742, 0.30992442, 0.060513485, 0.5668065, 0.903778, 0.3708838, 0.2330214, 0.55202013, 0.71683383, 0.72867715, -0.79054415, 0.6250968, 0.62841314, 0.029433481, 0.59295857, 0.07890911, 0.69306964, 0.046411548, 0.3131897, 0.6484566, -0.9306864, 0.93998045, 0.79156, 0.189643, 0.20862652, 0.8716581, 0.7038735, 0.7292351, 0.1795239, 0.49211392, -0.25107977, 0.9761521, 0.16719387, 0.29845348, 0.9631694, 0.87174356, 0.74422836, 0.7177861, 0.41156542, 0.72873366, -0.14755523, 0.88512164, 0.8863678, 0.096526965, 0.49474105, 0.9109074, 0.6385138, 0.63982385, 0.53899556, 0.5231154, -0.49385205, 0.5036258, 0.24803366, 0.12935568, 0.6987853, 0.37035698, 0.5183644, 0.8708705, 0.35817996, 0.032119915, -0.66701025, 0.5037863, 0.37249622, 0.22471993, 0.47759736, 0.81439203, 0.45790294, 0.32995966, 0.06626411, 0.721215, -0.33468077, 0.97528356, 0.6348461, 0.584456, 0.50090134, 0.04556473, 0.053612676, 0.695033, 0.69490194, 0.29771915, -0.23314431, 0.064049676, 0.19023955, 0.6564085, 0.99826187, 0.7474539, 0.7281185, 0.037838195, 0.5996682, 0.5928124, -0.35337916, 0.87335783, 0.3596061, 0.37944552, 0.06172341, 0.6437689, 0.51262546, 0.66164786, 0.6189296, 0.680349, -0.45300442, 0.3085541, 0.57355976, 0.81778055, 0.18843463, 0.51856846, 0.8687797, 0.6635776, 0.6284543, 0.6532206, -0.3167443, 0.8233314, 0.17596854, 0.06046078, 0.7989756, 0.6029606, 0.31354675, 0.7160877, 0.22645807, 0.7301434, -0.086273566, 0.42006475, 0.7302915, 0.4734517, 0.36783585, 0.4613229, 0.6156775, 0.2554006, 0.5227326, 0.8571324, -0.53293926, 0.39196482, 0.07610343, 0.014552955, 0.84471476, 0.9245902, 0.49048993, 0.37245902, 0.4679739, 0.47969338, -0.8786742, 0.06454086, 0.40938383, 0.9464476, 0.2760681, 0.5300478, 0.6973893, 0.2991453, 0.5804699, 0.45876285, -0.33022216, 0.79653776, 0.43518978, 0.8887862, 0.59407544, 0.032939672, 0.5782626, 0.10010804, 0.44994467, 0.7271117, -0.902891, 0.6133791, 0.140845, 0.77132195, 0.12028129, 0.9247795, 0.74722797, 0.16141559, 0.21574605, 0.8743854, -0.11247064, 0.9410877, 0.24811381, 0.74676466, 0.8514692, 0.021732707, 0.010680916, 0.7838439, 0.19738361, 0.8377881, -0.7639336, 0.31653216, 0.6749307, 0.06396978, 0.52691025, 0.7364015, 0.956775, 0.18731725, 0.42047754, 0.8117751, -0.34632754, 0.39038187, 0.9225143, 0.7408622, 0.57680243, 0.2652951, 0.92369586, 0.6380619, 0.82616633, 0.35128862, -0.7828198, 0.5359737, 0.08339928, 0.7060845, 0.3462922, 0.38913444, 0.54842395, 0.6884251, 0.037316978, 0.5723427, -0.022258755, 0.79441875, 0.90272444, 0.61215657, 0.9631781, 0.5863588, 0.9384484, 0.07687521, 0.24441172, 0.38387978, -0.96800447, 0.5599107, 0.74093807, 0.403971, 0.5280579, 0.72208875, 0.018573398, 0.5072516, 0.16996226, 0.58617413, -0.09803684, 0.37261903, 0.95767754, 0.84609497, 0.05496832, 0.22795987, 0.23313288, 0.9688462, 0.7176776, 0.1377758, -0.18797757, 0.26834992, 0.15000027, 0.8481348, 0.7895163, 0.5519088, 0.48765746, 0.31035778, 0.77768403, 0.9904436, -0.32684666, 0.84682065, 0.39365014, 0.44228655, 0.38328415, 0.22290905, 0.79503566, 0.6794283, 0.17802662, 0.62420344, -0.37056103, 0.041172326, 0.51846284, 0.45114288, 0.47430587, 0.6496397, 0.8367412, 0.05662944, 0.5571883, 0.7352182, -0.35322595, 0.9696022, 0.35919765, 0.10663593, 0.19590221, 0.6996546, 0.40991047, 0.89280325, 0.6144547, 0.9761491, -0.23443131, 0.70821565, 0.7295676, 0.17951865, 0.25932744, 0.25121617, 0.97896886, 0.515391, 0.46281084, 0.83205926, -0.4329242, 0.55370456, 0.7908196, 0.093474135, 0.7672148, 0.14680524, 0.74988705, 0.69885737, 0.37382892, 0.13987659, -0.7151676, 0.431028, 0.75316954, 0.04246583, 0.63721764, 0.35724443, 0.48762304, 0.28701422, 0.24638435, 0.6836296, -0.8129986, 0.9022324, 0.064973645, 0.20187753, 0.38977212, 0.6623454, 0.31160477, 0.3389442, 0.19181544, 0.2230897, -0.6706708, 0.32135025, 0.5938186, 0.725129, 0.30229402, 0.7995213, 0.17878264, 0.2657235, 0.33942115, 0.04909697, -0.94976753, 0.7110531, 0.5189743, 0.47457805, 0.2609815, 0.8034033, 0.9550461, 0.6871017, 0.542301, 0.90208304, -0.76359314, 0.6919547, 0.2690066, 0.77918124, 0.019060668, 0.5306918, 0.48873094, 0.58894205, 0.703702, 0.104869366, -0.8352005, 0.41094282, 0.507042, 0.15073924, 0.46920577, 0.3938173, 0.8372094, 0.028040525, 0.7401718, 0.8376963, -0.17846179, 0.22189952, 0.9475931, 0.19728738, 0.7338621, 0.101945534, 0.3832581, 0.59039557, 0.94089603, 0.5863688, -0.7072993, 0.624503, 0.7966432, 0.28973243, 0.45949653, 0.9787162, 0.052343633, 0.81463736, 0.70606834, 0.7716022, -0.31079042, 0.5898406, 0.5620215, 0.23455179, 0.21389648, 0.5388247, 0.2040111, 0.36823508, 0.0053723096, 0.8671642, -0.9661939, 0.9270056, 0.94692993, 0.7046047, 0.72362125, 0.5416936, 0.7443616, 0.07171923, 0.04531915, 0.91711515, -0.1474337, 0.89833534, 0.648046, 0.11733318, 0.39757007, 0.21069747, 0.6142996, 0.21730955, 0.6912427, 0.49048957, -0.34147367, 0.022572042, 0.3219722, 0.9685696, 0.5269059, 0.5886212, 0.659878, 0.7130413, 0.98339087, 0.19503741, -0.89793444, 0.015023004, 0.5850233, 0.07373183, 0.62017494, 0.7802937, 0.6775731, 0.09203854, 0.5661112, 0.9178029, -0.2343546, 0.9806244, 0.7693182, 0.7889532, 0.6241685, 0.41245508, 0.9417946, 0.44468832, 0.8369817, 0.0031990237, -0.9245251, 0.98670155, 0.6769924, 0.51488274, 0.5256905, 0.9436219, 0.6050334, 0.97836035, 0.17769879, 0.13500004, -0.8818156, 0.0313203, 0.08832834, 0.8502817, 0.019180698, 0.13241069, 0.31331208, 0.5743142, 0.49715826, 0.6172764, -0.5331244, 0.5222611, 0.6511984, 0.7734398, 0.256135, 0.3608493, 0.25325385, 0.533019, 0.34440103, 0.114450805, -0.6468266, 0.2151897, 0.8760596, 0.9801919, 0.27051234, 0.9112329, 0.3380306, 0.07014053, 0.54804134, 0.6765531, -0.1752603, 0.69921273, 0.9143398, 0.43111116, 0.035987273, 0.2030343, 0.8922961, 0.91903645, 0.76977247, 0.49175784, -0.099143006, 0.3674804, 0.94753003, 0.21970531, 0.47007462, 0.40226397, 0.3355032, 0.9035526, 0.25874776, 0.16484123, -0.69036806, 0.07201438, 0.63395935, 0.063247986, 0.48817343, 0.6666259, 0.15526073, 0.10813647, 0.5797694, 0.10794782, -0.79438007, 0.24317154, 0.026272861, 0.8206052, 0.4420161, 0.8339117, 0.6079213, 0.22008722, 0.73745257, 0.053100668, -0.46855322, 0.33421737, 0.76324654, 0.8526432, 0.015307797, 0.27934623, 0.26765963, 0.65635425, 0.51011723, 0.86824834, -0.57572967, 0.43447804, 0.8113928, 0.38320008, 0.986185, 0.10324592, 0.06525337, 0.85109174, 0.94293773, 0.36936134, -0.047773577, 0.7841596, 0.33926708, 0.66182464, 0.69737774, 0.85597146, 0.34120753, 0.12692484, 0.7776892, 0.63616294, -0.79434264, 0.11541597, 0.16610004, 0.2056471, 0.696288, 0.35615066, 0.30876786, 0.78131616, 0.04794019, 0.2088272, -0.39896628, 0.49890646, 0.59801924, 0.711521, 0.5322181, 0.35990205, 0.43177876, 0.6430728, 0.8344202, 0.33877015, -0.76865834, 0.75682956, 0.2771495, 0.3680912, 0.005327093, 0.68439364, 0.9949503, 0.10142185, 0.15526544, 0.15933633, -0.9381387, 0.14073479, 0.87866503, 0.8739543, 0.07390571, 0.46031374, 0.268378, 0.6057457, 0.68691206, 0.6300343, -0.79447806, 0.28393722, 0.80315155, 0.73411053, 0.9703951, 0.5488671, 0.18614037, 0.6277461, 0.12960654, 0.33747572, -0.4241927, 0.6981348, 0.29250467, 0.43891907, 0.8675046, 0.037513115, 0.8382665, 0.79800886, 0.20032, 0.011894401, -0.3612004, 0.207346, 0.6260507, 0.88860387, 0.27068847, 0.25823146, 0.62024146, 0.72406495, 0.6376153, 0.0719044, -0.09152406, 0.82603306, 0.9561607, 0.20438583, 0.5442921, 0.4847211, 0.95367795, 0.54303896, 0.3976961, 0.45646, -0.49825326, 0.3672042, 0.9718153, 0.81778973, 0.73514366, 0.24000394, 0.8482301, 0.43974596, 0.006449677, 0.036392592, -0.62204725, 0.47036913, 0.4054257, 0.67501765, 0.26883397, 0.58713204, 0.6578865, 0.91454774, 0.46342203, 0.7121636, -0.92862564, 0.46207544, 0.9901308, 0.057702154, 0.24595165, 0.5981596, 0.74197406, 0.08811883, 0.894627, 0.38278353, -0.08383514, 0.2952275, 0.40031275, 0.74386, 0.5136412, 0.9939962, 0.2355307, 0.808261, 0.15346022, 0.030684536, -0.41000134, 0.1804955, 0.71761525, 0.6012227, 0.44985715, 0.6211549, 0.4206074, 0.28114304, 0.9355519, 0.95716006, -0.82683456, 0.03913026, 0.07961693, 0.6855325, 0.52783436, 0.036177807, 0.3770734, 0.91411316, 0.5718381, 0.13698402, -0.4980299, 0.76011133, 0.545119, 0.62366617, 0.95255744, 0.32681978, 0.07005637, 0.66156566, 0.16137652, 0.27483776, -0.35160136, 0.8496255, 0.7610875, 0.4327375, 0.30216226, 0.74813014, 0.74446017, 0.38890806, 0.607845, 0.62479675, -0.17755221, 0.46083102, 0.15256695, 0.9374669, 0.5559489, 0.04470488, 0.21561056, 0.7147803, 0.21602567, 0.47746333, -0.6169228, 0.32141757, 0.23642296, 0.016476203, 0.53265464, 0.64989, 0.6353765, 0.0939491, 0.64866525, 0.12303737, -0.5510985, 0.7590417, 0.11976651, 0.6607141, 0.6055587, 0.9772091, 0.27804276, 0.64687943, 0.38337022, 0.7797042, -0.29171762, 0.9881654, 0.30626813, 0.94704133, 0.9594318, 0.037198868, 0.60754436, 0.60765207, 0.06771721, 0.9078526, -0.1112092, 0.3552761, 0.44554, 0.6839132, 0.657915, 0.030183792, 0.6132026, 0.74461126, 0.9000829, 0.6522722, -0.112753615, 0.6505111, 0.74024284, 0.48480767, 0.073698185, 0.4185105, 0.3410645, 0.49185285, 0.33190826, 0.5787399, -0.7666621, 0.5687311, 0.33141005, 0.43632144, 0.18574573, 0.6287574, 0.01514944, 0.28938162, 0.057044394, 0.49545577, -0.042345677, 0.027724478, 0.026231889, 0.74081266, 0.011828165, 0.19582245, 0.31350172, 0.43585333, 0.0027991086, 0.5753749, -0.36400652, 0.5334315, 0.74679655, 0.731098, 0.6669506, 0.6412065, 0.24792254, 0.8214605, 0.8733431, 0.54092133, -0.6961343, 0.115691505, 0.27574378, 0.48897734, 0.14119047, 0.5424781, 0.02386607, 0.009218562, 0.49816743, 0.029157575, -0.015034353, 0.32382092, 0.6875669, 0.40462708, 0.6099266, 0.08502913, 0.6242792, 0.9994301, 0.4729795, 0.87787575, -0.10500878, 0.90521115, 0.48905376, 0.7565334, 0.21473333, 0.23323065, 0.8219346, 0.60031205, 0.76937085, 0.5445392, -0.38083488, 0.19368897, 0.41603848, 0.51612306, 0.7993214, 0.92665416, 0.75198066, 0.5372545, 0.5996222, 0.4693501, -0.17195638, 0.30428314, 0.9376859, 0.9736415, 0.5603405, 0.040185597, 0.8458646, 0.34216946, 0.12117143, 0.58192146, -0.016927328, 0.24849239, 0.34848097, 0.99546736, 0.43591255, 0.7909232, 0.62663776, 0.51921046, 0.274244, 0.9079598, -0.72054344, 0.42355403, 0.2398477, 0.95362824, 0.6483227, 0.8213454, 0.90778244, 0.17144382, 0.6053057, 0.68327236, -0.33304846, 0.08702466, 0.39980793, 0.0036293846, 0.7059194, 0.80072564, 0.96752524, 0.5154122, 0.19619283, 0.17454775, -0.38736606, 0.47976512, 0.4791406, 0.1874494, 0.52761185, 0.13234249, 0.845208, 0.4205711, 0.08021053, 0.00839825, -0.3000164, 0.23277025, 0.26301053, 0.6916624, 0.74880666, 0.74840236, 0.064435445, 0.98405766, 0.32531884, 0.73899513, -0.13240317, 0.6744208, 0.7368638, 0.43789902, 0.24887301, 0.9299027, 0.8486845, 0.34485158, 0.289548, 0.6351869, -0.82339793, 0.11122555, 0.3230176, 0.09969627, 0.52059376, 0.24077836, 0.9444134, 0.05239831, 0.42601636, 0.5159802, -0.9761374, 0.48721132, 0.09123329, 0.59690744, 0.383256, 0.1002782, 0.8240141, 0.70814556, 0.25482276, 0.957517, -0.7362902, 0.9834676, 0.19009337, 0.45719767, 0.042144574, 0.71294534, 0.7429013, 0.041241586, 0.9385764, 0.59770924, -0.28365803, 0.50035644, 0.13102308, 0.44502363, 0.18500035, 0.18879086, 0.90975267, 0.16331425, 0.17106864, 0.50802827, -0.80398893, 0.012037134, 0.55804133, 0.8093386, 0.7628578, 0.64519185, 0.58318746, 0.1399564, 0.05464305, 0.14859481, -0.10588853, 0.14053893, 0.09002884, 0.332031, 0.89889675, 0.8399303, 0.9211322, 0.86581993, 0.057551697, 0.8076484, -0.49787706, 0.90317184, 0.113821924, 0.82830715, 0.23232217, 0.47578096, 0.35618824, 0.64620966, 0.41190708, 0.19446513, -0.19052555, 0.6606999, 0.5370769, 0.74679446, 0.15352806, 0.72425306, 0.42542627, 0.3807547, 0.6943399, 0.39695272, -0.12975785, 0.6029449, 0.98659855, 0.78998154, 0.4918207, 0.1431191, 0.41032755, 0.7989921, 0.5461269, 0.34507003, -0.26765865, 0.043932725, 0.105762556, 0.36342022, 0.010151213, 0.90081716, 0.89821523, 0.7297342, 0.5770165, 0.2870768, -0.28900358, 0.9369778, 0.72804934, 0.86017793, 0.95806926, 0.44518864, 0.60346204, 0.34323436, 0.17850293, 0.17464367, -0.41450405, 0.5403775, 0.17148003, 0.660599, 0.6778906, 0.89493215, 0.9165733, 0.32384035, 0.33648646, 0.08920308, -0.06545341, 0.5571962, 0.10008278, 0.06683705, 0.92680645, 0.14659283, 0.5549373, 0.17365667, 0.73664325, 0.25271094, -0.8260378, 0.69569206, 0.80373824, 0.4072631, 0.10794914, 0.19278006, 0.8748956, 0.12642062, 0.8319123, 0.04663203, -0.53965706, 0.06709321, 0.6204891, 0.37148324, 0.93056595, 0.7272812, 0.8724527, 0.44516358, 0.68552965, 0.11521906, -0.98424387, 0.57437485, 0.39324772, 0.48781338, 0.22162339, 0.7318074, 0.836895, 0.66121227, 0.9333714, 0.81147647, -0.89025134, 0.42980537, 0.6065911, 0.925792, 0.3486058, 0.718812, 0.7366392, 0.7642169, 0.55264986, 0.4851105, -0.02003657, 0.79015267, 0.49192804, 0.28985444, 0.54954606, 0.9983602, 0.936707, 0.72859955, 0.13627109, 0.1995253, -0.27414012, 0.10977373, 0.48812705, 0.6214242, 0.26846707, 0.251663, 0.30244434, 0.31592485, 0.18563971, 0.3761417, -0.35588506, 0.2136833, 0.19304918, 0.020435851, 0.1563807, 0.10985168, 0.46050212, 0.69469714, 0.022877397, 0.211754, -0.99064195, 0.10823577, 0.89251375, 0.20041913, 0.09518249, 0.19409119, 0.082446806, 0.1033933, 0.93826735, 0.22326319, -0.7951004, 0.108295456, 0.5249412, 0.7338461, 0.53733635, 0.7804776, 0.94167835, 0.9851669, 0.6573249, 0.09694284, -0.41636762, 0.42071435, 0.5785772, 0.17650813, 0.12922545, 0.8063533, 0.5971035, 0.4714922, 0.13347372, 0.43969434, -0.53785807, 0.2420099, 0.70572215, 0.9245171, 0.20888333, 0.16590436, 0.21725997, 0.2877079, 0.5262417, 0.07437589, -0.16921617, 0.19905105, 0.3776575, 0.96237653, 0.58104134, 0.2475896, 0.6887421, 0.459203, 0.48309952, 0.3759031, -0.16817336, 0.47533524, 0.037372224, 0.92593455, 0.7953864, 0.5699276, 0.52965856, 0.7160056, 0.07119369, 0.28882924, -0.5969877, 0.6109546, 0.96991956, 0.498573, 0.68540514, 0.5530905, 0.40257332, 0.6004241, 0.52496284, 0.37143198, -0.56321764, 0.6539704, 0.45892516, 0.58294904, 0.9277267, 0.21731657, 0.043056846, 0.6162007, 0.5954668, 0.88163584, -0.11761114, 0.13790047, 0.98839265, 0.7575706, 0.271521, 0.06252285, 0.20463766, 0.7797876, 0.1291307, 0.6389557, -0.6362458, 0.5012543, 0.21651421, 0.23741248, 0.4773882, 0.5582616, 0.22913149, 0.8790845, 0.27697143, 0.02795082, -0.8450163, 0.08831802, 0.9342402, 0.11166756, 0.8126855, 0.51420295, 0.016410068, 0.4544232, 0.99820787, 0.5780698, -0.5268707, 0.9134579, 0.12053883, 0.18955784, 0.1712181, 0.45908722, 0.62256193, 0.21234894, 0.227052, 0.62288225, -0.34845284, 0.6227857, 0.4712934, 0.8860071, 0.73518616, 0.06196327, 0.4374562, 0.22151268, 0.10556084, 0.3694651, -0.9881851, 0.16397232, 0.3392293, 0.56751597, 0.036619555, 0.029293122, 0.20366028, 0.87672514, 0.94488513, 0.757318, -0.04611278, 0.75021446, 0.78157973, 0.5510609, 0.112084985, 0.7227879, 0.38071552, 0.026956385, 0.0661944, 0.01830097, -0.93569964, 0.016782548, 0.6520325, 0.65408915, 0.67949796, 0.22223058, 0.6170246, 0.048233118, 0.37648138, 0.7507222, -0.07674675, 0.7948974, 0.34886235, 0.6287428, 0.5898847, 0.36289844, 0.5742286, 0.55302286, 0.15293828, 0.14192496, -0.25542694, 0.74583685, 0.26746377, 0.46973395, 0.5767695, 0.59823835, 0.841206, 0.9202325, 0.7739221, 0.012398226, -0.6812478, 0.4104998, 0.15531828, 0.087259874, 0.43376547, 0.9714025, 0.5119398, 0.68514013, 0.888018, 0.814389, -0.4122685, 0.15542716, 0.5002437, 0.19416295, 0.6805713, 0.2512154, 0.4013521, 0.15283692, 0.96117616, 0.7491866, -0.14855935, 0.8276927, 0.8740181, 0.92426944, 0.762874, 0.18986279, 0.7493188, 0.18229857, 0.07731968, 0.08125962, -0.3810246, 0.6967921, 0.27431104, 0.36408317, 0.06947445, 0.66624695, 0.6395791, 0.2616025, 0.19497731, 0.6184822, -0.85095865, 0.88908845, 0.66500485, 0.33854932, 0.72965646, 0.099999785, 0.24559312, 0.07330083, 0.78916264, 0.32555407, -0.19688624, 0.6883691, 0.9590563, 0.024735536, 0.86383885, 0.8535551, 0.53648174, 0.23104885, 0.32438585, 0.24390268, -0.22208378, 0.32964125, 0.60782045, 0.8067584, 0.4333644, 0.71547633, 0.88111615, 0.13616055, 0.1246885, 0.014324361, -0.6116363, 0.13974965, 0.9578596, 0.34269398, 0.89822793, 0.25947088, 0.16268782, 0.53546876, 0.19461296, 0.6628742, -0.94426966, 0.67601794, 0.3931359, 0.7517656, 0.88437337, 0.6926555, 0.7377358, 0.2495755, 0.50024426, 0.21591938, -0.12976523, 0.40853027, 0.93721664, 0.95107466, 0.39639843, 0.52131736, 0.28126806, 0.85824645, 0.9051849, 0.01418011, -0.21888365, 0.10943257, 0.94861233, 0.77483827, 0.7139178, 0.057136595, 0.73050946, 0.61636233, 0.1265076, 0.60436803, -0.69086725, 0.0010129241, 0.036435887, 0.6615116, 0.299633, 0.54606587, 0.9365053, 0.85605484, 0.922385, 0.7407089, -0.9777405, 0.63154066, 0.63591623, 0.90876913, 0.88455915, 0.20310602, 0.20253302, 0.0067849625, 0.94629556, 0.37691054, -0.9782028, 0.30444136, 0.63028383, 0.18043286, 0.4439906, 0.8348371, 0.7274056, 0.61829764, 0.037847787, 0.8272368, -0.96214604, 0.12137349, 0.123067886, 0.8958763, 0.52505213, 0.1287523, 0.3720944, 0.275705, 0.65144163, 0.85033256, -0.58481205, 0.42521322, 0.93586147, 0.16447607, 0.036439568, 0.58734304, 0.47351632, 0.039843205, 0.8902792, 0.5108118, -0.8546036, 0.72372454, 0.6700668, 0.7495971, 0.6261652, 0.3864259, 0.3707291, 0.85600305, 0.21752104, 0.4647959, -0.81866026, 0.3182077, 0.818207, 0.09514821, 0.77856284, 0.85636705, 0.50847274, 0.74004, 0.38371703, 0.7558068, -0.83101165, 0.926828, 0.35534334, 0.09596299, 0.7920985, 0.5529896, 0.36857986, 0.46580777, 0.14399329, 0.85664755, -0.3613208, 0.6875624, 0.72801846, 0.527036, 0.9726332, 0.23842148, 0.45130673, 0.37347084, 0.26971108, 0.1386262, -0.7580232, 0.51609135, 0.058183976, 0.18664573, 0.031672336, 0.26660433, 0.6070062, 0.84071326, 0.38591322, 0.18007252, -0.07887025, 0.73347634, 0.6561262, 0.13447234, 0.67980015, 0.92777556, 0.3683812, 0.5741038, 0.95749855, 0.07317559, -0.017846042, 0.9049213, 0.7120097, 0.36087346, 0.10347511, 0.13109785, 0.5901893, 0.29117107, 0.12251501, 0.54014134, -0.40506032, 0.13500193, 0.4703289, 0.24509083, 0.9977836, 0.3149203, 0.868644, 0.16869761, 0.06429065, 0.52549416, -0.94598347, 0.5278666, 0.079894565, 0.9639208, 0.7777773, 0.62784445, 0.0314362, 0.5935461, 0.8472358, 0.04485763, -0.8700403, 0.8772029, 0.4159723, 0.1965355, 0.120780155, 0.8531019, 0.80408156, 0.6973105, 0.08317062, 0.9005745, -0.6764151, 0.3158351, 0.71819824, 0.84577185, 0.7750122, 0.94386834, 0.26314744, 0.41103536, 0.13668874, 0.36487988, -0.059131548, 0.19968359, 0.50981313, 0.4320044, 0.12719214, 0.48997945, 0.82502675, 0.74808896, 0.58309615, 0.47563064, -0.09966165, 0.9966431, 0.44393525, 0.07765738, 0.67010105, 0.5278574, 0.71902966, 0.27379337, 0.12431067, 0.14468168, -0.5108387, 0.1713335, 0.08552699, 0.16371617, 0.8490791, 0.63014835, 0.80966836, 0.23412272, 0.18890859, 0.833909, -0.364697, 0.62040085, 0.45685738, 0.48235595, 0.98572606, 0.6703567, 0.3673898, 0.9839679, 0.06934336, 0.6308007, -0.02807519, 0.0559926, 0.11421437, 0.60753995, 0.80091286, 0.67977196, 0.87189984, 0.6405409, 0.17567077, 0.24715477, -0.22483869, 0.9893541, 0.2867247, 0.9920071, 0.85404116, 0.887798, 0.114156604, 0.34609696, 0.5829253, 0.49704382, -0.6803111, 0.590904, 0.5591804, 0.7491872, 0.110933654, 0.4792608, 0.53978574, 0.9615793, 0.091931306, 0.99974436, -0.1604676, 0.73506176, 0.20445003, 0.49350995, 0.11660648, 0.4548461, 0.057119142, 0.47798702, 0.36280334, 0.16930713, -0.7582485, 0.16912746, 0.058451943, 0.9417538, 0.6090703, 0.37534294, 0.33367616, 0.4648503, 0.6283148, 0.09792804, -0.5562001, 0.021292835, 0.40104258, 0.57229954, 0.95048964, 0.4371712, 0.49681222, 0.36502722, 0.49660632, 0.32165202, -0.13998619, 0.9103205, 0.54860955, 0.17592642, 0.086687185, 0.48977694, 0.78490406, 0.79321474, 0.8754006, 0.39919505, -0.8306789, 0.63616955, 0.98329365, 0.41361818, 0.73879534, 0.5111836, 0.53245205, 0.6174266, 0.14011684, 0.7355907, -0.14558467, 0.074935436, 0.33326453, 0.99400324, 0.44354424, 0.13917476, 0.33401918, 0.6321505, 0.5430203, 0.6794353, -0.9580339, 0.69209194, 0.9813807, 0.041151315, 0.029320937, 0.8479279, 0.6205179, 0.8825255, 0.85506666, 0.11929336, -0.5904389, 0.5404614, 0.58944976, 0.22911972, 0.26724914, 0.92003053, 0.037999198, 0.9874244, 0.83350426, 0.439306, -0.9047191, 0.87938565, 0.22491038, 0.7610156, 0.17606735, 0.06505076, 0.577056, 0.5546063, 0.7323822, 0.94751245, -0.15575777, 0.15275358, 0.2501944, 0.19596528, 0.44116116, 0.13858697, 0.65478885, 0.9421423, 0.38429725, 0.89086735, -0.8906657, 0.64992654, 0.7623599, 0.020823486, 0.14515182, 0.6051233, 0.4854857, 0.10414482, 0.7267541, 0.52351373, -0.10117556, 0.34659478, 0.7986462, 0.10371433, 0.7747162, 0.078648254, 0.46718153, 0.22036512, 0.86508393, 0.9642702, -0.27087194, 0.06591158, 0.15014334, 0.9075542, 0.9635356, 0.4376853, 0.290267, 0.39348447, 0.78795856, 0.12866218, -0.26524165, 0.095856875, 0.6031271, 0.94263685, 0.54864025, 0.25479257, 0.11702571, 0.20408688, 0.6158638, 0.5709441, -0.57956505, 0.47291118, 0.8278522, 0.20886846, 0.8463369, 0.809163, 0.35410735, 0.14648008, 0.4212491, 0.36251292, -0.67140543, 0.43442374, 0.07705836, 0.42002708, 0.6199954, 0.8247542, 0.4997832, 0.8548057, 0.057287898, 0.7074665, -0.31485626, 0.09200123, 0.31618625, 0.59809196, 0.25827205, 0.0053186826, 0.7434676, 0.85600936, 0.5550741, 0.5199236, -0.96162254, 0.26309466, 0.60450137, 0.29413986, 0.38470513, 0.79796076, 0.23805939, 0.9412749, 0.061217327, 0.15437259, -0.083577976, 0.14378692, 0.9722354, 0.42544565, 0.45725676, 0.8308179, 0.018798511, 0.18310007, 0.32264143, 0.72388613, -0.75500935, 0.26221997, 0.146799, 0.90839726, 0.25608784, 0.48756382, 0.15672493, 0.22976026, 0.9505964, 0.8410182, -0.06569535, 0.498098, 0.591406, 0.90132546, 0.40089035, 0.40831077, 0.82992244, 0.7829185, 0.03532195, 0.8220347, -0.5866948, 0.55850834, 0.7935884, 0.9029153, 0.62388855, 0.17106935, 0.11976584, 0.8907406, 0.14083518, 0.42745417, -0.9865202, 0.5603676, 0.53336793, 0.83118796, 0.7649143, 0.6994026, 0.116295666, 0.69610405, 0.03805204, 0.8971413, -0.6412358, 0.008299126, 0.9906785, 0.22019914, 0.08867724, 0.58548, 0.5523809, 0.07090994, 0.024555296, 0.048945986, -0.0008954834, 0.23588002, 0.14777812, 0.5006067, 0.13719136, 0.19650105, 0.46863157, 0.24388368, 0.28450873, 0.08501847, -0.367798, 0.26598433, 0.08892508, 0.5231422, 0.854498, 0.50532776, 0.96473, 0.760218, 0.13641119, 0.7014878, -0.2920151, 0.13381833, 0.74486643, 0.13818067, 0.18079887, 0.57839566, 0.56782985, 0.5733893, 0.8142381, 0.038408525, -0.61868846, 0.048855904, 0.8661853, 0.091889195, 0.42655867, 0.75064015, 0.41258946, 0.0327612, 0.6939966, 0.5684132, -0.230771, 0.87241197, 0.41159534, 0.95303357, 0.5293433, 0.37525147, 0.91937405, 0.46753627, 0.3657011, 0.58334947, -0.62074995, 0.79216284, 0.9344987, 0.32306752, 0.7569309, 0.8670772, 0.49101356, 0.0095974505, 0.31980786, 0.5587957, -0.6286712, 0.8952423, 0.42964563, 0.24610022, 0.46633002, 0.31894207, 0.39979902, 0.99703586, 0.09658354, 0.10385787, -0.092738345, 0.9319688, 0.066221446, 0.567998, 0.47071677, 0.41960314, 0.722223, 0.79183286, 0.60883737, 0.8055474, -0.6590216, 0.10029357, 0.20768817, 0.2308886, 0.41765857, 0.82652557, 0.11435715, 0.5431178, 0.3349583, 0.55948156, -0.2596266, 0.402992, 0.7129533, 0.13520089, 0.939742, 0.33552873, 0.44276634, 0.16549513, 0.48670354, 0.2104012, -0.9754525, 0.9223382, 0.37095273, 0.26184326, 0.4906111, 0.68878114, 0.7259414, 0.3665008, 0.8523507, 0.33732775, -0.14485414, 0.69918066, 0.40076008, 0.5142605, 0.89977413, 0.52837765, 0.6875541, 0.19875702, 0.8284416, 0.6398044, -0.20458493, 0.8566812, 0.66207755, 0.537102, 0.84423125, 0.6897463, 0.2190155, 0.93102056, 0.62825596, 0.13518804, -0.9768368, 0.5567279, 0.30512935, 0.39843616, 0.83009493, 0.7366834, 0.72934085, 0.9458449, 0.7402775, 0.7288774, -0.100584194, 0.7478564, 0.69076705, 0.99763054, 0.41462737, 0.5604459, 0.002231921, 0.19869287, 0.23542677, 0.41136438, -0.6479746, 0.24400933, 0.33705348, 0.8468991, 0.0058162767, 0.11877123, 0.26026058, 0.83385074, 0.417612, 0.80086476, -0.46976563, 0.79492086, 0.73824483, 0.71716267, 0.36049098, 0.58812624, 0.3940513, 0.0023239073, 0.68416554, 0.1630907, -0.7990368, 0.74170923, 0.45847952, 0.0995642, 0.5392202, 0.45672858, 0.16591415, 0.664447, 0.12247461, 0.28378534, -0.6875144, 0.020322617, 0.6955938, 0.21689159, 0.48721343, 0.7328274, 0.21967441, 0.45823023, 0.39261988, 0.7113237, -0.47642282, 0.8954901, 0.52823293, 0.9394127, 0.25911182, 0.30566335, 0.009611528, 0.9736044, 0.63713956, 0.82650113, -0.16639459, 0.99990803, 0.5145273, 0.07233607, 0.6123276, 0.9062654, 0.7855298, 0.23748927, 0.30767888, 0.5490877, -0.9528571, 0.5958136, 0.71137613, 0.13382663, 0.11335034, 0.449443, 0.09932706, 0.52135324, 0.22994924, 0.6276635, -0.36845186, 0.93582106, 0.609704, 0.9728418, 0.68666786, 0.9035467, 0.21347627, 0.51906675, 0.8404524, 0.2335569, -0.44711703, 0.19230975, 0.027307436, 0.29597348, 0.11739075, 0.6876064, 0.5057953, 0.6232577, 0.604564, 0.58094805, -0.94729763, 0.9821851, 0.15055138, 0.8435322, 0.7584666, 0.8806093, 0.18411398, 0.3944063, 0.8260624, 0.8096688, -0.20633629, 0.48825827, 0.74365515, 0.009476059, 0.45804924, 0.23057352, 0.39020398, 0.5416855, 0.3856682, 0.7087808, -0.69278914, 0.26646304, 0.39703688, 0.074121974, 0.10197067, 0.76054734, 0.5685061, 0.41540262, 0.016435882, 0.42574394, -0.94364774, 0.47606933, 0.91678923, 0.6490012, 0.68036586, 0.38626674, 0.78526974, 0.7661718, 0.2143752, 0.80605865, -0.7194327, 0.81907, 0.69300437, 0.030783592, 0.027220597, 0.9588587, 0.4486546, 0.017831376, 0.83792424, 0.8868172, -0.2974024, 0.9641097, 0.23758952, 0.8957832, 0.8881589, 0.6808346, 0.5851483, 0.0764294, 0.74156153, 0.9979193, -0.3121031, 0.7687113, 0.37797043, 0.40031847, 0.86602104, 0.730267, 0.57146907, 0.094653964, 0.32911018, 0.07178252, -0.4453038, 0.62403214, 0.32731032, 0.5796096, 0.9893481, 0.87371916, 0.5734587, 0.3662533, 0.046901383, 0.14311191, -0.31189272, 0.5506748, 0.5774784, 0.12961864, 0.12834151, 0.97953796, 0.23847981, 0.021006035, 0.76084226, 0.99953127, -0.8011185, 0.7088403, 0.024610326, 0.21645589, 0.49395552, 0.9507214, 0.44109955, 0.2926859, 0.16476253, 0.29695365, -0.3873897, 0.35400063, 0.6887212, 0.7661417, 0.44151342, 0.67337024, 0.6367994, 0.65797997, 0.906435, 0.014439769, -0.10737592, 0.21889497, 0.029528014, 0.5984496, 0.6860266, 0.76142836, 0.19123298, 0.24835177, 0.27197698, 0.8864831, -0.49178717, 0.550463, 0.3338117, 0.32957888, 0.27066407, 0.7364635, 0.59942186, 0.11085444, 0.08565405, 0.03862678, -0.4326196, 0.28077278, 0.20149076, 0.7499477, 0.7557222, 0.95789206, 0.86195356, 0.8113367, 0.6881052, 0.45497125, -0.34273857, 0.5804998, 0.11457099, 0.7464025, 0.8921554, 0.5822235, 0.6793123, 0.42616072, 0.5304293, 0.7325272, -0.7594884, 0.19274779, 0.02070892, 0.27827948, 0.8051665, 0.83692664, 0.020188946, 0.35914233, 0.49547768, 0.70504993, -0.07394841, 0.525945, 0.5723259, 0.8678083, 0.5818202, 0.8266031, 0.017404223, 0.27958027, 0.84272736, 0.7281345, -0.8994748, 0.3798963, 0.5602465, 0.8170057, 0.5437445, 0.9112873, 0.43589205, 0.5874092, 0.4374235, 0.68844056, -0.057151183, 0.1732611, 0.58042514, 0.35312688, 0.2791384, 0.23987181, 0.26006386, 0.9232113, 0.94478124, 0.9187956, -0.93770313, 0.50281125, 0.31585902, 0.9830553, 0.38102284, 0.8167936, 0.008173941, 0.24676272, 0.16458233, 0.06555225, -0.5648193, 0.39973202, 0.58343333, 0.8022948, 0.8330524, 0.3795921, 0.63250124, 0.20370321, 0.734535, 0.8938792, -0.40103462, 0.43277976, 0.92171884, 0.8070371, 0.64789873, 0.9006873, 0.94551986, 0.21919903, 0.5886699, 0.34194836, -0.5665393, 0.09419294, 0.33479902, 0.92393184, 0.7904314, 0.39666355, 0.0640373, 0.5771913, 0.43598288, 0.7269509, -0.90311337, 0.18912931, 0.42282686, 0.37187123, 0.12362129, 0.65741915, 0.5898278, 0.77813035, 0.5200745, 0.8995463, -0.6073706, 0.056360655, 0.18867631, 0.05090209, 0.51776093, 0.5049234, 0.5810924, 0.5088219, 0.3351565, 0.48033553, -0.87127376, 0.7889749, 0.65809286, 0.822634, 0.49901298, 0.47062632, 0.064933024, 0.65950155, 0.0118634105, 0.43638885, -0.3155548, 0.055309944, 0.76772034, 0.007584079, 0.9907658, 0.2119053, 0.0099529, 0.5498476, 0.68341583, 0.9904796, -0.31085956, 0.16738948, 0.6991246, 0.6891236, 0.7345778, 0.5101786, 0.9055166, 0.28389692, 0.40617087, 0.285508, -0.8155711, 0.5552154, 0.24203478, 0.95564735, 0.8556771, 0.11413846, 0.53103644, 0.6001929, 0.8728583, 0.652995, -0.59248614, 0.9303262, 0.76626694, 0.083685614, 0.5839915, 0.55206066, 0.28864032, 0.18109223, 0.06013629, 0.30585563, -0.49497047, 0.031244803, 0.8254061, 0.34467688, 0.16947599, 0.70388424, 0.089850344, 0.9689693, 0.088056214, 0.9888344, -0.56510967, 0.7810361, 0.25333068, 0.72635543, 0.6208177, 0.7603394, 0.81327516, 0.812073, 0.15190694, 0.8766273, -0.68086886, 0.40976003, 0.6769893, 0.03042084, 0.39799348, 0.38053334, 0.40112254, 0.61543894, 0.10513203, 0.18251711, -0.22153829, 0.7244244, 0.22376063, 0.10031522, 0.79053754, 0.7843263, 0.7298093, 0.8973579, 0.7861713, 0.15179288, -0.024288114, 0.56206715, 0.51213664, 0.8840239, 0.08788527, 0.81145, 0.6769955, 0.039911535, 0.4628679, 0.82365215, -0.7387855, 0.47656733, 0.029185295, 0.18350895, 0.62498677, 0.08521046, 0.35425547, 0.7949853, 0.9466834, 0.78894264, -0.30276173, 0.4744114, 0.86383724, 0.9055391, 0.7672961, 0.8406853, 0.5572755, 0.15301545, 0.9358179, 0.83649135, -0.030530108, 0.9159173, 0.025901658, 0.00011405395, 0.8523392, 0.1188017, 0.89762336, 0.7929654, 0.9425356, 0.58654344, -0.7035378, 0.361211, 0.15257105, 0.2814799, 0.44373164, 0.744971, 0.6952391, 0.040251687, 0.47532842, 0.70532703, -0.43007088, 0.93482405, 0.9506745, 0.9972287, 0.84903115, 0.5498767, 0.6982299, 0.60659754, 0.116727814, 0.24719998, -0.25417453, 0.5239801, 0.10409364, 0.6263765, 0.79312205, 0.82286817, 0.45066565, 0.02907124, 0.33116972, 0.5061851, -0.1875871, 0.56129, 0.8524497, 0.36013994, 0.085404865, 0.94155073, 0.32184035, 0.58235735, 0.46180746, 0.022325099, -0.14544618, 0.5170238, 0.67768705, 0.23049083, 0.4064205, 0.09570609, 0.9652428, 0.028672969, 0.1510829, 0.30246252, -0.4205718, 0.2910258, 0.67623764, 0.69533557, 0.33236894, 0.17955771, 0.25711736, 0.5261945, 0.48835787}; +static int _rnd_count = 9999; +static float _rnd[] = { + 0.39540747, 0.841546, 0.52073574, 0.80399257, 0.95868486, 0.46164507, 0.5644759, 0.50258803, + 0.1953517, 0.40522006, 0.7953865, 0.7795385, 0.6009604, 0.03921096, 0.56872225, 0.93369347, + 0.7019503, 0.5392296, 0.2671585, 0.87286836, 0.28110227, 0.41505373, 0.8609184, 0.65234584, + 0.18079561, 0.1345461, 0.26905555, 0.97823226, 0.9349287, 0.37662244, 0.47883937, 0.1831086, + 0.63446456, 0.2549137, 0.8205819, 0.44705132, 0.7044422, 0.36040744, 0.29616997, 0.60375917, + 0.21973382, 0.094351165, 0.3769042, 0.9975177, 0.6133292, 0.3379986, 0.88620085, 0.83456165, + 0.16677794, 0.2749627, 0.28938183, 0.6274365, 0.058304083, 0.97233975, 0.48520145, 0.9803537, + 0.9806276, 0.8683899, 0.62319696, 0.82413876, 0.19258952, 0.5862436, 0.5676593, 0.8187293, + 0.9263807, 0.6122779, 0.14507395, 0.34604672, 0.21862903, 0.121670924, 0.22925124, 0.34154287, + 0.2430596, 0.66339934, 0.6531345, 0.1867511, 0.038149532, 0.8634007, 0.039016694, 0.84279704, + 0.24834526, 0.4344939, 0.8114543, 0.65996605, 0.08724063, 0.8514029, 0.12480451, 0.6621248, + 0.76971227, 0.8402282, 0.46642372, 0.83605236, 0.73721045, 0.47203118, 0.41116965, 0.6334902, + 0.52669185, 0.55817497, 0.07113702, 0.0010512439, 0.19292463, 0.5401541, 0.61593264, 0.045107026, + 0.04571145, 0.94783896, 0.3843769, 0.39490476, 0.3192052, 0.29845035, 0.9422042, 0.11722695, + 0.8293732, 0.7804, 0.5757935, 0.7580956, 0.7747893, 0.90769327, 0.73148865, 0.074977815, + 0.4874734, 0.48294914, 0.5763345, 0.37840083, 0.6552472, 0.39319888, 0.6043324, 0.77102846, + 0.25222966, 0.019644327, 0.6600592, 0.4799746, 0.7922636, 0.03796545, 0.64987236, 0.70819116, + 0.81856126, 0.7663473, 0.6142546, 0.13940167, 0.46702597, 0.72989976, 0.34291962, 0.47126192, + 0.89802396, 0.34919676, 0.0066791615, 0.95681053, 0.8962376, 0.653074, 0.85870093, 0.6189986, + 0.8266863, 0.9961592, 0.5135778, 0.7099755, 0.9638197, 0.2375318, 0.3898598, 0.65251255, + 0.34350657, 0.6133485, 0.14267509, 0.29956087, 0.6383911, 0.4622296, 0.3249633, 0.79140776, + 0.13052759, 0.8676024, 0.93953437, 0.008441999, 0.2934387, 0.592087, 0.6079518, 0.75757366, + 0.14002953, 0.10507256, 0.48037684, 0.30605045, 0.38651973, 0.64752185, 0.8747908, 0.59915566, + 0.1609434, 0.04106063, 0.65328825, 0.79610443, 0.5243876, 0.9398969, 0.7443715, 0.5810295, + 0.3764875, 0.961742, 0.7958951, 0.8536775, 0.58722466, 0.043358732, 0.8328708, 0.43579438, + 0.024233455, 0.21527143, 0.8262829, 0.028635254, 0.71353966, 0.85025895, 0.3255599, 0.23459937, + 0.38820738, 0.7560042, 0.569946, 0.8587471, 0.75715494, 0.083809346, 0.26599285, 0.6959847, + 0.73855764, 0.54351944, 0.13861747, 0.59733045, 0.80894136, 0.52885884, 0.26702014, 0.1906307, + 0.123230904, 0.35850486, 0.6319545, 0.3316967, 0.7961919, 0.7542743, 0.17034897, 0.0966708, + 0.27220175, 0.04458247, 0.28181702, 0.1712483, 0.82123893, 0.8461555, 0.88561594, 0.3106845, + 0.7155007, 0.4186889, 0.40789708, 0.76838344, 0.36995092, 0.8856244, 0.82387453, 0.29267815, + 0.69574916, 0.099910386, 0.11511985, 0.04370523, 0.9047413, 0.23554033, 0.62685305, 0.4953746, + 0.9482513, 0.63565224, 0.9054043, 0.3550348, 0.21830441, 0.9938632, 0.4384075, 0.633933, + 0.5856552, 0.47327515, 0.58654535, 0.71257246, 0.80199236, 0.09474454, 0.8747458, 0.8924021, + 0.6579035, 0.82793295, 0.88182974, 0.39025244, 0.12096177, 0.4986367, 0.8206798, 0.23760653, + 0.53463036, 0.33927637, 0.6359475, 0.6962815, 0.6391545, 0.12664375, 0.19192953, 0.036661416, + 0.41772944, 0.7864424, 0.222997, 0.18558672, 0.9407512, 0.5305812, 0.092380084, 0.7216375, + 0.9802814, 0.77396405, 0.18272822, 0.89667577, 0.29907903, 0.11130205, 0.4906858, 0.60100466, + 0.22516462, 0.22271773, 0.38580173, 0.07680829, 0.3537106, 0.23660058, 0.37441283, 0.4496146, + 0.81497246, 0.6677978, 0.82040447, 0.879028, 0.35791573, 0.742126, 0.9947786, 0.45901147, + 0.28134564, 0.54988396, 0.29484302, 0.015549939, 0.87174755, 0.68915904, 0.9516509, 0.12732233, + 0.7355529, 0.16019227, 0.40997103, 0.34699774, 0.31590846, 0.924004, 0.93852746, 0.4233283, + 0.84859055, 0.034942873, 0.47111684, 0.41643673, 0.740842, 0.115121245, 0.68295085, 0.18112887, + 0.41202956, 0.77338237, 0.3706143, 0.27295336, 0.7101767, 0.21335205, 0.36372176, 0.2381554, + 0.7791855, 0.72371674, 0.6153301, 0.7491951, 0.816459, 0.47513586, 0.7292571, 0.5360056, + 0.2710668, 0.25847942, 0.3412554, 0.19351831, 0.8266295, 0.0274151, 0.13370614, 0.8909684, + 0.72927034, 0.39707616, 0.030437447, 0.32297286, 0.27100918, 0.57834184, 0.71816945, 0.16622439, + 0.8669331, 0.11371415, 0.6035204, 0.09836516, 0.31854475, 0.6786976, 0.41714564, 0.5222008, + 0.7964705, 0.17181565, 0.56781226, 0.5921917, 0.30867395, 0.1893324, 0.6068693, 0.37345472, + 0.3056858, 0.9351113, 0.14536993, 0.4823626, 0.7738658, 0.4894325, 0.35449934, 0.38461447, + 0.6396763, 0.4796459, 0.54368305, 0.31310055, 0.18291461, 0.040748898, 0.9671462, 0.20084366, + 0.0055472897, 0.4491057, 0.882262, 0.7027449, 0.87161547, 0.6308919, 0.21746083, 0.59236926, + 0.8413338, 0.81905454, 0.3970478, 0.6548139, 0.45960286, 0.5415144, 0.58229446, 0.539938, + 0.7902069, 0.6569827, 0.017287076, 0.33589792, 0.4329719, 0.23580688, 0.39235854, 0.3775006, + 0.7592148, 0.2189059, 0.45868888, 0.83889884, 0.13501453, 0.10404509, 0.3392862, 0.7557216, + 0.20466943, 0.36696857, 0.5866444, 0.85956824, 0.3070704, 0.9041244, 0.5018392, 0.67479384, + 0.7176504, 0.5530007, 0.6410288, 0.9548113, 0.092384726, 0.69968545, 0.92501163, 0.09816185, + 0.89735144, 0.0037450776, 0.52289367, 0.5259319, 0.023461822, 0.6312483, 0.7678718, 0.7697404, + 0.05674718, 0.5047614, 0.9435301, 0.6527096, 0.17220303, 0.37856197, 0.45735472, 0.7372887, + 0.47976837, 0.6413262, 0.45014447, 0.09263428, 0.95487, 0.7227262, 0.23286755, 0.8860825, + 0.15514348, 0.34249324, 0.61824745, 0.8799712, 0.59477806, 0.43754727, 0.28511587, 0.059529364, + 0.2938943, 0.36052704, 0.9415474, 0.13126945, 0.5811514, 0.8133543, 0.7322598, 0.5734211, + 0.5990968, 0.816904, 0.80282104, 0.802309, 0.96059436, 0.8491296, 0.50259084, 0.33908847, + 0.09564596, 0.9037401, 0.4750429, 0.45105854, 0.24954097, 0.8323773, 0.14329186, 0.17462522, + 0.77087754, 0.63681114, 0.3707884, 0.6809686, 0.013000839, 0.8879006, 0.17496233, 0.61919993, + 0.21964556, 0.8840007, 0.3588153, 0.81167597, 0.43701455, 0.32608527, 0.15613726, 0.666414, + 0.9090664, 0.87672335, 0.4935375, 0.13796596, 0.9199052, 0.43055856, 0.9254882, 0.30601385, + 0.8399024, 0.279159, 0.78432524, 0.69103795, 0.9625043, 0.83405733, 0.8099884, 0.46151695, + 0.2172352, 0.7669222, 0.3603919, 0.9443403, 0.44256592, 0.0512912, 0.5604203, 0.7111962, + 0.64194167, 0.18362112, 0.5826634, 0.07659364, 0.49031433, 0.6909148, 0.9020739, 0.7695607, + 0.7476028, 0.80862886, 0.5419922, 0.3728176, 0.33883983, 0.005325912, 0.25472003, 0.34031895, + 0.711323, 0.064774565, 0.8410662, 0.73384184, 0.10357534, 0.48392436, 0.65669554, 0.38558826, + 0.07401231, 0.8972984, 0.5944408, 0.67009234, 0.96569335, 0.21179698, 0.22384812, 0.8577752, + 0.31630307, 0.7823413, 0.49602425, 0.7362841, 0.84789515, 0.84889454, 0.8156995, 0.14898759, + 0.3770851, 0.01476456, 0.94343513, 0.15387547, 0.29206514, 0.43717077, 0.12267711, 0.21190928, + 0.5122022, 0.020072967, 0.23301727, 0.37779135, 0.21022503, 0.82657844, 0.60762084, 0.15801735, + 0.52692556, 0.19707517, 0.0025813282, 0.59301597, 0.09647403, 0.23198159, 0.80386734, 0.5358059, + 0.58478075, 0.684217, 0.056514528, 0.5564985, 0.50930166, 0.51843596, 0.4924238, 0.8624285, + 0.24907504, 0.6920786, 0.35675675, 0.08881078, 0.5404892, 0.5028201, 0.0935231, 0.63684154, + 0.77462125, 0.38253152, 0.15789017, 0.94562036, 0.97877973, 0.84605676, 0.64755017, 0.48972467, + 0.17472044, 0.3380069, 0.2093585, 0.65081996, 0.8463132, 0.22268358, 0.052513562, 0.1451035, + 0.21089722, 0.40762928, 0.5690947, 0.60784817, 0.38065624, 0.56617856, 0.70260763, 0.99376625, + 0.52764916, 0.37058878, 0.1287163, 0.51814646, 0.4698217, 0.5188101, 0.61752814, 0.024105478, + 0.103552066, 0.3657398, 0.81839466, 0.7139425, 0.07409142, 0.858247, 0.55702615, 0.738724, + 0.03666682, 0.56678987, 0.38177812, 0.17129473, 0.30907747, 0.8416038, 0.016115308, 0.02639147, + 0.639565, 0.21165326, 0.87791353, 0.13285992, 0.9337254, 0.48567492, 0.2561853, 0.20844269, + 0.6799239, 0.16412394, 0.41797122, 0.60819095, 0.71734047, 0.12940371, 0.019902974, 0.6559104, + 0.7204788, 0.18525302, 0.5472679, 0.4805734, 0.4042889, 0.33857107, 0.07101207, 0.35265025, + 0.85060316, 0.8303707, 0.57118136, 0.8138664, 0.18440045, 0.5313129, 0.68468875, 0.68604535, + 0.35447347, 0.10232483, 0.8785814, 0.25816843, 0.6408965, 0.48466823, 0.09038009, 0.6178771, + 0.10955451, 0.609952, 0.034018606, 0.9099675, 0.44027576, 0.9488352, 0.021383535, 0.9072631, + 0.5468869, 0.72586775, 0.45081598, 0.12382444, 0.29433593, 0.5355419, 0.62210256, 0.30099395, + 0.14064118, 0.5252633, 0.28225678, 0.10335469, 0.91449356, 0.44231892, 0.024042243, 0.14861101, + 0.47943518, 0.7319259, 0.2537175, 0.6150156, 0.25082228, 0.76173455, 0.01501382, 0.23581055, + 0.09487294, 0.9293908, 0.3710189, 0.7943369, 0.30455244, 0.1610446, 0.9123745, 0.90176797, + 0.80898714, 0.66391826, 0.2669795, 0.4585327, 0.08049692, 0.5608643, 0.3917094, 0.8189315, + 0.48022225, 0.5775875, 0.11752723, 0.11563321, 0.20241146, 0.9870254, 0.70338356, 0.6672356, + 0.5859097, 0.88540757, 0.4305323, 0.7083498, 0.69511765, 0.4063679, 0.6564408, 0.7851523, + 0.71085393, 0.21500541, 0.028951503, 0.36494514, 0.16452302, 0.8277657, 0.9964415, 0.9795966, + 0.6128888, 0.38048878, 0.29436752, 0.25057533, 0.17533945, 0.56550956, 0.06811409, 0.9185709, + 0.3402165, 0.43478596, 0.13479339, 0.6732348, 0.64420736, 0.8993806, 0.033399098, 0.10784754, + 0.22600721, 0.7037833, 0.20842715, 0.41914487, 0.7305123, 0.20402466, 0.2066503, 0.40261927, + 0.007477421, 0.48182714, 0.74767876, 0.8654915, 0.5319128, 0.026764244, 0.6544085, 0.6524566, + 0.58114594, 0.13793063, 0.50274444, 0.82192266, 0.6926579, 0.45280823, 0.49189615, 0.020400187, + 0.8172935, 0.51196146, 0.36813334, 0.26033172, 0.27157453, 0.983206, 0.140945, 0.81147337, + 0.18160632, 0.92110395, 0.13893794, 0.46073973, 0.6193385, 0.5772967, 0.2490843, 0.40886414, + 0.1738385, 0.89174825, 0.24309792, 0.6935123, 0.8178308, 0.20262258, 0.38665804, 0.31345224, + 0.78037745, 0.48233682, 0.09208888, 0.50627667, 0.3966362, 0.21147643, 0.41518968, 0.77319896, + 0.21188715, 0.18802696, 0.60185134, 0.21855086, 0.8358913, 0.94631857, 0.13104475, 0.024271427, + 0.34088212, 0.9362054, 0.6838852, 0.61080885, 0.8878263, 0.1936688, 0.03311803, 0.0038492912, + 0.88884634, 0.09388026, 0.64808416, 0.8009096, 0.2097103, 0.79838383, 0.20256937, 0.61467093, + 0.1253034, 0.054681093, 0.47995427, 0.7892377, 0.8911171, 0.6346683, 0.41483715, 0.9701299, + 0.5059143, 0.36573896, 0.24885257, 0.43131158, 0.97544533, 0.03053343, 0.57297283, 0.2275199, + 0.7607035, 0.21882649, 0.3526302, 0.8816254, 0.5187374, 0.77584916, 0.42562595, 0.58670866, + 0.44921878, 0.08823959, 0.6174303, 0.30275592, 0.5633923, 0.61428005, 0.56348866, 0.41350332, + 0.9854576, 0.9871804, 0.093247466, 0.7812102, 0.4663643, 0.34180707, 0.13315432, 0.70621383, + 0.52136827, 0.7137553, 0.10489457, 0.52208734, 0.94481623, 0.60180646, 0.028403986, 0.8583129, + 0.5209074, 0.42056426, 0.04020609, 0.9908838, 0.44575363, 0.32094392, 0.09593353, 0.34945422, + 0.62905514, 0.89324564, 0.3400189, 0.80287755, 0.017237967, 0.112081215, 0.40673763, 0.8916342, + 0.80225027, 0.83534926, 0.44585398, 0.98826486, 0.93728596, 0.79176265, 0.7611556, 0.41889647, + 0.08567218, 0.64641637, 0.3602572, 0.80498207, 0.6709546, 0.9035386, 0.64189243, 0.84741235, + 0.0598356, 0.7591174, 0.7818485, 0.142828, 0.574074, 0.5726049, 0.96774966, 0.6645137, + 0.8912469, 0.74379325, 0.15215507, 0.5731187, 0.0017881524, 0.3302768, 0.6889758, 0.40928704, + 0.30701768, 0.21326037, 0.71983707, 0.10946698, 0.1559525, 0.040139113, 0.92102695, 0.7291448, + 0.6594087, 0.62130964, 0.9052116, 0.79933727, 0.9606867, 0.29095143, 0.6784996, 0.72551656, + 0.2513532, 0.49260658, 0.74304193, 0.25812054, 0.33023268, 0.2639096, 0.31756023, 0.22964539, + 0.86759955, 0.7813403, 0.097017966, 0.19349271, 0.63960755, 0.18803692, 0.4171083, 0.7553954, + 0.95744056, 0.9509702, 0.4979644, 0.45769426, 0.18370152, 0.53242546, 0.69145983, 0.019696489, + 0.8380905, 0.052703734, 0.48341933, 0.95276433, 0.6673932, 0.16841243, 0.70382696, 0.6002955, + 0.06529366, 0.42663854, 0.32176548, 0.50918156, 0.58723485, 0.4308553, 0.079054326, 0.04310807, + 0.89570016, 0.4901917, 0.24186741, 0.3746122, 0.94312114, 0.72753423, 0.08953723, 0.47137174, + 0.20420133, 0.14981624, 0.8418967, 0.009716521, 0.79298705, 0.22080535, 0.541815, 0.71892774, + 0.80114675, 0.72334546, 0.42003006, 0.27752897, 0.7804903, 0.36479586, 0.56225216, 0.69918716, + 0.07751329, 0.4967225, 0.12819904, 0.212969, 0.86627144, 0.90792674, 0.16816054, 0.5265852, + 0.8719159, 0.45485634, 0.56199414, 0.6935098, 0.29055804, 0.31684762, 0.07657534, 0.11055623, + 0.9631665, 0.012047576, 0.74856305, 0.517577, 0.32651573, 0.69411045, 0.80730844, 0.8444883, + 0.88482356, 0.60283774, 0.7080349, 0.8638894, 0.010825248, 0.80152535, 0.26261777, 0.53090423, + 0.92793953, 0.54268026, 0.29709893, 0.44639865, 0.5993352, 0.8765682, 0.6051003, 0.2962746, + 0.9816557, 0.31531146, 0.13780066, 0.3381307, 0.6588112, 0.84830517, 0.4283697, 0.48429912, + 0.6467701, 0.30947384, 0.31436247, 0.7684427, 0.6162329, 0.044675153, 0.3726714, 0.38340282, + 0.689414, 0.28371072, 0.32814547, 0.26343372, 0.19989188, 0.30427113, 0.51576, 0.07039049, + 0.19223855, 0.031089857, 0.7655703, 0.7478778, 0.019748688, 0.63017666, 0.511221, 0.08659828, + 0.40694728, 0.45228842, 0.53592134, 0.011204251, 0.5563098, 0.46917772, 0.18567711, 0.036518365, + 0.17446801, 0.22373573, 0.21711932, 0.7013514, 0.48716292, 0.49417505, 0.9146714, 0.88326436, + 0.17000887, 0.9136961, 0.7569846, 0.3156245, 0.54842275, 0.34166658, 0.09638273, 0.67738456, + 0.7995515, 0.06741016, 0.14589214, 0.62772137, 0.08273488, 0.680492, 0.46455044, 0.016593413, + 0.7982528, 0.22776419, 0.36149544, 0.16394442, 0.50875384, 0.36146715, 0.827093, 0.22023632, + 0.098033614, 0.2916271, 0.088965714, 0.9761561, 0.08715181, 0.8144086, 0.5832276, 0.6980635, + 0.11641844, 0.8823059, 0.5778689, 0.106052585, 0.8731921, 0.19559653, 0.5381755, 0.06528069, + 0.3559057, 0.8585367, 0.21165277, 0.48889965, 0.32328558, 0.55795574, 0.95378345, 0.49397606, + 0.7591853, 0.20052591, 0.9030986, 0.25939873, 0.13267961, 0.750727, 0.37451053, 0.8085417, + 0.086603075, 0.5367483, 0.21759088, 0.25679567, 0.25270087, 0.120226584, 0.59023273, 0.9851429, + 0.48418257, 0.44782865, 0.51130295, 0.20042898, 0.102623075, 0.35849786, 0.14340132, 0.6026563, + 0.68958867, 0.29621476, 0.8080387, 0.6502171, 0.14981438, 0.3381934, 0.8969507, 0.54007787, + 0.33784363, 0.59498966, 0.21697083, 0.8866259, 0.91130996, 0.32382888, 0.5653839, 0.36569145, + 0.5077954, 0.76932716, 0.01944951, 0.3364438, 0.97800565, 0.28137985, 0.8125798, 0.2356791, + 0.268304, 0.22650987, 0.00471706, 0.8754569, 0.04665282, 0.7533545, 0.39135298, 0.40068746, + 0.05712457, 0.3004423, 0.56981003, 0.8364648, 0.9426883, 0.7242934, 0.65872735, 0.7484097, + 0.63979757, 0.677513, 0.91895205, 0.6577112, 0.90325576, 0.70360684, 0.07383294, 0.1603537, + 0.88244474, 0.14561148, 0.6926336, 0.3332959, 0.33904833, 0.80695754, 0.62465066, 0.40820882, + 0.48363495, 0.5723596, 0.38191313, 0.9233045, 0.33347633, 0.021493766, 0.49342504, 0.5844891, + 0.20363668, 0.81628335, 0.82950133, 0.6108677, 0.75401884, 0.728919, 0.42300317, 0.7835019, + 0.11059984, 0.2710398, 0.6966462, 0.30049264, 0.3624278, 0.1548686, 0.33242336, 0.56469715, + 0.15267694, 0.84436333, 0.9930122, 0.9010413, 0.06072089, 0.058057077, 0.061639126, 0.25016704, + 0.6757917, 0.16160122, 0.3528299, 0.37032866, 0.34238032, 0.7354228, 0.41493335, 0.6183038, + 0.18408795, 0.3344629, 0.45407453, 0.08697238, 0.8741055, 0.46296528, 0.40633488, 0.1535257, + 0.7226083, 0.90913165, 0.22269607, 0.068008505, 0.1103113, 0.32415798, 0.045781024, 0.32876635, + 0.23993625, 0.817216, 0.77062756, 0.48911297, 0.028481547, 0.5923837, 0.52376825, 0.14557959, + 0.7546443, 0.5793343, 0.935076, 0.5924176, 0.37608913, 0.05267449, 0.44112164, 0.37517703, + 0.85610646, 0.078342445, 0.11640469, 0.02796489, 0.70079404, 0.24545097, 0.69059163, 0.68971163, + 0.43802848, 0.83948654, 0.17843302, 0.15158923, 0.835361, 0.99363065, 0.13985574, 0.3516337, + 0.115820184, 0.02406358, 0.13039242, 0.5251643, 0.96479523, 0.92582035, 0.58982223, 0.59170425, + 0.8106947, 0.30849496, 0.33232814, 0.2947712, 0.5278893, 0.8139172, 0.77743655, 0.6699338, + 0.46801004, 0.84751904, 0.21190204, 0.031968854, 0.2077533, 0.017816134, 0.62797225, 0.99448526, + 0.12662433, 0.080915935, 0.05108449, 0.18899502, 0.41395068, 0.372179, 0.3102186, 0.7610136, + 0.43947858, 0.5834423, 0.47659743, 0.35202554, 0.9222821, 0.9159573, 0.4103818, 0.9302861, + 0.4885202, 0.52470046, 0.21727021, 0.39229912, 0.91312283, 0.39582044, 0.16182233, 0.62411124, + 0.062049974, 0.5084992, 0.6835792, 0.98784196, 0.78172857, 0.10788689, 0.1438804, 0.09800406, + 0.3960913, 0.13590716, 0.39854, 0.8838793, 0.8747359, 0.40082723, 0.17775355, 0.43851566, + 0.99827635, 0.5713145, 0.8552926, 0.94444704, 0.33731982, 0.42541102, 0.74765176, 0.55205274, + 0.43713725, 0.28161594, 0.5434486, 0.68305284, 0.80054593, 0.23567316, 0.08136242, 0.7308039, + 0.9190936, 0.42697325, 0.12694505, 0.9054515, 0.6885998, 0.32237664, 0.97928506, 0.33159167, + 0.43956187, 0.3785934, 0.9559342, 0.7863749, 0.5174173, 0.5265025, 0.05555021, 0.08769297, + 0.3469469, 0.77875453, 0.39402276, 0.34180835, 0.5405278, 0.21737531, 0.2867914, 0.636639, + 0.76084745, 0.13152646, 0.5507047, 0.50011265, 0.5644382, 0.46082756, 0.29745814, 0.16041815, + 0.054544732, 0.6677361, 0.9647857, 0.44776264, 0.27388218, 0.27230206, 0.74991584, 0.67589974, + 0.59202945, 0.52370095, 0.50488514, 0.9587264, 0.46947676, 0.9612768, 0.034635436, 0.91063476, + 0.22606573, 0.45575568, 0.33610594, 0.02179139, 0.8416504, 0.7395541, 0.19027609, 0.7017183, + 0.14018182, 0.49030608, 0.14460404, 0.55707335, 0.7716719, 0.47917238, 0.76715344, 0.9787343, + 0.08113525, 0.7955161, 0.7318302, 0.8496812, 0.5617168, 0.60778755, 0.81381077, 0.07464484, + 0.028838681, 0.718123, 0.74977887, 0.016826851, 0.71249014, 0.32806498, 0.16716221, 0.7995706, + 0.096891016, 0.64007, 0.27404693, 0.10868255, 0.12472161, 0.27566674, 0.31876773, 0.31499064, + 0.47746003, 0.2630674, 0.30758083, 0.78357613, 0.12769802, 0.1928425, 0.90422785, 0.112857096, + 0.7565475, 0.5261508, 0.8775912, 0.6739607, 0.22944665, 0.18495426, 0.3489179, 0.61827815, + 0.6419449, 0.2614611, 0.9929527, 0.12352738, 0.98977524, 0.17344923, 0.9892281, 0.81211686, + 0.32314387, 0.34503344, 0.46018234, 0.13160191, 0.20512545, 0.65847087, 0.8540127, 0.8054685, + 0.47674835, 0.41683954, 0.37222117, 0.29864943, 0.30020675, 0.03023468, 0.94694686, 0.8359962, + 0.8138952, 0.63692176, 0.26027933, 0.18633933, 0.45047382, 0.49320155, 0.570124, 0.91193676, + 0.2911521, 0.65576875, 0.46673766, 0.8632605, 0.28271404, 0.19524036, 0.32521543, 0.30401078, + 0.27383924, 0.495464, 0.46043226, 0.7826646, 0.7326602, 0.7726259, 0.90773165, 0.09807661, + 0.6721381, 0.07212267, 0.1972123, 0.8126071, 0.8127331, 0.05026847, 0.3180714, 0.6117102, + 0.31451428, 0.15695652, 0.30963218, 0.35285345, 0.9131699, 0.8028888, 0.36164302, 0.8299423, + 0.7749095, 0.54824555, 0.8404498, 0.5493567, 0.19173324, 0.9907522, 0.5227545, 0.281508, + 0.091624096, 0.06821037, 0.024810186, 0.80474275, 0.5698024, 0.16428226, 0.10333604, 0.04126928, + 0.7291901, 0.16220273, 0.5142012, 0.37835112, 0.29598927, 0.75751686, 0.09920368, 0.24088362, + 0.33769736, 0.85502744, 0.5487462, 0.12575752, 0.8856082, 0.972362, 0.3908409, 0.47095042, + 0.13382097, 0.63048995, 0.007755094, 0.18441458, 0.9321761, 0.35837498, 0.9063434, 0.6813859, + 0.5493682, 0.9157043, 0.720983, 0.7445227, 0.025458287, 0.5133287, 0.041907787, 0.15023202, + 0.053620476, 0.2683629, 0.6236633, 0.75096714, 0.28868756, 0.98329186, 0.5339531, 0.017392641, + 0.4490419, 0.5995662, 0.21165931, 0.3367058, 0.44200596, 0.39699697, 0.39589983, 0.11926211, + 0.6773695, 0.5538598, 0.6709218, 0.93931246, 0.15652716, 0.9189215, 0.10909318, 0.37081516, + 0.25585935, 0.83281535, 0.82898295, 0.38028497, 0.03653382, 0.35468096, 0.21542533, 0.8243687, + 0.81311965, 0.39851424, 0.07213704, 0.61724526, 0.34869868, 0.63987374, 0.18226288, 0.15052907, + 0.096536905, 0.99036247, 0.73537266, 0.3326099, 0.14671567, 0.5696376, 0.2393799, 0.15237123, + 0.5198045, 0.6017209, 0.067153245, 0.47159854, 0.84240687, 0.1025953, 0.99370486, 0.134699, + 0.15926972, 0.25284818, 0.4951078, 0.45587218, 0.15430894, 0.15366808, 0.9808588, 0.094360925, + 0.38414088, 0.3872906, 0.52358615, 0.043491747, 0.32485992, 0.7786546, 0.7705634, 0.037495736, + 0.37159687, 0.5203927, 0.8427756, 0.16616471, 0.18354878, 0.7764833, 0.22409947, 0.6862218, + 0.59343547, 0.6766117, 0.8604805, 0.4348129, 0.2875277, 0.7438268, 0.9819619, 0.7105244, + 0.4048094, 0.937438, 0.45797554, 0.09585048, 0.14476593, 0.7263907, 0.9962201, 0.9428688, + 0.009503636, 0.6410118, 0.94846904, 0.7594251, 0.04605143, 0.19588815, 0.8275113, 0.7411499, + 0.83115745, 0.02965751, 0.10000168, 0.32201412, 0.25981972, 0.82754016, 0.95115024, 0.38278645, + 0.02874871, 0.808886, 0.8624367, 0.47769725, 0.29318756, 0.5460459, 0.8068332, 0.6403141, + 0.4053287, 0.8130618, 0.63868237, 0.3874219, 0.320679, 0.67471296, 0.8927298, 0.64520615, + 0.5241726, 0.89990675, 0.15666108, 0.54253703, 0.82801425, 0.46467438, 0.64017034, 0.39754733, + 0.8491004, 0.11933059, 0.60365546, 0.25787023, 0.6438251, 0.65994775, 0.45070463, 0.57726926, + 0.98628783, 0.075189106, 0.06710178, 0.33587992, 0.863954, 0.51852286, 0.64968127, 0.46345773, + 0.83417857, 0.30815494, 0.35409638, 0.23298964, 0.5572058, 0.4400894, 0.4204709, 0.1564445, + 0.13692771, 0.4547955, 0.7978415, 0.35991296, 0.67087907, 0.4086132, 0.5547722, 0.56407434, + 0.16871567, 0.46488938, 0.62859684, 0.17385697, 0.94239044, 0.548963, 0.996489, 0.74538094, + 0.36235714, 0.061413143, 0.40113407, 0.24548991, 0.6076112, 0.5568499, 0.78125215, 0.005649717, + 0.2502255, 0.69320333, 0.70835847, 0.5198593, 0.110578, 0.4071807, 0.84034157, 0.40901098, + 0.6988597, 0.44721094, 0.12094251, 0.1890296, 0.86210626, 0.09079167, 0.90639013, 0.5776746, + 0.5204169, 0.50302744, 0.16716424, 0.39906463, 0.8899261, 0.47582427, 0.52106726, 0.2852156, + 0.31166598, 0.6087155, 0.87063247, 0.49579263, 0.03895533, 0.174981, 0.5488333, 0.5800778, + 0.67354333, 0.7921918, 0.10968746, 0.97767574, 0.70025474, 0.034912895, 0.45349634, 0.761535, + 0.6245478, 0.21958585, 0.47499728, 0.4951795, 0.42802048, 0.80745935, 0.8832747, 0.27156547, + 0.15502298, 0.8234595, 0.725073, 0.10458374, 0.38968566, 0.38218752, 0.11572367, 0.77440125, + 0.17213607, 0.42314288, 0.2081933, 0.5018625, 0.5365482, 0.3445489, 0.37005565, 0.5238787, + 0.8983776, 0.5408647, 0.51548624, 0.06991447, 0.9811042, 0.9287144, 0.8774199, 0.48550403, + 0.04953112, 0.40562928, 0.7745168, 0.6703402, 0.00082698837, 0.025887761, 0.8571951, 0.5042066, + 0.7254408, 0.59906703, 0.34076965, 0.21549584, 0.449908, 0.44424957, 0.19039217, 0.29135585, + 0.67646813, 0.33528623, 0.80553967, 0.27711186, 0.8267196, 0.95163375, 0.22498675, 0.2799989, + 0.8495302, 0.9511186, 0.5968019, 0.8871558, 0.2919731, 0.8133602, 0.29046127, 0.22630857, + 0.9460396, 0.23956898, 0.05505262, 0.98405635, 0.60767066, 0.4453835, 0.77357423, 0.14624831, + 0.5659478, 0.7039867, 0.7764218, 0.9374812, 0.0037792725, 0.1545598, 0.073970705, 0.45412806, + 0.35047254, 0.2241304, 0.39344636, 0.645818, 0.12317476, 0.600308, 0.65878445, 0.09789734, + 0.18064253, 0.49451795, 0.82080996, 0.049708407, 0.42908588, 0.9700393, 0.2122335, 0.9120806, + 0.30860576, 0.11446109, 0.26945624, 0.21033902, 0.38919696, 0.20633578, 0.6836851, 0.23108464, + 0.56171197, 0.6592914, 0.7111641, 0.122732915, 0.175212, 0.28750554, 0.2762196, 0.69497037, + 0.87714785, 0.14267384, 0.53668326, 0.06784272, 0.41991386, 0.6446433, 0.10313381, 0.34573162, + 0.58078456, 0.9571553, 0.8034138, 0.11315275, 0.62457347, 0.7238658, 0.71716243, 0.59590846, + 0.4917532, 0.8643412, 0.62887543, 0.88931817, 0.8851036, 0.86363167, 0.064931095, 0.14413676, + 0.54044527, 0.16236171, 0.084106006, 0.4638834, 0.8891439, 0.5360515, 0.9226853, 0.893137, + 0.21829833, 0.12583959, 0.17256053, 0.28641203, 0.4333561, 0.14439079, 0.49216673, 0.6639625, + 0.011327274, 0.9237246, 0.62955445, 0.43204167, 0.40292194, 0.5705324, 0.6065112, 0.83784616, + 0.94212896, 0.115255654, 0.6309797, 0.3108708, 0.6586301, 0.38690144, 0.8098668, 0.013516203, + 0.07774274, 0.39254647, 0.52739745, 0.25755215, 0.5605373, 0.6392504, 0.4565877, 0.044733036, + 0.034469932, 0.91027683, 0.8948544, 0.4987339, 0.5513053, 0.4307504, 0.16255233, 0.3473624, + 0.3721745, 0.96491295, 0.8779909, 0.961379, 0.2340772, 0.6328894, 0.7412148, 0.9699129, + 0.55585057, 0.24625985, 0.52175444, 0.77388823, 0.9050718, 0.61181456, 0.23450689, 0.8313969, + 0.31597278, 0.15904433, 0.20866929, 0.04080962, 0.6169933, 0.23461457, 0.1034252, 0.37207687, + 0.4671369, 0.58482146, 0.39757174, 0.4926451, 0.67567796, 0.107777245, 0.28654084, 0.5113785, + 0.9527033, 0.28361735, 0.9386963, 0.6937171, 0.50891054, 0.84848785, 0.779439, 0.44485334, + 0.65133166, 0.55748457, 0.7017016, 0.3142774, 0.11749596, 0.68269944, 0.13966125, 0.42265537, + 0.6757699, 0.06345752, 0.18276113, 0.39226097, 0.2220811, 0.12174272, 0.7303691, 0.13755992, + 0.8614878, 0.50591403, 0.4942421, 0.64925575, 0.23531766, 0.24856968, 0.29423487, 0.44807333, + 0.959719, 0.010375906, 0.82118493, 0.6214544, 0.67311823, 0.5407898, 0.3224864, 0.46748495, + 0.37960532, 0.76381594, 0.38947794, 0.05950873, 0.53291297, 0.7891478, 0.2545809, 0.7844374, + 0.44516018, 0.97491634, 0.81687516, 0.61222047, 0.9250161, 0.89427984, 0.28929746, 0.83096063, + 0.5532483, 0.8011364, 0.8322293, 0.0029964554, 0.35424575, 0.13018323, 0.20953566, 0.402762, + 0.2632497, 0.25362825, 0.3545584, 0.10712006, 0.8615145, 0.51820683, 0.7495371, 0.13498017, + 0.74097115, 0.7152762, 0.0126556605, 0.45826513, 0.73226476, 0.67086035, 0.6046469, 0.07234, + 0.25133318, 0.70980465, 0.20409557, 0.2604013, 0.43169454, 0.6820144, 0.5230572, 0.065439165, + 0.72107846, 0.99022436, 0.06820616, 0.87198186, 0.70856047, 0.31948993, 0.11323921, 0.24942209, + 0.5542803, 0.9867159, 0.79625905, 0.27928472, 0.4345894, 0.14746083, 0.9229229, 0.9269534, + 0.22537923, 0.681895, 0.8712493, 0.20973994, 0.8816242, 0.83103234, 0.098695815, 0.88238794, + 0.19648944, 0.75988936, 0.75166327, 0.64444107, 0.9260877, 0.94913435, 0.9710675, 0.5812353, + 0.7305711, 0.28911924, 0.3860416, 0.87129015, 0.45000067, 0.87755525, 0.42641973, 0.4214812, + 0.60203695, 0.7632336, 0.90398484, 0.74554884, 0.8746013, 0.32536224, 0.6377506, 0.10387234, + 0.7868817, 0.2771422, 0.035022065, 0.74979955, 0.8107651, 0.31331727, 0.18381497, 0.8900461, + 0.89152855, 0.18581823, 0.6754924, 0.9486711, 0.5678266, 0.4687981, 0.32333443, 0.60514593, + 0.015648454, 0.21502374, 0.5487136, 0.14547014, 0.76141924, 0.05163277, 0.4769527, 0.34782398, + 0.25547525, 0.44976813, 0.607703, 0.11839061, 0.9270475, 0.35314697, 0.007786621, 0.8711272, + 0.12213872, 0.64779097, 0.8575594, 0.64894545, 0.9141123, 0.22126794, 0.77047014, 0.4172538, + 0.10530428, 0.4959955, 0.97976166, 0.26418245, 0.20206283, 0.47774863, 0.85365456, 0.13323887, + 0.43989918, 0.29883888, 0.7299004, 0.65957755, 0.7766486, 0.49228048, 0.34245312, 0.7352489, + 0.8001895, 0.6871981, 0.49432427, 0.360997, 0.70561427, 0.06542435, 0.96299857, 0.5383816, + 0.1780316, 0.8043652, 0.82653236, 0.92003566, 0.6112387, 0.67438895, 0.6910336, 0.79438055, + 0.44455358, 0.13145985, 0.04016586, 0.26542372, 0.07187113, 0.21277027, 0.14576113, 0.77772665, + 0.59611356, 0.47446412, 0.6784915, 0.62820864, 0.62324655, 0.34820905, 0.094478644, 0.62985826, + 0.30533785, 0.122310445, 0.84875596, 0.22691421, 0.7269437, 0.40947318, 0.7116395, 0.039879926, + 0.5329969, 0.44138008, 0.08615084, 0.39769763, 0.65121627, 0.93361884, 0.52200013, 0.7655102, + 0.60780525, 0.9355199, 0.21502401, 0.64518875, 0.45211464, 0.0770294, 0.6633778, 0.5874192, + 0.541437, 0.7165977, 0.7648834, 0.2311502, 0.3869329, 0.33478996, 0.915135, 0.82982254, + 0.70988655, 0.19667415, 0.6146979, 0.4889283, 0.825633, 0.46411943, 0.067436874, 0.035080392, + 0.41982034, 0.0002859342, 0.7324268, 0.630491, 0.12661943, 0.7480635, 0.12651038, 0.6624947, + 0.952464, 0.9129812, 0.020403363, 0.6877267, 0.13318504, 0.44928992, 0.1777436, 0.22830844, + 0.45893264, 0.2613367, 0.68547726, 0.010346001, 0.6445898, 0.4804893, 0.652947, 0.19820693, + 0.52624506, 0.25632828, 0.687811, 0.4545421, 0.31892103, 0.033071853, 0.9398772, 0.14368583, + 0.868083, 0.17994362, 0.2253684, 0.4518287, 0.34460258, 0.032886766, 0.4607998, 0.7933734, + 0.59008723, 0.10238874, 0.27868623, 0.47395167, 0.3143866, 0.22740832, 0.6966375, 0.26059666, + 0.018930554, 0.3863894, 0.029995646, 0.5642963, 0.7786422, 0.05709087, 0.39049065, 0.939331, + 0.3473389, 0.53421986, 0.10424597, 0.8702912, 0.060252476, 0.6719683, 0.34357366, 0.9193921, + 0.97310406, 0.8767175, 0.8196437, 0.9532414, 0.22392152, 0.7259149, 0.88370585, 0.42604586, + 0.80053693, 0.8921038, 0.42025873, 0.54220104, 0.2018031, 0.17899537, 0.8838203, 0.29883677, + 0.5596908, 0.42721438, 0.43561155, 0.9325316, 0.0030762074, 0.37558094, 0.36504367, 0.8109921, + 0.78945297, 0.2860374, 0.10448979, 0.8103827, 0.9286408, 0.59050864, 0.733121, 0.91811895, + 0.75881505, 0.35929412, 0.50084764, 0.4376691, 0.40776464, 0.7433961, 0.036675144, 0.29301566, + 0.5026836, 0.6039498, 0.7637594, 0.8865383, 0.6368321, 0.8482896, 0.7375279, 0.16834354, + 0.65039957, 0.8054092, 0.31060037, 0.6330381, 0.23635677, 0.41104206, 0.9163159, 0.5975231, + 0.51167387, 0.008651535, 0.16378845, 0.93788415, 0.62142515, 0.07332315, 0.49740508, 0.21002825, + 0.15898286, 0.5021398, 0.78338593, 0.842509, 0.67814773, 0.44615123, 0.8910721, 0.81629467, + 0.39053923, 0.14259589, 0.42984807, 0.39912644, 0.61182153, 0.47850534, 0.17416, 0.94116336, + 0.5485095, 0.93614626, 0.15998314, 0.12323159, 0.27990827, 0.10008287, 0.6817622, 0.34777302, + 0.4429782, 0.9033245, 0.92599523, 0.39911312, 0.57960767, 0.09879101, 0.6715905, 0.4293604, + 0.1065447, 0.55373114, 0.72755545, 0.13469236, 0.06490368, 0.89501894, 0.4901958, 0.20424834, + 0.9143371, 0.4943057, 0.24249884, 0.093760885, 0.98119396, 0.5171895, 0.98570156, 0.03316852, + 0.83449155, 0.22262509, 0.38937467, 0.6852789, 0.91334003, 0.3741735, 0.93012, 0.05889999, + 0.8203776, 0.43561292, 0.3995308, 0.77482325, 0.52015597, 0.491959, 0.23668702, 0.29174823, + 0.47100535, 0.0004876647, 0.29258174, 0.058090426, 0.75094986, 0.039467655, 0.8762597, 0.65349054, + 0.44595045, 0.9557348, 0.20889449, 0.78560257, 0.857584, 0.5880013, 0.36657903, 0.9257887, + 0.917623, 0.89282674, 0.56462157, 0.35698256, 0.70941633, 0.9863116, 0.51602036, 0.7323712, + 0.62361115, 0.6686555, 0.31431475, 0.62929076, 0.4954881, 0.71537256, 0.68409234, 0.4223781, + 0.2576187, 0.9507506, 0.6227555, 0.98070633, 0.22460775, 0.9276111, 0.28221866, 0.79502386, + 0.34636542, 0.73588413, 0.23932843, 0.95760524, 0.165279, 0.1445174, 0.20131597, 0.23237628, + 0.069033906, 0.47374207, 0.85720026, 0.62732923, 0.9273374, 0.8797045, 0.5823319, 0.48469374, + 0.48446727, 0.5602105, 0.43447927, 0.08229436, 0.7251529, 0.24696892, 0.15800244, 0.7305779, + 0.27164242, 0.78651637, 0.52798384, 0.9068334, 0.9652458, 0.3858727, 0.701181, 0.9900118, + 0.61060804, 0.7695977, 0.010617126, 0.97353226, 0.74698323, 0.5584152, 0.56709224, 0.47909376, + 0.46733952, 0.08193848, 0.56025684, 0.021746036, 0.8581723, 0.056763105, 0.49504068, 0.37791422, + 0.36841872, 0.13806179, 0.49623904, 0.66439724, 0.49313185, 0.19992432, 0.06987098, 0.09939649, + 0.5778817, 0.50875056, 0.6859628, 0.3787626, 0.6165335, 0.29448256, 0.2671305, 0.6831612, + 0.77256113, 0.86718845, 0.016721206, 0.1577397, 0.86908734, 0.60879964, 0.73771054, 0.9260521, + 0.9931183, 0.9553855, 0.6149548, 0.6432144, 0.6867121, 0.1362564, 0.8724056, 0.21487932, + 0.2914757, 0.15006965, 0.53841466, 0.827184, 0.88963366, 0.03678374, 0.49687997, 0.41068372, + 0.69972676, 0.9112206, 0.39565054, 0.23823264, 0.8724524, 0.18832962, 0.8625602, 0.17285694, + 0.814808, 0.87709564, 0.24918492, 0.99098384, 0.0400419, 0.337301, 0.50882685, 0.7596191, + 0.4003513, 0.5701869, 0.67127895, 0.5377463, 0.58496946, 0.42665657, 0.4126844, 0.4416253, + 0.63634497, 0.47108346, 0.08728689, 0.4664639, 0.75606793, 0.4399465, 0.79352754, 0.7357774, + 0.3703085, 0.6060375, 0.45801297, 0.9578667, 0.2131491, 0.49947786, 0.05359975, 0.8047887, + 0.092825316, 0.4420979, 0.82840645, 0.80961645, 0.8870715, 0.88142174, 0.17483743, 0.95417476, + 0.6412428, 0.7787956, 0.4268327, 0.31944674, 0.3655048, 0.9591336, 0.82571423, 0.2730702, + 0.49853623, 0.95402527, 0.6018877, 0.4013689, 0.10104273, 0.39609635, 0.41678905, 0.37486148, + 0.083568096, 0.5134075, 0.6206753, 0.43400443, 0.879288, 0.5509602, 0.54647, 0.9008734, + 0.5165872, 0.86649024, 0.44492102, 0.14287159, 0.59825015, 0.60306793, 0.5545538, 0.7549232, + 0.29624605, 0.13311216, 0.8252211, 0.97727233, 0.013113789, 0.4740808, 0.37027258, 0.41117483, + 0.7803232, 0.18494278, 0.45933047, 0.25912383, 0.89759016, 0.65223086, 0.70374596, 0.696729, + 0.02530885, 0.45354494, 0.72604835, 0.37366393, 0.2607464, 0.740833, 0.07488672, 0.09028263, + 0.23232558, 0.5259593, 0.80285954, 0.49901456, 0.5142126, 0.6828427, 0.67482007, 0.8954683, + 0.39947143, 0.8469645, 0.10512285, 0.96793056, 0.5708752, 0.43951672, 0.3617477, 0.6094873, + 0.14313498, 0.2095005, 0.6536812, 0.69434524, 0.09162968, 0.28734615, 0.0032832306, 0.86435634, + 0.1627443, 0.748192, 0.11756273, 0.14470519, 0.8770196, 0.1808899, 0.49417683, 0.55541307, + 0.05822544, 0.73493844, 0.7449467, 0.48715448, 0.67122126, 0.871258, 0.8969622, 0.097480536, + 0.5101227, 0.5638622, 0.8596524, 0.050625734, 0.547108, 0.7358154, 0.12585375, 0.5857921, + 0.09179724, 0.11656108, 0.23052894, 0.051245883, 0.08715177, 0.38054147, 0.99865294, 0.9449794, + 0.52267605, 0.93850327, 0.33627024, 0.7660206, 0.56527996, 0.5301148, 0.018448701, 0.21858154, + 0.3527876, 0.5497098, 0.90970516, 0.8359368, 0.69457, 0.8745932, 0.93826604, 0.27187696, + 0.3125383, 0.5562007, 0.1842225, 0.5277675, 0.42769375, 0.9526575, 0.3172483, 0.42692894, + 0.6223383, 0.5317706, 0.05290796, 0.7604585, 0.95036095, 0.44293094, 0.46826127, 0.67768395, + 0.7362855, 0.7999673, 0.96447843, 0.732718, 0.53498775, 0.13094164, 0.5322006, 0.9800079, + 0.5454135, 0.64107084, 0.6978381, 0.9973982, 0.82611024, 0.28991696, 0.8912221, 0.21720403, + 0.17829505, 0.95865196, 0.7387076, 0.5309511, 0.19631897, 0.47088546, 0.5172857, 0.5700186, + 0.6212549, 0.90934134, 0.14368229, 0.033509336, 0.4772069, 0.25799018, 0.26822057, 0.9098567, + 0.08144851, 0.23202117, 0.09965124, 0.8946027, 0.91011477, 0.20554802, 0.7368892, 0.18159665, + 0.024000084, 0.20421462, 0.982354, 0.7866229, 0.2548194, 0.31985012, 0.6008187, 0.33242133, + 0.64054847, 0.8357039, 0.58216345, 0.991709, 0.70422333, 0.93731016, 0.481365, 0.26540005, + 0.2826816, 0.39445987, 0.1114631, 0.6256465, 0.9872593, 0.49869126, 0.502801, 0.2874233, + 0.37285027, 0.78798145, 0.9159497, 0.5940891, 0.19026573, 0.99661946, 0.30708927, 0.972747, + 0.22176278, 0.55711097, 0.50695103, 0.99210435, 0.48853147, 0.73066276, 0.31519917, 0.3014048, + 0.30852264, 0.81126094, 0.39296088, 0.641503, 0.6758267, 0.27651158, 0.20563333, 0.14413832, + 0.7506562, 0.83425117, 0.6119211, 0.5156549, 0.094084926, 0.111242734, 0.1943373, 0.52530885, + 0.70141363, 0.6949307, 0.41377264, 0.46683794, 0.4039004, 0.006729609, 0.14215559, 0.643929, + 0.52861464, 0.6094164, 0.7699462, 0.1471124, 0.43035918, 0.4892606, 0.7768686, 0.5520188, + 0.07926069, 0.8100583, 0.31712383, 0.17599839, 0.105730385, 0.861298, 0.6115966, 0.096338674, + 0.5823481, 0.77181137, 0.8434329, 0.35601455, 0.38469836, 0.79143435, 0.8786621, 0.11052005, + 0.36277366, 0.9816422, 0.29069075, 0.7936008, 0.31689015, 0.84836125, 0.8975044, 0.30179304, + 0.66910535, 0.7490319, 0.1128883, 0.06641029, 0.5065654, 0.058520928, 0.71377915, 0.26139554, + 0.057382602, 0.059902266, 0.4363942, 0.28402662, 0.7941189, 0.018338913, 0.41957843, 0.84011555, + 0.083334126, 0.31743395, 0.88448983, 0.632089, 0.16329671, 0.78614104, 0.2592306, 0.7371803, + 0.7307543, 0.65942615, 0.7843387, 0.448717, 0.19856988, 0.9832678, 0.23512867, 0.23089947, + 0.9125539, 0.015330798, 0.50689304, 0.3566985, 0.74840975, 0.5451863, 0.5897733, 0.5238272, + 0.05803223, 0.5820373, 0.29863194, 0.3247961, 0.35504016, 0.5946355, 0.31640115, 0.34443474, + 0.56206375, 0.45057517, 0.71026665, 0.99945617, 0.9638714, 0.26541534, 0.13849631, 0.8829643, + 0.48980126, 0.375708, 0.33565596, 0.84713924, 0.2741822, 0.26506215, 0.06282568, 0.07411481, + 0.8247736, 0.20549475, 0.37147272, 0.7787881, 0.5114459, 0.06287994, 0.09170583, 0.53814787, + 0.72766066, 0.36066267, 0.5740568, 0.58125937, 0.4875091, 0.93443453, 0.38214013, 0.13611887, + 0.343025, 0.439904, 0.88665324, 0.7479947, 0.27300113, 0.23567249, 0.26702806, 0.64713854, + 0.8768345, 0.62392867, 0.8668972, 0.37270173, 0.20953032, 0.74263406, 0.249645, 0.79297006, + 0.51921165, 0.22451714, 0.50002253, 0.14954542, 0.22316273, 0.53761303, 0.83298886, 0.4991838, + 0.35886934, 0.17211881, 0.2717955, 0.6032087, 0.6913585, 0.5572369, 0.3954552, 0.55536675, + 0.9935679, 0.19953707, 0.5041142, 0.83427817, 0.3784089, 0.314831, 0.80111367, 0.58910114, + 0.93846667, 0.7243342, 0.90195364, 0.8875172, 0.19598271, 0.7190041, 0.3286175, 0.9850266, + 0.11101766, 0.78108674, 0.06204771, 0.26299196, 0.434412, 0.23259473, 0.9129562, 0.805412, + 0.6069152, 0.38746944, 0.38912535, 0.10088234, 0.96387696, 0.6638193, 0.95578, 0.31959754, + 0.22847345, 0.3115305, 0.37913388, 0.009993258, 0.23851983, 0.4153668, 0.41456118, 0.20438069, + 0.42340347, 0.9109214, 0.21107873, 0.49882856, 0.6356594, 0.94547164, 0.3032011, 0.6398653, + 0.84350127, 0.28676888, 0.49219108, 0.91027176, 0.49518922, 0.13246326, 0.120954745, 0.76097316, + 0.28658092, 0.6987022, 0.22736304, 0.99093944, 0.9257056, 0.7002313, 0.6252242, 0.27464733, + 0.76855415, 0.5823561, 0.6590438, 0.8844522, 0.3398702, 0.31862426, 0.7465068, 0.6956509, + 0.36652556, 0.857667, 0.8395885, 0.5234906, 0.021515984, 0.4141276, 0.16975257, 0.66144353, + 0.084268354, 0.74926007, 0.25738105, 0.67710805, 0.17162827, 0.045508236, 0.8244083, 0.0960102, + 0.19057575, 0.6181607, 0.72341233, 0.5398176, 0.18800376, 0.4236217, 0.27867505, 0.7231721, + 0.28569725, 0.9364314, 0.73027444, 0.05330333, 0.28642786, 0.4187489, 0.29999506, 0.524877, + 0.5402621, 0.7965402, 0.54374623, 0.6375222, 0.29287475, 0.59746414, 0.73945713, 0.87245333, + 0.5289497, 0.56591946, 0.9066711, 0.17644554, 0.4428503, 0.94811606, 0.10301907, 0.7230459, + 0.75794774, 0.5630336, 0.69387645, 0.7217095, 0.5952119, 0.20668921, 0.5076471, 0.9429038, + 0.57899195, 0.116416365, 0.23779334, 0.08508458, 0.6838532, 0.11644924, 0.3750157, 0.6655195, + 0.44926503, 0.73250407, 0.13684598, 0.37508807, 0.50176203, 0.1868861, 0.80313545, 0.59311163, + 0.8787036, 0.850959, 0.0108679095, 0.62208426, 0.5169506, 0.10222952, 0.28032187, 0.3375812, + 0.83341235, 0.0072284974, 0.2953556, 0.7233943, 0.7248724, 0.5782856, 0.9296651, 0.3335729, + 0.28889313, 0.6008424, 0.05853025, 0.17645839, 0.3596708, 0.6543726, 0.18860014, 0.41250044, + 0.19090378, 0.24115163, 0.7271805, 0.7103462, 0.8112701, 0.727931, 0.22128391, 0.5710617, + 0.7598981, 0.10076484, 0.8430059, 0.7442529, 0.1958213, 0.8855628, 0.4259532, 0.47676244, + 0.8360945, 0.90021217, 0.25167224, 0.67662466, 0.8210937, 0.6516214, 0.940647, 0.8709795, + 0.802839, 0.8032731, 0.08619493, 0.9009196, 0.12835586, 0.62667704, 0.2334408, 0.224331, + 0.6623589, 0.59836745, 0.4311805, 0.27579898, 0.37504902, 0.5699756, 0.5263111, 0.10548131, + 0.7859446, 0.72429395, 0.96349615, 0.6241076, 0.7352797, 0.18541217, 0.13775158, 0.40333033, + 0.17488916, 0.5817678, 0.34036386, 0.45945865, 0.40270033, 0.51197547, 0.59140676, 0.5392824, + 0.3005046, 0.85620105, 0.9075073, 0.007996995, 0.6417361, 0.3203643, 0.44270578, 0.13322107, + 0.86732405, 0.6186749, 0.08189404, 0.59745383, 0.4543823, 0.15015423, 0.10171343, 0.2661189, + 0.37390104, 0.14619094, 0.8906801, 0.096799746, 0.68812525, 0.31653944, 0.13569976, 0.6174268, + 0.6655215, 0.6828646, 0.72603047, 0.54658806, 0.28631318, 0.77398217, 0.8216307, 0.15038341, + 0.0069607063, 0.8918981, 0.97529435, 0.518848, 0.6624684, 0.5183141, 0.46374524, 0.4655803, + 0.28158814, 0.83027506, 0.75678355, 0.11660483, 0.10351813, 0.54029775, 0.948948, 0.024734931, + 0.48005438, 0.074244976, 0.0855576, 0.2565094, 0.62129533, 0.49460703, 0.85115707, 0.98396516, + 0.7205013, 0.2900805, 0.34247547, 0.9588715, 0.5943338, 0.89611775, 0.8469079, 0.09334188, + 0.79704416, 0.9315106, 0.59049314, 0.5624842, 0.17485987, 0.5828654, 0.60365057, 0.85558695, + 0.6824457, 0.4250998, 0.8152116, 0.8578502, 0.55975586, 0.01909494, 0.5139087, 0.12522376, + 0.73391664, 0.7012955, 0.06653367, 0.2120682, 0.6884245, 0.5651213, 0.5290881, 0.51235366, + 0.040741026, 0.9913292, 0.7983467, 0.3723879, 0.17583862, 0.50487375, 0.87124646, 0.3854704, + 0.9833672, 0.66344166, 0.31956065, 0.1720075, 0.94980466, 0.38646382, 0.8498751, 0.89718896, + 0.4705944, 0.22997065, 0.57406366, 0.19619557, 0.67939544, 0.9933069, 0.4242093, 0.70140636, + 0.7761718, 0.21725173, 0.22495484, 0.89303833, 0.82958406, 0.6348397, 0.40491733, 0.23192288, + 0.40242258, 0.07813944, 0.5217432, 0.18353066, 0.7845187, 0.23126268, 0.6797483, 0.17757194, + 0.55385333, 0.42974123, 0.874483, 0.8963142, 0.6995343, 0.34190118, 0.17541912, 0.34745282, + 0.85142046, 0.16934472, 0.7414738, 0.4584539, 0.99105763, 0.33289248, 0.8329583, 0.04743413, + 0.5671199, 0.09694037, 0.5962161, 0.9585869, 0.2799189, 0.9782081, 0.5558863, 0.3485275, + 0.25852436, 0.08763776, 0.76958495, 0.8716652, 0.86472064, 0.6663444, 0.1126702, 0.23933174, + 0.55022234, 0.39649174, 0.64234227, 0.24965419, 0.118823886, 0.5278951, 0.0018720366, 0.43427062, + 0.04183261, 0.877502, 0.04161787, 0.66023934, 0.8933659, 0.9464634, 0.24086526, 0.069530085, + 0.24518117, 0.47430903, 0.61641073, 0.6875784, 0.6350466, 0.7211614, 0.89765304, 0.5756452, + 0.87385494, 0.5259555, 0.63778985, 0.6118965, 0.5723162, 0.3037539, 0.48273215, 0.18507604, + 0.05667453, 0.5021421, 0.90823156, 0.59456587, 0.69055027, 0.5833041, 0.92861027, 0.039224792, + 0.095068336, 0.16194543, 0.9167543, 0.40241688, 0.93659025, 0.895647, 0.4551616, 0.31206095, + 0.8467725, 0.7000548, 0.62648404, 0.39041162, 0.049933646, 0.42509183, 0.6042851, 0.8290609, + 0.49883872, 0.06669706, 0.37579927, 0.5928684, 0.89010525, 0.3899755, 0.8619544, 0.7380787, + 0.39476988, 0.8565418, 0.6035648, 0.39122385, 0.038231853, 0.64629936, 0.37897983, 0.6618771, + 0.54569876, 0.577186, 0.59251004, 0.47310117, 0.8044071, 0.49523613, 0.6390549, 0.97820795, + 0.07079393, 0.3257289, 0.765124, 0.8722614, 0.6772699, 0.092320524, 0.1351424, 0.6315827, + 0.89785695, 0.07917066, 0.09572715, 0.6238532, 0.20750481, 0.33574188, 0.14911953, 0.70509285, + 0.29999104, 0.1786756, 0.0076469877, 0.08004845, 0.29208216, 0.063937746, 0.27382907, 0.20047311, + 0.32107502, 0.96460694, 0.84471285, 0.47274768, 0.8325818, 0.13118395, 0.024653764, 0.0036025788, + 0.42764217, 0.39759132, 0.52207446, 0.56437635, 0.62485147, 0.989693, 0.060808785, 0.30244938, + 0.7213994, 0.9719821, 0.49336693, 0.9590612, 0.5505722, 0.75512666, 0.4543723, 0.2099569, + 0.42806646, 0.8874172, 0.17311013, 0.6257315, 0.48758915, 0.55900645, 0.68612576, 0.0068561803, + 0.051899806, 0.56465095, 0.5511864, 0.71266294, 0.2476077, 0.6623947, 0.7990009, 0.76667297, + 0.054516893, 0.092124574, 0.19621104, 0.80991346, 0.8136675, 0.58474314, 0.08024137, 0.31029803, + 0.117866814, 0.70519763, 0.35864902, 0.32010004, 0.5705708, 0.3147679, 0.64990085, 0.56594837, + 0.51023465, 0.6347559, 0.044681232, 0.94516456, 0.9580738, 0.39892223, 0.51601344, 0.8686357, + 0.71146554, 0.51521826, 0.51247656, 0.06020054, 0.43850663, 0.3481458, 0.054841675, 0.059004717, + 0.1729812, 0.7266939, 0.9045443, 0.45844766, 0.5589156, 0.6444588, 0.39628944, 0.8433233, + 0.8071758, 0.8628121, 0.5078647, 0.78239155, 0.20035744, 0.36602575, 0.43628535, 0.7371319, + 0.91475004, 0.985238, 0.20242831, 0.61285174, 0.6177135, 0.8538363, 0.8085992, 0.65559465, + 0.57611114, 0.32757533, 0.09844793, 0.2984492, 0.07226656, 0.020040827, 0.87179136, 0.769721, + 0.65035594, 0.2996443, 0.14711884, 0.8438769, 0.4102236, 0.1914532, 0.007032739, 0.8657759, + 0.23846649, 0.20135792, 0.13798875, 0.09526171, 0.8910575, 0.7336219, 0.6682783, 0.34543982, + 0.078932896, 0.77534467, 0.14545049, 0.45326862, 0.14571752, 0.44198993, 0.44129124, 0.31914487, + 0.9180948, 0.24894963, 0.8823365, 0.23134027, 0.54601085, 0.09784024, 0.7710568, 0.787135, + 0.99102074, 0.73814374, 0.13203558, 0.90071315, 0.2189069, 0.5924085, 0.32690832, 0.7232968, + 0.97820526, 0.33665246, 0.37438527, 0.41635555, 0.71584755, 0.7133375, 0.76453716, 0.84248924, + 0.6592971, 0.7530081, 0.2195163, 0.29692188, 0.87459034, 0.41852275, 0.62400347, 0.20836602, + 0.8583531, 0.82797396, 0.9257821, 0.16127396, 0.3091167, 0.77569246, 0.31976497, 0.14062625, + 0.43030116, 0.35085374, 0.104240976, 0.15291376, 0.6015863, 0.76756513, 0.12653293, 0.48652443, + 0.44843635, 0.42215365, 0.47506335, 0.80906504, 0.06760467, 0.02493567, 0.6032973, 0.20475733, + 0.48441246, 0.039847255, 0.5720432, 0.7930028, 0.8783239, 0.47413486, 0.91254467, 0.57249796, + 0.11414025, 0.9236696, 0.042360075, 0.39093295, 0.6666264, 0.16563436, 0.41418016, 0.20251282, + 0.016887465, 0.23375902, 0.9860544, 0.36499384, 0.60909647, 0.6116234, 0.24090295, 0.891732, + 0.6264752, 0.7329919, 0.8484855, 0.45243672, 0.9434594, 0.8149384, 0.14076136, 0.8334174, + 0.22467664, 0.72102475, 0.6768615, 0.26926944, 0.20364925, 0.52676225, 0.2623023, 0.95616627, + 0.43830907, 0.531743, 0.03877351, 0.67791677, 0.72520506, 0.7356, 0.81989807, 0.282802, + 0.007973485, 0.27255052, 0.7921776, 0.8338457, 0.038881265, 0.23830348, 0.59566087, 0.872789, + 0.7989443, 0.68031126, 0.16652757, 0.14533207, 0.62564933, 0.46010798, 0.6290386, 0.29920182, + 0.7829082, 0.20894268, 0.16625631, 0.94560164, 0.48877287, 0.14491072, 0.9988636, 0.49012524, + 0.9714567, 0.029888112, 0.92668474, 0.07735347, 0.5728499, 0.5629862, 0.16652691, 0.8908752, + 0.91309386, 0.56568354, 0.44446322, 0.67090887, 0.022760825, 0.3069157, 0.7945361, 0.9863731, + 0.12536389, 0.80407244, 0.47032514, 0.523338, 0.36023465, 0.11697024, 0.33051696, 0.9782011, + 0.9027044, 0.7395717, 0.89500856, 0.51626235, 0.5693437, 0.8742964, 0.7940291, 0.86306274, + 0.27368698, 0.30205235, 0.86238897, 0.008993154, 0.31161872, 0.5183074, 0.29993913, 0.2359581, + 0.51378435, 0.27565238, 0.23223823, 0.059965752, 0.01564475, 0.9581297, 0.276441, 0.4759925, + 0.41440654, 0.17988315, 0.82023776, 0.68470037, 0.6745856, 0.47552556, 0.12989059, 0.85448647, + 0.69937116, 0.94848365, 0.17464903, 0.83327824, 0.6679777, 0.65026456, 0.32153153, 0.038797423, + 0.7716544, 0.58140045, 0.3972219, 0.7207085, 0.44452676, 0.78554296, 0.67475444, 0.6070565, + 0.50413334, 0.23436703, 0.009553685, 0.08458229, 0.884732, 0.27055123, 0.96255636, 0.9445748, + 0.46313068, 0.41901603, 0.10185582, 0.38946053, 0.05405868, 0.10932874, 0.18847717, 0.79816145, + 0.17216177, 0.007902476, 0.30962202, 0.36313507, 0.34365836, 0.46666092, 0.5679804, 0.8635198, + 0.9541208, 0.19344081, 0.2883113, 0.4342443, 0.5609078, 0.55573255, 0.03146575, 0.6288636, + 0.50512874, 0.21318124, 0.18056706, 0.44021857, 0.46597186, 0.045308296, 0.96975446, 0.42881992, + 0.9859273, 0.23007429, 0.37014756, 0.24896163, 0.54840875, 0.932071, 0.98473877, 0.6623257, + 0.39292327, 0.5990605, 0.5485467, 0.4366243, 0.47592095, 0.31161934, 0.26339814, 0.037472416, + 0.6663866, 0.1460339, 0.13046144, 0.6912912, 0.9822399, 0.528312, 0.38366696, 0.90739816, + 0.3875503, 0.47299224, 0.88433176, 0.8408774, 0.92876166, 0.7482586, 0.33218956, 0.12685347, + 0.038148023, 0.8808021, 0.37720776, 0.11358407, 0.09651337, 0.3190188, 0.31511107, 0.022049852, + 0.20870206, 0.6259856, 0.041321024, 0.9618473, 0.007185834, 0.5948415, 0.15294261, 0.19350938, + 0.9497831, 0.14309464, 0.77383196, 0.31993797, 0.91484684, 0.27846324, 0.44658, 0.45761526, + 0.8464073, 0.46274942, 0.86141133, 0.075416476, 0.0477392, 0.14386131, 0.733564, 0.64466465, + 0.26687092, 0.42169324, 0.39847627, 0.5951189, 0.9344116, 0.14981407, 0.94095904, 0.3473678, + 0.83092284, 0.108411595, 0.48258916, 0.3562543, 0.48699102, 0.42181966, 0.9002123, 0.7927088, + 0.32004964, 0.6908224, 0.8910943, 0.78566706, 0.9744266, 0.012251603, 0.21200661, 0.7596848, + 0.4342221, 0.9195925, 0.26717675, 0.63376397, 0.45760745, 0.2396946, 0.97431064, 0.06484076, + 0.8924216, 0.39665636, 0.6949764, 0.5854926, 0.1963652, 0.5578238, 0.2590978, 0.799969, + 0.2021356, 0.42646417, 0.48901513, 0.8064353, 0.7958741, 0.0903257, 0.9706242, 0.42458767, + 0.56253713, 0.068702534, 0.75536686, 0.3569168, 0.25276697, 0.94789696, 0.670238, 0.2546193, + 0.2096866, 0.6387915, 0.16089676, 0.01481907, 0.8826373, 0.3071951, 0.8897603, 0.59122825, + 0.13410094, 0.4177484, 0.4638327, 0.09033466, 0.72684324, 0.3147197, 0.5963436, 0.76222587, + 0.43172458, 0.091125324, 0.58353144, 0.5479625, 0.52323645, 0.40557137, 0.9638107, 0.3438964, + 0.9489683, 0.8425891, 0.07122685, 0.38890493, 0.48432773, 0.61739385, 0.8120738, 0.9445246, + 0.7264184, 0.4403571, 0.375806, 0.55757374, 0.396927, 0.24427874, 0.9173317, 0.8949405, + 0.5367038, 0.8977869, 0.6723343, 0.3781257, 0.626493, 0.88028955, 0.6977444, 0.24781741, + 0.4723589, 0.993141, 0.9251922, 0.16164163, 0.36436552, 0.12227554, 0.73138285, 0.80411524, + 0.6749808, 0.8170004, 0.06585078, 0.040048227, 0.23596825, 0.5008554, 0.10690048, 0.51670706, + 0.6056746, 0.5193081, 0.3639163, 0.28648618, 0.9389137, 0.03876988, 0.36529887, 0.18744585, + 0.17379361, 0.68859094, 0.011258623, 0.62544954, 0.733237, 0.585685, 0.7174034, 0.06867873, + 0.14484468, 0.82340944, 0.916546, 0.49118677, 0.6922017, 0.65043217, 0.58015907, 0.60414284, + 0.70897424, 0.57169074, 0.8825929, 0.5799266, 0.17842796, 0.8772835, 0.65897226, 0.03584844, + 0.7908864, 0.15562724, 0.7724511, 0.10718488, 0.5163733, 0.41125825, 0.3089037, 0.43358904, + 0.62784207, 0.73774636, 0.98784804, 0.6757746, 0.111016914, 0.10593328, 0.07087821, 0.08929581, + 0.09959695, 0.99717206, 0.89520353, 0.4125588, 0.5843094, 0.6157137, 0.82450545, 0.95524246, + 0.939149, 0.7597735, 0.5775119, 0.36722296, 0.15617695, 0.78537226, 0.009017896, 0.29651013, + 0.029618707, 0.97541016, 0.83456314, 0.5776098, 0.8132339, 0.6102185, 0.55230546, 0.73358643, + 0.51450574, 0.48295695, 0.86334467, 0.9544553, 0.6625841, 0.90438455, 0.49312592, 0.603041, + 0.50081253, 0.7932971, 0.4803297, 0.1812559, 0.9820799, 0.24641345, 0.45153904, 0.1751727, + 0.3311218, 0.81720865, 0.16803588, 0.7565998, 0.8337463, 0.9416807, 0.2774121, 0.8424698, + 0.7287285, 0.6913379, 0.64615583, 0.13560674, 0.27137014, 0.4932684, 0.27606192, 0.48937842, + 0.4448666, 0.16161712, 0.89805305, 0.10135246, 0.75236905, 0.87005013, 0.29265827, 0.034764472, + 0.26664755, 0.9744709, 0.86641043, 0.3628798, 0.30504256, 0.827762, 0.31443018, 0.7832053, + 0.5238711, 0.65939045, 0.246488, 0.9960252, 0.44218266, 0.7957057, 0.8998401, 0.572825, + 0.20554484, 0.020874852, 0.22572684, 0.97124624, 0.2582287, 0.35751918, 0.33167085, 0.007544129, + 0.5172352, 0.99095124, 0.73638934, 0.8204628, 0.34836042, 0.3501866, 0.4228037, 0.46107167, + 0.5245504, 0.1332714, 0.48995224, 0.8592754, 0.07527029, 0.91453224, 0.53742725, 0.90096647, + 0.3769077, 0.8629506, 0.6117356, 0.61197966, 0.2467804, 0.2800367, 0.047195755, 0.6491609, + 0.261777, 0.32522804, 0.8958076, 0.7314942, 0.6443233, 0.32141203, 0.7765358, 0.90912837, + 0.6428001, 0.85886633, 0.8456446, 0.31409132, 0.09137268, 0.49396735, 0.43484485, 0.17368458, + 0.23658675, 0.78541636, 0.47147486, 0.30891126, 0.30575344, 0.040564716, 0.49755472, 0.2910126, + 0.48344758, 0.32476038, 0.59433854, 0.39527807, 0.7457836, 0.71969116, 0.76076376, 0.23719852, + 0.9437555, 0.087228395, 0.55868584, 0.023132376, 0.45437896, 0.6913095, 0.8167484, 0.20313835, + 0.35673562, 0.58082384, 0.2164753, 0.21640398, 0.06888765, 0.22333595, 0.8095938, 0.88294035, + 0.42810574, 0.43805102, 0.37539294, 0.46136406, 0.80856186, 0.7382845, 0.34340748, 0.2212123, + 0.8276733, 0.60479504, 0.24804658, 0.3195629, 0.7270735, 0.3812577, 0.16334477, 0.92310894, + 0.09810257, 0.6084461, 0.37033582, 0.004144284, 0.9352815, 0.41171247, 0.71930563, 0.54527724, + 0.968668, 0.2683365, 0.9521756, 0.7249296, 0.8240894, 0.28115076, 0.22212493, 0.26011166, + 0.5151666, 0.71139824, 0.9671723, 0.3077326, 0.3442982, 0.29939967, 0.42863667, 0.20547101, + 0.7438209, 0.33747354, 0.19545908, 0.8495839, 0.44326293, 0.49718547, 0.4760649, 0.97547793, + 0.4174791, 0.29336637, 0.11830141, 0.46044156, 0.85300016, 0.8054495, 0.9476588, 0.016393282, + 0.7187454, 0.8301157, 0.49269608, 0.5402253, 0.78610885, 0.6184779, 0.39712286, 0.54652256, + 0.3826701, 0.98793495, 0.80439633, 0.015675247, 0.4140854, 0.85561216, 0.5788107, 0.7987029, + 0.17980942, 0.16486481, 0.26032335, 0.597808, 0.2162534, 0.86972165, 0.102014296, 0.47148252, + 0.7922716, 0.97669774, 0.3074505, 0.53072304, 0.16284934, 0.7616834, 0.40711153, 0.7097171, + 0.7637394, 0.950779, 0.58898723, 0.5141825, 0.8067036, 0.88841134, 0.41936216, 0.12534304, + 0.94035065, 0.6489365, 0.46691382, 0.45532802, 0.69278914, 0.46038964, 0.56139255, 0.56186694, + 0.7145557, 0.31959853, 0.28063214, 0.6881353, 0.54512614, 0.3498508, 0.8001399, 0.8490237, + 0.7281014, 0.021213572, 0.7479538, 0.8094111, 0.31102738, 0.8663998, 0.38367322, 0.6209867, + 0.5808234, 0.09467922, 0.25193584, 0.46330634, 0.26662496, 0.06462818, 0.99199927, 0.29139808, + 0.74550265, 0.13498032, 0.65745735, 0.5673169, 0.40280786, 0.64668626, 0.7786934, 0.33188194, + 0.4153052, 0.7455836, 0.8161674, 0.8432508, 0.48105124, 0.7189762, 0.16459095, 0.41388863, + 0.15063916, 0.73996353, 0.78608114, 0.78549004, 0.14045759, 0.609951, 0.8143157, 0.07395084, + 0.26526332, 0.8459271, 0.8745046, 0.5981099, 0.20845382, 0.098086186, 0.29524195, 0.6499275, + 0.32759923, 0.98923403, 0.9426327, 0.41014582, 0.6923934, 0.23282301, 0.44621587, 0.08141512, + 0.24252021, 0.4160718, 0.3941059, 0.5654438, 0.050232418, 0.5404224, 0.13993548, 0.8618472, + 0.9300883, 0.8380472, 0.31266716, 0.52666146, 0.27854705, 0.20650926, 0.1509405, 0.13555165, + 0.32066464, 0.5835065, 0.30205357, 0.5568808, 0.7721817, 0.18058343, 0.123428136, 0.31721902, + 0.45034164, 0.16623993, 0.5156516, 0.4918172, 0.7763435, 0.75444514, 0.7214952, 0.91781616, + 0.29374766, 0.704666, 0.5429698, 0.7243858, 0.21584511, 0.24887188, 0.02371842, 0.7248409, + 0.7059916, 0.012657363, 0.6680217, 0.37040663, 0.785419, 0.7685805, 0.37138042, 0.12108998, + 0.83829355, 0.80708104, 0.08948117, 0.108886935, 0.93076944, 0.8893351, 0.30923343, 0.061936773, + 0.29264367, 0.07688689, 0.11510216, 0.8839925, 0.02477082, 0.64811826, 0.08550372, 0.17564313, + 0.11655201, 0.39485103, 0.23291379, 0.57388103, 0.6635394, 0.42655468, 0.9197065, 0.071792774, + 0.5597881, 0.57721263, 0.8508891, 0.75952435, 0.5125618, 0.75302154, 0.53180003, 0.6817611, + 0.79485947, 0.3945616, 0.6535236, 0.9692625, 0.66496396, 0.61260825, 0.98704666, 0.40441254, + 0.3954326, 0.48103306, 0.43174213, 0.13895822, 0.13376972, 0.13972592, 0.7000701, 0.05787335, + 0.92715365, 0.49237853, 0.2538546, 0.390568, 0.5356667, 0.7974994, 0.45755056, 0.41173887, + 0.8873745, 0.017688395, 0.54909885, 0.3535568, 0.038445998, 0.54970914, 0.549375, 0.5396221, + 0.54508686, 0.43334106, 0.089132994, 0.6302092, 0.99459463, 0.11624123, 0.5106792, 0.50394374, + 0.40780434, 0.8285013, 0.17844845, 0.18250638, 0.99481255, 0.7807483, 0.93802303, 0.42006215, + 0.87714255, 0.7930158, 0.8323707, 0.020183232, 0.4991669, 0.14123203, 0.1460944, 0.9973601, + 0.93701106, 0.24178477, 0.081888, 0.64727557, 0.06350941, 0.6334899, 0.36596653, 0.84572345, + 0.931658, 0.89212, 0.59387136, 0.70042866, 0.050592937, 0.06986087, 0.063278705, 0.81091243, + 0.98169935, 0.74991083, 0.98276365, 0.7071655, 0.6190509, 0.27504414, 0.41692632, 0.106626175, + 0.07966534, 0.12903668, 0.47641423, 0.24543023, 0.71733844, 0.5291918, 0.040455237, 0.40385485, + 0.28724664, 0.091772884, 0.69319814, 0.7528099, 0.034353238, 0.8634036, 0.44043434, 0.77431446, + 0.46253473, 0.332725, 0.25084835, 0.10269255, 0.18687698, 0.23759438, 0.36946923, 0.8072817, + 0.72973704, 0.021458272, 0.038483858, 0.7492561, 0.1584684, 0.43892893, 0.37830916, 0.6619669, + 0.8248584, 0.9752618, 0.5676102, 0.93447274, 0.15707563, 0.120536305, 0.12838502, 0.40246627, + 0.8516648, 0.19001648, 0.41318202, 0.95882004, 0.3766627, 0.31046882, 0.7765592, 0.11829578, + 0.3094765, 0.20844917, 0.24463072, 0.28632593, 0.024195805, 0.31423378, 0.9197492, 0.84207094, + 0.75956744, 0.66913253, 0.5156932, 0.6958802, 0.4907079, 0.29119918, 0.24538647, 0.8483177, + 0.7134637, 0.031231258, 0.92795146, 0.059091415, 0.29579335, 0.5059616, 0.6172388, 0.34199843, + 0.20433997, 0.84838206, 0.2510278, 0.9968605, 0.82441235, 0.41064918, 0.43061897, 0.41926822, + 0.2448991, 0.92018807, 0.43977955, 0.95001924, 0.19429821, 0.09198324, 0.63777107, 0.51062465, + 0.055512622, 0.72553927, 0.17490527, 0.48794308, 0.60484314, 0.43250486, 0.91175836, 0.5604656, + 0.94463, 0.56486434, 0.24535634, 0.34543145, 0.38251737, 0.7174677, 0.82250243, 0.8035149, + 0.59121037, 0.9026323, 0.081985965, 0.17581372, 0.06320599, 0.9228887, 0.017658591, 0.3489183, + 0.23851357, 0.096424945, 0.45098105, 0.57051986, 0.8514196, 0.29536724, 0.6540195, 0.62148046, + 0.39346015, 0.41732678, 0.0035787956, 0.5702541, 0.33105636, 0.12929575, 0.7371553, 0.7718351, + 0.93662375, 0.6905622, 0.052230474, 0.25954804, 0.16529284, 0.08518753, 0.03675085, 0.52743137, + 0.097685665, 0.6362647, 0.35880888, 0.2916659, 0.009997273, 0.46195737, 0.4474187, 0.13262391, + 0.7078807, 0.825987, 0.24942951, 0.5084182, 0.9815238, 0.3412385, 0.70904595, 0.6492628, + 0.9108448, 0.62387586, 0.9519713, 0.9651906, 0.71388894, 0.25224832, 0.4724585, 0.4619146, + 0.16547702, 0.31015086, 0.23919, 0.37264377, 0.8706582, 0.7581105, 0.18362544, 0.15332605, + 0.05967409, 0.9235497, 0.47283417, 0.21515496, 0.93655837, 0.3623536, 0.6114832, 0.93150276, + 0.9699081, 0.8709549, 0.8623734, 0.5050694, 0.87986624, 0.2287371, 0.7903113, 0.5953852, + 0.98151624, 0.40296772, 0.34870324, 0.541417, 0.13321623, 0.07156025, 0.81354237, 0.84543735, + 0.16380614, 0.8968943, 0.12618889, 0.6998464, 0.22276738, 0.07477489, 0.2619657, 0.94977015, + 0.6423615, 0.09610346, 0.4487441, 0.05797409, 0.8684043, 0.49389097, 0.7127044, 0.54849124, + 0.012392659, 0.020468513, 0.99528253, 0.8429341, 0.3898749, 0.96738917, 0.58204836, 0.9367399, + 0.5198395, 0.6438048, 0.39112753, 0.46769053, 0.40940732, 0.64220846, 0.02010981, 0.9881138, + 0.11000732, 0.6273968, 0.051348828, 0.039664086, 0.2361647, 0.91163677, 0.7087354, 0.8951332, + 0.6089892, 0.91260326, 0.86270785, 0.7837628, 0.779993, 0.73233724, 0.72698087, 0.48762527, + 0.69026333, 0.800212, 0.5290243, 0.11274772, 0.07627774, 0.9706083, 0.45556244, 0.19641699, + 0.31484595, 0.18944897, 0.18000686, 0.5789626, 0.6836474, 0.79427516, 0.54036283, 0.00015307916, + 0.07599365, 0.46063024, 0.94796675, 0.24100749, 0.44254217, 0.67304033, 0.31232652, 0.10075587, + 0.31173313, 0.100149296, 0.23394488, 0.47727165, 0.10468131, 0.79828554, 0.1567469, 0.78750235, + 0.9168239, 0.9035022, 0.7774272, 0.6091953, 0.11318414, 0.9073621, 0.9118361, 0.139399, + 0.17183441, 0.85493183, 0.7248181, 0.04671574, 0.7316299, 0.1297728, 0.21148583, 0.814714, + 0.37224042, 0.8625547, 0.70776916, 0.31936276, 0.7843705, 0.4859734, 0.04508312, 0.017223012, + 0.4878855, 0.42826846, 0.8010146, 0.97612846, 0.73666346, 0.9782908, 0.09173568, 0.51656044, + 0.032702066, 0.3925045, 0.6621387, 0.7801451, 0.01684795, 0.93116754, 0.886969, 0.16863157, + 0.54879415, 0.80856776, 0.06917309, 0.5876103, 0.94822216, 0.26561078, 0.36912593, 0.18196031, + 0.8886635, 0.41923082, 0.1050312, 0.24212655, 0.09051639, 0.8373841, 0.0031318855, 0.4308505, + 0.8584191, 0.7602042, 0.121309794, 0.68491566, 0.10634747, 0.9357077, 0.4027356, 0.19354361, + 0.7631962, 0.2082577, 0.014013676, 0.3391254, 0.46763408, 0.43134072, 0.7978661, 0.44107288, + 0.9755858, 0.5391376, 0.7705686, 0.9758027, 0.4168003, 0.4574728, 0.06900084, 0.22227472, + 0.059142508, 0.6190543, 0.08746498, 0.3174326, 0.8732596, 0.84960914, 0.42604402, 0.19531794, + 0.38937265, 0.2312882, 0.921726, 0.25664374, 0.8098577, 0.20205325, 0.06228409, 0.61308646, + 0.40583217, 0.8756295, 0.8244142, 0.7399645, 0.2515971, 0.030000538, 0.7143262, 0.45732272, + 0.6213647, 0.6639583, 0.26654074, 0.5513788, 0.0668155, 0.02732918, 0.014050223, 0.40094635, + 0.69120336, 0.8990351, 0.6257732, 0.48729318, 0.8482427, 0.08530297, 0.320284, 0.91358703, + 0.7822137, 0.8186957, 0.94975275, 0.2363459, 0.50961477, 0.54122233, 0.63121516, 0.77353257, + 0.4768535, 0.15748215, 0.56997055, 0.54117084, 0.6330586, 0.32903638, 0.9706776, 0.02914197, + 0.90472806, 0.6301423, 0.69606787, 0.20930128, 0.5830684, 0.8746652, 0.12850243, 0.36204344, + 0.21723796, 0.5207796, 0.5654404, 0.9108227, 0.57628006, 0.5749909, 0.7648438, 0.3205292, + 0.5553455, 0.91082716, 0.9577508, 0.43290135, 0.08024777, 0.47798032, 0.94770795, 0.0801424, + 0.03274318, 0.49300817, 0.07452531, 0.90933335, 0.45735866, 0.4728794, 0.7678877, 0.362167, + 0.9283575, 0.5966312, 0.5825651, 0.21810043, 0.3892351, 0.11098274, 0.33051863, 0.9075484, + 0.6901933, 0.5877093, 0.019107932, 0.9888351, 0.9757819, 0.72039247, 0.19725248, 0.90186256, + 0.39263836, 0.24944134, 0.98582536, 0.72223145, 0.3712856, 0.5377763, 0.9488942, 0.42674774, + 0.68243426, 0.6159255, 0.1765581, 0.09006023, 0.8001399, 0.21916907, 0.9046848, 0.74435854, + 0.7528919, 0.20327342, 0.9824652, 0.9796489, 0.9924258, 0.5467434, 0.9312941, 0.44436273, + 0.58030856, 0.05020233, 0.742708, 0.49253845, 0.4588724, 0.95887285, 0.10436046, 0.31235072, + 0.29575568, 0.17266272, 0.516695, 0.20791732, 0.48705408, 0.045656245, 0.9908814, 0.3905812, + 0.647737, 0.15581739, 0.5356661, 0.77330965, 0.93442464, 0.2404584, 0.10740854, 0.47102425, + 0.6830245, 0.27474937, 0.2359432, 0.7725085, 0.73792726, 0.21760361, 0.9094368, 0.845895, + 0.31814724, 0.5414626, 0.14192294, 0.32108325, 0.7950682, 0.45635575, 0.96787536, 0.72356147, + 0.511565, 0.8642074, 0.79430455, 0.62747717, 0.70247406, 0.6967675, 0.2573045, 0.7072357, + 0.212392, 0.591884, 0.33191186, 0.8366084, 0.01107724, 0.15798447, 0.5099381, 0.33985013, + 0.9427938, 0.27168378, 0.8095139, 0.18412302, 0.72292966, 0.33185193, 0.5744235, 0.078152075, + 0.2632259, 0.67080003, 0.8897701, 0.94559145, 0.9037333, 0.66979814, 0.595513, 0.19138126, + 0.18794204, 0.8121047, 0.26174462, 0.07021725, 0.44615385, 0.47993135, 0.76855016, 0.986257, + 0.017444894, 0.5287075, 0.5601165, 0.1460432, 0.88569176, 0.07282839, 0.8348177, 0.16016278, + 0.031524524, 0.80207276, 0.37828946, 0.52338445, 0.6468418, 0.7837523, 0.00063179433, 0.17971309, + 0.2897839, 0.7161524, 0.3642513, 0.031674027, 0.8069974, 0.31171304, 0.8035024, 0.54259384, + 0.9963711, 0.14053062, 0.6486664, 0.19897254, 0.8962398, 0.43972084, 0.8936963, 0.46286246, + 0.5031336, 0.8232569, 0.16667813, 0.19422211, 0.7717354, 0.42838028, 0.19246033, 0.19039753, + 0.8359823, 0.7296073, 0.9140669, 0.10166052, 0.29150867, 0.07212853, 0.54453945, 0.40418974, + 0.8114729, 0.08203155, 0.78043336, 0.7300014, 0.11568007, 0.73687613, 0.1792596, 0.70573187, + 0.7252052, 0.017522655, 0.14967212, 0.7451611, 0.42416203, 0.6358452, 0.26392296, 0.59180367, + 0.9083765, 0.915427, 0.020250821, 0.8235849, 0.6170742, 0.80640966, 0.40797767, 0.86140364, + 0.52369213, 0.17385374, 0.19569172, 0.07739012, 0.3976461, 0.70184183, 0.2510852, 0.92424256, + 0.59599113, 0.24447663, 0.38749963, 0.81420827, 0.6592875, 0.16369487, 0.34718236, 0.76625746, + 0.6439973, 0.46094626, 0.46901694, 0.75421274, 0.27870816, 0.44729918, 0.76623553, 0.20013711, + 0.46568435, 0.32226324, 0.193284, 0.37608168, 0.051877704, 0.72095454, 0.7871155, 0.0050632227, + 0.6740539, 0.9190297, 0.20630927, 0.94182634, 0.5411844, 0.10186948, 0.30808574, 0.023363324, + 0.7664375, 0.22542956, 0.14916998, 0.17968538, 0.24834555, 0.44971466, 0.93251616, 0.74468166, + 0.56824464, 0.25399336, 0.17958756, 0.15612793, 0.33739275, 0.6537649, 0.5826955, 0.07639295, + 0.40761822, 0.9955546, 0.6117058, 0.07538286, 0.50855786, 0.8750035, 0.8723649, 0.8750366, + 0.4573611, 0.38243642, 0.1401544, 0.7402578, 0.9573856, 0.40535605, 0.22507304, 0.54212785, + 0.1528605, 0.44565362, 0.98777527, 0.05327858, 0.2981292, 0.5865501, 0.9517916, 0.015969688, + 0.38974705, 0.44860238, 0.807837, 0.79788435, 0.541367, 0.6309876, 0.6676705, 0.02028897, + 0.33633423, 0.12991633, 0.5342081, 0.5456298, 0.4901637, 0.2327029, 0.5148055, 0.89143395, + 0.35306472, 0.27413338, 0.7223243, 0.86590916, 0.30956024, 0.1922584, 0.787296, 0.1628886, + 0.02892033, 0.6374597, 0.0032674163, 0.89173913, 0.66598964, 0.5294169, 0.77826375, 0.8210681, + 0.043763056, 0.5957361, 0.6856358, 0.05995547, 0.06716649, 0.07448051, 0.3336696, 0.8263735, + 0.7147659, 0.11986544, 0.40392354, 0.8274693, 0.87114793, 0.67944324, 0.051964145, 0.9201576, + 0.9308481, 0.096341334, 0.70021385, 0.02399584, 0.8642258, 0.08588241, 0.70640945, 0.19748867, + 0.6613063, 0.6449484, 0.768964, 0.9039073, 0.6277202, 0.77593136, 0.35429934, 0.8069173, + 0.3516526, 0.71314, 0.50186676, 0.8944276, 0.5470671, 0.45485002, 0.82426745, 0.2785842, + 0.9404638, 0.8959508, 0.15114321, 0.18969482, 0.78833485, 0.9598267, 0.29174066, 0.3494771, + 0.5854956, 0.0831098, 0.960891, 0.56964827, 0.829203, 0.7542679, 0.9568423, 0.9578806, + 0.88932663, 0.48814714, 0.39864913, 0.42221805, 0.3055165, 0.42976233, 0.19865331, 0.93883455, + 0.7655661, 0.5970062, 0.4758167, 0.15800795, 0.17757647, 0.15753652, 0.3730905, 0.47599813, + 0.27207386, 0.42162967, 0.08353208, 0.96827507, 0.9347392, 0.51671463, 0.40915382, 0.7014796, + 0.35320777, 0.4194869, 0.3184117, 0.5446104, 0.81504035, 0.78465104, 0.9777143, 0.5973847, + 0.7562977, 0.54398614, 0.0051009622, 0.05891997, 0.05620089, 0.4020494, 0.9730677, 0.5107014, + 0.69729745, 0.21230865, 0.4241287, 0.19132863, 0.48401004, 0.1337327, 0.17190064, 0.42795905, + 0.7100193, 0.48489287, 0.29757443, 0.40757337, 0.67073584, 0.98856723, 0.023141444, 0.37261203, + 0.07899332, 0.6971695, 0.06901029, 0.8860296, 0.11135061, 0.65404296, 0.12379419, 0.98091507, + 0.6192919, 0.878432, 0.40171024, 0.63359034, 0.15243557, 0.31417054, 0.41979724, 0.87002444, + 0.44856197, 0.5728306, 0.2709776, 0.7224305, 0.09258589, 0.21782517, 0.21746957, 0.21947508, + 0.24758625, 0.8904527, 0.8345911, 0.3301475, 0.48707664, 0.57014096, 0.92664886, 0.7677305, + 0.5208447, 0.6324889, 0.97992665, 0.35903138, 0.3330391, 0.0870381, 0.39935082, 0.043254532, + 0.08851445, 0.44321367, 0.57203674, 0.60557806, 0.73202246, 0.5383103, 0.27552348, 0.39584875, + 0.06509563, 0.42754996, 0.95901144, 0.09790518, 0.7175897, 0.3007109, 0.28002614, 0.86116815, + 0.47969994, 0.8495352, 0.63844335, 0.22089794, 0.8194518, 0.7936467, 0.4938384, 0.049150985, + 0.9517831, 0.6339798, 0.11274567, 0.51994663, 0.3342439, 0.060765848, 0.53698534, 0.36152387, + 0.17347981, 0.22772305, 0.6339161, 0.6493722, 0.64578843, 0.6118915, 0.48745263, 0.70927596, + 0.6149292, 0.43874234, 0.26505187, 0.05952667, 0.6111295, 0.8287437, 0.050140806, 0.22013378, + 0.35246277, 0.1187585, 0.87933147, 0.4835039, 0.44859475, 0.1784529, 0.2238027, 0.29486778, + 0.9493753, 0.52288574, 0.65379494, 0.09804267, 0.42556462, 0.75557685, 0.061604857, 0.0043297815, + 0.8905646, 0.59748757, 0.92442536, 0.4898666, 0.6667948, 0.6306539, 0.21537969, 0.8678084, + 0.3620826, 0.9291674, 0.6059688, 0.3807095, 0.5285948, 0.43431175, 0.43802148, 0.123039424, + 0.583839, 0.8926119, 0.16748385, 0.2154854, 0.18143441, 0.05348144, 0.9129291, 0.99502695, + 0.003920352, 0.33904833, 0.69999695, 0.12290272, 0.9580966, 0.38940993, 0.2837113, 0.85935235, + 0.37713748, 0.2607221, 0.16896206, 0.013641968, 0.90431833, 0.5602742, 0.553339, 0.72180885, + 0.9033788, 0.011523027, 0.1214213, 0.51942736, 0.57248414, 0.8430932, 0.76627296, 0.5150635, + 0.084864266, 0.5307555, 0.51420367, 0.5329527, 0.588093, 0.84611946, 0.82289535, 0.83708316, + 0.68455845, 0.9293985, 0.48594627, 0.32774645, 0.930657, 0.092476964, 0.9097118, 0.97267264, + 0.6454561, 0.74661636, 0.003572011, 0.2678727, 0.2653497, 0.4243795, 0.2187211, 0.023564778, + 0.3392729, 0.44567502, 0.31210658, 0.16991138, 0.9320601, 0.39350176, 0.42254278, 0.16082714, + 0.57277536, 0.18493341, 0.03803846, 0.4273411, 0.87520623, 0.7507586, 0.27125937, 0.531018, + 0.43782672, 0.33187887, 0.32908353, 0.97491986, 0.07432794, 0.22559255, 0.7911518, 0.8109018, + 0.10181122, 0.14874865, 0.8739713, 0.8258678, 0.83952117, 0.49840027, 0.24971384, 0.6604848, + 0.3120344, 0.4906389, 0.19367984, 0.14241797, 0.5340129, 0.65298396, 0.90502304, 0.2910567, + 0.50685567, 0.3251191, 0.7549711, 0.7457236, 0.054438505, 0.4823707, 0.09746641, 0.8946975, + 0.47535703, 0.472554, 0.83004594, 0.9334708, 0.09529597, 0.24380124, 0.9492368, 0.11368034, + 0.6545232, 0.5012047, 0.06810016, 0.7833115, 0.5195305, 0.59667504, 0.32130596, 0.07437508, + 0.9352196, 0.3775537, 0.11530671, 0.38456735, 0.5570788, 0.12884142, 0.9970051, 0.7848427, + 0.42685586, 0.03802683, 0.4680642, 0.7492088, 0.47062147, 0.045428254, 0.75646335, 0.6194405, + 0.05128224, 0.9792738, 0.35051075, 0.3669672, 0.66835433, 0.31624305, 0.56518877, 0.06823316, + 0.5414021, 0.0799995, 0.4878948, 0.032808155, 0.5848838, 0.12171154, 0.7715262, 0.9101807, + 0.0038131434, 0.680596, 0.810504, 0.67688483, 0.36706397, 0.7128991, 0.3376187, 0.3465156, + 0.47554886, 0.04520323, 0.5066149, 0.05726915, 0.77573705, 0.200028, 0.6430589, 0.6090949, + 0.7447414, 0.44865963, 0.73202926, 0.5402566, 0.24616429, 0.9543388, 0.40602076, 0.61897653, + 0.8123649, 0.047073558, 0.8431653, 0.47707924, 0.6409466, 0.964197, 0.1999589, 0.3051443, + 0.2665006, 0.5578835, 0.7453957, 0.7900255, 0.23492423, 0.07957853, 0.25237653, 0.33838317, + 0.6416551, 0.0039951354, 0.89141834, 0.62315106, 0.80962807, 0.50791967, 0.29249611, 0.34137407, + 0.4369406, 0.8787999, 0.28806677, 0.1362242, 0.3896823, 0.23126958, 0.66401637, 0.049474377, + 0.27457523, 0.19152752, 0.8645199, 0.31999043, 0.8697338, 0.8605395, 0.70556897, 0.5113519, + 0.84524435, 0.20147063, 0.79076856, 0.21785353, 0.4546323, 0.8530334, 0.3741707, 0.66516286, + 0.1962831, 0.3936461, 0.89860153, 0.24216916, 0.062920436, 0.7828697, 0.8093484, 0.30444527, + 0.75457746, 0.5017912, 0.040138636, 0.7621467, 0.6761302, 0.06373471, 0.915462, 0.035231, + 0.89386714, 0.6959213, 0.51545024, 0.04339671, 0.21505861, 0.9323861, 0.46864936, 0.7811156, + 0.29842615, 0.38006642, 0.7779068, 0.60815746, 0.7171511, 0.07464257, 0.88674176, 0.5839072, + 0.5046292, 0.6229039, 0.9399411, 0.9960362, 0.33266804, 0.42184722, 0.9865539, 0.49170554, + 0.38217908, 0.5600747, 0.565413, 0.36794263, 0.82040083, 0.94342226, 0.8352217, 0.78150964, + 0.2860086, 0.75553757, 0.32398638, 0.758711, 0.3375832, 0.33077398, 0.45010427, 0.26389697, + 0.92499673, 0.11748593, 0.943743, 0.682854, 0.004962936, 0.20119096, 0.58729416, 0.67993486, + 0.6150494, 0.45623145, 0.25751752, 0.053226303, 0.12379362, 0.91942585, 0.702563, 0.47201994, + 0.7093674, 0.023744669, 0.66121763, 0.65498394, 0.36697313, 0.10070673, 0.96071476, 0.3550039, + 0.54484475, 0.99639714, 0.32214886, 0.96161354, 0.7506562, 0.12803078, 0.24632397, 0.17385522, + 0.17279965, 0.6760441, 0.071039446, 0.2151821, 0.4781042, 0.30369994, 0.48674262, 0.18098812, + 0.97278047, 0.8854781, 0.7528932, 0.3641694, 0.68590474, 0.7819954, 0.657716, 0.36658275, + 0.05297459, 0.85196644, 0.049343612, 0.31383854, 0.6695563, 0.7951203, 0.89692384, 0.82429004, + 0.15677115, 0.5887391, 0.13800927, 0.0085657975, 0.8790421, 0.6256806, 0.9292787, 0.48701864, + 0.20990747, 0.083662316, 0.88042665, 0.4477495, 0.8483864, 0.48738086, 0.99391574, 0.40566745, + 0.537002, 0.4802295, 0.6822035, 0.48149505, 0.34781352, 0.5965454, 0.66909915, 0.76284933, + 0.33868113, 0.9555661, 0.90863895, 0.89868975, 0.07868716, 0.93248546, 0.50429887, 0.37767935, + 0.77912027, 0.24674945, 0.05841095, 0.8893651, 0.16569066, 0.4781768, 0.301946, 0.34709984, + 0.9561994, 0.26587456, 0.15426192, 0.6022424, 0.9015687, 0.20996648, 0.51819634, 0.5655937, + 0.8580507, 0.64367616, 0.7768365, 0.18932684, 0.11291685, 0.4154288, 0.4764765, 0.5602257, + 0.91964, 0.37515992, 0.6698847, 0.923476, 0.7170417, 0.030588947, 0.40833148, 0.27742204, + 0.57936347, 0.5027473, 0.6686292, 0.60163695, 0.42896992, 0.10455062, 0.2399768, 0.058825243, + 0.17828348, 0.3351036, 0.5252956, 0.08193896, 0.44228348, 0.06685673, 0.8612806, 0.12871465, + 0.43736976, 0.34304523, 0.040639006, 0.435011, 0.15564895, 0.314972, 0.2647625, 0.36369145, + 0.770273, 0.4981852, 0.96972513, 0.79053074, 0.80829215, 0.37847006, 0.63005817, 0.9256105, + 0.85754305, 0.8768399, 0.022878975, 0.3988214, 0.54133725, 0.9165594, 0.1366238, 0.7535001, + 0.40369937, 0.71801126, 0.011043364, 0.77781326, 0.89013314, 0.39453754, 0.11794228, 0.85278326, + 0.5138793, 0.54117, 0.4861062, 0.37399647, 0.98994994, 0.9733205, 0.12177309, 0.26439142, + 0.23798482, 0.30493778, 0.83136404, 0.9307847, 0.13482551, 0.44944605, 0.25053307, 0.7998134, + 0.70504546, 0.5996852, 0.22439589, 0.5654436, 0.043977752, 0.4624592, 0.5873774, 0.52081037, + 0.20642142, 0.2871389, 0.031311635, 0.43763772, 0.30392867, 0.48694924, 0.4735583, 0.37573543, + 0.3802429, 0.11694187, 0.27665144, 0.26712215, 0.89236385, 0.25606167, 0.93566054, 0.8842226, + 0.7550668, 0.7584876, 0.16083659, 0.23639946, 0.08519537, 0.20583908, 0.6186746, 0.9542533, + 0.46747816, 0.21122995, 0.07276781, 0.29044798, 0.17014165, 0.5524987, 0.8088055, 0.0514201, + 0.9537926, 0.9652958, 0.16757506, 0.70281106, 0.94200885, 0.6841354, 0.96046275, 0.7510356, + 0.8313795, 0.45562857, 0.5505418, 0.017883644, 0.17279461, 0.9834109, 0.90744954, 0.44898376, + 0.66402465, 0.34017327, 0.81037676, 0.28549019, 0.3016226, 0.35097796, 0.43561503, 0.00058234343, + 0.6684643, 0.07705832, 0.97015953, 0.092698716, 0.41418144, 0.18311031, 0.20559378, 0.82774425, + 0.30813637, 0.22523133, 0.31332958, 0.92706805, 0.08848662, 0.23284948, 0.9422138, 0.07093142, + 0.7980248, 0.409801, 0.40501997, 0.6295668, 0.6552973, 0.600791, 0.7814587, 0.48406723, + 0.3037804, 0.62378407, 0.62642336, 0.82996833, 0.7421219, 0.5233153, 0.74979746, 0.6028146, + 0.5296808, 0.16699271, 0.03434674, 0.86495054, 0.71397585, 0.86776406, 0.33685416, 0.6482692, + 0.2500348, 0.7227976, 0.70974725, 0.9475633, 0.6700813, 0.9803815, 0.36049715, 0.43117517, + 0.39795953, 0.7394454, 0.4874654, 0.8918216, 0.94595796, 0.8060482, 0.3452851, 0.06767335, + 0.29559964, 0.4860923, 0.7889183, 0.7903974, 0.556687, 0.3756254, 0.08562232, 0.7848211, + 0.47543386, 0.71051496, 0.3973873, 0.9214939, 0.19850273, 0.07726323, 0.3569556, 0.9302608, + 0.072946854, 0.7567508, 0.37953198, 0.9324997, 0.89104366, 0.8338954, 0.8139859, 0.32339892, + 0.2632869, 0.19524816, 0.43200883, 0.002676534, 0.035849903, 0.8579759, 0.65685666, 0.7236325, + 0.82170767, 0.9666734, 0.5693509, 0.22788355, 0.07884572, 0.54645675, 0.09158218, 0.8744094, + 0.63717526, 0.9249262, 0.47212943, 0.9595664, 0.58299416, 0.43900326, 0.23267244, 0.3206963, + 0.3824898, 0.55720466, 0.8188748, 0.18920717, 0.42651626, 0.41278538, 0.17662966, 0.46170422, + 0.6721064, 0.4655194, 0.5271105, 0.3614388, 0.94361657, 0.08294579, 0.74897116, 0.617458, + 0.053658314, 0.67375475, 0.09978627, 0.23182935, 0.50791234, 0.12907204, 0.85141504, 0.5264901, + 0.66516864, 0.50512254, 0.29532441, 0.9661175, 0.36176598, 0.8544195, 0.7404047, 0.82428366, + 0.96257573, 0.11131253, 0.62018675, 0.47864527, 0.039101128, 0.46764946, 0.29711628, 0.40892226, + 0.7900437, 0.10764668, 0.55577713, 0.6133263, 0.019346252, 0.73014337, 0.9307928, 0.5542295, + 0.17595504, 0.8546715, 0.90590805, 0.9092394, 0.33921698, 0.0008430821, 0.81278396, 0.25341776, + 0.7057896, 0.29238465, 0.52403855, 0.9213937, 0.11746097, 0.21051219, 0.09993823, 0.8176869, + 0.72511464, 0.70282686, 0.3988631, 0.83230406, 0.46275905, 0.2703259, 0.57835686, 0.58600885, + 0.3766385, 0.690864, 0.44178563, 0.40026566, 0.5732949, 0.23808873, 0.50714386, 0.9350253, + 0.57432973, 0.74109495, 0.79016244, 0.5070945, 0.9485114, 0.8311653, 0.48506665, 0.9617326, + 0.29852858, 0.366769, 0.77285564, 0.74671644, 0.94361097, 0.3757226, 0.29146126, 0.57953155, + 0.007708449, 0.7380902, 0.88821167, 0.31651938, 0.33128026, 0.09848877, 0.09147043, 0.90562916, + 0.27631462, 0.31989923, 0.53260094, 0.648353, 0.5590575, 0.4125183, 0.68012285, 0.4677009, + 0.7852408, 0.5890133, 0.34706393, 0.37636602, 0.42034975, 0.5928437, 0.86917543, 0.89394933, + 0.21776019, 0.43713045, 0.5337755, 0.09599007, 0.49747026, 0.83164036, 0.6423979, 0.00091591524, + 0.39940274, 0.8622541, 0.3925572, 0.83520466, 0.3498771, 0.19062445, 0.603745, 0.475841, + 0.6496245, 0.8845333, 0.2307799, 0.6286122, 0.29856437, 0.83671373, 0.40267518, 0.8860103, + 0.6866461, 0.30515477, 0.9614757, 0.3545977, 0.028658632, 0.9150952, 0.15918177, 0.41486475, + 0.8689148, 0.9942623, 0.0987592, 0.8941498, 0.5647133, 0.99548036, 0.40815887, 0.44467425, + 0.6775013, 0.531685, 0.24895021, 0.69680333, 0.019961093, 0.8449182, 0.1178238, 0.59461635, + 0.98526824, 0.871223, 0.7267415, 0.53581643, 0.3620638, 0.24056326, 0.59538496, 0.38104647, + 0.034455262, 0.6477652, 0.40934396, 0.19231549, 0.8701647, 0.28780022, 0.97225726, 0.48430753, + 0.7030723, 0.9776925, 0.9662899, 0.3556148, 0.09186526, 0.7095952, 0.9111277, 0.65414417, + 0.47637445, 0.78610563, 0.9511109, 0.7668794, 0.5877635, 0.7058718, 0.8660492, 0.8417279, + 0.18733096, 0.3668593, 0.36932942, 0.15743567, 0.18835372, 0.62336534, 0.05280094, 0.6283515, + 0.3988773, 0.7177127, 0.85969454, 0.9169481, 0.5861364, 0.21584338, 0.5745095, 0.3897011, + 0.55942774, 0.7646427, 0.993731, 0.042268623, 0.8786283, 0.762209, 0.5027511, 0.27567303, + 0.9600953, 0.072597355, 0.059442017, 0.57595813, 0.2894524, 0.82850564, 0.793283, 0.32858342, + 0.78171605, 0.56761605, 0.0049845274, 0.50330544, 0.9184708, 0.8148216, 0.29595378, 0.07970701, + 0.92489153, 0.33793837, 0.9567375, 0.37415254, 0.84990066, 0.9941796, 0.06800775, 0.26053104, + 0.21159613, 0.5614098, 0.20745164, 0.8231208, 0.7121408, 0.82378054, 0.9630996, 0.42512196, + 0.8641082, 0.09365638, 0.19734041, 0.11575636, 0.5639233, 0.4768428, 0.33889914, 0.5703717, + 0.9244297, 0.5311111, 0.13523202, 0.01852037, 0.21085885, 0.071204096, 0.4712303, 0.74460614, + 0.4686889, 0.914024, 0.117377095, 0.54068995, 0.80547154, 0.12859856, 0.4257724, 0.9659156, + 0.0045896024, 0.798911, 0.36436203, 0.7280426, 0.621054, 0.9701622, 0.6164426, 0.9579355, + 0.6045164, 0.5798626, 0.63919723, 0.82481444, 0.61748123, 0.18019743, 0.5157837, 0.44804874, + 0.99903923, 0.3863658, 0.44972283, 0.31878954, 0.85894763, 0.049487386, 0.04967219, 0.14039204, + 0.09017946, 0.4628455, 0.3544319, 0.7981168, 0.70640343, 0.42240968, 0.6196504, 0.73550963, + 0.667884, 0.23142478, 0.11116676, 0.7650123, 0.112480775, 0.6108565, 0.9493177, 0.9542675, + 0.9146685, 0.17729652, 0.41400397, 0.6309963, 0.43200687, 0.6464159, 0.12712492, 0.2884915, + 0.3982403, 0.66932833, 0.54165065, 0.4191057, 0.67887574, 0.10698286, 0.10696802, 0.9551022, + 0.7492388, 0.22396998, 0.63786316, 0.15820846, 0.6157303, 0.8183258, 0.25153205, 0.18210672, + 0.9602121, 0.9036876, 0.15693043, 0.38605642, 0.06903067, 0.7507714, 0.33556795, 0.38818276, + 0.43704808, 0.4954553, 0.40412104, 0.6816511, 0.63548344, 0.4186759, 0.70838517, 0.44376358, + 0.3357206, 0.06594042, 0.39987648, 0.037075095, 0.88075906, 0.20054473, 0.05663389, 0.5609011, + 0.124456756, 0.15606454, 0.015773552, 0.88851076, 0.9729933, 0.79110926, 0.33853722, 0.09634267, + 0.9257645, 0.23189723, 0.6707842, 0.52831924, 0.48948547, 0.7410685, 0.2194608, 0.6474689, + 0.3337604, 0.15346791, 0.98205763, 0.18342042, 0.70286185, 0.42531693, 0.3196188, 0.3305629, + 0.5155848, 0.19409959, 0.82248783, 0.5497899, 0.41844934, 0.21445695, 0.3013477, 0.7596674, + 0.8470537, 0.5960293, 0.26159966, 0.91296613, 0.7349978, 0.44705716, 0.41518942, 0.6459388, + 0.1569181, 0.30777836, 0.7558866, 0.4035862, 0.7478917, 0.18006596, 0.9542781, 0.5946521, + 0.8464796, 0.75240755, 0.7033147, 0.7272911, 0.2184871, 0.87321347, 0.8580393, 0.69913983, + 0.83644575, 0.68521065, 0.372926, 0.77889377, 0.96862143, 0.7887473, 0.67789334, 0.7113075, + 0.93054956, 0.9111168, 0.6812655, 0.89345616, 0.47946882, 0.30649468, 0.9124711, 0.88670325, + 0.7382785, 0.33611885, 0.026502334, 0.39508346, 0.6694303, 0.9160326, 0.5826711, 0.33551884, + 0.23982148, 0.22783574, 0.70331025, 0.6660418, 0.51114225, 0.57405657, 0.5411803, 0.9738403, + 0.73799, 0.5624598, 0.07652036, 0.04978715, 0.07413118, 0.6362957, 0.6773174, 0.36817077, + 0.629885, 0.044579085, 0.47303665, 0.836775, 0.49880046, 0.06082195, 0.115183294, 0.53998494, + 0.83993644, 0.81661147, 0.98901266, 0.88236827, 0.84671116, 0.46295583, 0.029709496, 0.9204132, + 0.10253954, 0.03740714, 0.5390723, 0.74078566, 0.08543706, 0.011851499, 0.20016527, 0.356493, + 0.36993647, 0.70742524, 0.15546617, 0.917009, 0.22997431, 0.86268395, 0.81257206, 0.1019828, + 0.65880144, 0.6583316, 0.7651984, 0.6248512, 0.44299594, 0.74589616, 0.8367184, 0.17899951, + 0.11265245, 0.16332534, 0.8261054, 0.6945308, 0.5850439, 0.65881205, 0.12712914, 0.27503416, + 0.53275037, 0.15610719, 0.9472476, 0.036724042, 0.0972234, 0.9365317, 0.2827337, 0.6180335, + 0.8444138, 0.116543666, 0.46683854, 0.7913752, 0.9053558, 0.19817433, 0.3100106, 0.9772525, + 0.0040394296, 0.8870298, 0.22356682, 0.18837956, 0.6977574, 0.40485826, 0.47741726, 0.35664338, + 0.20068875, 0.36007276, 0.62813324, 0.92211175, 0.1857461, 0.5056345, 0.7714491, 0.7111244, + 0.5802961, 0.880432, 0.3842586, 0.07386713, 0.9154364, 0.775848, 0.0047594067, 0.7222697, + 0.37559786, 0.14716488, 0.7804374, 0.32645226, 0.27905762, 0.04534316, 0.27364373, 0.9144781, + 0.8533147, 0.84885293, 0.6904914, 0.6980141, 0.43524522, 0.93874955, 0.57727677, 0.1278921, + 0.67868996, 0.5906042, 0.8360353, 0.73715067, 0.30839851, 0.360622, 0.43228745, 0.33877933, + 0.3450946, 0.7557141, 0.21107915, 0.024923787, 0.8139157, 0.23614348, 0.061816096, 0.22819144, + 0.88227046, 0.5012971, 0.8127817, 0.55059254, 0.6244208, 0.15096499, 0.07758577, 0.15534559, + 0.08642902, 0.7136551, 0.068797, 0.33689317, 0.8151431, 0.073435, 0.27587917, 0.6415465, + 0.30315524, 0.25636652, 0.3951772, 0.32483214, 0.9398127, 0.26760876, 0.41387123, 0.014975904, + 0.7148774, 0.4416581, 0.9813577, 0.5233435, 0.83426404, 0.24871995, 0.100562416, 0.6171712, + 0.78703684, 0.4622999, 0.8157436, 0.93394816, 0.1259679, 0.026684225, 0.50347126, 0.527725, + 0.5130184, 0.6806897, 0.6507216, 0.59474343, 0.29182497, 0.09539426, 0.52363616, 0.27165958, + 0.47983494, 0.56953263, 0.72176856, 0.5575492, 0.8409663, 0.73698395, 0.28837872, 0.6146617, + 0.08742587, 0.7978058, 0.8357151, 0.18276273, 0.16960731, 0.55424225, 0.32108158, 0.83770907, + 0.61309266, 0.45162576, 0.54985636, 0.35284323, 0.25769138, 0.34193105, 0.5155786, 0.27647102, + 0.75289524, 0.86745226, 0.8118137, 0.259123, 0.61688715, 0.8191278, 0.7231509, 0.6194832, + 0.9180219, 0.7096981, 0.043508567, 0.26473138, 0.5269514, 0.5430132, 0.77620494, 0.05005288, + 0.1739212, 0.20108196, 0.8465223, 0.32816213, 0.19096912, 0.32070854, 0.35811764, 0.9587762, + 0.3596081, 0.81301254, 0.9816507, 0.84019923, 0.54553795, 0.17079297, 0.013968218, 0.13790388, + 0.053954035, 0.44529754, 0.80465394, 0.9735141, 0.92517024, 0.029255724, 0.99777454, 0.26829806, + 0.07465485, 0.21623193, 0.2647408, 0.45990923, 0.5107337, 0.056350194, 0.31075767, 0.07007945, + 0.6754208, 0.49980345, 0.17892201, 0.056609415, 0.4954088, 0.18741646, 0.08550189, 0.4321867, + 0.5093346, 0.85303754, 0.89951485, 0.8038746, 0.8374771, 0.88295174, 0.073945254, 0.7472289, + 0.69572985, 0.90560466, 0.21077734, 0.08165387, 0.7383593, 0.80269086, 0.12488264, 0.14466548, + 0.20330743, 0.5782242, 0.2535073, 0.9747372, 0.055967752, 0.8982084, 0.44804245, 0.30325794, + 0.50225484, 0.91157126, 0.16477837, 0.045734458, 0.99187094, 0.9573588, 0.6424951, 0.8665376, + 0.35979563, 0.37246728, 0.46417946, 0.0721327, 0.12974085, 0.19389993, 0.430821, 0.19170313, + 0.14228667, 0.51751184, 0.76417935, 0.605129, 0.8455728, 0.2291038, 0.3317202, 0.87272996, + 0.37492082, 0.034256544, 0.853302, 0.9171846, 0.9339092, 0.11076469, 0.37621894, 0.6111262, + 0.40499508, 0.5962569, 0.30161974, 0.92590576, 0.7181733, 0.028210793, 0.755358, 0.7383711, + 0.2631096, 0.34423977, 0.7218582, 0.365892, 0.3385114, 0.05274994, 0.014924624, 0.0094075035, + 0.1474032, 0.061804168, 0.8324505, 0.5384559, 0.13402902, 0.84291345, 0.45768508, 0.27315107, + 0.5798511, 0.29204842, 0.6708136, 0.9576144, 0.10405682, 0.7253105, 0.9326284, 0.24903095, + 0.99624836, 0.8530533, 0.6671376, 0.5334839, 0.8922802, 0.50491524, 0.47352976, 0.114075884, + 0.76215386, 0.025808325, 0.34201944, 0.50133306, 0.5072456, 0.9658282, 0.53421855, 0.32217088, + 0.019331919, 0.8438945, 0.7697814, 0.872105, 0.27831417, 0.837763, 0.47709718, 0.56208163, + 0.13857186, 0.028468672, 0.34605467, 0.42612493, 0.35739717, 0.79774356, 0.63431424, 0.5377991, + 0.4116114, 0.4728273, 0.36964366, 0.48545814, 0.3856123, 0.48144072, 0.11712731, 0.64248794, + 0.5882744, 0.71837467, 0.77630204, 0.1082207, 0.500894, 0.956352, 0.7659055, 0.6140229, + 0.75782984, 0.34864277, 0.9382825, 0.26016235, 0.9555291, 0.06052337, 0.9707168, 0.15848531, + 0.3759561, 0.10505597, 0.39491206, 0.86381155, 0.15886053, 0.047404833, 0.7566787, 0.96441025, + 0.3914941, 0.8042203, 0.08972167, 0.0344183, 0.59618455, 0.0487604, 0.93655854, 0.5378912, + 0.7267672, 0.12729345, 0.2838306, 0.5599395, 0.06146098, 0.3688765, 0.061187647, 0.18221985, + 0.2625632, 0.7320318, 0.6682951, 0.008754399, 0.85946107, 0.3741519, 0.58227, 0.35108802, + 0.5021105, 0.21115834, 0.10950206, 0.28055635, 0.08652866, 0.25331578, 0.48362744, 0.5408696, + 0.9616959, 0.8118918, 0.7167266, 0.6966737, 0.8666303, 0.73148715, 0.017838325, 0.7090695, + 0.4120842, 0.40039128, 0.5333952, 0.8282356, 0.77669275, 0.41077727, 0.09702433, 0.007079605, + 0.043868326, 0.21269222, 0.6012483, 0.42682874, 0.37910977, 0.7479243, 0.10494917, 0.01734221, + 0.22195028, 0.73863363, 0.5323078, 0.38502622, 0.93925834, 0.6560022, 0.45136255, 0.47345138, + 0.643666, 0.74296105, 0.5982436, 0.24956919, 0.65214986, 0.36451396, 0.31558952, 0.531076, + 0.71419346, 0.9592256, 0.5966702, 0.45906982, 0.8407567, 0.7540344, 0.5743953, 0.09133322, + 0.114134, 0.10242245, 0.23668802, 0.87383646, 0.6520674, 0.056798704, 0.16175981, 0.2137716, + 0.7069426, 0.6993844, 0.4747234, 0.1279967, 0.19917937, 0.6328121, 0.76981115, 0.756082, + 0.94902873, 0.059943788, 0.1845696, 0.03373171, 0.8125337, 0.84745514, 0.35492972, 0.67935437, + 0.8971027, 0.07017233, 0.7126353, 0.41988418, 0.15125412, 0.6458793, 0.1765855, 0.46791586, + 0.16423836, 0.4409746, 0.27089223, 0.83683586, 0.4193142, 0.5775261, 0.82138395, 0.58686733, + 0.58120126, 0.384472, 0.54262656, 0.95276546, 0.8897906, 0.1875928, 0.33189663, 0.08138137, + 0.18941447, 0.8405882, 0.51004106, 0.7808129, 0.5694648, 0.54066354, 0.27879953, 0.26667887, + 0.74749273, 0.55733365, 0.97673374, 0.5818951, 0.34416345, 0.74187565, 0.06251747, 0.061063267, + 0.5227989, 0.0068075284, 0.96375835, 0.75820476, 0.36191988, 0.93297523, 0.3367678, 0.37150264, + 0.23855984, 0.5977023, 0.45253047, 0.42806166, 0.30482855, 0.40216422, 0.7895638, 0.7095099, + 0.7382757, 0.6312539, 0.23046969, 0.3106659, 0.13583827, 0.39577258, 0.89845103, 0.6235748, + 0.16217506, 0.004213362, 0.08934315, 0.86198056, 0.60079235, 0.23948883, 0.24270387, 0.8393256, + 0.32195452, 0.4815633, 0.4299666, 0.8829831, 0.22383447, 0.57369184, 0.7194615, 0.2564392, + 0.5038204, 0.13853844, 0.5422531, 0.97176254, 0.0881331, 0.85073787, 0.9618503, 0.3453285, + 0.76776993, 0.26722383, 0.8436194, 0.7129096, 0.51140594, 0.75185156, 0.925225, 0.1270263, + 0.10835649, 0.34018353, 0.5960297, 0.35770652, 0.8436321, 0.47478724, 0.7707103, 0.999071, + 0.35499844, 0.6132049, 0.106107146, 0.82326525, 0.97219765, 0.9065807, 0.48567542, 0.16458383, + 0.9117924, 0.9740305, 0.8068454, 0.99729985, 0.8535195, 0.9266885, 0.5354417, 0.3114372, + 0.04236306, 0.7440147, 0.09421062, 0.3335685, 0.3958694, 0.52979434, 0.32791966, 0.57010293, + 0.5563383, 0.30294028, 0.77462655, 0.88365096, 0.97766215, 0.36175498, 0.41280714, 0.029033197, + 0.36782816, 0.5431821, 0.61676407, 0.47492823, 0.7446307, 0.13858505, 0.37313086, 0.86118925, + 0.7815484, 0.6790356, 0.8011172, 0.53737545, 0.94500613, 0.92792517, 0.27350682, 0.18166798, + 0.8047418, 0.2845925, 0.31534344, 0.09961744, 0.38057664, 0.43714178, 0.6032016, 0.82520413, + 0.28528523, 0.5360042, 0.26692694, 0.66925734, 0.13195412, 0.6020245, 0.18692169, 0.5500374, + 0.5612233, 0.77781224, 0.62947166, 0.31033742, 0.30992442, 0.060513485, 0.5668065, 0.903778, + 0.3708838, 0.2330214, 0.55202013, 0.71683383, 0.72867715, 0.79054415, 0.6250968, 0.62841314, + 0.029433481, 0.59295857, 0.07890911, 0.69306964, 0.046411548, 0.3131897, 0.6484566, 0.9306864, + 0.93998045, 0.79156, 0.189643, 0.20862652, 0.8716581, 0.7038735, 0.7292351, 0.1795239, + 0.49211392, 0.25107977, 0.9761521, 0.16719387, 0.29845348, 0.9631694, 0.87174356, 0.74422836, + 0.7177861, 0.41156542, 0.72873366, 0.14755523, 0.88512164, 0.8863678, 0.096526965, 0.49474105, + 0.9109074, 0.6385138, 0.63982385, 0.53899556, 0.5231154, 0.49385205, 0.5036258, 0.24803366, + 0.12935568, 0.6987853, 0.37035698, 0.5183644, 0.8708705, 0.35817996, 0.032119915, 0.66701025, + 0.5037863, 0.37249622, 0.22471993, 0.47759736, 0.81439203, 0.45790294, 0.32995966, 0.06626411, + 0.721215, 0.33468077, 0.97528356, 0.6348461, 0.584456, 0.50090134, 0.04556473, 0.053612676, + 0.695033, 0.69490194, 0.29771915, 0.23314431, 0.064049676, 0.19023955, 0.6564085, 0.99826187, + 0.7474539, 0.7281185, 0.037838195, 0.5996682, 0.5928124, 0.35337916, 0.87335783, 0.3596061, + 0.37944552, 0.06172341, 0.6437689, 0.51262546, 0.66164786, 0.6189296, 0.680349, 0.45300442, + 0.3085541, 0.57355976, 0.81778055, 0.18843463, 0.51856846, 0.8687797, 0.6635776, 0.6284543, + 0.6532206, 0.3167443, 0.8233314, 0.17596854, 0.06046078, 0.7989756, 0.6029606, 0.31354675, + 0.7160877, 0.22645807, 0.7301434, 0.086273566, 0.42006475, 0.7302915, 0.4734517, 0.36783585, + 0.4613229, 0.6156775, 0.2554006, 0.5227326, 0.8571324, 0.53293926, 0.39196482, 0.07610343, + 0.014552955, 0.84471476, 0.9245902, 0.49048993, 0.37245902, 0.4679739, 0.47969338, 0.8786742, + 0.06454086, 0.40938383, 0.9464476, 0.2760681, 0.5300478, 0.6973893, 0.2991453, 0.5804699, + 0.45876285, 0.33022216, 0.79653776, 0.43518978, 0.8887862, 0.59407544, 0.032939672, 0.5782626, + 0.10010804, 0.44994467, 0.7271117, 0.902891, 0.6133791, 0.140845, 0.77132195, 0.12028129, + 0.9247795, 0.74722797, 0.16141559, 0.21574605, 0.8743854, 0.11247064, 0.9410877, 0.24811381, + 0.74676466, 0.8514692, 0.021732707, 0.010680916, 0.7838439, 0.19738361, 0.8377881, 0.7639336, + 0.31653216, 0.6749307, 0.06396978, 0.52691025, 0.7364015, 0.956775, 0.18731725, 0.42047754, + 0.8117751, 0.34632754, 0.39038187, 0.9225143, 0.7408622, 0.57680243, 0.2652951, 0.92369586, + 0.6380619, 0.82616633, 0.35128862, 0.7828198, 0.5359737, 0.08339928, 0.7060845, 0.3462922, + 0.38913444, 0.54842395, 0.6884251, 0.037316978, 0.5723427, 0.022258755, 0.79441875, 0.90272444, + 0.61215657, 0.9631781, 0.5863588, 0.9384484, 0.07687521, 0.24441172, 0.38387978, 0.96800447, + 0.5599107, 0.74093807, 0.403971, 0.5280579, 0.72208875, 0.018573398, 0.5072516, 0.16996226, + 0.58617413, 0.09803684, 0.37261903, 0.95767754, 0.84609497, 0.05496832, 0.22795987, 0.23313288, + 0.9688462, 0.7176776, 0.1377758, 0.18797757, 0.26834992, 0.15000027, 0.8481348, 0.7895163, + 0.5519088, 0.48765746, 0.31035778, 0.77768403, 0.9904436, 0.32684666, 0.84682065, 0.39365014, + 0.44228655, 0.38328415, 0.22290905, 0.79503566, 0.6794283, 0.17802662, 0.62420344, 0.37056103, + 0.041172326, 0.51846284, 0.45114288, 0.47430587, 0.6496397, 0.8367412, 0.05662944, 0.5571883, + 0.7352182, 0.35322595, 0.9696022, 0.35919765, 0.10663593, 0.19590221, 0.6996546, 0.40991047, + 0.89280325, 0.6144547, 0.9761491, 0.23443131, 0.70821565, 0.7295676, 0.17951865, 0.25932744, + 0.25121617, 0.97896886, 0.515391, 0.46281084, 0.83205926, 0.4329242, 0.55370456, 0.7908196, + 0.093474135, 0.7672148, 0.14680524, 0.74988705, 0.69885737, 0.37382892, 0.13987659, 0.7151676, + 0.431028, 0.75316954, 0.04246583, 0.63721764, 0.35724443, 0.48762304, 0.28701422, 0.24638435, + 0.6836296, 0.8129986, 0.9022324, 0.064973645, 0.20187753, 0.38977212, 0.6623454, 0.31160477, + 0.3389442, 0.19181544, 0.2230897, 0.6706708, 0.32135025, 0.5938186, 0.725129, 0.30229402, + 0.7995213, 0.17878264, 0.2657235, 0.33942115, 0.04909697, 0.94976753, 0.7110531, 0.5189743, + 0.47457805, 0.2609815, 0.8034033, 0.9550461, 0.6871017, 0.542301, 0.90208304, 0.76359314, + 0.6919547, 0.2690066, 0.77918124, 0.019060668, 0.5306918, 0.48873094, 0.58894205, 0.703702, + 0.104869366, 0.8352005, 0.41094282, 0.507042, 0.15073924, 0.46920577, 0.3938173, 0.8372094, + 0.028040525, 0.7401718, 0.8376963, 0.17846179, 0.22189952, 0.9475931, 0.19728738, 0.7338621, + 0.101945534, 0.3832581, 0.59039557, 0.94089603, 0.5863688, 0.7072993, 0.624503, 0.7966432, + 0.28973243, 0.45949653, 0.9787162, 0.052343633, 0.81463736, 0.70606834, 0.7716022, 0.31079042, + 0.5898406, 0.5620215, 0.23455179, 0.21389648, 0.5388247, 0.2040111, 0.36823508, 0.0053723096, + 0.8671642, 0.9661939, 0.9270056, 0.94692993, 0.7046047, 0.72362125, 0.5416936, 0.7443616, + 0.07171923, 0.04531915, 0.91711515, 0.1474337, 0.89833534, 0.648046, 0.11733318, 0.39757007, + 0.21069747, 0.6142996, 0.21730955, 0.6912427, 0.49048957, 0.34147367, 0.022572042, 0.3219722, + 0.9685696, 0.5269059, 0.5886212, 0.659878, 0.7130413, 0.98339087, 0.19503741, 0.89793444, + 0.015023004, 0.5850233, 0.07373183, 0.62017494, 0.7802937, 0.6775731, 0.09203854, 0.5661112, + 0.9178029, 0.2343546, 0.9806244, 0.7693182, 0.7889532, 0.6241685, 0.41245508, 0.9417946, + 0.44468832, 0.8369817, 0.0031990237, 0.9245251, 0.98670155, 0.6769924, 0.51488274, 0.5256905, + 0.9436219, 0.6050334, 0.97836035, 0.17769879, 0.13500004, 0.8818156, 0.0313203, 0.08832834, + 0.8502817, 0.019180698, 0.13241069, 0.31331208, 0.5743142, 0.49715826, 0.6172764, 0.5331244, + 0.5222611, 0.6511984, 0.7734398, 0.256135, 0.3608493, 0.25325385, 0.533019, 0.34440103, + 0.114450805, 0.6468266, 0.2151897, 0.8760596, 0.9801919, 0.27051234, 0.9112329, 0.3380306, + 0.07014053, 0.54804134, 0.6765531, 0.1752603, 0.69921273, 0.9143398, 0.43111116, 0.035987273, + 0.2030343, 0.8922961, 0.91903645, 0.76977247, 0.49175784, 0.099143006, 0.3674804, 0.94753003, + 0.21970531, 0.47007462, 0.40226397, 0.3355032, 0.9035526, 0.25874776, 0.16484123, 0.69036806, + 0.07201438, 0.63395935, 0.063247986, 0.48817343, 0.6666259, 0.15526073, 0.10813647, 0.5797694, + 0.10794782, 0.79438007, 0.24317154, 0.026272861, 0.8206052, 0.4420161, 0.8339117, 0.6079213, + 0.22008722, 0.73745257, 0.053100668, 0.46855322, 0.33421737, 0.76324654, 0.8526432, 0.015307797, + 0.27934623, 0.26765963, 0.65635425, 0.51011723, 0.86824834, 0.57572967, 0.43447804, 0.8113928, + 0.38320008, 0.986185, 0.10324592, 0.06525337, 0.85109174, 0.94293773, 0.36936134, 0.047773577, + 0.7841596, 0.33926708, 0.66182464, 0.69737774, 0.85597146, 0.34120753, 0.12692484, 0.7776892, + 0.63616294, 0.79434264, 0.11541597, 0.16610004, 0.2056471, 0.696288, 0.35615066, 0.30876786, + 0.78131616, 0.04794019, 0.2088272, 0.39896628, 0.49890646, 0.59801924, 0.711521, 0.5322181, + 0.35990205, 0.43177876, 0.6430728, 0.8344202, 0.33877015, 0.76865834, 0.75682956, 0.2771495, + 0.3680912, 0.005327093, 0.68439364, 0.9949503, 0.10142185, 0.15526544, 0.15933633, 0.9381387, + 0.14073479, 0.87866503, 0.8739543, 0.07390571, 0.46031374, 0.268378, 0.6057457, 0.68691206, + 0.6300343, 0.79447806, 0.28393722, 0.80315155, 0.73411053, 0.9703951, 0.5488671, 0.18614037, + 0.6277461, 0.12960654, 0.33747572, 0.4241927, 0.6981348, 0.29250467, 0.43891907, 0.8675046, + 0.037513115, 0.8382665, 0.79800886, 0.20032, 0.011894401, 0.3612004, 0.207346, 0.6260507, + 0.88860387, 0.27068847, 0.25823146, 0.62024146, 0.72406495, 0.6376153, 0.0719044, 0.09152406, + 0.82603306, 0.9561607, 0.20438583, 0.5442921, 0.4847211, 0.95367795, 0.54303896, 0.3976961, + 0.45646, 0.49825326, 0.3672042, 0.9718153, 0.81778973, 0.73514366, 0.24000394, 0.8482301, + 0.43974596, 0.006449677, 0.036392592, 0.62204725, 0.47036913, 0.4054257, 0.67501765, 0.26883397, + 0.58713204, 0.6578865, 0.91454774, 0.46342203, 0.7121636, 0.92862564, 0.46207544, 0.9901308, + 0.057702154, 0.24595165, 0.5981596, 0.74197406, 0.08811883, 0.894627, 0.38278353, 0.08383514, + 0.2952275, 0.40031275, 0.74386, 0.5136412, 0.9939962, 0.2355307, 0.808261, 0.15346022, + 0.030684536, 0.41000134, 0.1804955, 0.71761525, 0.6012227, 0.44985715, 0.6211549, 0.4206074, + 0.28114304, 0.9355519, 0.95716006, 0.82683456, 0.03913026, 0.07961693, 0.6855325, 0.52783436, + 0.036177807, 0.3770734, 0.91411316, 0.5718381, 0.13698402, 0.4980299, 0.76011133, 0.545119, + 0.62366617, 0.95255744, 0.32681978, 0.07005637, 0.66156566, 0.16137652, 0.27483776, 0.35160136, + 0.8496255, 0.7610875, 0.4327375, 0.30216226, 0.74813014, 0.74446017, 0.38890806, 0.607845, + 0.62479675, 0.17755221, 0.46083102, 0.15256695, 0.9374669, 0.5559489, 0.04470488, 0.21561056, + 0.7147803, 0.21602567, 0.47746333, 0.6169228, 0.32141757, 0.23642296, 0.016476203, 0.53265464, + 0.64989, 0.6353765, 0.0939491, 0.64866525, 0.12303737, 0.5510985, 0.7590417, 0.11976651, + 0.6607141, 0.6055587, 0.9772091, 0.27804276, 0.64687943, 0.38337022, 0.7797042, 0.29171762, + 0.9881654, 0.30626813, 0.94704133, 0.9594318, 0.037198868, 0.60754436, 0.60765207, 0.06771721, + 0.9078526, 0.1112092, 0.3552761, 0.44554, 0.6839132, 0.657915, 0.030183792, 0.6132026, + 0.74461126, 0.9000829, 0.6522722, 0.112753615, 0.6505111, 0.74024284, 0.48480767, 0.073698185, + 0.4185105, 0.3410645, 0.49185285, 0.33190826, 0.5787399, 0.7666621, 0.5687311, 0.33141005, + 0.43632144, 0.18574573, 0.6287574, 0.01514944, 0.28938162, 0.057044394, 0.49545577, 0.042345677, + 0.027724478, 0.026231889, 0.74081266, 0.011828165, 0.19582245, 0.31350172, 0.43585333, 0.0027991086, + 0.5753749, 0.36400652, 0.5334315, 0.74679655, 0.731098, 0.6669506, 0.6412065, 0.24792254, + 0.8214605, 0.8733431, 0.54092133, 0.6961343, 0.115691505, 0.27574378, 0.48897734, 0.14119047, + 0.5424781, 0.02386607, 0.009218562, 0.49816743, 0.029157575, 0.015034353, 0.32382092, 0.6875669, + 0.40462708, 0.6099266, 0.08502913, 0.6242792, 0.9994301, 0.4729795, 0.87787575, 0.10500878, + 0.90521115, 0.48905376, 0.7565334, 0.21473333, 0.23323065, 0.8219346, 0.60031205, 0.76937085, + 0.5445392, 0.38083488, 0.19368897, 0.41603848, 0.51612306, 0.7993214, 0.92665416, 0.75198066, + 0.5372545, 0.5996222, 0.4693501, 0.17195638, 0.30428314, 0.9376859, 0.9736415, 0.5603405, + 0.040185597, 0.8458646, 0.34216946, 0.12117143, 0.58192146, 0.016927328, 0.24849239, 0.34848097, + 0.99546736, 0.43591255, 0.7909232, 0.62663776, 0.51921046, 0.274244, 0.9079598, 0.72054344, + 0.42355403, 0.2398477, 0.95362824, 0.6483227, 0.8213454, 0.90778244, 0.17144382, 0.6053057, + 0.68327236, 0.33304846, 0.08702466, 0.39980793, 0.0036293846, 0.7059194, 0.80072564, 0.96752524, + 0.5154122, 0.19619283, 0.17454775, 0.38736606, 0.47976512, 0.4791406, 0.1874494, 0.52761185, + 0.13234249, 0.845208, 0.4205711, 0.08021053, 0.00839825, 0.3000164, 0.23277025, 0.26301053, + 0.6916624, 0.74880666, 0.74840236, 0.064435445, 0.98405766, 0.32531884, 0.73899513, 0.13240317, + 0.6744208, 0.7368638, 0.43789902, 0.24887301, 0.9299027, 0.8486845, 0.34485158, 0.289548, + 0.6351869, 0.82339793, 0.11122555, 0.3230176, 0.09969627, 0.52059376, 0.24077836, 0.9444134, + 0.05239831, 0.42601636, 0.5159802, 0.9761374, 0.48721132, 0.09123329, 0.59690744, 0.383256, + 0.1002782, 0.8240141, 0.70814556, 0.25482276, 0.957517, 0.7362902, 0.9834676, 0.19009337, + 0.45719767, 0.042144574, 0.71294534, 0.7429013, 0.041241586, 0.9385764, 0.59770924, 0.28365803, + 0.50035644, 0.13102308, 0.44502363, 0.18500035, 0.18879086, 0.90975267, 0.16331425, 0.17106864, + 0.50802827, 0.80398893, 0.012037134, 0.55804133, 0.8093386, 0.7628578, 0.64519185, 0.58318746, + 0.1399564, 0.05464305, 0.14859481, 0.10588853, 0.14053893, 0.09002884, 0.332031, 0.89889675, + 0.8399303, 0.9211322, 0.86581993, 0.057551697, 0.8076484, 0.49787706, 0.90317184, 0.113821924, + 0.82830715, 0.23232217, 0.47578096, 0.35618824, 0.64620966, 0.41190708, 0.19446513, 0.19052555, + 0.6606999, 0.5370769, 0.74679446, 0.15352806, 0.72425306, 0.42542627, 0.3807547, 0.6943399, + 0.39695272, 0.12975785, 0.6029449, 0.98659855, 0.78998154, 0.4918207, 0.1431191, 0.41032755, + 0.7989921, 0.5461269, 0.34507003, 0.26765865, 0.043932725, 0.105762556, 0.36342022, 0.010151213, + 0.90081716, 0.89821523, 0.7297342, 0.5770165, 0.2870768, 0.28900358, 0.9369778, 0.72804934, + 0.86017793, 0.95806926, 0.44518864, 0.60346204, 0.34323436, 0.17850293, 0.17464367, 0.41450405, + 0.5403775, 0.17148003, 0.660599, 0.6778906, 0.89493215, 0.9165733, 0.32384035, 0.33648646, + 0.08920308, 0.06545341, 0.5571962, 0.10008278, 0.06683705, 0.92680645, 0.14659283, 0.5549373, + 0.17365667, 0.73664325, 0.25271094, 0.8260378, 0.69569206, 0.80373824, 0.4072631, 0.10794914, + 0.19278006, 0.8748956, 0.12642062, 0.8319123, 0.04663203, 0.53965706, 0.06709321, 0.6204891, + 0.37148324, 0.93056595, 0.7272812, 0.8724527, 0.44516358, 0.68552965, 0.11521906, 0.98424387, + 0.57437485, 0.39324772, 0.48781338, 0.22162339, 0.7318074, 0.836895, 0.66121227, 0.9333714, + 0.81147647, 0.89025134, 0.42980537, 0.6065911, 0.925792, 0.3486058, 0.718812, 0.7366392, + 0.7642169, 0.55264986, 0.4851105, 0.02003657, 0.79015267, 0.49192804, 0.28985444, 0.54954606, + 0.9983602, 0.936707, 0.72859955, 0.13627109, 0.1995253, 0.27414012, 0.10977373, 0.48812705, + 0.6214242, 0.26846707, 0.251663, 0.30244434, 0.31592485, 0.18563971, 0.3761417, 0.35588506, + 0.2136833, 0.19304918, 0.020435851, 0.1563807, 0.10985168, 0.46050212, 0.69469714, 0.022877397, + 0.211754, 0.99064195, 0.10823577, 0.89251375, 0.20041913, 0.09518249, 0.19409119, 0.082446806, + 0.1033933, 0.93826735, 0.22326319, 0.7951004, 0.108295456, 0.5249412, 0.7338461, 0.53733635, + 0.7804776, 0.94167835, 0.9851669, 0.6573249, 0.09694284, 0.41636762, 0.42071435, 0.5785772, + 0.17650813, 0.12922545, 0.8063533, 0.5971035, 0.4714922, 0.13347372, 0.43969434, 0.53785807, + 0.2420099, 0.70572215, 0.9245171, 0.20888333, 0.16590436, 0.21725997, 0.2877079, 0.5262417, + 0.07437589, 0.16921617, 0.19905105, 0.3776575, 0.96237653, 0.58104134, 0.2475896, 0.6887421, + 0.459203, 0.48309952, 0.3759031, 0.16817336, 0.47533524, 0.037372224, 0.92593455, 0.7953864, + 0.5699276, 0.52965856, 0.7160056, 0.07119369, 0.28882924, 0.5969877, 0.6109546, 0.96991956, + 0.498573, 0.68540514, 0.5530905, 0.40257332, 0.6004241, 0.52496284, 0.37143198, 0.56321764, + 0.6539704, 0.45892516, 0.58294904, 0.9277267, 0.21731657, 0.043056846, 0.6162007, 0.5954668, + 0.88163584, 0.11761114, 0.13790047, 0.98839265, 0.7575706, 0.271521, 0.06252285, 0.20463766, + 0.7797876, 0.1291307, 0.6389557, 0.6362458, 0.5012543, 0.21651421, 0.23741248, 0.4773882, + 0.5582616, 0.22913149, 0.8790845, 0.27697143, 0.02795082, 0.8450163, 0.08831802, 0.9342402, + 0.11166756, 0.8126855, 0.51420295, 0.016410068, 0.4544232, 0.99820787, 0.5780698, 0.5268707, + 0.9134579, 0.12053883, 0.18955784, 0.1712181, 0.45908722, 0.62256193, 0.21234894, 0.227052, + 0.62288225, 0.34845284, 0.6227857, 0.4712934, 0.8860071, 0.73518616, 0.06196327, 0.4374562, + 0.22151268, 0.10556084, 0.3694651, 0.9881851, 0.16397232, 0.3392293, 0.56751597, 0.036619555, + 0.029293122, 0.20366028, 0.87672514, 0.94488513, 0.757318, 0.04611278, 0.75021446, 0.78157973, + 0.5510609, 0.112084985, 0.7227879, 0.38071552, 0.026956385, 0.0661944, 0.01830097, 0.93569964, + 0.016782548, 0.6520325, 0.65408915, 0.67949796, 0.22223058, 0.6170246, 0.048233118, 0.37648138, + 0.7507222, 0.07674675, 0.7948974, 0.34886235, 0.6287428, 0.5898847, 0.36289844, 0.5742286, + 0.55302286, 0.15293828, 0.14192496, 0.25542694, 0.74583685, 0.26746377, 0.46973395, 0.5767695, + 0.59823835, 0.841206, 0.9202325, 0.7739221, 0.012398226, 0.6812478, 0.4104998, 0.15531828, + 0.087259874, 0.43376547, 0.9714025, 0.5119398, 0.68514013, 0.888018, 0.814389, 0.4122685, + 0.15542716, 0.5002437, 0.19416295, 0.6805713, 0.2512154, 0.4013521, 0.15283692, 0.96117616, + 0.7491866, 0.14855935, 0.8276927, 0.8740181, 0.92426944, 0.762874, 0.18986279, 0.7493188, + 0.18229857, 0.07731968, 0.08125962, 0.3810246, 0.6967921, 0.27431104, 0.36408317, 0.06947445, + 0.66624695, 0.6395791, 0.2616025, 0.19497731, 0.6184822, 0.85095865, 0.88908845, 0.66500485, + 0.33854932, 0.72965646, 0.099999785, 0.24559312, 0.07330083, 0.78916264, 0.32555407, 0.19688624, + 0.6883691, 0.9590563, 0.024735536, 0.86383885, 0.8535551, 0.53648174, 0.23104885, 0.32438585, + 0.24390268, 0.22208378, 0.32964125, 0.60782045, 0.8067584, 0.4333644, 0.71547633, 0.88111615, + 0.13616055, 0.1246885, 0.014324361, 0.6116363, 0.13974965, 0.9578596, 0.34269398, 0.89822793, + 0.25947088, 0.16268782, 0.53546876, 0.19461296, 0.6628742, 0.94426966, 0.67601794, 0.3931359, + 0.7517656, 0.88437337, 0.6926555, 0.7377358, 0.2495755, 0.50024426, 0.21591938, 0.12976523, + 0.40853027, 0.93721664, 0.95107466, 0.39639843, 0.52131736, 0.28126806, 0.85824645, 0.9051849, + 0.01418011, 0.21888365, 0.10943257, 0.94861233, 0.77483827, 0.7139178, 0.057136595, 0.73050946, + 0.61636233, 0.1265076, 0.60436803, 0.69086725, 0.0010129241, 0.036435887, 0.6615116, 0.299633, + 0.54606587, 0.9365053, 0.85605484, 0.922385, 0.7407089, 0.9777405, 0.63154066, 0.63591623, + 0.90876913, 0.88455915, 0.20310602, 0.20253302, 0.0067849625, 0.94629556, 0.37691054, 0.9782028, + 0.30444136, 0.63028383, 0.18043286, 0.4439906, 0.8348371, 0.7274056, 0.61829764, 0.037847787, + 0.8272368, 0.96214604, 0.12137349, 0.123067886, 0.8958763, 0.52505213, 0.1287523, 0.3720944, + 0.275705, 0.65144163, 0.85033256, 0.58481205, 0.42521322, 0.93586147, 0.16447607, 0.036439568, + 0.58734304, 0.47351632, 0.039843205, 0.8902792, 0.5108118, 0.8546036, 0.72372454, 0.6700668, + 0.7495971, 0.6261652, 0.3864259, 0.3707291, 0.85600305, 0.21752104, 0.4647959, 0.81866026, + 0.3182077, 0.818207, 0.09514821, 0.77856284, 0.85636705, 0.50847274, 0.74004, 0.38371703, + 0.7558068, 0.83101165, 0.926828, 0.35534334, 0.09596299, 0.7920985, 0.5529896, 0.36857986, + 0.46580777, 0.14399329, 0.85664755, 0.3613208, 0.6875624, 0.72801846, 0.527036, 0.9726332, + 0.23842148, 0.45130673, 0.37347084, 0.26971108, 0.1386262, 0.7580232, 0.51609135, 0.058183976, + 0.18664573, 0.031672336, 0.26660433, 0.6070062, 0.84071326, 0.38591322, 0.18007252, 0.07887025, + 0.73347634, 0.6561262, 0.13447234, 0.67980015, 0.92777556, 0.3683812, 0.5741038, 0.95749855, + 0.07317559, 0.017846042, 0.9049213, 0.7120097, 0.36087346, 0.10347511, 0.13109785, 0.5901893, + 0.29117107, 0.12251501, 0.54014134, 0.40506032, 0.13500193, 0.4703289, 0.24509083, 0.9977836, + 0.3149203, 0.868644, 0.16869761, 0.06429065, 0.52549416, 0.94598347, 0.5278666, 0.079894565, + 0.9639208, 0.7777773, 0.62784445, 0.0314362, 0.5935461, 0.8472358, 0.04485763, 0.8700403, + 0.8772029, 0.4159723, 0.1965355, 0.120780155, 0.8531019, 0.80408156, 0.6973105, 0.08317062, + 0.9005745, 0.6764151, 0.3158351, 0.71819824, 0.84577185, 0.7750122, 0.94386834, 0.26314744, + 0.41103536, 0.13668874, 0.36487988, 0.059131548, 0.19968359, 0.50981313, 0.4320044, 0.12719214, + 0.48997945, 0.82502675, 0.74808896, 0.58309615, 0.47563064, 0.09966165, 0.9966431, 0.44393525, + 0.07765738, 0.67010105, 0.5278574, 0.71902966, 0.27379337, 0.12431067, 0.14468168, 0.5108387, + 0.1713335, 0.08552699, 0.16371617, 0.8490791, 0.63014835, 0.80966836, 0.23412272, 0.18890859, + 0.833909, 0.364697, 0.62040085, 0.45685738, 0.48235595, 0.98572606, 0.6703567, 0.3673898, + 0.9839679, 0.06934336, 0.6308007, 0.02807519, 0.0559926, 0.11421437, 0.60753995, 0.80091286, + 0.67977196, 0.87189984, 0.6405409, 0.17567077, 0.24715477, 0.22483869, 0.9893541, 0.2867247, + 0.9920071, 0.85404116, 0.887798, 0.114156604, 0.34609696, 0.5829253, 0.49704382, 0.6803111, + 0.590904, 0.5591804, 0.7491872, 0.110933654, 0.4792608, 0.53978574, 0.9615793, 0.091931306, + 0.99974436, 0.1604676, 0.73506176, 0.20445003, 0.49350995, 0.11660648, 0.4548461, 0.057119142, + 0.47798702, 0.36280334, 0.16930713, 0.7582485, 0.16912746, 0.058451943, 0.9417538, 0.6090703, + 0.37534294, 0.33367616, 0.4648503, 0.6283148, 0.09792804, 0.5562001, 0.021292835, 0.40104258, + 0.57229954, 0.95048964, 0.4371712, 0.49681222, 0.36502722, 0.49660632, 0.32165202, 0.13998619, + 0.9103205, 0.54860955, 0.17592642, 0.086687185, 0.48977694, 0.78490406, 0.79321474, 0.8754006, + 0.39919505, 0.8306789, 0.63616955, 0.98329365, 0.41361818, 0.73879534, 0.5111836, 0.53245205, + 0.6174266, 0.14011684, 0.7355907, 0.14558467, 0.074935436, 0.33326453, 0.99400324, 0.44354424, + 0.13917476, 0.33401918, 0.6321505, 0.5430203, 0.6794353, 0.9580339, 0.69209194, 0.9813807, + 0.041151315, 0.029320937, 0.8479279, 0.6205179, 0.8825255, 0.85506666, 0.11929336, 0.5904389, + 0.5404614, 0.58944976, 0.22911972, 0.26724914, 0.92003053, 0.037999198, 0.9874244, 0.83350426, + 0.439306, 0.9047191, 0.87938565, 0.22491038, 0.7610156, 0.17606735, 0.06505076, 0.577056, + 0.5546063, 0.7323822, 0.94751245, 0.15575777, 0.15275358, 0.2501944, 0.19596528, 0.44116116, + 0.13858697, 0.65478885, 0.9421423, 0.38429725, 0.89086735, 0.8906657, 0.64992654, 0.7623599, + 0.020823486, 0.14515182, 0.6051233, 0.4854857, 0.10414482, 0.7267541, 0.52351373, 0.10117556, + 0.34659478, 0.7986462, 0.10371433, 0.7747162, 0.078648254, 0.46718153, 0.22036512, 0.86508393, + 0.9642702, 0.27087194, 0.06591158, 0.15014334, 0.9075542, 0.9635356, 0.4376853, 0.290267, + 0.39348447, 0.78795856, 0.12866218, 0.26524165, 0.095856875, 0.6031271, 0.94263685, 0.54864025, + 0.25479257, 0.11702571, 0.20408688, 0.6158638, 0.5709441, 0.57956505, 0.47291118, 0.8278522, + 0.20886846, 0.8463369, 0.809163, 0.35410735, 0.14648008, 0.4212491, 0.36251292, 0.67140543, + 0.43442374, 0.07705836, 0.42002708, 0.6199954, 0.8247542, 0.4997832, 0.8548057, 0.057287898, + 0.7074665, 0.31485626, 0.09200123, 0.31618625, 0.59809196, 0.25827205, 0.0053186826, 0.7434676, + 0.85600936, 0.5550741, 0.5199236, 0.96162254, 0.26309466, 0.60450137, 0.29413986, 0.38470513, + 0.79796076, 0.23805939, 0.9412749, 0.061217327, 0.15437259, 0.083577976, 0.14378692, 0.9722354, + 0.42544565, 0.45725676, 0.8308179, 0.018798511, 0.18310007, 0.32264143, 0.72388613, 0.75500935, + 0.26221997, 0.146799, 0.90839726, 0.25608784, 0.48756382, 0.15672493, 0.22976026, 0.9505964, + 0.8410182, 0.06569535, 0.498098, 0.591406, 0.90132546, 0.40089035, 0.40831077, 0.82992244, + 0.7829185, 0.03532195, 0.8220347, 0.5866948, 0.55850834, 0.7935884, 0.9029153, 0.62388855, + 0.17106935, 0.11976584, 0.8907406, 0.14083518, 0.42745417, 0.9865202, 0.5603676, 0.53336793, + 0.83118796, 0.7649143, 0.6994026, 0.116295666, 0.69610405, 0.03805204, 0.8971413, 0.6412358, + 0.008299126, 0.9906785, 0.22019914, 0.08867724, 0.58548, 0.5523809, 0.07090994, 0.024555296, + 0.048945986, 0.0008954834, 0.23588002, 0.14777812, 0.5006067, 0.13719136, 0.19650105, 0.46863157, + 0.24388368, 0.28450873, 0.08501847, 0.367798, 0.26598433, 0.08892508, 0.5231422, 0.854498, + 0.50532776, 0.96473, 0.760218, 0.13641119, 0.7014878, 0.2920151, 0.13381833, 0.74486643, + 0.13818067, 0.18079887, 0.57839566, 0.56782985, 0.5733893, 0.8142381, 0.038408525, 0.61868846, + 0.048855904, 0.8661853, 0.091889195, 0.42655867, 0.75064015, 0.41258946, 0.0327612, 0.6939966, + 0.5684132, 0.230771, 0.87241197, 0.41159534, 0.95303357, 0.5293433, 0.37525147, 0.91937405, + 0.46753627, 0.3657011, 0.58334947, 0.62074995, 0.79216284, 0.9344987, 0.32306752, 0.7569309, + 0.8670772, 0.49101356, 0.0095974505, 0.31980786, 0.5587957, 0.6286712, 0.8952423, 0.42964563, + 0.24610022, 0.46633002, 0.31894207, 0.39979902, 0.99703586, 0.09658354, 0.10385787, 0.092738345, + 0.9319688, 0.066221446, 0.567998, 0.47071677, 0.41960314, 0.722223, 0.79183286, 0.60883737, + 0.8055474, 0.6590216, 0.10029357, 0.20768817, 0.2308886, 0.41765857, 0.82652557, 0.11435715, + 0.5431178, 0.3349583, 0.55948156, 0.2596266, 0.402992, 0.7129533, 0.13520089, 0.939742, + 0.33552873, 0.44276634, 0.16549513, 0.48670354, 0.2104012, 0.9754525, 0.9223382, 0.37095273, + 0.26184326, 0.4906111, 0.68878114, 0.7259414, 0.3665008, 0.8523507, 0.33732775, 0.14485414, + 0.69918066, 0.40076008, 0.5142605, 0.89977413, 0.52837765, 0.6875541, 0.19875702, 0.8284416, + 0.6398044, 0.20458493, 0.8566812, 0.66207755, 0.537102, 0.84423125, 0.6897463, 0.2190155, + 0.93102056, 0.62825596, 0.13518804, 0.9768368, 0.5567279, 0.30512935, 0.39843616, 0.83009493, + 0.7366834, 0.72934085, 0.9458449, 0.7402775, 0.7288774, 0.100584194, 0.7478564, 0.69076705, + 0.99763054, 0.41462737, 0.5604459, 0.002231921, 0.19869287, 0.23542677, 0.41136438, 0.6479746, + 0.24400933, 0.33705348, 0.8468991, 0.0058162767, 0.11877123, 0.26026058, 0.83385074, 0.417612, + 0.80086476, 0.46976563, 0.79492086, 0.73824483, 0.71716267, 0.36049098, 0.58812624, 0.3940513, + 0.0023239073, 0.68416554, 0.1630907, 0.7990368, 0.74170923, 0.45847952, 0.0995642, 0.5392202, + 0.45672858, 0.16591415, 0.664447, 0.12247461, 0.28378534, 0.6875144, 0.020322617, 0.6955938, + 0.21689159, 0.48721343, 0.7328274, 0.21967441, 0.45823023, 0.39261988, 0.7113237, 0.47642282, + 0.8954901, 0.52823293, 0.9394127, 0.25911182, 0.30566335, 0.009611528, 0.9736044, 0.63713956, + 0.82650113, 0.16639459, 0.99990803, 0.5145273, 0.07233607, 0.6123276, 0.9062654, 0.7855298, + 0.23748927, 0.30767888, 0.5490877, 0.9528571, 0.5958136, 0.71137613, 0.13382663, 0.11335034, + 0.449443, 0.09932706, 0.52135324, 0.22994924, 0.6276635, 0.36845186, 0.93582106, 0.609704, + 0.9728418, 0.68666786, 0.9035467, 0.21347627, 0.51906675, 0.8404524, 0.2335569, 0.44711703, + 0.19230975, 0.027307436, 0.29597348, 0.11739075, 0.6876064, 0.5057953, 0.6232577, 0.604564, + 0.58094805, 0.94729763, 0.9821851, 0.15055138, 0.8435322, 0.7584666, 0.8806093, 0.18411398, + 0.3944063, 0.8260624, 0.8096688, 0.20633629, 0.48825827, 0.74365515, 0.009476059, 0.45804924, + 0.23057352, 0.39020398, 0.5416855, 0.3856682, 0.7087808, 0.69278914, 0.26646304, 0.39703688, + 0.074121974, 0.10197067, 0.76054734, 0.5685061, 0.41540262, 0.016435882, 0.42574394, 0.94364774, + 0.47606933, 0.91678923, 0.6490012, 0.68036586, 0.38626674, 0.78526974, 0.7661718, 0.2143752, + 0.80605865, 0.7194327, 0.81907, 0.69300437, 0.030783592, 0.027220597, 0.9588587, 0.4486546, + 0.017831376, 0.83792424, 0.8868172, 0.2974024, 0.9641097, 0.23758952, 0.8957832, 0.8881589, + 0.6808346, 0.5851483, 0.0764294, 0.74156153, 0.9979193, 0.3121031, 0.7687113, 0.37797043, + 0.40031847, 0.86602104, 0.730267, 0.57146907, 0.094653964, 0.32911018, 0.07178252, 0.4453038, + 0.62403214, 0.32731032, 0.5796096, 0.9893481, 0.87371916, 0.5734587, 0.3662533, 0.046901383, + 0.14311191, 0.31189272, 0.5506748, 0.5774784, 0.12961864, 0.12834151, 0.97953796, 0.23847981, + 0.021006035, 0.76084226, 0.99953127, 0.8011185, 0.7088403, 0.024610326, 0.21645589, 0.49395552, + 0.9507214, 0.44109955, 0.2926859, 0.16476253, 0.29695365, 0.3873897, 0.35400063, 0.6887212, + 0.7661417, 0.44151342, 0.67337024, 0.6367994, 0.65797997, 0.906435, 0.014439769, 0.10737592, + 0.21889497, 0.029528014, 0.5984496, 0.6860266, 0.76142836, 0.19123298, 0.24835177, 0.27197698, + 0.8864831, 0.49178717, 0.550463, 0.3338117, 0.32957888, 0.27066407, 0.7364635, 0.59942186, + 0.11085444, 0.08565405, 0.03862678, 0.4326196, 0.28077278, 0.20149076, 0.7499477, 0.7557222, + 0.95789206, 0.86195356, 0.8113367, 0.6881052, 0.45497125, 0.34273857, 0.5804998, 0.11457099, + 0.7464025, 0.8921554, 0.5822235, 0.6793123, 0.42616072, 0.5304293, 0.7325272, 0.7594884, + 0.19274779, 0.02070892, 0.27827948, 0.8051665, 0.83692664, 0.020188946, 0.35914233, 0.49547768, + 0.70504993, 0.07394841, 0.525945, 0.5723259, 0.8678083, 0.5818202, 0.8266031, 0.017404223, + 0.27958027, 0.84272736, 0.7281345, 0.8994748, 0.3798963, 0.5602465, 0.8170057, 0.5437445, + 0.9112873, 0.43589205, 0.5874092, 0.4374235, 0.68844056, 0.057151183, 0.1732611, 0.58042514, + 0.35312688, 0.2791384, 0.23987181, 0.26006386, 0.9232113, 0.94478124, 0.9187956, 0.93770313, + 0.50281125, 0.31585902, 0.9830553, 0.38102284, 0.8167936, 0.008173941, 0.24676272, 0.16458233, + 0.06555225, 0.5648193, 0.39973202, 0.58343333, 0.8022948, 0.8330524, 0.3795921, 0.63250124, + 0.20370321, 0.734535, 0.8938792, 0.40103462, 0.43277976, 0.92171884, 0.8070371, 0.64789873, + 0.9006873, 0.94551986, 0.21919903, 0.5886699, 0.34194836, 0.5665393, 0.09419294, 0.33479902, + 0.92393184, 0.7904314, 0.39666355, 0.0640373, 0.5771913, 0.43598288, 0.7269509, 0.90311337, + 0.18912931, 0.42282686, 0.37187123, 0.12362129, 0.65741915, 0.5898278, 0.77813035, 0.5200745, + 0.8995463, 0.6073706, 0.056360655, 0.18867631, 0.05090209, 0.51776093, 0.5049234, 0.5810924, + 0.5088219, 0.3351565, 0.48033553, 0.87127376, 0.7889749, 0.65809286, 0.822634, 0.49901298, + 0.47062632, 0.064933024, 0.65950155, 0.0118634105, 0.43638885, 0.3155548, 0.055309944, 0.76772034, + 0.007584079, 0.9907658, 0.2119053, 0.0099529, 0.5498476, 0.68341583, 0.9904796, 0.31085956, + 0.16738948, 0.6991246, 0.6891236, 0.7345778, 0.5101786, 0.9055166, 0.28389692, 0.40617087, + 0.285508, 0.8155711, 0.5552154, 0.24203478, 0.95564735, 0.8556771, 0.11413846, 0.53103644, + 0.6001929, 0.8728583, 0.652995, 0.59248614, 0.9303262, 0.76626694, 0.083685614, 0.5839915, + 0.55206066, 0.28864032, 0.18109223, 0.06013629, 0.30585563, 0.49497047, 0.031244803, 0.8254061, + 0.34467688, 0.16947599, 0.70388424, 0.089850344, 0.9689693, 0.088056214, 0.9888344, 0.56510967, + 0.7810361, 0.25333068, 0.72635543, 0.6208177, 0.7603394, 0.81327516, 0.812073, 0.15190694, + 0.8766273, 0.68086886, 0.40976003, 0.6769893, 0.03042084, 0.39799348, 0.38053334, 0.40112254, + 0.61543894, 0.10513203, 0.18251711, 0.22153829, 0.7244244, 0.22376063, 0.10031522, 0.79053754, + 0.7843263, 0.7298093, 0.8973579, 0.7861713, 0.15179288, 0.024288114, 0.56206715, 0.51213664, + 0.8840239, 0.08788527, 0.81145, 0.6769955, 0.039911535, 0.4628679, 0.82365215, 0.7387855, + 0.47656733, 0.029185295, 0.18350895, 0.62498677, 0.08521046, 0.35425547, 0.7949853, 0.9466834, + 0.78894264, 0.30276173, 0.4744114, 0.86383724, 0.9055391, 0.7672961, 0.8406853, 0.5572755, + 0.15301545, 0.9358179, 0.83649135, 0.030530108, 0.9159173, 0.025901658, 0.00011405395, 0.8523392, + 0.1188017, 0.89762336, 0.7929654, 0.9425356, 0.58654344, 0.7035378, 0.361211, 0.15257105, + 0.2814799, 0.44373164, 0.744971, 0.6952391, 0.040251687, 0.47532842, 0.70532703, 0.43007088, + 0.93482405, 0.9506745, 0.9972287, 0.84903115, 0.5498767, 0.6982299, 0.60659754, 0.116727814, + 0.24719998, 0.25417453, 0.5239801, 0.10409364, 0.6263765, 0.79312205, 0.82286817, 0.45066565, + 0.02907124, 0.33116972, 0.5061851, 0.1875871, 0.56129, 0.8524497, 0.36013994, 0.085404865, + 0.94155073, 0.32184035, 0.58235735, 0.46180746, 0.022325099, 0.14544618, 0.5170238, 0.67768705, + 0.23049083, 0.4064205, 0.09570609, 0.9652428, 0.028672969, 0.1510829, 0.30246252, 0.4205718, + 0.2910258, 0.67623764, 0.69533557, 0.33236894, 0.17955771, 0.25711736, 0.5261945, 0.48835787}; float rndf() { - static int _cur_rnd = 0; - if (_cur_rnd > _rnd_count) - _cur_rnd = 0; - return _rnd[_cur_rnd++]; + static int _cur_rnd = 0; + if (_cur_rnd > _rnd_count) + _cur_rnd = 0; + return _rnd[_cur_rnd++]; } diff --git a/tests/common/test.c b/tests/common/test.c index c583f8f..0295993 100644 --- a/tests/common/test.c +++ b/tests/common/test.c @@ -3,842 +3,795 @@ #include <string.h> #if defined(_WIN32) || defined(_WIN64) -int gettimeofday(struct timeval * tp, void * tzp) -{ - // FILETIME Jan 1 1970 00:00:00 - // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's - static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); +int gettimeofday(struct timeval *tp, void *tzp) { + // FILETIME Jan 1 1970 00:00:00 + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL); - SYSTEMTIME nSystemTime; - FILETIME nFileTime; - uint64_t nTime; + SYSTEMTIME nSystemTime; + FILETIME nFileTime; + uint64_t nTime; - GetSystemTime( &nSystemTime ); - SystemTimeToFileTime( &nSystemTime, &nFileTime ); - nTime = ((uint64_t)nFileTime.dwLowDateTime ) ; - nTime += ((uint64_t)nFileTime.dwHighDateTime) << 32; + GetSystemTime(&nSystemTime); + SystemTimeToFileTime(&nSystemTime, &nFileTime); + nTime = ((uint64_t)nFileTime.dwLowDateTime); + nTime += ((uint64_t)nFileTime.dwHighDateTime) << 32; - tp->tv_sec = (long) ((nTime - EPOCH) / 10000000L); - tp->tv_usec = (long) (nSystemTime.wMilliseconds * 1000); - return 0; + tp->tv_sec = (long)((nTime - EPOCH) / 10000000L); + tp->tv_usec = (long)(nSystemTime.wMilliseconds * 1000); + return 0; } #endif -float panX = 0.f; -float panY = 0.f; -float lastX = 0.f; -float lastY = 0.f; -float zoom = 1.0f; -bool mouseDown = false; +float panX = 0.f; +float panY = 0.f; +float lastX = 0.f; +float lastY = 0.f; +float zoom = 1.0f; +bool mouseDown = false; -VkvgDevice device = NULL; -VkvgSurface surf = NULL; +VkvgDevice device = NULL; +VkvgSurface surf = NULL; -uint32_t test_size = 500; // items drawn in one run, or complexity -uint32_t iterations = 500; // repeat test n times -uint32_t test_width = 512; -uint32_t test_height= 512; -bool test_vsync = false; -bool quiet = false;//if true, don't print details and head row -bool first_test = true; //if multiple tests, dont print header row. -bool no_test_size= false;//several test consist of a single draw sequence without looping 'size' times - //those test must be preceded by setting no_test_size to 'true' -int test_index = 0; -int single_test = -1; //if not < 0, contains the index of the single test to run +uint32_t test_size = 500; // items drawn in one run, or complexity +uint32_t iterations = 500; // repeat test n times +uint32_t test_width = 512; +uint32_t test_height = 512; +bool test_vsync = false; +bool quiet = false; // if true, don't print details and head row +bool first_test = true; // if multiple tests, dont print header row. +bool no_test_size = false; // several test consist of a single draw sequence without looping 'size' times + // those test must be preceded by setting no_test_size to 'true' +int test_index = 0; +int single_test = -1; // if not < 0, contains the index of the single test to run - -static bool paused = false; -static bool offscreen = false; -static bool threadAware = false; -static VkSampleCountFlags samples = VK_SAMPLE_COUNT_1_BIT; +static bool paused = false; +static bool offscreen = false; +static bool threadAware = false; +static VkSampleCountFlags samples = VK_SAMPLE_COUNT_1_BIT; static VkPhysicalDeviceType preferedPhysicalDeviceType = VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU; -static vk_engine_t* e; -static char* saveToPng = NULL; +static vk_engine_t *e; +static char *saveToPng = NULL; -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { - if (action != GLFW_PRESS) - return; - switch (key) { - case GLFW_KEY_SPACE: - paused = !paused; - break; - case GLFW_KEY_ESCAPE : - glfwSetWindowShouldClose(window, GLFW_TRUE); - break; +static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) { + if (action != GLFW_PRESS) + return; + switch (key) { + case GLFW_KEY_SPACE: + paused = !paused; + break; + case GLFW_KEY_ESCAPE: + glfwSetWindowShouldClose(window, GLFW_TRUE); + break; #ifdef VKVG_WIRED_DEBUG - case GLFW_KEY_F1: - vkvg_wired_debug ^= (1U << 0); - break; - case GLFW_KEY_F2: - vkvg_wired_debug ^= (1U << 1); - break; - case GLFW_KEY_F3: - vkvg_wired_debug ^= (1U << 2); - break; + case GLFW_KEY_F1: + vkvg_wired_debug ^= (1U << 0); + break; + case GLFW_KEY_F2: + vkvg_wired_debug ^= (1U << 1); + break; + case GLFW_KEY_F3: + vkvg_wired_debug ^= (1U << 2); + break; #endif - } + } } -static void char_callback (GLFWwindow* window, uint32_t c){} -static void mouse_move_callback(GLFWwindow* window, double x, double y){ - if (mouseDown) { - panX += ((float)x-lastX); - panY += ((float)y-lastY); - } - lastX = (float)x; - lastY = (float)y; +static void char_callback(GLFWwindow *window, uint32_t c) {} +static void mouse_move_callback(GLFWwindow *window, double x, double y) { + if (mouseDown) { + panX += ((float)x - lastX); + panY += ((float)y - lastY); + } + lastX = (float)x; + lastY = (float)y; } -static void scroll_callback(GLFWwindow* window, double x, double y){ - if (y<0.f) - zoom *= 0.5f; - else - zoom *= 2.0f; +static void scroll_callback(GLFWwindow *window, double x, double y) { + if (y < 0.f) + zoom *= 0.5f; + else + zoom *= 2.0f; } -static void mouse_button_callback(GLFWwindow* window, int but, int state, int modif){ - if (but != GLFW_MOUSE_BUTTON_1) - return; - if (state == GLFW_TRUE) - mouseDown = true; - else - mouseDown = false; +static void mouse_button_callback(GLFWwindow *window, int but, int state, int modif) { + if (but != GLFW_MOUSE_BUTTON_1) + return; + if (state == GLFW_TRUE) + mouseDown = true; + else + mouseDown = false; } -double time_diff(struct timeval x , struct timeval y) -{ - double x_ms , y_ms , diff; +double time_diff(struct timeval x, struct timeval y) { + double x_ms, y_ms, diff; - x_ms = (double)x.tv_sec*1000000 + (double)x.tv_usec; - y_ms = (double)y.tv_sec*1000000 + (double)y.tv_usec; + x_ms = (double)x.tv_sec * 1000000 + (double)x.tv_usec; + y_ms = (double)y.tv_sec * 1000000 + (double)y.tv_usec; - diff = (double)y_ms - (double)x_ms; + diff = (double)y_ms - (double)x_ms; - return diff; + return diff; } /* from caskbench */ -double get_tick (void) -{ - struct timeval now; - gettimeofday (&now, NULL); - return (double)now.tv_sec + (double)now.tv_usec / 1000000.0; +double get_tick(void) { + struct timeval now; + gettimeofday(&now, NULL); + return (double)now.tv_sec + (double)now.tv_usec / 1000000.0; } -double median_run_time (double data[], int n) -{ - double temp; - int i, j; - for (i = 0; i < n; i++) - for (j = i+1; j < n; j++) - { - if (data[i] > data[j]) - { - temp = data[j]; - data[j] = data[i]; - data[i] = temp; - } - } - if (n % 2 == 0) - return (data[n/2] + data[n/2-1])/2; - return data[n/2]; +double median_run_time(double data[], int n) { + double temp; + int i, j; + for (i = 0; i < n; i++) + for (j = i + 1; j < n; j++) { + if (data[i] > data[j]) { + temp = data[j]; + data[j] = data[i]; + data[i] = temp; + } + } + if (n % 2 == 0) + return (data[n / 2] + data[n / 2 - 1]) / 2; + return data[n / 2]; } -double standard_deviation (const double data[], int n, double mean) -{ - double sum_deviation = 0.0; - int i; - for (i = 0; i < n; ++i) - sum_deviation += (data[i]-mean) * (data[i]-mean); - return sqrt (sum_deviation / n); +double standard_deviation(const double data[], int n, double mean) { + double sum_deviation = 0.0; + int i; + for (i = 0; i < n; ++i) + sum_deviation += (data[i] - mean) * (data[i] - mean); + return sqrt(sum_deviation / n); } /***************/ -void init_test (uint32_t width, uint32_t height){ - if (test_vsync) - e = vkengine_create (preferedPhysicalDeviceType, VK_PRESENT_MODE_FIFO_KHR, width, height); - else - e = vkengine_create (preferedPhysicalDeviceType, VK_PRESENT_MODE_MAILBOX_KHR, width, height); +void init_test(uint32_t width, uint32_t height) { + if (test_vsync) + e = vkengine_create(preferedPhysicalDeviceType, VK_PRESENT_MODE_FIFO_KHR, width, height); + else + e = vkengine_create(preferedPhysicalDeviceType, VK_PRESENT_MODE_MAILBOX_KHR, width, height); - VkhPresenter r = e->renderer; - vkengine_set_key_callback (e, key_callback); - vkengine_set_mouse_but_callback(e, mouse_button_callback); - vkengine_set_cursor_pos_callback(e, mouse_move_callback); - vkengine_set_scroll_callback(e, scroll_callback); + VkhPresenter r = e->renderer; + vkengine_set_key_callback(e, key_callback); + vkengine_set_mouse_but_callback(e, mouse_button_callback); + vkengine_set_cursor_pos_callback(e, mouse_move_callback); + vkengine_set_scroll_callback(e, scroll_callback); - vkvg_device_create_info_t info = { - samples, - false, - vkh_app_get_inst(e->app), - r->dev->phy, - r->dev->dev, - r->qFam, - 0 - }; + vkvg_device_create_info_t info = {samples, false, vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0}; device = vkvg_device_create(&info); - surf = vkvg_surface_create(device, width, height); + surf = vkvg_surface_create(device, width, height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), width, height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), width, height); } -void clear_test () { - vkDeviceWaitIdle(e->dev->dev); +void clear_test() { + vkDeviceWaitIdle(e->dev->dev); - vkvg_surface_destroy (surf); - vkvg_device_destroy (device); + vkvg_surface_destroy(surf); + vkvg_device_destroy(device); - vkengine_destroy (e); + vkengine_destroy(e); } #ifdef VKVG_TEST_DIRECT_DRAW -VkvgSurface* surfaces; +VkvgSurface *surfaces; #endif -void _print_usage_and_exit () { - printf("\nUsage: test [options]\n\n"); - printf("\t-i iterations:\tSpecify the repeat count for the test.\n"); - printf("\t-s size:\tWhen applicable, specify the size of the test.\n"); - printf("\t-x width:\tOutput surface width.\n"); - printf("\t-y height:\tOutput surface height.\n"); - printf("\t-S num samples:\tOutput surface filter, default is 1.\n"); +void _print_usage_and_exit() { + printf("\nUsage: test [options]\n\n"); + printf("\t-i iterations:\tSpecify the repeat count for the test.\n"); + printf("\t-s size:\tWhen applicable, specify the size of the test.\n"); + printf("\t-x width:\tOutput surface width.\n"); + printf("\t-y height:\tOutput surface height.\n"); + printf("\t-S num samples:\tOutput surface filter, default is 1.\n"); printf("\t-g gpu_type:\tSet prefered GPU type:\n"); - printf("\t\t\t - 0: Other\n"); - printf("\t\t\t - 1: Integrated (second choice)\n"); - printf("\t\t\t - 2: Discrete (first choice)\n"); - printf("\t\t\t - 3: Virtual\n"); - printf("\t\t\t - 4: Cpu\n"); - printf("\t-l line_width:\tset lines width for stokes.\n"); - printf("\t-j line_join:\tset line joins for strokes:\n"); - printf("\t\t\t - m: Mitter(default)\n"); - printf("\t\t\t - r: Rount\n"); - printf("\t\t\t - b: Bevel\n"); - printf("\t-c line_cap:\tset line caps for strokes:\n"); - printf("\t\t\t - b: Butt (default)\n"); - printf("\t\t\t - r: Rount\n"); - printf("\t\t\t - s: Square\n"); - printf("\t-f fill_rule:\tset current fill rule:\n"); - printf("\t\t\t - 0: Even Odd\n"); - printf("\t\t\t - 1: Non Zero\n"); - printf("\t-d:\t\tenable dashes.\n"); - printf("\t-n index:\tRun only a single test, zero based index.\n"); - printf("\t-q:\t\tQuiet, don't print measures table head row, usefull for batch tests.\n"); - printf("\t-t:\t\tThread aware, set device in multithreading aware mode.\n"); - printf("\t-p:\t\tPrint test details and exit without performing test, usefull to print details in logs.\n"); - printf("\t-vsync:\t\tEnable VSync, disabled by default.\n"); - printf("\t-o:\t\tPerform test offscreen.\n"); - printf("\t-w filepath:\twrite last image to png.\n"); + printf("\t\t\t - 0: Other\n"); + printf("\t\t\t - 1: Integrated (second choice)\n"); + printf("\t\t\t - 2: Discrete (first choice)\n"); + printf("\t\t\t - 3: Virtual\n"); + printf("\t\t\t - 4: Cpu\n"); + printf("\t-l line_width:\tset lines width for stokes.\n"); + printf("\t-j line_join:\tset line joins for strokes:\n"); + printf("\t\t\t - m: Mitter(default)\n"); + printf("\t\t\t - r: Rount\n"); + printf("\t\t\t - b: Bevel\n"); + printf("\t-c line_cap:\tset line caps for strokes:\n"); + printf("\t\t\t - b: Butt (default)\n"); + printf("\t\t\t - r: Rount\n"); + printf("\t\t\t - s: Square\n"); + printf("\t-f fill_rule:\tset current fill rule:\n"); + printf("\t\t\t - 0: Even Odd\n"); + printf("\t\t\t - 1: Non Zero\n"); + printf("\t-d:\t\tenable dashes.\n"); + printf("\t-n index:\tRun only a single test, zero based index.\n"); + printf("\t-q:\t\tQuiet, don't print measures table head row, usefull for batch tests.\n"); + printf("\t-t:\t\tThread aware, set device in multithreading aware mode.\n"); + printf("\t-p:\t\tPrint test details and exit without performing test, usefull to print details in logs.\n"); + printf("\t-vsync:\t\tEnable VSync, disabled by default.\n"); + printf("\t-o:\t\tPerform test offscreen.\n"); + printf("\t-w filepath:\twrite last image to png.\n"); #ifdef DEBUG - printf("\t-L level:\tLog level in hexadecimal format (0xFF), 0 to disable.\n"); - printf("\t\t\tsee vkvg.h for possible values.\n"); + printf("\t-L level:\tLog level in hexadecimal format (0xFF), 0 to disable.\n"); + printf("\t\t\tsee vkvg.h for possible values.\n"); #endif - printf("\t-h:\t\tThis help message.\n"); - printf("\n"); - exit(-1); + printf("\t-h:\t\tThis help message.\n"); + printf("\n"); + exit(-1); } -void _parse_args (int argc, char* argv[]) { - bool printTestDetailsAndExit = false; - for (int i = 1; i < argc; i++) { - if (strcmp (argv[i], "-h\0") == 0) - _print_usage_and_exit (); - if (strcmp (argv[i], "-p\0") == 0) - printTestDetailsAndExit = true; - else if (strcmp (argv[i], "-vsync\0") == 0) - test_vsync = true; - else if (strcmp(argv[i], "-q\0") == 0) - quiet = true; - else if (strcmp(argv[i], "-t\0") == 0) - threadAware = true; - else if (strcmp (argv[i], "-i\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - iterations = atoi (argv[i]); - }else if (strcmp (argv[i], "-x\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - test_width = atoi (argv[i]); - }else if (strcmp (argv[i], "-y\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - test_height = atoi (argv[i]); - }else if (strcmp (argv[i], "-n\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - single_test = atoi (argv[i]); - }else if (strcmp (argv[i], "-s\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - test_size = atoi (argv[i]); - }else if (strcmp (argv[i], "-S\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - samples = (VkSampleCountFlags)atoi (argv[i]); - }else if (strcmp (argv[i], "-g\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - preferedPhysicalDeviceType = (VkPhysicalDeviceType)atoi (argv[i]); - }else if (strcmp (argv[i], "-l\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - line_width = atoi (argv[i]); - }else if (strcmp (argv[i], "-d\0") == 0) { - dashes_count = 2; - }else if (strcmp (argv[i], "-f\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - fill_rule = atoi (argv[i]); - } else if (strcmp (argv[i], "-o\0") == 0) { - offscreen = true; - }else if (strcmp (argv[i], "-j\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - switch (argv[i][0]) { - case 'm': - line_join = VKVG_LINE_JOIN_MITER; - break; - case 'r': - line_join = VKVG_LINE_JOIN_ROUND; - break; - case 'b': - line_join = VKVG_LINE_JOIN_BEVEL; - break; - default: - _print_usage_and_exit(); - } - }else if (strcmp (argv[i], "-c\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - switch (argv[i][0]) { - case 'b': - line_cap = VKVG_LINE_CAP_BUTT; - break; - case 'r': - line_cap = VKVG_LINE_CAP_ROUND; - break; - case 's': - line_cap = VKVG_LINE_CAP_SQUARE; - break; - default: - _print_usage_and_exit(); - } - }else if (strcmp (argv[i], "-w\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - saveToPng = argv[i]; +void _parse_args(int argc, char *argv[]) { + bool printTestDetailsAndExit = false; + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-h\0") == 0) + _print_usage_and_exit(); + if (strcmp(argv[i], "-p\0") == 0) + printTestDetailsAndExit = true; + else if (strcmp(argv[i], "-vsync\0") == 0) + test_vsync = true; + else if (strcmp(argv[i], "-q\0") == 0) + quiet = true; + else if (strcmp(argv[i], "-t\0") == 0) + threadAware = true; + else if (strcmp(argv[i], "-i\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + iterations = atoi(argv[i]); + } else if (strcmp(argv[i], "-x\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + test_width = atoi(argv[i]); + } else if (strcmp(argv[i], "-y\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + test_height = atoi(argv[i]); + } else if (strcmp(argv[i], "-n\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + single_test = atoi(argv[i]); + } else if (strcmp(argv[i], "-s\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + test_size = atoi(argv[i]); + } else if (strcmp(argv[i], "-S\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + samples = (VkSampleCountFlags)atoi(argv[i]); + } else if (strcmp(argv[i], "-g\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + preferedPhysicalDeviceType = (VkPhysicalDeviceType)atoi(argv[i]); + } else if (strcmp(argv[i], "-l\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + line_width = atoi(argv[i]); + } else if (strcmp(argv[i], "-d\0") == 0) { + dashes_count = 2; + } else if (strcmp(argv[i], "-f\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + fill_rule = atoi(argv[i]); + } else if (strcmp(argv[i], "-o\0") == 0) { + offscreen = true; + } else if (strcmp(argv[i], "-j\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + switch (argv[i][0]) { + case 'm': + line_join = VKVG_LINE_JOIN_MITER; + break; + case 'r': + line_join = VKVG_LINE_JOIN_ROUND; + break; + case 'b': + line_join = VKVG_LINE_JOIN_BEVEL; + break; + default: + _print_usage_and_exit(); + } + } else if (strcmp(argv[i], "-c\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + switch (argv[i][0]) { + case 'b': + line_cap = VKVG_LINE_CAP_BUTT; + break; + case 'r': + line_cap = VKVG_LINE_CAP_ROUND; + break; + case 's': + line_cap = VKVG_LINE_CAP_SQUARE; + break; + default: + _print_usage_and_exit(); + } + } else if (strcmp(argv[i], "-w\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + saveToPng = argv[i]; #ifdef DEBUG - }else if (strcmp (argv[i], "-L\0") == 0) { - if (argc -1 < ++i) - _print_usage_and_exit(); - sscanf(argv[i], "%x", &vkvg_log_level); + } else if (strcmp(argv[i], "-L\0") == 0) { + if (argc - 1 < ++i) + _print_usage_and_exit(); + sscanf(argv[i], "%x", &vkvg_log_level); #endif - }else - _print_usage_and_exit(); - } - if (printTestDetailsAndExit) { + } else + _print_usage_and_exit(); + } + if (printTestDetailsAndExit) { #ifdef DEBUG - printf("Debug build\n"); + printf("Debug build\n"); #else - printf("Release build\n"); + printf("Release build\n"); #endif #ifdef VKVG_USE_RENDERDOC - printf("Render doc enabled\n"); + printf("Render doc enabled\n"); #endif #ifdef VKVG_USE_VALIDATION - printf("Validation:\tenabled\n"); + printf("Validation:\tenabled\n"); #else - printf("Validation:\no\n"); + printf("Validation:\no\n"); #endif - printf("surf dims:\t%d x %d\n", test_width, test_height); - printf("Samples:\t%d\n", samples); - printf("Gpu type:\t"); - switch (preferedPhysicalDeviceType) { - case VK_PHYSICAL_DEVICE_TYPE_OTHER: - printf("Other\n"); - break; - case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: - printf("Integrated\n"); - break; - case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: - printf("Discrete\n"); - break; - case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: - printf("Virtual\n"); - break; - case VK_PHYSICAL_DEVICE_TYPE_CPU: - printf("CPU\n"); - break; - } + printf("surf dims:\t%d x %d\n", test_width, test_height); + printf("Samples:\t%d\n", samples); + printf("Gpu type:\t"); + switch (preferedPhysicalDeviceType) { + case VK_PHYSICAL_DEVICE_TYPE_OTHER: + printf("Other\n"); + break; + case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: + printf("Integrated\n"); + break; + case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: + printf("Discrete\n"); + break; + case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: + printf("Virtual\n"); + break; + case VK_PHYSICAL_DEVICE_TYPE_CPU: + printf("CPU\n"); + break; + } - if (offscreen) - printf("Offscreen:\ttrue\n"); - else - printf("Offscreen:\tfalse\n"); + if (offscreen) + printf("Offscreen:\ttrue\n"); + else + printf("Offscreen:\tfalse\n"); - if (fill_rule == VKVG_FILL_RULE_EVEN_ODD) - printf("Fillrule:\tEven/Odd\n"); - else - printf("Fillrule:\tNon zero\n"); + if (fill_rule == VKVG_FILL_RULE_EVEN_ODD) + printf("Fillrule:\tEven/Odd\n"); + else + printf("Fillrule:\tNon zero\n"); - printf("\n"); - exit(0); - } + printf("\n"); + exit(0); + } } -void _print_results (const char *testName, int argc, char* argv[], uint32_t i, double run_total, double* run_time_values) { - char* whoami; - (whoami = strrchr(argv[0], '/')) ? ++whoami : (whoami = argv[0]); +void _print_results(const char *testName, int argc, char *argv[], uint32_t i, double run_total, + double *run_time_values) { + char *whoami; + (whoami = strrchr(argv[0], '/')) ? ++whoami : (whoami = argv[0]); - double avg_run_time = run_total / (double)i; - double med_run_time = median_run_time (run_time_values, i); - double standard_dev = standard_deviation (run_time_values, i, avg_run_time); - double avg_frames_per_second = (1.0 / avg_run_time); - avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999; + double avg_run_time = run_total / (double)i; + double med_run_time = median_run_time(run_time_values, i); + double standard_dev = standard_deviation(run_time_values, i, avg_run_time); + double avg_frames_per_second = (1.0 / avg_run_time); + avg_frames_per_second = (avg_frames_per_second < 9999) ? avg_frames_per_second : 9999; - if (!quiet && (test_index == 0 || test_index == single_test)) { + if (!quiet && (test_index == 0 || test_index == single_test)) { #if VKVG_DBG_STATS - printf ("_____________________________________________________________________________________________________________________________\n"); - printf ("| N° | Test File Name | Sub Test | Iter | Size | Pts |Pathes| Vx cache | Ix cache | VBO | IBO |\n"); - printf ("|----|-----------------|---------------------------|------|------|-------|------|----------|----------|----------|----------|\n"); + printf("_______________________________________________________________________________________________________" + "______________________\n"); + printf("| N° | Test File Name | Sub Test | Iter | Size | Pts |Pathes| Vx cache | Ix cache " + "| VBO | IBO |\n"); + printf("|----|-----------------|---------------------------|------|------|-------|------|----------|----------|" + "----------|----------|\n"); #else - printf ("__________________________________________________________________________________________________________\n"); - printf ("| N° | Test File Name | Sub Test | Iter | Size | FPS | Average | Median | Sigma |\n"); - printf ("|----|-----------------|---------------------------|------|------|---------|---------|---------|---------|\n"); + printf("_______________________________________________________________________________________________________" + "___\n"); + printf("| N° | Test File Name | Sub Test | Iter | Size | FPS | Average | Median | Sigma " + " |\n"); + printf("|----|-----------------|---------------------------|------|------|---------|---------|---------|-------" + "--|\n"); #endif - } - - printf ("| %2d | %-15s | %-25s | %4d | ", test_index, whoami, testName, i); - if (no_test_size) - printf ("%4d | ", 1); - else - printf ("%4d | ", test_size); + } + + printf("| %2d | %-15s | %-25s | %4d | ", test_index, whoami, testName, i); + if (no_test_size) + printf("%4d | ", 1); + else + printf("%4d | ", test_size); #if VKVG_DBG_STATS - vkvg_debug_stats_t dbgStats = vkvg_device_get_stats (device); - printf ("%5d | %4d | %8d | %8d | %8d | %8d |\n", - dbgStats.sizePoints, dbgStats.sizePathes, dbgStats.sizeVertices, - dbgStats.sizeIndices, dbgStats.sizeVBO, dbgStats.sizeIBO); -#else - printf ("%7.2f | %6.5f | %6.5f | %6.5f |\n", - avg_frames_per_second, avg_run_time, med_run_time, standard_dev); -#endif + vkvg_debug_stats_t dbgStats = vkvg_device_get_stats(device); + printf("%5d | %4d | %8d | %8d | %8d | %8d |\n", dbgStats.sizePoints, dbgStats.sizePathes, dbgStats.sizeVertices, + dbgStats.sizeIndices, dbgStats.sizeVBO, dbgStats.sizeIBO); +#else + printf("%7.2f | %6.5f | %6.5f | %6.5f |\n", avg_frames_per_second, avg_run_time, med_run_time, standard_dev); +#endif } #if VKVG_DBG_STATS -void _print_debug_stats () { +void _print_debug_stats() { - vkvg_debug_stats_t dbgStats = vkvg_device_get_stats (device); - printf ("| %8d | %8d | %8d | %8d | %8d | %8d |\n", dbgStats.sizePoints, dbgStats.sizePathes, dbgStats.sizeVertices, - dbgStats.sizeIndices, dbgStats.sizeVBO, dbgStats.sizeIBO); + vkvg_debug_stats_t dbgStats = vkvg_device_get_stats(device); + printf("| %8d | %8d | %8d | %8d | %8d | %8d |\n", dbgStats.sizePoints, dbgStats.sizePathes, dbgStats.sizeVertices, + dbgStats.sizeIndices, dbgStats.sizeVBO, dbgStats.sizeIBO); } #endif -void perform_test (void(*testfunc)(void), const char *testName, int argc, char* argv[]) { - setlocale(LC_ALL, ""); - //dumpLayerExts(); - _parse_args (argc, argv); +void perform_test(void (*testfunc)(void), const char *testName, int argc, char *argv[]) { + setlocale(LC_ALL, ""); + // dumpLayerExts(); + _parse_args(argc, argv); - //init random gen - struct timeval currentTime; - gettimeofday(¤tTime, NULL); - srand((unsigned)currentTime.tv_usec); + // init random gen + struct timeval currentTime; + gettimeofday(¤tTime, NULL); + srand((unsigned)currentTime.tv_usec); - if (iterations == 0) - iterations = 9999; + if (iterations == 0) + iterations = 9999; - if (single_test >= 0 && test_index != single_test) { - test_index++; - return; - } + if (single_test >= 0 && test_index != single_test) { + test_index++; + return; + } - if (offscreen) - perform_test_offscreen(testfunc, testName, argc, argv); - else - perform_test_onscreen(testfunc, testName, argc, argv); + if (offscreen) + perform_test_offscreen(testfunc, testName, argc, argv); + else + perform_test_onscreen(testfunc, testName, argc, argv); } -void perform_test_offscreen (void(*testfunc)(void), const char *testName, int argc, char* argv[]) { - uint32_t enabledExtsCount = 0, phyCount = 0; - const char* enabledExts [10]; +void perform_test_offscreen(void (*testfunc)(void), const char *testName, int argc, char *argv[]) { + uint32_t enabledExtsCount = 0, phyCount = 0; + const char *enabledExts[10]; #ifdef VKVG_USE_RENDERDOC - const uint32_t enabledLayersCount = 2; - const char* enabledLayers[] = {"VK_LAYER_KHRONOS_validation", "VK_LAYER_RENDERDOC_Capture"}; -#elif defined (VKVG_USE_VALIDATION) - const uint32_t enabledLayersCount = 1; - const char* enabledLayers[] = {"VK_LAYER_KHRONOS_validation"}; + const uint32_t enabledLayersCount = 2; + const char *enabledLayers[] = {"VK_LAYER_KHRONOS_validation", "VK_LAYER_RENDERDOC_Capture"}; +#elif defined(VKVG_USE_VALIDATION) + const uint32_t enabledLayersCount = 1; + const char *enabledLayers[] = {"VK_LAYER_KHRONOS_validation"}; #else - const uint32_t enabledLayersCount = 0; - const char* enabledLayers[] = {NULL}; + const uint32_t enabledLayersCount = 0; + const char *enabledLayers[] = {NULL}; #endif -#if defined(DEBUG) && defined (VKVG_DBG_UTILS) - enabledExts[enabledExtsCount] = "VK_EXT_debug_utils"; - enabledExtsCount++; +#if defined(DEBUG) && defined(VKVG_DBG_UTILS) + enabledExts[enabledExtsCount] = "VK_EXT_debug_utils"; + enabledExtsCount++; #endif - VkhApp app = vkh_app_create(1, 1, "vkvgTest", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts); -#if defined(DEBUG) && defined (VKVG_DBG_UTILS) - vkh_app_enable_debug_messenger(app - , VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT - , VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT - //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT - //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT - , NULL); + VkhApp app = vkh_app_create(1, 1, "vkvgTest", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts); +#if defined(DEBUG) && defined(VKVG_DBG_UTILS) + vkh_app_enable_debug_messenger( + app, + VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | + VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, + VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT + //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT + //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT + , + NULL); #endif - bool deferredResolve = false; - VkhPhyInfo* phys = vkh_app_get_phyinfos (app, &phyCount, VK_NULL_HANDLE); - VkhPhyInfo pi = 0; - if (!vkengine_try_get_phyinfo(phys, phyCount, preferedPhysicalDeviceType, &pi)) - if (!vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, &pi)) - if (!vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, &pi)) - pi = phys[0]; + bool deferredResolve = false; + VkhPhyInfo *phys = vkh_app_get_phyinfos(app, &phyCount, VK_NULL_HANDLE); + VkhPhyInfo pi = 0; + if (!vkengine_try_get_phyinfo(phys, phyCount, preferedPhysicalDeviceType, &pi)) + if (!vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, &pi)) + if (!vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, &pi)) + pi = phys[0]; - uint32_t qCount = 0; - float qPriorities[] = {0.0}; - VkDeviceQueueCreateInfo pQueueInfos[] = { {0},{0},{0} }; - if (vkh_phyinfo_create_queues (pi, pi->gQueue, 1, qPriorities, &pQueueInfos[qCount])) - qCount++; - VkPhysicalDeviceFeatures enabledFeatures = { - .fillModeNonSolid = true, - }; + uint32_t qCount = 0; + float qPriorities[] = {0.0}; + VkDeviceQueueCreateInfo pQueueInfos[] = {{0}, {0}, {0}}; + if (vkh_phyinfo_create_queues(pi, pi->gQueue, 1, qPriorities, &pQueueInfos[qCount])) + qCount++; + VkPhysicalDeviceFeatures enabledFeatures = { + .fillModeNonSolid = true, + }; - VkDeviceCreateInfo device_info = { .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, - .queueCreateInfoCount = qCount, - .pQueueCreateInfos = (VkDeviceQueueCreateInfo*)&pQueueInfos, - .pEnabledFeatures = &enabledFeatures}; + VkDeviceCreateInfo device_info = {.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, + .queueCreateInfoCount = qCount, + .pQueueCreateInfos = (VkDeviceQueueCreateInfo *)&pQueueInfos, + .pEnabledFeatures = &enabledFeatures}; - VkhDevice dev = vkh_device_create(app, pi, &device_info); + VkhDevice dev = vkh_device_create(app, pi, &device_info); vkvg_device_create_info_t info = { - samples, - deferredResolve, - vkh_app_get_inst(e->app), - dev->phy, - dev->dev, - pi->gQueue, - 0 - }; + samples, deferredResolve, vkh_app_get_inst(e->app), dev->phy, dev->dev, pi->gQueue, 0}; device = vkvg_device_create(&info); - //vkvg_device_set_dpy(device, 96, 96); + // vkvg_device_set_dpy(device, 96, 96); - vkh_app_free_phyinfos (phyCount, phys); + vkh_app_free_phyinfos(phyCount, phys); - surf = vkvg_surface_create(device, test_width, test_height); + surf = vkvg_surface_create(device, test_width, test_height); - double start_time = 0.0, stop_time = 0.0, run_time = 0.0, run_total = 0.0, min_run_time = -1, max_run_time = 0.0; - double* run_time_values = (double*)malloc(iterations*sizeof(double)); + double start_time = 0.0, stop_time = 0.0, run_time = 0.0, run_total = 0.0, min_run_time = -1, max_run_time = 0.0; + double *run_time_values = (double *)malloc(iterations * sizeof(double)); - uint32_t i = 0; - while (i < iterations) { - start_time = get_tick(); + uint32_t i = 0; + while (i < iterations) { + start_time = get_tick(); - testfunc(); + testfunc(); - if (deferredResolve) - vkvg_surface_resolve(surf); + if (deferredResolve) + vkvg_surface_resolve(surf); - stop_time = get_tick(); - run_time = stop_time - start_time; - run_time_values[i] = run_time; + stop_time = get_tick(); + run_time = stop_time - start_time; + run_time_values[i] = run_time; - if (min_run_time < 0) - min_run_time = run_time; - else - min_run_time = MIN(run_time, min_run_time); - max_run_time = MAX(run_time, max_run_time); - run_total += run_time; - i++; - } + if (min_run_time < 0) + min_run_time = run_time; + else + min_run_time = MIN(run_time, min_run_time); + max_run_time = MAX(run_time, max_run_time); + run_total += run_time; + i++; + } - _print_results (testName, argc, argv, i, run_total, run_time_values); + _print_results(testName, argc, argv, i, run_total, run_time_values); - free (run_time_values); + free(run_time_values); - vkDeviceWaitIdle(dev->dev); + vkDeviceWaitIdle(dev->dev); - if (saveToPng) - vkvg_surface_write_to_png (surf, saveToPng); + if (saveToPng) + vkvg_surface_write_to_png(surf, saveToPng); - vkvg_surface_destroy (surf); - vkvg_device_destroy (device); + vkvg_surface_destroy(surf); + vkvg_device_destroy(device); - vkh_device_destroy (dev); - vkh_app_destroy (app); + vkh_device_destroy(dev); + vkh_app_destroy(app); - test_index++; + test_index++; } -void perform_test_onscreen (void(*testfunc)(void), const char *testName, int argc, char* argv[]) { - if (test_vsync) - e = vkengine_create (preferedPhysicalDeviceType, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); - else - e = vkengine_create (preferedPhysicalDeviceType, VK_PRESENT_MODE_MAILBOX_KHR, test_width, test_height); +void perform_test_onscreen(void (*testfunc)(void), const char *testName, int argc, char *argv[]) { + if (test_vsync) + e = vkengine_create(preferedPhysicalDeviceType, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); + else + e = vkengine_create(preferedPhysicalDeviceType, VK_PRESENT_MODE_MAILBOX_KHR, test_width, test_height); - VkhPresenter r = e->renderer; - vkengine_set_key_callback (e, key_callback); - vkengine_set_mouse_but_callback (e, mouse_button_callback); - vkengine_set_cursor_pos_callback (e, mouse_move_callback); - vkengine_set_scroll_callback (e, scroll_callback); + VkhPresenter r = e->renderer; + vkengine_set_key_callback(e, key_callback); + vkengine_set_mouse_but_callback(e, mouse_button_callback); + vkengine_set_cursor_pos_callback(e, mouse_move_callback); + vkengine_set_scroll_callback(e, scroll_callback); - vkvg_device_create_info_t info = { - samples, - false, - vkh_app_get_inst(e->app), - r->dev->phy, - r->dev->dev, - r->qFam, - 0 - }; - device = vkvg_device_create(&info); + vkvg_device_create_info_t info = {samples, false, vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0}; + device = vkvg_device_create(&info); - vkvg_device_set_dpy (device, 96, 96); - if (threadAware) - vkvg_device_set_thread_aware (device, 1); + vkvg_device_set_dpy(device, 96, 96); + if (threadAware) + vkvg_device_set_thread_aware(device, 1); #ifdef VKVG_TEST_DIRECT_DRAW - surfaces = (VkvgSurface*)malloc(r->imgCount * sizeof (VkvgSurface)); - for (uint32_t i=0; i < r->imgCount;i++) - surfaces[i] = vkvg_surface_create_for_VkhImage (device, r->ScBuffers[i]); + surfaces = (VkvgSurface *)malloc(r->imgCount * sizeof(VkvgSurface)); + for (uint32_t i = 0; i < r->imgCount; i++) + surfaces[i] = vkvg_surface_create_for_VkhImage(device, r->ScBuffers[i]); #else - surf = vkvg_surface_create (device, test_width, test_height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); + surf = vkvg_surface_create(device, test_width, test_height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); #endif - double start_time = 0.0, stop_time = 0.0, run_time = 0.0, run_total = 0.0, min_run_time = -1, max_run_time = 0.0; - double* run_time_values = (double*)malloc(iterations*sizeof(double)); + double start_time = 0.0, stop_time = 0.0, run_time = 0.0, run_total = 0.0, min_run_time = -1, max_run_time = 0.0; + double *run_time_values = (double *)malloc(iterations * sizeof(double)); - uint32_t i = 0; + uint32_t i = 0; - vkengine_set_title (e, testName); + vkengine_set_title(e, testName); - while (!vkengine_should_close (e) && i < iterations) { - glfwPollEvents(); + while (!vkengine_should_close(e) && i < iterations) { + glfwPollEvents(); - start_time = get_tick(); + start_time = get_tick(); #ifdef VKVG_TEST_DIRECT_DRAW - if (!vkh_presenter_acquireNextImage(r, NULL, NULL)) { - for (uint32_t i=0; i < r->imgCount;i++) - vkvg_surface_destroy (surfaces[i]); + if (!vkh_presenter_acquireNextImage(r, NULL, NULL)) { + for (uint32_t i = 0; i < r->imgCount; i++) + vkvg_surface_destroy(surfaces[i]); - vkh_presenter_create_swapchain (r); + vkh_presenter_create_swapchain(r); - for (uint32_t i=0; i < r->imgCount;i++) - surfaces[i] = vkvg_surface_create_for_VkhImage (device, r->ScBuffers[i]); - }else{ - surf = surfaces[r->currentScBufferIndex]; + for (uint32_t i = 0; i < r->imgCount; i++) + surfaces[i] = vkvg_surface_create_for_VkhImage(device, r->ScBuffers[i]); + } else { + surf = surfaces[r->currentScBufferIndex]; - testfunc(); + testfunc(); - if (deferredResolve) - vkvg_multisample_surface_resolve(surf); + if (deferredResolve) + vkvg_multisample_surface_resolve(surf); - VkPresentInfoKHR present = { .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, - .swapchainCount = 1, - .pSwapchains = &r->swapChain, - .pImageIndices = &r->currentScBufferIndex }; + VkPresentInfoKHR present = {.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, + .swapchainCount = 1, + .pSwapchains = &r->swapChain, + .pImageIndices = &r->currentScBufferIndex}; - vkQueuePresentKHR(r->queue, &present); - } + vkQueuePresentKHR(r->queue, &present); + } #else - if (paused) - continue; + if (paused) + continue; - testfunc(); + testfunc(); if (info.deferredResolve) - vkvg_surface_resolve(surf); - if (!vkh_presenter_draw (r)){ - vkh_presenter_get_size (r, &test_width, &test_height); - vkvg_surface_destroy (surf); - surf = vkvg_surface_create(device, test_width, test_height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); - vkDeviceWaitIdle(r->dev->dev); - continue; - } + vkvg_surface_resolve(surf); + if (!vkh_presenter_draw(r)) { + vkh_presenter_get_size(r, &test_width, &test_height); + vkvg_surface_destroy(surf); + surf = vkvg_surface_create(device, test_width, test_height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); + vkDeviceWaitIdle(r->dev->dev); + continue; + } #endif - stop_time = get_tick(); - run_time = stop_time - start_time; - run_time_values[i] = run_time; + stop_time = get_tick(); + run_time = stop_time - start_time; + run_time_values[i] = run_time; - if (min_run_time < 0) - min_run_time = run_time; - else - min_run_time = MIN(run_time, min_run_time); - max_run_time = MAX(run_time, max_run_time); - run_total += run_time; - i++; - } + if (min_run_time < 0) + min_run_time = run_time; + else + min_run_time = MIN(run_time, min_run_time); + max_run_time = MAX(run_time, max_run_time); + run_total += run_time; + i++; + } - if (saveToPng) - vkvg_surface_write_to_png (surf, saveToPng); + if (saveToPng) + vkvg_surface_write_to_png(surf, saveToPng); - _print_results (testName, argc, argv, i, run_total, run_time_values); + _print_results(testName, argc, argv, i, run_total, run_time_values); - free (run_time_values); + free(run_time_values); - vkDeviceWaitIdle(e->dev->dev); + vkDeviceWaitIdle(e->dev->dev); #ifdef VKVG_TEST_DIRECT_DRAW - for (uint32_t i=0; i<r->imgCount;i++) - vkvg_surface_destroy (surfaces[i]); + for (uint32_t i = 0; i < r->imgCount; i++) + vkvg_surface_destroy(surfaces[i]); - free (surfaces); + free(surfaces); #else - vkvg_surface_destroy (surf); + vkvg_surface_destroy(surf); #endif - - vkvg_device_destroy (device); - vkengine_destroy (e); - - test_index++; -} + vkvg_device_destroy(device); + + vkengine_destroy(e); + test_index++; +} /* common context init for several tests */ -vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_NON_ZERO; -vkvg_line_cap_t line_cap = VKVG_LINE_CAP_BUTT; -vkvg_line_join_t line_join = VKVG_LINE_JOIN_MITER; -float dashes[] = {10.0f, 6.0f}; -//float dashes[] = {0.0f, 10.0f}; -uint32_t dashes_count= 0; -float dash_offset = 0; -float line_width = 2.f; +vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_NON_ZERO; +vkvg_line_cap_t line_cap = VKVG_LINE_CAP_BUTT; +vkvg_line_join_t line_join = VKVG_LINE_JOIN_MITER; +float dashes[] = {10.0f, 6.0f}; +// float dashes[] = {0.0f, 10.0f}; +uint32_t dashes_count = 0; +float dash_offset = 0; +float line_width = 2.f; VkvgContext _initCtx() { - VkvgContext ctx = vkvg_create(surf); + VkvgContext ctx = vkvg_create(surf); - vkvg_set_line_width (ctx,line_width); - vkvg_set_line_join (ctx, line_join); - vkvg_set_line_cap (ctx, line_cap); - vkvg_set_dash (ctx, dashes, dashes_count, dash_offset); - vkvg_set_fill_rule (ctx, fill_rule); + vkvg_set_line_width(ctx, line_width); + vkvg_set_line_join(ctx, line_join); + vkvg_set_line_cap(ctx, line_cap); + vkvg_set_dash(ctx, dashes, dashes_count, dash_offset); + vkvg_set_fill_rule(ctx, fill_rule); - vkvg_clear (ctx); - return ctx; + vkvg_clear(ctx); + return ctx; } +const int star_points[11][2] = {{0, 85}, {75, 75}, {100, 10}, {125, 75}, {200, 85}, {150, 125}, + {160, 190}, {100, 150}, {40, 190}, {50, 125}, {0, 85}}; +void randomize_color(VkvgContext ctx) { vkvg_set_source_rgba(ctx, rndf(), rndf(), rndf(), rndf()); } +void draw_random_shape(VkvgContext ctx, shape_t shape, float sizeFact) { + float w = (float)test_width; + float h = (float)test_height; + float x, y, z, v, r; -const int star_points[11][2] = { - { 0, 85 }, - { 75, 75 }, - { 100, 10 }, - { 125, 75 }, - { 200, 85 }, - { 150, 125 }, - { 160, 190 }, - { 100, 150 }, - { 40, 190 }, - { 50, 125 }, - { 0, 85 } -}; -void randomize_color(VkvgContext ctx) { - vkvg_set_source_rgba(ctx, - rndf(), - rndf(), - rndf(), - rndf() - ); -} -void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact) { - float w = (float)test_width; - float h = (float)test_height; - - float x, y, z, v, r; - - randomize_color (ctx); + randomize_color(ctx); - switch (shape) { - case SHAPE_LINE: - x = rndf() * w; - y = rndf() * h; - z = rndf() * w; - v = rndf() * h; + switch (shape) { + case SHAPE_LINE: + x = rndf() * w; + y = rndf() * h; + z = rndf() * w; + v = rndf() * h; - vkvg_move_to(ctx, x, y); - vkvg_line_to(ctx, z, v); - vkvg_stroke(ctx); - break; - case SHAPE_RECTANGLE: - z = truncf((sizeFact*w*rndf())+1.f); - v = truncf((sizeFact*h*rndf())+1.f); - x = truncf((w-z)*rndf()); - y = truncf((h-v)*rndf()); + vkvg_move_to(ctx, x, y); + vkvg_line_to(ctx, z, v); + vkvg_stroke(ctx); + break; + case SHAPE_RECTANGLE: + z = truncf((sizeFact * w * rndf()) + 1.f); + v = truncf((sizeFact * h * rndf()) + 1.f); + x = truncf((w - z) * rndf()); + y = truncf((h - v) * rndf()); - vkvg_rectangle(ctx, x+1, y+1, z, v); - break; - case SHAPE_ROUNDED_RECTANGLE: - z = truncf((sizeFact*w*rndf())+1.f); - v = truncf((sizeFact*h*rndf())+1.f); - x = truncf((w-z)*rndf()); - y = truncf((h-v)*rndf()); - r = truncf((0.2f*z*rndf())+1.f); + vkvg_rectangle(ctx, x + 1, y + 1, z, v); + break; + case SHAPE_ROUNDED_RECTANGLE: + z = truncf((sizeFact * w * rndf()) + 1.f); + v = truncf((sizeFact * h * rndf()) + 1.f); + x = truncf((w - z) * rndf()); + y = truncf((h - v) * rndf()); + r = truncf((0.2f * z * rndf()) + 1.f); - if ((r > v / 2) || (r > z / 2)) - r = MIN(v / 2, z / 2); + if ((r > v / 2) || (r > z / 2)) + r = MIN(v / 2, z / 2); - vkvg_move_to(ctx, x, y + r); - vkvg_arc(ctx, x + r, y + r, r, (float)M_PI, (float)-M_PI_2); - vkvg_line_to(ctx, x + z - r, y); - vkvg_arc(ctx, x + z - r, y + r, r, (float)-M_PI_2, 0); - vkvg_line_to(ctx, x + z, y + v - r); - vkvg_arc(ctx, x + z - r, y + v - r, r, 0, (float)M_PI_2); - vkvg_line_to(ctx, x + r, y + v); - vkvg_arc(ctx, x + r, y + v - r, r, (float)M_PI_2, (float)M_PI); - vkvg_line_to(ctx, x, y + r); - vkvg_close_path(ctx); - break; - case SHAPE_CIRCLE: - /*x = truncf((float)w * rnd()/RAND_MAX); - y = truncf((float)h * rnd()/RAND_MAX); - v = truncf((float)w * rnd()/RAND_MAX * 0.2f);*/ - x = rndf() * w; - y = rndf() * h; + vkvg_move_to(ctx, x, y + r); + vkvg_arc(ctx, x + r, y + r, r, (float)M_PI, (float)-M_PI_2); + vkvg_line_to(ctx, x + z - r, y); + vkvg_arc(ctx, x + z - r, y + r, r, (float)-M_PI_2, 0); + vkvg_line_to(ctx, x + z, y + v - r); + vkvg_arc(ctx, x + z - r, y + v - r, r, 0, (float)M_PI_2); + vkvg_line_to(ctx, x + r, y + v); + vkvg_arc(ctx, x + r, y + v - r, r, (float)M_PI_2, (float)M_PI); + vkvg_line_to(ctx, x, y + r); + vkvg_close_path(ctx); + break; + case SHAPE_CIRCLE: + /*x = truncf((float)w * rnd()/RAND_MAX); + y = truncf((float)h * rnd()/RAND_MAX); + v = truncf((float)w * rnd()/RAND_MAX * 0.2f);*/ + x = rndf() * w; + y = rndf() * h; - r = truncf((sizeFact*MIN(w,h)*rndf())+1.f); + r = truncf((sizeFact * MIN(w, h) * rndf()) + 1.f); - /*float r = 0.5f*w*rand()/RAND_MAX; - float x = truncf(0.5f * w*rand()/RAND_MAX + r); - float y = truncf(0.5f * w*rand()/RAND_MAX + r);*/ + /*float r = 0.5f*w*rand()/RAND_MAX; + float x = truncf(0.5f * w*rand()/RAND_MAX + r); + float y = truncf(0.5f * w*rand()/RAND_MAX + r);*/ - vkvg_arc(ctx, x, y, r, 0, (float)M_PI * 2.0f); - break; - case SHAPE_TRIANGLE: - case SHAPE_STAR: - x = rndf() * w; - y = rndf() * h; - z = rndf() * sizeFact + 0.15f; //scale + vkvg_arc(ctx, x, y, r, 0, (float)M_PI * 2.0f); + break; + case SHAPE_TRIANGLE: + case SHAPE_STAR: + x = rndf() * w; + y = rndf() * h; + z = rndf() * sizeFact + 0.15f; // scale - vkvg_move_to (ctx, x+star_points[0][0]*z, y+star_points[0][1]*z); - for (int s=1; s<11; s++) - vkvg_line_to (ctx, x+star_points[s][0]*z, y+star_points[s][1]*z); - vkvg_close_path (ctx); - break; - case SHAPE_RANDOM: - draw_random_shape(ctx, 1 + (rndf() * 4), sizeFact); - break; - } + vkvg_move_to(ctx, x + star_points[0][0] * z, y + star_points[0][1] * z); + for (int s = 1; s < 11; s++) + vkvg_line_to(ctx, x + star_points[s][0] * z, y + star_points[s][1] * z); + vkvg_close_path(ctx); + break; + case SHAPE_RANDOM: + draw_random_shape(ctx, 1 + (rndf() * 4), sizeFact); + break; + } } -void draw_random_curve (VkvgContext ctx) { - float w = (float)test_width; - float h = (float)test_height; +void draw_random_curve(VkvgContext ctx) { + float w = (float)test_width; + float h = (float)test_height; - float x2 = w*rndf(); - float y2 = h*rndf(); - float cp_x1 = w*rndf(); - float cp_y1 = h*rndf(); - float cp_x2 = w*rndf(); - float cp_y2 = h*rndf(); + float x2 = w * rndf(); + float y2 = h * rndf(); + float cp_x1 = w * rndf(); + float cp_y1 = h * rndf(); + float cp_x2 = w * rndf(); + float cp_y2 = h * rndf(); - vkvg_curve_to(ctx, cp_x1, cp_y1, cp_x2, cp_y2, x2, y2); + vkvg_curve_to(ctx, cp_x1, cp_y1, cp_x2, cp_y2, x2, y2); } /*void draw_random_shape (VkvgContext ctx, shape_t shape) { - float w = (float)test_width; - float h = (float)test_height; - randomize_color(ctx); - float z = truncf((0.5f*w*rand()/RAND_MAX)+1.f); - float v = truncf((0.5f*w*rand()/RAND_MAX)+1.f); - float x = truncf((w-z)*rand()/RAND_MAX); - float y = truncf((h-v)*rand()/RAND_MAX); - vkvg_rectangle(ctx, x, y, z, v); + float w = (float)test_width; + float h = (float)test_height; + randomize_color(ctx); + float z = truncf((0.5f*w*rand()/RAND_MAX)+1.f); + float v = truncf((0.5f*w*rand()/RAND_MAX)+1.f); + float x = truncf((w-z)*rand()/RAND_MAX); + float y = truncf((h-v)*rand()/RAND_MAX); + vkvg_rectangle(ctx, x, y, z, v); }*/ diff --git a/tests/common/test.h b/tests/common/test.h index d61858e..8079cec 100644 --- a/tests/common/test.h +++ b/tests/common/test.h @@ -12,113 +12,113 @@ #include "vkh_presenter.h" #include "vkh_phyinfo.h" -#define M_PIF 3.14159265359f /* float pi */ -#define M_PIF_MULT_2 6.28318530718f +#define M_PIF 3.14159265359f /* float pi */ +#define M_PIF_MULT_2 6.28318530718f #ifndef M_PI -# define M_PI 3.14159265358979323846 /* pi */ +#define M_PI 3.14159265358979323846 /* pi */ #endif #ifndef M_PI_2 -# define M_PI_2 1.57079632679489661923 /* pi/2 */ +#define M_PI_2 1.57079632679489661923 /* pi/2 */ #endif #ifndef MIN -# define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif #ifndef MAX -# define MAX(a,b) (((a) > (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif #define PERFORM_TEST(testName, argc, argv) perform_test(testName, #testName, argc, argv); #if defined(_WIN32) || defined(_WIN64) - #define WIN32_LEAN_AND_MEAN - #define NOMINMAX - #include <Windows.h> // Windows.h -> WinDef.h defines min() max() +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#include <Windows.h> // Windows.h -> WinDef.h defines min() max() - /* - typedef uint16_t WORD ; - typedef uint32_t DWORD; +/* + typedef uint16_t WORD ; + typedef uint32_t DWORD; - typedef struct _FILETIME { - DWORD dwLowDateTime; - DWORD dwHighDateTime; - } FILETIME; + typedef struct _FILETIME { + DWORD dwLowDateTime; + DWORD dwHighDateTime; + } FILETIME; - typedef struct _SYSTEMTIME { - WORD wYear; - WORD wMonth; - WORD wDayOfWeek; - WORD wDay; - WORD wHour; - WORD wMinute; - WORD wSecond; - WORD wMilliseconds; - } SYSTEMTIME, *PSYSTEMTIME; - */ + typedef struct _SYSTEMTIME { + WORD wYear; + WORD wMonth; + WORD wDayOfWeek; + WORD wDay; + WORD wHour; + WORD wMinute; + WORD wSecond; + WORD wMilliseconds; + } SYSTEMTIME, *PSYSTEMTIME; +*/ - // *sigh* Microsoft has this in winsock2.h because they are too lazy to put it in the standard location ... !?!? +// *sigh* Microsoft has this in winsock2.h because they are too lazy to put it in the standard location ... !?!? #ifdef _MSC_VER - typedef struct timeval { - long tv_sec; - long tv_usec; - } timeval; +typedef struct timeval { + long tv_sec; + long tv_usec; +} timeval; #endif - // *sigh* no gettimeofday on Win32/Win64 - int gettimeofday(struct timeval * tp, void * tzp); +// *sigh* no gettimeofday on Win32/Win64 +int gettimeofday(struct timeval *tp, void *tzp); #else - #include <sys/time.h> +#include <sys/time.h> #endif typedef enum _shape_t { - SHAPE_LINE, - SHAPE_RECTANGLE, - SHAPE_ROUNDED_RECTANGLE, - SHAPE_CIRCLE, - SHAPE_TRIANGLE, - SHAPE_STAR, - SHAPE_RANDOM, + SHAPE_LINE, + SHAPE_RECTANGLE, + SHAPE_ROUNDED_RECTANGLE, + SHAPE_CIRCLE, + SHAPE_TRIANGLE, + SHAPE_STAR, + SHAPE_RANDOM, } shape_t; extern uint32_t test_size; extern uint32_t iterations; extern uint32_t test_width; extern uint32_t test_height; -extern bool no_test_size; +extern bool no_test_size; extern float panX; extern float panY; extern float lastX; extern float lastY; extern float zoom; -extern bool mouseDown; +extern bool mouseDown; -extern VkvgDevice device; +extern VkvgDevice device; extern VkvgSurface surf; /* common context init for several tests */ -extern float dash_offset; -extern float line_width; +extern float dash_offset; +extern float line_width; extern vkvg_fill_rule_t fill_rule; -extern vkvg_line_cap_t line_cap; +extern vkvg_line_cap_t line_cap; extern vkvg_line_join_t line_join; -extern float dashes[]; -extern uint32_t dashes_count; +extern float dashes[]; +extern uint32_t dashes_count; VkvgContext _initCtx(); -void _parse_args (int argc, char* argv[]); +void _parse_args(int argc, char *argv[]); /*******************************/ -//run test in one step -void perform_test (void(*testfunc)(), const char* testName, int argc, char *argv[]); -void perform_test_onscreen (void(*testfunc)(void), const char *testName, int argc, char* argv[]); -void perform_test_offscreen (void(*testfunc)(void), const char *testName, int argc, char* argv[]); +// run test in one step +void perform_test(void (*testfunc)(), const char *testName, int argc, char *argv[]); +void perform_test_onscreen(void (*testfunc)(void), const char *testName, int argc, char *argv[]); +void perform_test_offscreen(void (*testfunc)(void), const char *testName, int argc, char *argv[]); -void randomize_color (VkvgContext ctx); -void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact); -void draw_random_curve (VkvgContext ctx); +void randomize_color(VkvgContext ctx); +void draw_random_shape(VkvgContext ctx, shape_t shape, float sizeFact); +void draw_random_curve(VkvgContext ctx); -//run test in 3 step: init, run, clear. -void init_test (uint32_t width, uint32_t height); -void clear_test (); +// run test in 3 step: init, run, clear. +void init_test(uint32_t width, uint32_t height); +void clear_test(); diff --git a/tests/common/tinycthread.c b/tests/common/tinycthread.c index f9cea2e..5dcf01f 100644 --- a/tests/common/tinycthread.c +++ b/tests/common/tinycthread.c @@ -32,103 +32,96 @@ freely, subject to the following restrictions: /* Platform specific includes */ #if defined(_TTHREAD_POSIX_) - #include <signal.h> - #include <sched.h> - #include <unistd.h> - #include <sys/time.h> - #include <errno.h> +#include <signal.h> +#include <sched.h> +#include <unistd.h> +#include <sys/time.h> +#include <errno.h> #elif defined(_TTHREAD_WIN32_) - #include <process.h> - #include <sys/timeb.h> +#include <process.h> +#include <sys/timeb.h> #endif /* Standard, good-to-have defines */ #ifndef NULL - #define NULL (void*)0 +#define NULL (void *)0 #endif #ifndef TRUE - #define TRUE 1 +#define TRUE 1 #endif #ifndef FALSE - #define FALSE 0 +#define FALSE 0 #endif -int mtx_init(mtx_t *mtx, int type) -{ +int mtx_init(mtx_t *mtx, int type) { #if defined(_TTHREAD_WIN32_) - mtx->mAlreadyLocked = FALSE; - mtx->mRecursive = type & mtx_recursive; - InitializeCriticalSection(&mtx->mHandle); - return thrd_success; + mtx->mAlreadyLocked = FALSE; + mtx->mRecursive = type & mtx_recursive; + InitializeCriticalSection(&mtx->mHandle); + return thrd_success; #else - int ret; - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - if (type & mtx_recursive) - { - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - } - ret = pthread_mutex_init(mtx, &attr); - pthread_mutexattr_destroy(&attr); - return ret == 0 ? thrd_success : thrd_error; + int ret; + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + if (type & mtx_recursive) { + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + } + ret = pthread_mutex_init(mtx, &attr); + pthread_mutexattr_destroy(&attr); + return ret == 0 ? thrd_success : thrd_error; #endif } -void mtx_destroy(mtx_t *mtx) -{ +void mtx_destroy(mtx_t *mtx) { #if defined(_TTHREAD_WIN32_) - DeleteCriticalSection(&mtx->mHandle); + DeleteCriticalSection(&mtx->mHandle); #else - pthread_mutex_destroy(mtx); + pthread_mutex_destroy(mtx); #endif } -int mtx_lock(mtx_t *mtx) -{ +int mtx_lock(mtx_t *mtx) { #if defined(_TTHREAD_WIN32_) - EnterCriticalSection(&mtx->mHandle); - if (!mtx->mRecursive) - { - while(mtx->mAlreadyLocked) Sleep(1000); /* Simulate deadlock... */ - mtx->mAlreadyLocked = TRUE; - } - return thrd_success; + EnterCriticalSection(&mtx->mHandle); + if (!mtx->mRecursive) { + while (mtx->mAlreadyLocked) + Sleep(1000); /* Simulate deadlock... */ + mtx->mAlreadyLocked = TRUE; + } + return thrd_success; #else - return pthread_mutex_lock(mtx) == 0 ? thrd_success : thrd_error; + return pthread_mutex_lock(mtx) == 0 ? thrd_success : thrd_error; #endif } -int mtx_timedlock(mtx_t *mtx, const struct timespec *ts) -{ - /* FIXME! */ - (void)mtx; - (void)ts; - return thrd_error; +int mtx_timedlock(mtx_t *mtx, const struct timespec *ts) { + /* FIXME! */ + (void)mtx; + (void)ts; + return thrd_error; } -int mtx_trylock(mtx_t *mtx) -{ +int mtx_trylock(mtx_t *mtx) { #if defined(_TTHREAD_WIN32_) - int ret = TryEnterCriticalSection(&mtx->mHandle) ? thrd_success : thrd_busy; - if ((!mtx->mRecursive) && (ret == thrd_success) && mtx->mAlreadyLocked) - { - LeaveCriticalSection(&mtx->mHandle); - ret = thrd_busy; - } - return ret; + int ret = TryEnterCriticalSection(&mtx->mHandle) ? thrd_success : thrd_busy; + if ((!mtx->mRecursive) && (ret == thrd_success) && mtx->mAlreadyLocked) { + LeaveCriticalSection(&mtx->mHandle); + ret = thrd_busy; + } + return ret; #else - return (pthread_mutex_trylock(mtx) == 0) ? thrd_success : thrd_busy; + return (pthread_mutex_trylock(mtx) == 0) ? thrd_success : thrd_busy; #endif } -int mtx_unlock(mtx_t *mtx) -{ +int mtx_unlock(mtx_t *mtx) { #if defined(_TTHREAD_WIN32_) - mtx->mAlreadyLocked = FALSE; - LeaveCriticalSection(&mtx->mHandle); - return thrd_success; + mtx->mAlreadyLocked = FALSE; + LeaveCriticalSection(&mtx->mHandle); + return thrd_success; #else - return pthread_mutex_unlock(mtx) == 0 ? thrd_success : thrd_error;; + return pthread_mutex_unlock(mtx) == 0 ? thrd_success : thrd_error; + ; #endif } @@ -137,458 +130,397 @@ int mtx_unlock(mtx_t *mtx) #define _CONDITION_EVENT_ALL 1 #endif -int cnd_init(cnd_t *cond) -{ +int cnd_init(cnd_t *cond) { #if defined(_TTHREAD_WIN32_) - cond->mWaitersCount = 0; + cond->mWaitersCount = 0; - /* Init critical section */ - InitializeCriticalSection(&cond->mWaitersCountLock); + /* Init critical section */ + InitializeCriticalSection(&cond->mWaitersCountLock); - /* Init events */ - cond->mEvents[_CONDITION_EVENT_ONE] = CreateEvent(NULL, FALSE, FALSE, NULL); - if (cond->mEvents[_CONDITION_EVENT_ONE] == NULL) - { - cond->mEvents[_CONDITION_EVENT_ALL] = NULL; - return thrd_error; - } - cond->mEvents[_CONDITION_EVENT_ALL] = CreateEvent(NULL, TRUE, FALSE, NULL); - if (cond->mEvents[_CONDITION_EVENT_ALL] == NULL) - { - CloseHandle(cond->mEvents[_CONDITION_EVENT_ONE]); - cond->mEvents[_CONDITION_EVENT_ONE] = NULL; - return thrd_error; - } + /* Init events */ + cond->mEvents[_CONDITION_EVENT_ONE] = CreateEvent(NULL, FALSE, FALSE, NULL); + if (cond->mEvents[_CONDITION_EVENT_ONE] == NULL) { + cond->mEvents[_CONDITION_EVENT_ALL] = NULL; + return thrd_error; + } + cond->mEvents[_CONDITION_EVENT_ALL] = CreateEvent(NULL, TRUE, FALSE, NULL); + if (cond->mEvents[_CONDITION_EVENT_ALL] == NULL) { + CloseHandle(cond->mEvents[_CONDITION_EVENT_ONE]); + cond->mEvents[_CONDITION_EVENT_ONE] = NULL; + return thrd_error; + } - return thrd_success; + return thrd_success; #else - return pthread_cond_init(cond, NULL) == 0 ? thrd_success : thrd_error; + return pthread_cond_init(cond, NULL) == 0 ? thrd_success : thrd_error; #endif } -void cnd_destroy(cnd_t *cond) -{ +void cnd_destroy(cnd_t *cond) { #if defined(_TTHREAD_WIN32_) - if (cond->mEvents[_CONDITION_EVENT_ONE] != NULL) - { - CloseHandle(cond->mEvents[_CONDITION_EVENT_ONE]); - } - if (cond->mEvents[_CONDITION_EVENT_ALL] != NULL) - { - CloseHandle(cond->mEvents[_CONDITION_EVENT_ALL]); - } - DeleteCriticalSection(&cond->mWaitersCountLock); + if (cond->mEvents[_CONDITION_EVENT_ONE] != NULL) { + CloseHandle(cond->mEvents[_CONDITION_EVENT_ONE]); + } + if (cond->mEvents[_CONDITION_EVENT_ALL] != NULL) { + CloseHandle(cond->mEvents[_CONDITION_EVENT_ALL]); + } + DeleteCriticalSection(&cond->mWaitersCountLock); #else - pthread_cond_destroy(cond); + pthread_cond_destroy(cond); #endif } -int cnd_signal(cnd_t *cond) -{ +int cnd_signal(cnd_t *cond) { #if defined(_TTHREAD_WIN32_) - int haveWaiters; + int haveWaiters; - /* Are there any waiters? */ - EnterCriticalSection(&cond->mWaitersCountLock); - haveWaiters = (cond->mWaitersCount > 0); - LeaveCriticalSection(&cond->mWaitersCountLock); + /* Are there any waiters? */ + EnterCriticalSection(&cond->mWaitersCountLock); + haveWaiters = (cond->mWaitersCount > 0); + LeaveCriticalSection(&cond->mWaitersCountLock); - /* If we have any waiting threads, send them a signal */ - if(haveWaiters) - { - if (SetEvent(cond->mEvents[_CONDITION_EVENT_ONE]) == 0) - { - return thrd_error; + /* If we have any waiting threads, send them a signal */ + if (haveWaiters) { + if (SetEvent(cond->mEvents[_CONDITION_EVENT_ONE]) == 0) { + return thrd_error; + } } - } - return thrd_success; + return thrd_success; #else - return pthread_cond_signal(cond) == 0 ? thrd_success : thrd_error; + return pthread_cond_signal(cond) == 0 ? thrd_success : thrd_error; #endif } -int cnd_broadcast(cnd_t *cond) -{ +int cnd_broadcast(cnd_t *cond) { #if defined(_TTHREAD_WIN32_) - int haveWaiters; + int haveWaiters; - /* Are there any waiters? */ - EnterCriticalSection(&cond->mWaitersCountLock); - haveWaiters = (cond->mWaitersCount > 0); - LeaveCriticalSection(&cond->mWaitersCountLock); + /* Are there any waiters? */ + EnterCriticalSection(&cond->mWaitersCountLock); + haveWaiters = (cond->mWaitersCount > 0); + LeaveCriticalSection(&cond->mWaitersCountLock); - /* If we have any waiting threads, send them a signal */ - if(haveWaiters) - { - if (SetEvent(cond->mEvents[_CONDITION_EVENT_ALL]) == 0) - { - return thrd_error; + /* If we have any waiting threads, send them a signal */ + if (haveWaiters) { + if (SetEvent(cond->mEvents[_CONDITION_EVENT_ALL]) == 0) { + return thrd_error; + } } - } - return thrd_success; + return thrd_success; #else - return pthread_cond_signal(cond) == 0 ? thrd_success : thrd_error; + return pthread_cond_signal(cond) == 0 ? thrd_success : thrd_error; #endif } #if defined(_TTHREAD_WIN32_) -static int _cnd_timedwait_win32(cnd_t *cond, mtx_t *mtx, DWORD timeout) -{ - int result, lastWaiter; +static int _cnd_timedwait_win32(cnd_t *cond, mtx_t *mtx, DWORD timeout) { + int result, lastWaiter; - /* Increment number of waiters */ - EnterCriticalSection(&cond->mWaitersCountLock); - ++ cond->mWaitersCount; - LeaveCriticalSection(&cond->mWaitersCountLock); + /* Increment number of waiters */ + EnterCriticalSection(&cond->mWaitersCountLock); + ++cond->mWaitersCount; + LeaveCriticalSection(&cond->mWaitersCountLock); - /* Release the mutex while waiting for the condition (will decrease - the number of waiters when done)... */ - mtx_unlock(mtx); + /* Release the mutex while waiting for the condition (will decrease + the number of waiters when done)... */ + mtx_unlock(mtx); - /* Wait for either event to become signaled due to cnd_signal() or - cnd_broadcast() being called */ - result = WaitForMultipleObjects(2, cond->mEvents, FALSE, timeout); - if (result == WAIT_TIMEOUT) - { - return thrd_timeout; - } - else if (result == (int)WAIT_FAILED) - { - return thrd_error; - } + /* Wait for either event to become signaled due to cnd_signal() or + cnd_broadcast() being called */ + result = WaitForMultipleObjects(2, cond->mEvents, FALSE, timeout); + if (result == WAIT_TIMEOUT) { + return thrd_timeout; + } else if (result == (int)WAIT_FAILED) { + return thrd_error; + } - /* Check if we are the last waiter */ - EnterCriticalSection(&cond->mWaitersCountLock); - -- cond->mWaitersCount; - lastWaiter = (result == (WAIT_OBJECT_0 + _CONDITION_EVENT_ALL)) && - (cond->mWaitersCount == 0); - LeaveCriticalSection(&cond->mWaitersCountLock); + /* Check if we are the last waiter */ + EnterCriticalSection(&cond->mWaitersCountLock); + --cond->mWaitersCount; + lastWaiter = (result == (WAIT_OBJECT_0 + _CONDITION_EVENT_ALL)) && (cond->mWaitersCount == 0); + LeaveCriticalSection(&cond->mWaitersCountLock); - /* If we are the last waiter to be notified to stop waiting, reset the event */ - if (lastWaiter) - { - if (ResetEvent(cond->mEvents[_CONDITION_EVENT_ALL]) == 0) - { - return thrd_error; + /* If we are the last waiter to be notified to stop waiting, reset the event */ + if (lastWaiter) { + if (ResetEvent(cond->mEvents[_CONDITION_EVENT_ALL]) == 0) { + return thrd_error; + } } - } - /* Re-acquire the mutex */ - mtx_lock(mtx); + /* Re-acquire the mutex */ + mtx_lock(mtx); - return thrd_success; + return thrd_success; } #endif -int cnd_wait(cnd_t *cond, mtx_t *mtx) -{ +int cnd_wait(cnd_t *cond, mtx_t *mtx) { #if defined(_TTHREAD_WIN32_) - return _cnd_timedwait_win32(cond, mtx, INFINITE); + return _cnd_timedwait_win32(cond, mtx, INFINITE); #else - return pthread_cond_wait(cond, mtx) == 0 ? thrd_success : thrd_error; + return pthread_cond_wait(cond, mtx) == 0 ? thrd_success : thrd_error; #endif } -int cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *ts) -{ +int cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *ts) { #if defined(_TTHREAD_WIN32_) - struct timespec now; - if (clock_gettime(CLOCK_REALTIME, &now) == 0) - { - DWORD delta = (DWORD) ((ts->tv_sec - now.tv_sec) * 1000 + - (ts->tv_nsec - now.tv_nsec + 500000) / 1000000); - return _cnd_timedwait_win32(cond, mtx, delta); - } - else - return thrd_error; + struct timespec now; + if (clock_gettime(CLOCK_REALTIME, &now) == 0) { + DWORD delta = (DWORD)((ts->tv_sec - now.tv_sec) * 1000 + (ts->tv_nsec - now.tv_nsec + 500000) / 1000000); + return _cnd_timedwait_win32(cond, mtx, delta); + } else + return thrd_error; #else - int ret; - ret = pthread_cond_timedwait(cond, mtx, ts); - if (ret == ETIMEDOUT) - { - return thrd_timeout; - } - return ret == 0 ? thrd_success : thrd_error; + int ret; + ret = pthread_cond_timedwait(cond, mtx, ts); + if (ret == ETIMEDOUT) { + return thrd_timeout; + } + return ret == 0 ? thrd_success : thrd_error; #endif } - /** Information to pass to the new thread (what to run). */ typedef struct { - thrd_start_t mFunction; /**< Pointer to the function to be executed. */ - void * mArg; /**< Function argument for the thread function. */ + thrd_start_t mFunction; /**< Pointer to the function to be executed. */ + void *mArg; /**< Function argument for the thread function. */ } _thread_start_info; /* Thread wrapper function. */ #if defined(_TTHREAD_WIN32_) -static unsigned WINAPI _thrd_wrapper_function(void * aArg) +static unsigned WINAPI _thrd_wrapper_function(void *aArg) #elif defined(_TTHREAD_POSIX_) -static void * _thrd_wrapper_function(void * aArg) +static void *_thrd_wrapper_function(void *aArg) #endif { - thrd_start_t fun; - void *arg; - int res; + thrd_start_t fun; + void *arg; + int res; #if defined(_TTHREAD_POSIX_) - void *pres; + void *pres; #endif - /* Get thread startup information */ - _thread_start_info *ti = (_thread_start_info *) aArg; - fun = ti->mFunction; - arg = ti->mArg; + /* Get thread startup information */ + _thread_start_info *ti = (_thread_start_info *)aArg; + fun = ti->mFunction; + arg = ti->mArg; - /* The thread is responsible for freeing the startup information */ - free((void *)ti); + /* The thread is responsible for freeing the startup information */ + free((void *)ti); - /* Call the actual client thread function */ - res = fun(arg); + /* Call the actual client thread function */ + res = fun(arg); #if defined(_TTHREAD_WIN32_) - return res; + return res; #else - pres = malloc(sizeof(int)); - if (pres != NULL) - { - *(int*)pres = res; - } - return pres; + pres = malloc(sizeof(int)); + if (pres != NULL) { + *(int *)pres = res; + } + return pres; #endif } -int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) -{ - /* Fill out the thread startup information (passed to the thread wrapper, - which will eventually free it) */ - _thread_start_info* ti = (_thread_start_info*)malloc(sizeof(_thread_start_info)); - if (ti == NULL) - { - return thrd_nomem; - } - ti->mFunction = func; - ti->mArg = arg; +int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) { + /* Fill out the thread startup information (passed to the thread wrapper, + which will eventually free it) */ + _thread_start_info *ti = (_thread_start_info *)malloc(sizeof(_thread_start_info)); + if (ti == NULL) { + return thrd_nomem; + } + ti->mFunction = func; + ti->mArg = arg; - /* Create the thread */ + /* Create the thread */ #if defined(_TTHREAD_WIN32_) - *thr = (HANDLE)_beginthreadex(NULL, 0, _thrd_wrapper_function, (void *)ti, 0, NULL); + *thr = (HANDLE)_beginthreadex(NULL, 0, _thrd_wrapper_function, (void *)ti, 0, NULL); #elif defined(_TTHREAD_POSIX_) - if(pthread_create(thr, NULL, _thrd_wrapper_function, (void *)ti) != 0) - { - *thr = 0; - } + if (pthread_create(thr, NULL, _thrd_wrapper_function, (void *)ti) != 0) { + *thr = 0; + } #endif - /* Did we fail to create the thread? */ - if(!*thr) - { - free(ti); - return thrd_error; - } + /* Did we fail to create the thread? */ + if (!*thr) { + free(ti); + return thrd_error; + } - return thrd_success; + return thrd_success; } -thrd_t thrd_current(void) -{ +thrd_t thrd_current(void) { #if defined(_TTHREAD_WIN32_) - return GetCurrentThread(); + return GetCurrentThread(); #else - return pthread_self(); + return pthread_self(); #endif } -int thrd_detach(thrd_t thr) -{ - /* FIXME! */ - (void)thr; - return thrd_error; +int thrd_detach(thrd_t thr) { + /* FIXME! */ + (void)thr; + return thrd_error; } -int thrd_equal(thrd_t thr0, thrd_t thr1) -{ +int thrd_equal(thrd_t thr0, thrd_t thr1) { #if defined(_TTHREAD_WIN32_) - return thr0 == thr1; + return thr0 == thr1; #else - return pthread_equal(thr0, thr1); + return pthread_equal(thr0, thr1); #endif } -void thrd_exit(int res) -{ +void thrd_exit(int res) { #if defined(_TTHREAD_WIN32_) - ExitThread(res); + ExitThread(res); #else - void *pres = malloc(sizeof(int)); - if (pres != NULL) - { - *(int*)pres = res; - } - pthread_exit(pres); + void *pres = malloc(sizeof(int)); + if (pres != NULL) { + *(int *)pres = res; + } + pthread_exit(pres); #endif } -int thrd_join(thrd_t thr, int *res) -{ +int thrd_join(thrd_t thr, int *res) { #if defined(_TTHREAD_WIN32_) - if (WaitForSingleObject(thr, INFINITE) == WAIT_FAILED) - { - return thrd_error; - } - if (res != NULL) - { - DWORD dwRes; - GetExitCodeThread(thr, &dwRes); - *res = dwRes; - } + if (WaitForSingleObject(thr, INFINITE) == WAIT_FAILED) { + return thrd_error; + } + if (res != NULL) { + DWORD dwRes; + GetExitCodeThread(thr, &dwRes); + *res = dwRes; + } #elif defined(_TTHREAD_POSIX_) - void *pres; - int ires = 0; - if (pthread_join(thr, &pres) != 0) - { - return thrd_error; - } - if (pres != NULL) - { - ires = *(int*)pres; - free(pres); - } - if (res != NULL) - { - *res = ires; - } + void *pres; + int ires = 0; + if (pthread_join(thr, &pres) != 0) { + return thrd_error; + } + if (pres != NULL) { + ires = *(int *)pres; + free(pres); + } + if (res != NULL) { + *res = ires; + } #endif - return thrd_success; + return thrd_success; } -int thrd_sleep(const struct timespec *time_point, struct timespec *remaining) -{ - struct timespec now; +int thrd_sleep(const struct timespec *time_point, struct timespec *remaining) { + struct timespec now; #if defined(_TTHREAD_WIN32_) - DWORD delta; + DWORD delta; #else - long delta; + long delta; #endif - /* Get the current time */ - if (clock_gettime(CLOCK_REALTIME, &now) != 0) - return -2; // FIXME: Some specific error code? + /* Get the current time */ + if (clock_gettime(CLOCK_REALTIME, &now) != 0) + return -2; // FIXME: Some specific error code? #if defined(_TTHREAD_WIN32_) - /* Delta in milliseconds */ - delta = (DWORD) ((time_point->tv_sec - now.tv_sec) * 1000 + - (time_point->tv_nsec - now.tv_nsec + 500000) / 1000000); - if (delta > 0) - { - Sleep(delta); - } + /* Delta in milliseconds */ + delta = (DWORD)((time_point->tv_sec - now.tv_sec) * 1000 + (time_point->tv_nsec - now.tv_nsec + 500000) / 1000000); + if (delta > 0) { + Sleep(delta); + } #else - /* Delta in microseconds */ - delta = (time_point->tv_sec - now.tv_sec) * 1000000L + - (time_point->tv_nsec - now.tv_nsec + 500L) / 1000L; + /* Delta in microseconds */ + delta = (time_point->tv_sec - now.tv_sec) * 1000000L + (time_point->tv_nsec - now.tv_nsec + 500L) / 1000L; - /* On some systems, the usleep argument must be < 1000000 */ - while (delta > 999999L) - { - usleep(999999); - delta -= 999999L; - } - if (delta > 0L) - { - usleep((useconds_t)delta); - } + /* On some systems, the usleep argument must be < 1000000 */ + while (delta > 999999L) { + usleep(999999); + delta -= 999999L; + } + if (delta > 0L) { + usleep((useconds_t)delta); + } #endif - /* We don't support waking up prematurely (yet) */ - if (remaining) - { - remaining->tv_sec = 0; - remaining->tv_nsec = 0; - } - return 0; + /* We don't support waking up prematurely (yet) */ + if (remaining) { + remaining->tv_sec = 0; + remaining->tv_nsec = 0; + } + return 0; } -void thrd_yield(void) -{ +void thrd_yield(void) { #if defined(_TTHREAD_WIN32_) - Sleep(0); + Sleep(0); #else - sched_yield(); + sched_yield(); #endif } -int tss_create(tss_t *key, tss_dtor_t dtor) -{ +int tss_create(tss_t *key, tss_dtor_t dtor) { #if defined(_TTHREAD_WIN32_) - /* FIXME: The destructor function is not supported yet... */ - if (dtor != NULL) - { - return thrd_error; - } - *key = TlsAlloc(); - if (*key == TLS_OUT_OF_INDEXES) - { - return thrd_error; - } + /* FIXME: The destructor function is not supported yet... */ + if (dtor != NULL) { + return thrd_error; + } + *key = TlsAlloc(); + if (*key == TLS_OUT_OF_INDEXES) { + return thrd_error; + } #else - if (pthread_key_create(key, dtor) != 0) - { - return thrd_error; - } + if (pthread_key_create(key, dtor) != 0) { + return thrd_error; + } #endif - return thrd_success; + return thrd_success; } -void tss_delete(tss_t key) -{ +void tss_delete(tss_t key) { #if defined(_TTHREAD_WIN32_) - TlsFree(key); + TlsFree(key); #else - pthread_key_delete(key); + pthread_key_delete(key); #endif } -void *tss_get(tss_t key) -{ +void *tss_get(tss_t key) { #if defined(_TTHREAD_WIN32_) - return TlsGetValue(key); + return TlsGetValue(key); #else - return pthread_getspecific(key); + return pthread_getspecific(key); #endif } -int tss_set(tss_t key, void *val) -{ +int tss_set(tss_t key, void *val) { #if defined(_TTHREAD_WIN32_) - if (TlsSetValue(key, val) == 0) - { - return thrd_error; - } + if (TlsSetValue(key, val) == 0) { + return thrd_error; + } #else - if (pthread_setspecific(key, val) != 0) - { - return thrd_error; - } + if (pthread_setspecific(key, val) != 0) { + return thrd_error; + } #endif - return thrd_success; + return thrd_success; } #if defined(_TTHREAD_EMULATE_CLOCK_GETTIME_) -int _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts) -{ +int _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts) { #if defined(_TTHREAD_WIN32_) - struct _timeb tb; - _ftime(&tb); - ts->tv_sec = (time_t)tb.time; - ts->tv_nsec = 1000000L * (long)tb.millitm; + struct _timeb tb; + _ftime(&tb); + ts->tv_sec = (time_t)tb.time; + ts->tv_nsec = 1000000L * (long)tb.millitm; #else - struct timeval tv; - gettimeofday(&tv, NULL); - ts->tv_sec = (time_t)tv.tv_sec; - ts->tv_nsec = 1000L * (long)tv.tv_usec; + struct timeval tv; + gettimeofday(&tv, NULL); + ts->tv_sec = (time_t)tv.tv_sec; + ts->tv_nsec = 1000L * (long)tv.tv_usec; #endif - return 0; + return 0; } #endif // _TTHREAD_EMULATE_CLOCK_GETTIME_ - diff --git a/tests/common/tinycthread.h b/tests/common/tinycthread.h index 42958c3..eaacfbe 100644 --- a/tests/common/tinycthread.h +++ b/tests/common/tinycthread.h @@ -25,52 +25,52 @@ freely, subject to the following restrictions: #define _TINYCTHREAD_H_ /** -* @file -* @mainpage TinyCThread API Reference -* -* @section intro_sec Introduction -* TinyCThread is a minimal, portable implementation of basic threading -* classes for C. -* -* They closely mimic the functionality and naming of the C11 standard, and -* should be easily replaceable with the corresponding standard variants. -* -* @section port_sec Portability -* The Win32 variant uses the native Win32 API for implementing the thread -* classes, while for other systems, the POSIX threads API (pthread) is used. -* -* @section misc_sec Miscellaneous -* The following special keywords are available: #_Thread_local. -* -* For more detailed information, browse the different sections of this -* documentation. A good place to start is: -* tinycthread.h. -*/ + * @file + * @mainpage TinyCThread API Reference + * + * @section intro_sec Introduction + * TinyCThread is a minimal, portable implementation of basic threading + * classes for C. + * + * They closely mimic the functionality and naming of the C11 standard, and + * should be easily replaceable with the corresponding standard variants. + * + * @section port_sec Portability + * The Win32 variant uses the native Win32 API for implementing the thread + * classes, while for other systems, the POSIX threads API (pthread) is used. + * + * @section misc_sec Miscellaneous + * The following special keywords are available: #_Thread_local. + * + * For more detailed information, browse the different sections of this + * documentation. A good place to start is: + * tinycthread.h. + */ /* Which platform are we on? */ #if !defined(_TTHREAD_PLATFORM_DEFINED_) - #if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__) - #define _TTHREAD_WIN32_ - #else - #define _TTHREAD_POSIX_ - #endif - #define _TTHREAD_PLATFORM_DEFINED_ +#if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__) +#define _TTHREAD_WIN32_ +#else +#define _TTHREAD_POSIX_ +#endif +#define _TTHREAD_PLATFORM_DEFINED_ #endif /* Activate some POSIX functionality (e.g. clock_gettime and recursive mutexes) */ #if defined(_TTHREAD_POSIX_) - #undef _FEATURES_H - #if !defined(_GNU_SOURCE) - #define _GNU_SOURCE - #endif - #if !defined(_POSIX_C_SOURCE) || ((_POSIX_C_SOURCE - 0) < 199309L) - #undef _POSIX_C_SOURCE - #define _POSIX_C_SOURCE 199309L - #endif - #if !defined(_XOPEN_SOURCE) || ((_XOPEN_SOURCE - 0) < 500) - #undef _XOPEN_SOURCE - #define _XOPEN_SOURCE 500 - #endif +#undef _FEATURES_H +#if !defined(_GNU_SOURCE) +#define _GNU_SOURCE +#endif +#if !defined(_POSIX_C_SOURCE) || ((_POSIX_C_SOURCE - 0) < 199309L) +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199309L +#endif +#if !defined(_XOPEN_SOURCE) || ((_XOPEN_SOURCE - 0) < 500) +#undef _XOPEN_SOURCE +#define _XOPEN_SOURCE 500 +#endif #endif /* Generic includes */ @@ -78,18 +78,18 @@ freely, subject to the following restrictions: /* Platform specific includes */ #if defined(_TTHREAD_POSIX_) - #include <sys/time.h> - #include <pthread.h> +#include <sys/time.h> +#include <pthread.h> #elif defined(_TTHREAD_WIN32_) - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN - #define __UNDEF_LEAN_AND_MEAN - #endif - #include <windows.h> - #ifdef __UNDEF_LEAN_AND_MEAN - #undef WIN32_LEAN_AND_MEAN - #undef __UNDEF_LEAN_AND_MEAN - #endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#define __UNDEF_LEAN_AND_MEAN +#endif +#include <windows.h> +#ifdef __UNDEF_LEAN_AND_MEAN +#undef WIN32_LEAN_AND_MEAN +#undef __UNDEF_LEAN_AND_MEAN +#endif #endif /* Workaround for missing TIME_UTC: If time.h doesn't provide TIME_UTC, @@ -97,11 +97,11 @@ freely, subject to the following restrictions: the only other supported time specifier: CLOCK_REALTIME (and if that fails, we're probably emulating clock_gettime anyway, so anything goes). */ #ifndef TIME_UTC - #ifdef CLOCK_REALTIME - #define TIME_UTC CLOCK_REALTIME - #else - #define TIME_UTC 0 - #endif +#ifdef CLOCK_REALTIME +#define TIME_UTC CLOCK_REALTIME +#else +#define TIME_UTC 0 +#endif #endif /* Workaround for missing clock_gettime (most Windows compilers, afaik) */ @@ -110,8 +110,8 @@ freely, subject to the following restrictions: /* Emulate struct timespec */ #if defined(_TTHREAD_WIN32_) struct _ttherad_timespec { - time_t tv_sec; - long tv_nsec; + time_t tv_sec; + long tv_nsec; }; #define timespec _ttherad_timespec #endif @@ -124,11 +124,10 @@ typedef int _tthread_clockid_t; int _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts); #define clock_gettime _tthread_clock_gettime #ifndef CLOCK_REALTIME - #define CLOCK_REALTIME 0 +#define CLOCK_REALTIME 0 #endif #endif - /** TinyCThread version (major number). */ #define TINYCTHREAD_VERSION_MAJOR 1 /** TinyCThread version (minor number). */ @@ -137,42 +136,44 @@ int _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts); #define TINYCTHREAD_VERSION (TINYCTHREAD_VERSION_MAJOR * 100 + TINYCTHREAD_VERSION_MINOR) /** -* @def _Thread_local -* Thread local storage keyword. -* A variable that is declared with the @c _Thread_local keyword makes the -* value of the variable local to each thread (known as thread-local storage, -* or TLS). Example usage: -* @code -* // This variable is local to each thread. -* _Thread_local int variable; -* @endcode -* @note The @c _Thread_local keyword is a macro that maps to the corresponding -* compiler directive (e.g. @c __declspec(thread)). -* @note This directive is currently not supported on Mac OS X (it will give -* a compiler error), since compile-time TLS is not supported in the Mac OS X -* executable format. Also, some older versions of MinGW (before GCC 4.x) do -* not support this directive. -* @hideinitializer -*/ + * @def _Thread_local + * Thread local storage keyword. + * A variable that is declared with the @c _Thread_local keyword makes the + * value of the variable local to each thread (known as thread-local storage, + * or TLS). Example usage: + * @code + * // This variable is local to each thread. + * _Thread_local int variable; + * @endcode + * @note The @c _Thread_local keyword is a macro that maps to the corresponding + * compiler directive (e.g. @c __declspec(thread)). + * @note This directive is currently not supported on Mac OS X (it will give + * a compiler error), since compile-time TLS is not supported in the Mac OS X + * executable format. Also, some older versions of MinGW (before GCC 4.x) do + * not support this directive. + * @hideinitializer + */ /* FIXME: Check for a PROPER value of __STDC_VERSION__ to know if we have C11 */ #if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201102L)) && !defined(_Thread_local) - #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__SUNPRO_CC) || defined(__IBMCPP__) - #define _Thread_local __thread - #else - #define _Thread_local __declspec(thread) - #endif +#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__SUNPRO_CC) || defined(__IBMCPP__) +#define _Thread_local __thread +#else +#define _Thread_local __declspec(thread) +#endif #endif /* Macros */ #define TSS_DTOR_ITERATIONS 0 /* Function return values */ -#define thrd_error 0 /**< The requested operation failed */ -#define thrd_success 1 /**< The requested operation succeeded */ -#define thrd_timeout 2 /**< The time specified in the call was reached without acquiring the requested resource */ -#define thrd_busy 3 /**< The requested operation failed because a tesource requested by a test and return function is already in use */ -#define thrd_nomem 4 /**< The requested operation failed because it was unable to allocate memory */ +#define thrd_error 0 /**< The requested operation failed */ +#define thrd_success 1 /**< The requested operation succeeded */ +#define thrd_timeout 2 /**< The time specified in the call was reached without acquiring the requested resource */ +#define thrd_busy \ + 3 /**< The requested operation failed because a tesource requested by a test and return function is already in use \ + */ +#define thrd_nomem 4 /**< The requested operation failed because it was unable to allocate memory */ /* Mutex types */ #define mtx_plain 1 @@ -183,261 +184,259 @@ int _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts); /* Mutex */ #if defined(_TTHREAD_WIN32_) typedef struct { - CRITICAL_SECTION mHandle; /* Critical section handle */ - int mAlreadyLocked; /* TRUE if the mutex is already locked */ - int mRecursive; /* TRUE if the mutex is recursive */ + CRITICAL_SECTION mHandle; /* Critical section handle */ + int mAlreadyLocked; /* TRUE if the mutex is already locked */ + int mRecursive; /* TRUE if the mutex is recursive */ } mtx_t; #else typedef pthread_mutex_t mtx_t; #endif /** Create a mutex object. -* @param mtx A mutex object. -* @param type Bit-mask that must have one of the following six values: -* @li @c mtx_plain for a simple non-recursive mutex -* @li @c mtx_timed for a non-recursive mutex that supports timeout -* @li @c mtx_try for a non-recursive mutex that supports test and return -* @li @c mtx_plain | @c mtx_recursive (same as @c mtx_plain, but recursive) -* @li @c mtx_timed | @c mtx_recursive (same as @c mtx_timed, but recursive) -* @li @c mtx_try | @c mtx_recursive (same as @c mtx_try, but recursive) -* @return @ref thrd_success on success, or @ref thrd_error if the request could -* not be honored. -*/ + * @param mtx A mutex object. + * @param type Bit-mask that must have one of the following six values: + * @li @c mtx_plain for a simple non-recursive mutex + * @li @c mtx_timed for a non-recursive mutex that supports timeout + * @li @c mtx_try for a non-recursive mutex that supports test and return + * @li @c mtx_plain | @c mtx_recursive (same as @c mtx_plain, but recursive) + * @li @c mtx_timed | @c mtx_recursive (same as @c mtx_timed, but recursive) + * @li @c mtx_try | @c mtx_recursive (same as @c mtx_try, but recursive) + * @return @ref thrd_success on success, or @ref thrd_error if the request could + * not be honored. + */ int mtx_init(mtx_t *mtx, int type); /** Release any resources used by the given mutex. -* @param mtx A mutex object. -*/ + * @param mtx A mutex object. + */ void mtx_destroy(mtx_t *mtx); /** Lock the given mutex. -* Blocks until the given mutex can be locked. If the mutex is non-recursive, and -* the calling thread already has a lock on the mutex, this call will block -* forever. -* @param mtx A mutex object. -* @return @ref thrd_success on success, or @ref thrd_error if the request could -* not be honored. -*/ + * Blocks until the given mutex can be locked. If the mutex is non-recursive, and + * the calling thread already has a lock on the mutex, this call will block + * forever. + * @param mtx A mutex object. + * @return @ref thrd_success on success, or @ref thrd_error if the request could + * not be honored. + */ int mtx_lock(mtx_t *mtx); /** NOT YET IMPLEMENTED. -*/ + */ int mtx_timedlock(mtx_t *mtx, const struct timespec *ts); /** Try to lock the given mutex. -* The specified mutex shall support either test and return or timeout. If the -* mutex is already locked, the function returns without blocking. -* @param mtx A mutex object. -* @return @ref thrd_success on success, or @ref thrd_busy if the resource -* requested is already in use, or @ref thrd_error if the request could not be -* honored. -*/ + * The specified mutex shall support either test and return or timeout. If the + * mutex is already locked, the function returns without blocking. + * @param mtx A mutex object. + * @return @ref thrd_success on success, or @ref thrd_busy if the resource + * requested is already in use, or @ref thrd_error if the request could not be + * honored. + */ int mtx_trylock(mtx_t *mtx); /** Unlock the given mutex. -* @param mtx A mutex object. -* @return @ref thrd_success on success, or @ref thrd_error if the request could -* not be honored. -*/ + * @param mtx A mutex object. + * @return @ref thrd_success on success, or @ref thrd_error if the request could + * not be honored. + */ int mtx_unlock(mtx_t *mtx); /* Condition variable */ #if defined(_TTHREAD_WIN32_) typedef struct { - HANDLE mEvents[2]; /* Signal and broadcast event HANDLEs. */ - unsigned int mWaitersCount; /* Count of the number of waiters. */ - CRITICAL_SECTION mWaitersCountLock; /* Serialize access to mWaitersCount. */ + HANDLE mEvents[2]; /* Signal and broadcast event HANDLEs. */ + unsigned int mWaitersCount; /* Count of the number of waiters. */ + CRITICAL_SECTION mWaitersCountLock; /* Serialize access to mWaitersCount. */ } cnd_t; #else -typedef pthread_cond_t cnd_t; +typedef pthread_cond_t cnd_t; #endif /** Create a condition variable object. -* @param cond A condition variable object. -* @return @ref thrd_success on success, or @ref thrd_error if the request could -* not be honored. -*/ + * @param cond A condition variable object. + * @return @ref thrd_success on success, or @ref thrd_error if the request could + * not be honored. + */ int cnd_init(cnd_t *cond); /** Release any resources used by the given condition variable. -* @param cond A condition variable object. -*/ + * @param cond A condition variable object. + */ void cnd_destroy(cnd_t *cond); /** Signal a condition variable. -* Unblocks one of the threads that are blocked on the given condition variable -* at the time of the call. If no threads are blocked on the condition variable -* at the time of the call, the function does nothing and return success. -* @param cond A condition variable object. -* @return @ref thrd_success on success, or @ref thrd_error if the request could -* not be honored. -*/ + * Unblocks one of the threads that are blocked on the given condition variable + * at the time of the call. If no threads are blocked on the condition variable + * at the time of the call, the function does nothing and return success. + * @param cond A condition variable object. + * @return @ref thrd_success on success, or @ref thrd_error if the request could + * not be honored. + */ int cnd_signal(cnd_t *cond); /** Broadcast a condition variable. -* Unblocks all of the threads that are blocked on the given condition variable -* at the time of the call. If no threads are blocked on the condition variable -* at the time of the call, the function does nothing and return success. -* @param cond A condition variable object. -* @return @ref thrd_success on success, or @ref thrd_error if the request could -* not be honored. -*/ + * Unblocks all of the threads that are blocked on the given condition variable + * at the time of the call. If no threads are blocked on the condition variable + * at the time of the call, the function does nothing and return success. + * @param cond A condition variable object. + * @return @ref thrd_success on success, or @ref thrd_error if the request could + * not be honored. + */ int cnd_broadcast(cnd_t *cond); /** Wait for a condition variable to become signaled. -* The function atomically unlocks the given mutex and endeavors to block until -* the given condition variable is signaled by a call to cnd_signal or to -* cnd_broadcast. When the calling thread becomes unblocked it locks the mutex -* before it returns. -* @param cond A condition variable object. -* @param mtx A mutex object. -* @return @ref thrd_success on success, or @ref thrd_error if the request could -* not be honored. -*/ + * The function atomically unlocks the given mutex and endeavors to block until + * the given condition variable is signaled by a call to cnd_signal or to + * cnd_broadcast. When the calling thread becomes unblocked it locks the mutex + * before it returns. + * @param cond A condition variable object. + * @param mtx A mutex object. + * @return @ref thrd_success on success, or @ref thrd_error if the request could + * not be honored. + */ int cnd_wait(cnd_t *cond, mtx_t *mtx); /** Wait for a condition variable to become signaled. -* The function atomically unlocks the given mutex and endeavors to block until -* the given condition variable is signaled by a call to cnd_signal or to -* cnd_broadcast, or until after the specified time. When the calling thread -* becomes unblocked it locks the mutex before it returns. -* @param cond A condition variable object. -* @param mtx A mutex object. -* @param xt A point in time at which the request will time out (absolute time). -* @return @ref thrd_success upon success, or @ref thrd_timeout if the time -* specified in the call was reached without acquiring the requested resource, or -* @ref thrd_error if the request could not be honored. -*/ + * The function atomically unlocks the given mutex and endeavors to block until + * the given condition variable is signaled by a call to cnd_signal or to + * cnd_broadcast, or until after the specified time. When the calling thread + * becomes unblocked it locks the mutex before it returns. + * @param cond A condition variable object. + * @param mtx A mutex object. + * @param xt A point in time at which the request will time out (absolute time). + * @return @ref thrd_success upon success, or @ref thrd_timeout if the time + * specified in the call was reached without acquiring the requested resource, or + * @ref thrd_error if the request could not be honored. + */ int cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *ts); /* Thread */ #if defined(_TTHREAD_WIN32_) typedef HANDLE thrd_t; #else -typedef pthread_t thrd_t; +typedef pthread_t thrd_t; #endif /** Thread start function. -* Any thread that is started with the @ref thrd_create() function must be -* started through a function of this type. -* @param arg The thread argument (the @c arg argument of the corresponding -* @ref thrd_create() call). -* @return The thread return value, which can be obtained by another thread -* by using the @ref thrd_join() function. -*/ + * Any thread that is started with the @ref thrd_create() function must be + * started through a function of this type. + * @param arg The thread argument (the @c arg argument of the corresponding + * @ref thrd_create() call). + * @return The thread return value, which can be obtained by another thread + * by using the @ref thrd_join() function. + */ typedef int (*thrd_start_t)(void *arg); /** Create a new thread. -* @param thr Identifier of the newly created thread. -* @param func A function pointer to the function that will be executed in -* the new thread. -* @param arg An argument to the thread function. -* @return @ref thrd_success on success, or @ref thrd_nomem if no memory could -* be allocated for the thread requested, or @ref thrd_error if the request -* could not be honored. -* @note A thread’s identifier may be reused for a different thread once the -* original thread has exited and either been detached or joined to another -* thread. -*/ + * @param thr Identifier of the newly created thread. + * @param func A function pointer to the function that will be executed in + * the new thread. + * @param arg An argument to the thread function. + * @return @ref thrd_success on success, or @ref thrd_nomem if no memory could + * be allocated for the thread requested, or @ref thrd_error if the request + * could not be honored. + * @note A thread’s identifier may be reused for a different thread once the + * original thread has exited and either been detached or joined to another + * thread. + */ int thrd_create(thrd_t *thr, thrd_start_t func, void *arg); /** Identify the calling thread. -* @return The identifier of the calling thread. -*/ + * @return The identifier of the calling thread. + */ thrd_t thrd_current(void); /** NOT YET IMPLEMENTED. -*/ + */ int thrd_detach(thrd_t thr); /** Compare two thread identifiers. -* The function determines if two thread identifiers refer to the same thread. -* @return Zero if the two thread identifiers refer to different threads. -* Otherwise a nonzero value is returned. -*/ + * The function determines if two thread identifiers refer to the same thread. + * @return Zero if the two thread identifiers refer to different threads. + * Otherwise a nonzero value is returned. + */ int thrd_equal(thrd_t thr0, thrd_t thr1); /** Terminate execution of the calling thread. -* @param res Result code of the calling thread. -*/ + * @param res Result code of the calling thread. + */ void thrd_exit(int res); /** Wait for a thread to terminate. -* The function joins the given thread with the current thread by blocking -* until the other thread has terminated. -* @param thr The thread to join with. -* @param res If this pointer is not NULL, the function will store the result -* code of the given thread in the integer pointed to by @c res. -* @return @ref thrd_success on success, or @ref thrd_error if the request could -* not be honored. -*/ + * The function joins the given thread with the current thread by blocking + * until the other thread has terminated. + * @param thr The thread to join with. + * @param res If this pointer is not NULL, the function will store the result + * code of the given thread in the integer pointed to by @c res. + * @return @ref thrd_success on success, or @ref thrd_error if the request could + * not be honored. + */ int thrd_join(thrd_t thr, int *res); /** Put the calling thread to sleep. -* Suspend execution of the calling thread. -* @param time_point A point in time at which the thread will resume (absolute time). -* @param remaining If non-NULL, this parameter will hold the remaining time until -* time_point upon return. This will typically be zero, but if -* the thread was woken up by a signal that is not ignored before -* time_point was reached @c remaining will hold a positive -* time. -* @return 0 (zero) on successful sleep, or -1 if an interrupt occurred. -*/ + * Suspend execution of the calling thread. + * @param time_point A point in time at which the thread will resume (absolute time). + * @param remaining If non-NULL, this parameter will hold the remaining time until + * time_point upon return. This will typically be zero, but if + * the thread was woken up by a signal that is not ignored before + * time_point was reached @c remaining will hold a positive + * time. + * @return 0 (zero) on successful sleep, or -1 if an interrupt occurred. + */ int thrd_sleep(const struct timespec *time_point, struct timespec *remaining); /** Yield execution to another thread. -* Permit other threads to run, even if the current thread would ordinarily -* continue to run. -*/ + * Permit other threads to run, even if the current thread would ordinarily + * continue to run. + */ void thrd_yield(void); /* Thread local storage */ #if defined(_TTHREAD_WIN32_) typedef DWORD tss_t; #else -typedef pthread_key_t tss_t; +typedef pthread_key_t tss_t; #endif /** Destructor function for a thread-specific storage. -* @param val The value of the destructed thread-specific storage. -*/ + * @param val The value of the destructed thread-specific storage. + */ typedef void (*tss_dtor_t)(void *val); /** Create a thread-specific storage. -* @param key The unique key identifier that will be set if the function is -* successful. -* @param dtor Destructor function. This can be NULL. -* @return @ref thrd_success on success, or @ref thrd_error if the request could -* not be honored. -* @note The destructor function is not supported under Windows. If @c dtor is -* not NULL when calling this function under Windows, the function will fail -* and return @ref thrd_error. -*/ + * @param key The unique key identifier that will be set if the function is + * successful. + * @param dtor Destructor function. This can be NULL. + * @return @ref thrd_success on success, or @ref thrd_error if the request could + * not be honored. + * @note The destructor function is not supported under Windows. If @c dtor is + * not NULL when calling this function under Windows, the function will fail + * and return @ref thrd_error. + */ int tss_create(tss_t *key, tss_dtor_t dtor); /** Delete a thread-specific storage. -* The function releases any resources used by the given thread-specific -* storage. -* @param key The key that shall be deleted. -*/ + * The function releases any resources used by the given thread-specific + * storage. + * @param key The key that shall be deleted. + */ void tss_delete(tss_t key); /** Get the value for a thread-specific storage. -* @param key The thread-specific storage identifier. -* @return The value for the current thread held in the given thread-specific -* storage. -*/ + * @param key The thread-specific storage identifier. + * @return The value for the current thread held in the given thread-specific + * storage. + */ void *tss_get(tss_t key); /** Set the value for a thread-specific storage. -* @param key The thread-specific storage identifier. -* @param val The value of the thread-specific storage to set for the current -* thread. -* @return @ref thrd_success on success, or @ref thrd_error if the request could -* not be honored. -*/ + * @param key The thread-specific storage identifier. + * @param val The value of the thread-specific storage to set for the current + * thread. + * @return @ref thrd_success on success, or @ref thrd_error if the request could + * not be honored. + */ int tss_set(tss_t key, void *val); - #endif /* _TINYTHREAD_H_ */ - diff --git a/tests/common/vkengine.c b/tests/common/vkengine.c index b1e8a9d..57307ff 100644 --- a/tests/common/vkengine.c +++ b/tests/common/vkengine.c @@ -30,281 +30,270 @@ #include "vkvg.h" -#define TRY_LOAD_DEVICE_EXT(ext) { \ -if (vkh_phyinfo_try_get_extension_properties(pi, #ext, NULL)) \ - enabledExts[enabledExtsCount++] = #ext; \ -} +#define TRY_LOAD_DEVICE_EXT(ext) \ + { \ + if (vkh_phyinfo_try_get_extension_properties(pi, #ext, NULL)) \ + enabledExts[enabledExtsCount++] = #ext; \ + } static void glfw_error_callback(int error, const char *description) { - fprintf(stderr, "vkengine: GLFW error %d: %s\n", error, description); + fprintf(stderr, "vkengine: GLFW error %d: %s\n", error, description); } -VkSampleCountFlagBits getMaxUsableSampleCount(VkSampleCountFlags counts) -{ - if (counts & VK_SAMPLE_COUNT_64_BIT) { return VK_SAMPLE_COUNT_64_BIT; } - if (counts & VK_SAMPLE_COUNT_32_BIT) { return VK_SAMPLE_COUNT_32_BIT; } - if (counts & VK_SAMPLE_COUNT_16_BIT) { return VK_SAMPLE_COUNT_16_BIT; } - if (counts & VK_SAMPLE_COUNT_8_BIT) { return VK_SAMPLE_COUNT_8_BIT; } - if (counts & VK_SAMPLE_COUNT_4_BIT) { return VK_SAMPLE_COUNT_4_BIT; } - if (counts & VK_SAMPLE_COUNT_2_BIT) { return VK_SAMPLE_COUNT_2_BIT; } - return VK_SAMPLE_COUNT_1_BIT; +VkSampleCountFlagBits getMaxUsableSampleCount(VkSampleCountFlags counts) { + if (counts & VK_SAMPLE_COUNT_64_BIT) { + return VK_SAMPLE_COUNT_64_BIT; + } + if (counts & VK_SAMPLE_COUNT_32_BIT) { + return VK_SAMPLE_COUNT_32_BIT; + } + if (counts & VK_SAMPLE_COUNT_16_BIT) { + return VK_SAMPLE_COUNT_16_BIT; + } + if (counts & VK_SAMPLE_COUNT_8_BIT) { + return VK_SAMPLE_COUNT_8_BIT; + } + if (counts & VK_SAMPLE_COUNT_4_BIT) { + return VK_SAMPLE_COUNT_4_BIT; + } + if (counts & VK_SAMPLE_COUNT_2_BIT) { + return VK_SAMPLE_COUNT_2_BIT; + } + return VK_SAMPLE_COUNT_1_BIT; } -void vkengine_dump_Infos (VkEngine e){ - printf("max samples = %d\n", getMaxUsableSampleCount(e->gpu_props.limits.framebufferColorSampleCounts)); - printf("max tex2d size = %d\n", e->gpu_props.limits.maxImageDimension2D); - printf("max tex array layers = %d\n", e->gpu_props.limits.maxImageArrayLayers); - printf("max mem alloc count = %d\n", e->gpu_props.limits.maxMemoryAllocationCount); +void vkengine_dump_Infos(VkEngine e) { + printf("max samples = %d\n", getMaxUsableSampleCount(e->gpu_props.limits.framebufferColorSampleCounts)); + printf("max tex2d size = %d\n", e->gpu_props.limits.maxImageDimension2D); + printf("max tex array layers = %d\n", e->gpu_props.limits.maxImageArrayLayers); + printf("max mem alloc count = %d\n", e->gpu_props.limits.maxMemoryAllocationCount); - for (uint32_t i = 0; i < e->memory_properties.memoryHeapCount; i++) { - printf("Mem Heap %d\n", i); - printf("\tflags= %d\n", e->memory_properties.memoryHeaps[i].flags); - printf("\tsize = %lu Mo\n", (unsigned long)e->memory_properties.memoryHeaps[i].size/ (uint32_t)(1024*1024)); - } - for (uint32_t i = 0; i < e->memory_properties.memoryTypeCount; i++) { - printf("Mem type %d\n", i); - printf("\theap %d: ", e->memory_properties.memoryTypes[i].heapIndex); - if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) - printf("VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|"); - if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) - printf("VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|"); - if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) - printf("VK_MEMORY_PROPERTY_HOST_COHERENT_BIT|"); - if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) - printf("VK_MEMORY_PROPERTY_HOST_CACHED_BIT|"); - if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) - printf("VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT|"); - printf("\n"); - } + for (uint32_t i = 0; i < e->memory_properties.memoryHeapCount; i++) { + printf("Mem Heap %d\n", i); + printf("\tflags= %d\n", e->memory_properties.memoryHeaps[i].flags); + printf("\tsize = %lu Mo\n", (unsigned long)e->memory_properties.memoryHeaps[i].size / (uint32_t)(1024 * 1024)); + } + for (uint32_t i = 0; i < e->memory_properties.memoryTypeCount; i++) { + printf("Mem type %d\n", i); + printf("\theap %d: ", e->memory_properties.memoryTypes[i].heapIndex); + if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) + printf("VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|"); + if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) + printf("VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|"); + if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) + printf("VK_MEMORY_PROPERTY_HOST_COHERENT_BIT|"); + if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) + printf("VK_MEMORY_PROPERTY_HOST_CACHED_BIT|"); + if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) + printf("VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT|"); + printf("\n"); + } } +void vkengine_dump_available_layers() { + uint32_t layerCount; + vkEnumerateInstanceLayerProperties(&layerCount, NULL); + VkLayerProperties *availableLayers = (VkLayerProperties *)malloc(layerCount * sizeof(VkLayerProperties)); + vkEnumerateInstanceLayerProperties(&layerCount, availableLayers); -void vkengine_dump_available_layers () { - uint32_t layerCount; - vkEnumerateInstanceLayerProperties(&layerCount, NULL); - - VkLayerProperties* availableLayers = (VkLayerProperties*)malloc(layerCount*sizeof(VkLayerProperties)); - vkEnumerateInstanceLayerProperties(&layerCount, availableLayers); - - printf("Available Layers:\n"); - printf("-----------------\n"); - for (uint32_t i=0; i<layerCount; i++) { - printf ("\t - %s\n", availableLayers[i].layerName); - } - printf("-----------------\n\n"); - free (availableLayers); + printf("Available Layers:\n"); + printf("-----------------\n"); + for (uint32_t i = 0; i < layerCount; i++) { + printf("\t - %s\n", availableLayers[i].layerName); + } + printf("-----------------\n\n"); + free(availableLayers); } -bool vkengine_try_get_phyinfo (VkhPhyInfo* phys, uint32_t phyCount, VkPhysicalDeviceType gpuType, VkhPhyInfo* phy) { - for (uint32_t i=0; i<phyCount; i++){ - if (phys[i]->properties.deviceType == gpuType) { - *phy = phys[i]; - return true; - } - } - return false; +bool vkengine_try_get_phyinfo(VkhPhyInfo *phys, uint32_t phyCount, VkPhysicalDeviceType gpuType, VkhPhyInfo *phy) { + for (uint32_t i = 0; i < phyCount; i++) { + if (phys[i]->properties.deviceType == gpuType) { + *phy = phys[i]; + return true; + } + } + return false; } -bool instance_extension_supported (VkExtensionProperties* instanceExtProps, uint32_t extCount, const char* instanceName) { - for (uint32_t i=0; i<extCount; i++) { - if (!strcmp(instanceExtProps[i].extensionName, instanceName)) - return true; - } - return false; +bool instance_extension_supported(VkExtensionProperties *instanceExtProps, uint32_t extCount, + const char *instanceName) { + for (uint32_t i = 0; i < extCount; i++) { + if (!strcmp(instanceExtProps[i].extensionName, instanceName)) + return true; + } + return false; } -vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR presentMode, uint32_t width, uint32_t height) { - glfwSetErrorCallback(glfw_error_callback); +vk_engine_t *vkengine_create(VkPhysicalDeviceType preferedGPU, VkPresentModeKHR presentMode, uint32_t width, + uint32_t height) { + glfwSetErrorCallback(glfw_error_callback); - if (!glfwInit()) { - perror ("glfwInit failed"); - exit(-1); - } + if (!glfwInit()) { + perror("glfwInit failed"); + exit(-1); + } - if (!glfwVulkanSupported()) { - perror ("glfwVulkanSupported return false."); - exit(-1); - } + if (!glfwVulkanSupported()) { + perror("glfwVulkanSupported return false."); + exit(-1); + } - const char* enabledLayers[10]; - const char* enabledExts [10]; - uint32_t enabledExtsCount = 0, enabledLayersCount = 0, phyCount = 0; + const char *enabledLayers[10]; + const char *enabledExts[10]; + uint32_t enabledExtsCount = 0, enabledLayersCount = 0, phyCount = 0; - vkh_layers_check_init(); + vkh_layers_check_init(); #ifdef VKVG_USE_VALIDATION - if (vkh_layer_is_present("VK_LAYER_KHRONOS_validation")) - enabledLayers[enabledLayersCount++] = "VK_LAYER_KHRONOS_validation"; + if (vkh_layer_is_present("VK_LAYER_KHRONOS_validation")) + enabledLayers[enabledLayersCount++] = "VK_LAYER_KHRONOS_validation"; #endif #ifdef VKVG_USE_MESA_OVERLAY - if (vkh_layer_is_present("VK_LAYER_MESA_overlay")) - enabledLayers[enabledLayersCount++] = "VK_LAYER_MESA_overlay"; + if (vkh_layer_is_present("VK_LAYER_MESA_overlay")) + enabledLayers[enabledLayersCount++] = "VK_LAYER_MESA_overlay"; #endif #ifdef VKVG_USE_RENDERDOC - if (vkh_layer_is_present("VK_LAYER_RENDERDOC_Capture")) - enabledLayers[enabledLayersCount++] = "VK_LAYER_RENDERDOC_Capture"; + if (vkh_layer_is_present("VK_LAYER_RENDERDOC_Capture")) + enabledLayers[enabledLayersCount++] = "VK_LAYER_RENDERDOC_Capture"; #endif - vkh_layers_check_release(); + vkh_layers_check_release(); - uint32_t glfwReqExtsCount = 0; - const char** gflwExts = glfwGetRequiredInstanceExtensions (&glfwReqExtsCount); + uint32_t glfwReqExtsCount = 0; + const char **gflwExts = glfwGetRequiredInstanceExtensions(&glfwReqExtsCount); - vkvg_get_required_instance_extensions (enabledExts, &enabledExtsCount); + vkvg_get_required_instance_extensions(enabledExts, &enabledExtsCount); - for (uint32_t i=0;i<glfwReqExtsCount;i++) - enabledExts[i+enabledExtsCount] = gflwExts[i]; + for (uint32_t i = 0; i < glfwReqExtsCount; i++) + enabledExts[i + enabledExtsCount] = gflwExts[i]; - enabledExtsCount += glfwReqExtsCount; + enabledExtsCount += glfwReqExtsCount; - vk_engine_t* e = (vk_engine_t*)calloc(1,sizeof(vk_engine_t)); + vk_engine_t *e = (vk_engine_t *)calloc(1, sizeof(vk_engine_t)); #ifdef VK_VERSION_1_2 - e->app = vkh_app_create(1, 2, "vkvg", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts); + e->app = vkh_app_create(1, 2, "vkvg", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts); #else - e->app = vkh_app_create(1, 1, "vkvg", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts); + e->app = vkh_app_create(1, 1, "vkvg", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts); #endif - -#if defined(DEBUG) && defined (VKVG_DBG_UTILS) - vkh_app_enable_debug_messenger(e->app - , VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT - //| VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT - //| VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT - , VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT - //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT - //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT - , NULL); +#if defined(DEBUG) && defined(VKVG_DBG_UTILS) + vkh_app_enable_debug_messenger(e->app, + VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT + //| VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT + //| VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT + , + VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | + VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT + //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT + //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT + , + NULL); #endif - glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); - glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); - glfwWindowHint(GLFW_FLOATING, GLFW_FALSE); - glfwWindowHint(GLFW_DECORATED, GLFW_TRUE); + glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); + glfwWindowHint(GLFW_FLOATING, GLFW_FALSE); + glfwWindowHint(GLFW_DECORATED, GLFW_TRUE); - e->window = glfwCreateWindow ((int)width, (int)height, "Window Title", NULL, NULL); + e->window = glfwCreateWindow((int)width, (int)height, "Window Title", NULL, NULL); - VkSurfaceKHR surf; - VK_CHECK_RESULT (glfwCreateWindowSurface(e->app->inst, e->window, NULL, &surf)) + VkSurfaceKHR surf; + VK_CHECK_RESULT(glfwCreateWindowSurface(e->app->inst, e->window, NULL, &surf)) - VkhPhyInfo* phys = vkh_app_get_phyinfos (e->app, &phyCount, surf); + VkhPhyInfo *phys = vkh_app_get_phyinfos(e->app, &phyCount, surf); - VkhPhyInfo pi = 0; - if (!vkengine_try_get_phyinfo(phys, phyCount, preferedGPU, &pi) - && !vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, &pi) - && !vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, &pi)) - pi = phys[0]; - assert(pi && "No vulkan physical device found."); + VkhPhyInfo pi = 0; + if (!vkengine_try_get_phyinfo(phys, phyCount, preferedGPU, &pi) && + !vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, &pi) && + !vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, &pi)) + pi = phys[0]; + assert(pi && "No vulkan physical device found."); - e->memory_properties = pi->memProps; - e->gpu_props = pi->properties; + e->memory_properties = pi->memProps; + e->gpu_props = pi->properties; - uint32_t qCount = 0; - float qPriorities[] = {0.0}; + uint32_t qCount = 0; + float qPriorities[] = {0.0}; - VkDeviceQueueCreateInfo pQueueInfos[] = { {0},{0},{0} }; - if (vkh_phyinfo_create_presentable_queues (pi, 1, qPriorities, &pQueueInfos[qCount])) - qCount++; - /*if (vkh_phyinfo_create_compute_queues (pi, 1, qPriorities, &pQueueInfos[qCount])) - qCount++; - if (vkh_phyinfo_create_transfer_queues (pi, 1, qPriorities, &pQueueInfos[qCount])) - qCount++;*/ + VkDeviceQueueCreateInfo pQueueInfos[] = {{0}, {0}, {0}}; + if (vkh_phyinfo_create_presentable_queues(pi, 1, qPriorities, &pQueueInfos[qCount])) + qCount++; + /*if (vkh_phyinfo_create_compute_queues (pi, 1, qPriorities, &pQueueInfos[qCount])) + qCount++; + if (vkh_phyinfo_create_transfer_queues (pi, 1, qPriorities, &pQueueInfos[qCount])) + qCount++;*/ - enabledExtsCount=0; + enabledExtsCount = 0; - if (vkvg_get_required_device_extensions (pi->phy, enabledExts, &enabledExtsCount) != VKVG_STATUS_SUCCESS) { - perror ("vkvg_get_required_device_extensions failed, enable log for details.\n"); - exit(-1); - } - TRY_LOAD_DEVICE_EXT (VK_KHR_swapchain) + if (vkvg_get_required_device_extensions(pi->phy, enabledExts, &enabledExtsCount) != VKVG_STATUS_SUCCESS) { + perror("vkvg_get_required_device_extensions failed, enable log for details.\n"); + exit(-1); + } + TRY_LOAD_DEVICE_EXT(VK_KHR_swapchain) - VkPhysicalDeviceFeatures enabledFeatures = {0}; - const void* pNext = vkvg_get_device_requirements (&enabledFeatures); + VkPhysicalDeviceFeatures enabledFeatures = {0}; + const void *pNext = vkvg_get_device_requirements(&enabledFeatures); - VkDeviceCreateInfo device_info = { .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, - .queueCreateInfoCount = qCount, - .pQueueCreateInfos = (VkDeviceQueueCreateInfo*)&pQueueInfos, - .enabledExtensionCount = enabledExtsCount, - .ppEnabledExtensionNames = enabledExts, - .pEnabledFeatures = &enabledFeatures, - .pNext = pNext}; + VkDeviceCreateInfo device_info = {.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, + .queueCreateInfoCount = qCount, + .pQueueCreateInfos = (VkDeviceQueueCreateInfo *)&pQueueInfos, + .enabledExtensionCount = enabledExtsCount, + .ppEnabledExtensionNames = enabledExts, + .pEnabledFeatures = &enabledFeatures, + .pNext = pNext}; - e->dev = vkh_device_create(e->app, pi, &device_info); + e->dev = vkh_device_create(e->app, pi, &device_info); - e->renderer = vkh_presenter_create - (e->dev, (uint32_t) pi->pQueue, surf, width, height, VK_FORMAT_B8G8R8A8_UNORM, presentMode); + e->renderer = + vkh_presenter_create(e->dev, (uint32_t)pi->pQueue, surf, width, height, VK_FORMAT_B8G8R8A8_UNORM, presentMode); - vkh_app_free_phyinfos (phyCount, phys); + vkh_app_free_phyinfos(phyCount, phys); - return e; + return e; } -void vkengine_destroy (VkEngine e) { - //vkDeviceWaitIdle(e->dev->dev); +void vkengine_destroy(VkEngine e) { + // vkDeviceWaitIdle(e->dev->dev); - VkSurfaceKHR surf = e->renderer->surface; + VkSurfaceKHR surf = e->renderer->surface; - vkh_presenter_destroy (e->renderer); - vkDestroySurfaceKHR (e->app->inst, surf, NULL); + vkh_presenter_destroy(e->renderer); + vkDestroySurfaceKHR(e->app->inst, surf, NULL); - vkh_device_destroy (e->dev); + vkh_device_destroy(e->dev); - glfwDestroyWindow (e->window); - vkh_app_destroy (e->app); + glfwDestroyWindow(e->window); + vkh_app_destroy(e->app); - glfwTerminate (); + glfwTerminate(); - free(e); + free(e); } -void vkengine_close (VkEngine e) { - glfwSetWindowShouldClose(e->window, GLFW_TRUE); -} -void vkengine_blitter_run (VkEngine e, VkImage img, uint32_t width, uint32_t height) { - VkhPresenter p = e->renderer; - vkh_presenter_build_blit_cmd (p, img, width, height); +void vkengine_close(VkEngine e) { glfwSetWindowShouldClose(e->window, GLFW_TRUE); } +void vkengine_blitter_run(VkEngine e, VkImage img, uint32_t width, uint32_t height) { + VkhPresenter p = e->renderer; + vkh_presenter_build_blit_cmd(p, img, width, height); - while (!vkengine_should_close (e)) { - glfwPollEvents(); - if (!vkh_presenter_draw (p)) - vkh_presenter_build_blit_cmd (p, img, width, height); - } -} -bool vkengine_should_close (VkEngine e) { - return glfwWindowShouldClose (e->window); -} -void vkengine_set_title (VkEngine e, const char* title) { - glfwSetWindowTitle(e->window, title); -} -VkInstance vkengine_get_instance (VkEngine e){ - return e->dev->instance; -} -VkDevice vkengine_get_device (VkEngine e){ - return e->dev->dev; -} -VkPhysicalDevice vkengine_get_physical_device (VkEngine e){ - return e->dev->phy; -} -VkQueue vkengine_get_queue (VkEngine e){ - return e->renderer->queue; -} -uint32_t vkengine_get_queue_fam_idx (VkEngine e){ - return e->renderer->qFam; -} -void vkengine_wait_idle (VkEngine e) { - vkDeviceWaitIdle(e->dev->dev); + while (!vkengine_should_close(e)) { + glfwPollEvents(); + if (!vkh_presenter_draw(p)) + vkh_presenter_build_blit_cmd(p, img, width, height); + } } +bool vkengine_should_close(VkEngine e) { return glfwWindowShouldClose(e->window); } +void vkengine_set_title(VkEngine e, const char *title) { glfwSetWindowTitle(e->window, title); } +VkInstance vkengine_get_instance(VkEngine e) { return e->dev->instance; } +VkDevice vkengine_get_device(VkEngine e) { return e->dev->dev; } +VkPhysicalDevice vkengine_get_physical_device(VkEngine e) { return e->dev->phy; } +VkQueue vkengine_get_queue(VkEngine e) { return e->renderer->queue; } +uint32_t vkengine_get_queue_fam_idx(VkEngine e) { return e->renderer->qFam; } +void vkengine_wait_idle(VkEngine e) { vkDeviceWaitIdle(e->dev->dev); } -void vkengine_set_key_callback (VkEngine e, GLFWkeyfun key_callback){ - glfwSetKeyCallback (e->window, key_callback); -} -void vkengine_set_mouse_but_callback (VkEngine e, GLFWmousebuttonfun onMouseBut){ - glfwSetMouseButtonCallback(e->window, onMouseBut); -} -void vkengine_set_cursor_pos_callback (VkEngine e, GLFWcursorposfun onMouseMove){ - glfwSetCursorPosCallback(e->window, onMouseMove); -} -void vkengine_set_scroll_callback (VkEngine e, GLFWscrollfun onScroll){ - glfwSetScrollCallback(e->window, onScroll); +void vkengine_set_key_callback(VkEngine e, GLFWkeyfun key_callback) { glfwSetKeyCallback(e->window, key_callback); } +void vkengine_set_mouse_but_callback(VkEngine e, GLFWmousebuttonfun onMouseBut) { + glfwSetMouseButtonCallback(e->window, onMouseBut); } -void vkengine_set_char_callback (VkEngine e, GLFWcharfun onChar){ - glfwSetCharCallback(e->window, onChar); +void vkengine_set_cursor_pos_callback(VkEngine e, GLFWcursorposfun onMouseMove) { + glfwSetCursorPosCallback(e->window, onMouseMove); } +void vkengine_set_scroll_callback(VkEngine e, GLFWscrollfun onScroll) { glfwSetScrollCallback(e->window, onScroll); } +void vkengine_set_char_callback(VkEngine e, GLFWcharfun onChar) { glfwSetCharCallback(e->window, onChar); } diff --git a/tests/common/vkengine.h b/tests/common/vkengine.h index ebed772..a8016ec 100644 --- a/tests/common/vkengine.h +++ b/tests/common/vkengine.h @@ -36,38 +36,39 @@ #define FENCE_TIMEOUT 100000000 -typedef struct _vk_engine_t* VkEngine; +typedef struct _vk_engine_t *VkEngine; typedef struct _vk_engine_t { - VkhApp app; - VkPhysicalDeviceMemoryProperties memory_properties; - VkPhysicalDeviceProperties gpu_props; - VkhDevice dev; - GLFWwindow* window; - VkhPresenter renderer; -}vk_engine_t; + VkhApp app; + VkPhysicalDeviceMemoryProperties memory_properties; + VkPhysicalDeviceProperties gpu_props; + VkhDevice dev; + GLFWwindow *window; + VkhPresenter renderer; +} vk_engine_t; -vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR presentMode, uint32_t width, uint32_t height); -void vkengine_dump_available_layers (); -bool vkengine_try_get_phyinfo (VkhPhyInfo* phys, uint32_t phyCount, VkPhysicalDeviceType gpuType, VkhPhyInfo* phy); -void vkengine_destroy (VkEngine e); -bool vkengine_should_close (VkEngine e); -void vkengine_close (VkEngine e); -void vkengine_dump_Infos (VkEngine e); -void vkengine_set_title (VkEngine e, const char* title); -VkInstance vkengine_get_instance (VkEngine e); -VkDevice vkengine_get_device (VkEngine e); -VkPhysicalDevice vkengine_get_physical_device(VkEngine e); -VkQueue vkengine_get_queue (VkEngine e); -uint32_t vkengine_get_queue_fam_idx (VkEngine e); +vk_engine_t *vkengine_create(VkPhysicalDeviceType preferedGPU, VkPresentModeKHR presentMode, uint32_t width, + uint32_t height); +void vkengine_dump_available_layers(); +bool vkengine_try_get_phyinfo(VkhPhyInfo *phys, uint32_t phyCount, VkPhysicalDeviceType gpuType, VkhPhyInfo *phy); +void vkengine_destroy(VkEngine e); +bool vkengine_should_close(VkEngine e); +void vkengine_close(VkEngine e); +void vkengine_dump_Infos(VkEngine e); +void vkengine_set_title(VkEngine e, const char *title); +VkInstance vkengine_get_instance(VkEngine e); +VkDevice vkengine_get_device(VkEngine e); +VkPhysicalDevice vkengine_get_physical_device(VkEngine e); +VkQueue vkengine_get_queue(VkEngine e); +uint32_t vkengine_get_queue_fam_idx(VkEngine e); -void vkengine_get_queues_properties (vk_engine_t* e, VkQueueFamilyProperties** qFamProps, uint32_t* count); +void vkengine_get_queues_properties(vk_engine_t *e, VkQueueFamilyProperties **qFamProps, uint32_t *count); -void vkengine_set_key_callback (VkEngine e, GLFWkeyfun key_callback); -void vkengine_set_mouse_but_callback (VkEngine e, GLFWmousebuttonfun onMouseBut); -void vkengine_set_cursor_pos_callback (VkEngine e, GLFWcursorposfun onMouseMove); -void vkengine_set_scroll_callback (VkEngine e, GLFWscrollfun onScroll); -void vkengine_set_char_callback (VkEngine e, GLFWcharfun onChar); +void vkengine_set_key_callback(VkEngine e, GLFWkeyfun key_callback); +void vkengine_set_mouse_but_callback(VkEngine e, GLFWmousebuttonfun onMouseBut); +void vkengine_set_cursor_pos_callback(VkEngine e, GLFWcursorposfun onMouseMove); +void vkengine_set_scroll_callback(VkEngine e, GLFWscrollfun onScroll); +void vkengine_set_char_callback(VkEngine e, GLFWcharfun onChar); -void vkengine_wait_idle (VkEngine e); +void vkengine_wait_idle(VkEngine e); #endif diff --git a/tests/compositing.c b/tests/compositing.c index 54711b4..76e9490 100644 --- a/tests/compositing.c +++ b/tests/compositing.c @@ -1,40 +1,39 @@ #include "test.h" -void compositing(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); +void compositing() { + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - vkvg_set_source_rgba(ctx, 1,0,0,0.5f); - vkvg_rectangle(ctx,100,100,200,200); - vkvg_fill(ctx); + vkvg_set_source_rgba(ctx, 1, 0, 0, 0.5f); + vkvg_rectangle(ctx, 100, 100, 200, 200); + vkvg_fill(ctx); - vkvg_set_source_rgba(ctx, 0,0,1,0.5f); - vkvg_rectangle(ctx,200,200,200,200); - vkvg_fill(ctx); + vkvg_set_source_rgba(ctx, 0, 0, 1, 0.5f); + vkvg_rectangle(ctx, 200, 200, 200, 200); + vkvg_fill(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void opacity(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); +void opacity() { + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - vkvg_set_source_rgba(ctx, 1,0,0,1.0f); - vkvg_rectangle(ctx,100,100,200,200); - vkvg_fill(ctx); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1.0f); + vkvg_rectangle(ctx, 100, 100, 200, 200); + vkvg_fill(ctx); - vkvg_set_opacity(ctx,0.5f); + vkvg_set_opacity(ctx, 0.5f); - vkvg_set_source_rgba(ctx, 0,0,1,1.0f); - vkvg_rectangle(ctx,200,200,200,200); - vkvg_fill(ctx); + vkvg_set_source_rgba(ctx, 0, 0, 1, 1.0f); + vkvg_rectangle(ctx, 200, 200, 200, 200); + vkvg_fill(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } - int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (compositing, argc, argv); - PERFORM_TEST (opacity, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(compositing, argc, argv); + PERFORM_TEST(opacity, argc, argv); + return 0; } diff --git a/tests/context.c b/tests/context.c index b22da8a..caf0a26 100644 --- a/tests/context.c +++ b/tests/context.c @@ -1,22 +1,22 @@ #include "test.h" -void create_destroy_multi(){ - VkvgContext* ctxs = (VkvgContext*)malloc(sizeof(VkvgContext)*test_size); - for (uint32_t i = 0; i < test_size; i++) - ctxs[i] = vkvg_create(surf); - for (uint32_t i = 0; i < test_size; i++) - vkvg_destroy(ctxs[i]); - free(ctxs); +void create_destroy_multi() { + VkvgContext *ctxs = (VkvgContext *)malloc(sizeof(VkvgContext) * test_size); + for (uint32_t i = 0; i < test_size; i++) + ctxs[i] = vkvg_create(surf); + for (uint32_t i = 0; i < test_size; i++) + vkvg_destroy(ctxs[i]); + free(ctxs); } -void create_destroy_single(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_destroy(ctx); +void create_destroy_single() { + VkvgContext ctx = vkvg_create(surf); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - PERFORM_TEST (create_destroy_multi, argc, argv); - no_test_size = true; - PERFORM_TEST (create_destroy_single, argc, argv); - return 0; + PERFORM_TEST(create_destroy_multi, argc, argv); + no_test_size = true; + PERFORM_TEST(create_destroy_single, argc, argv); + return 0; } diff --git a/tests/curve.c b/tests/curve.c index ff78bc8..d1bcfd1 100644 --- a/tests/curve.c +++ b/tests/curve.c @@ -2,203 +2,200 @@ //"M80 170 C100 170 160 170 180 170 lZ" void test3() { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear (ctx); - vkvg_set_line_width(ctx, 20); - vkvg_set_source_rgb (ctx,1,0,0); - vkvg_move_to (ctx,80,170); - vkvg_curve_to (ctx, 100,170,160,171,180,170); - //vkvg_rel_line_to (ctx, -30,100); - vkvg_close_path (ctx); - vkvg_stroke (ctx); - vkvg_destroy (ctx); - + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); + vkvg_set_line_width(ctx, 20); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_move_to(ctx, 80, 170); + vkvg_curve_to(ctx, 100, 170, 160, 171, 180, 170); + // vkvg_rel_line_to (ctx, -30,100); + vkvg_close_path(ctx); + vkvg_stroke(ctx); + vkvg_destroy(ctx); } -void test(){ - VkvgContext ctx = vkvg_create(surf); - - vkvg_set_line_width(ctx, 20); - - vkvg_scale(ctx,2,2); - vkvg_set_line_join(ctx, VKVG_LINE_JOIN_BEVEL); +void test() { + VkvgContext ctx = vkvg_create(surf); - //vkvg_arc (ctx, 200, 500, 100, 0, M_PI); + vkvg_set_line_width(ctx, 20); - vkvg_set_source_rgb (ctx, 0.5f,0,0); + vkvg_scale(ctx, 2, 2); + vkvg_set_line_join(ctx, VKVG_LINE_JOIN_BEVEL); + // vkvg_arc (ctx, 200, 500, 100, 0, M_PI); - /*vkvg_move_to(ctx,100,100); - vkvg_line_to(ctx,300,100); - vkvg_line_to(ctx,500,300); - vkvg_line_to(ctx,300,500); - //vkvg_arc (ctx, 200, 500, 100, 0, M_PI); - vkvg_line_to(ctx,300,700); - vkvg_line_to(ctx,100,500);*/ + vkvg_set_source_rgb(ctx, 0.5f, 0, 0); - /*vkvg_arc(ctx, 300, 300, 100, 0, M_PI); - vkvg_line_to(ctx,100,200); - vkvg_line_to(ctx,200,100); - vkvg_arc(ctx, 250, 100, 50, M_PI, M_PI * 1.5f); - vkvg_line_to(ctx,350,50); - vkvg_arc(ctx, 350, 100, 50, M_PI*1.5f, M_PI * 2.0f); + /*vkvg_move_to(ctx,100,100); + vkvg_line_to(ctx,300,100); + vkvg_line_to(ctx,500,300); + vkvg_line_to(ctx,300,500); + //vkvg_arc (ctx, 200, 500, 100, 0, M_PI); + vkvg_line_to(ctx,300,700); + vkvg_line_to(ctx,100,500);*/ - vkvg_stroke(ctx); - vkvg_translate(ctx,400,30); + /*vkvg_arc(ctx, 300, 300, 100, 0, M_PI); + vkvg_line_to(ctx,100,200); + vkvg_line_to(ctx,200,100); + vkvg_arc(ctx, 250, 100, 50, M_PI, M_PI * 1.5f); + vkvg_line_to(ctx,350,50); + vkvg_arc(ctx, 350, 100, 50, M_PI*1.5f, M_PI * 2.0f); - */ - //vkvg_set_fill_rule(ctx,VKVG_FILL_RULE_EVEN_ODD); - vkvg_translate(ctx,200,30); - vkvg_arc(ctx, 200, 200, 20, 0, M_PIF*2); - //vkvg_stroke(ctx); + vkvg_stroke(ctx); + vkvg_translate(ctx,400,30); - vkvg_set_source_rgba (ctx, 0.5f,0.0f,1.0f,0.5f); - 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); - vkvg_line_to(ctx,100,400); - vkvg_curve_to(ctx,50,400,10,350,10,300); - vkvg_line_to(ctx,10,200); - vkvg_curve_to(ctx,10,150,50,100,100,100); - //vkvg_close_path(ctx); - vkvg_fill_preserve(ctx); - vkvg_set_source_rgba (ctx, 0.1f,0.3f,0.7f,0.5f); - vkvg_stroke(ctx); + */ + // vkvg_set_fill_rule(ctx,VKVG_FILL_RULE_EVEN_ODD); + vkvg_translate(ctx, 200, 30); + vkvg_arc(ctx, 200, 200, 20, 0, M_PIF * 2); + // vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 0.5f, 0.0f, 1.0f, 0.5f); + 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); + vkvg_line_to(ctx, 100, 400); + vkvg_curve_to(ctx, 50, 400, 10, 350, 10, 300); + vkvg_line_to(ctx, 10, 200); + vkvg_curve_to(ctx, 10, 150, 50, 100, 100, 100); + // vkvg_close_path(ctx); + vkvg_fill_preserve(ctx); + vkvg_set_source_rgba(ctx, 0.1f, 0.3f, 0.7f, 0.5f); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } void curved_rect() { - VkvgContext ctx = vkvg_create(surf); + VkvgContext ctx = vkvg_create(surf); - float x = 50, y = 50, width = 150, height = 140, radius = 30; + float x = 50, y = 50, width = 150, height = 140, radius = 30; - vkvg_scale(ctx, 2, 2); - //vkvg_rotate(ctx,0.5f); + vkvg_scale(ctx, 2, 2); + // vkvg_rotate(ctx,0.5f); - vkvg_set_line_width(ctx, 15); - vkvg_set_source_rgba(ctx, 0, 0.5f, 0.4f, 1); + 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); + 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.5f, 0, 0, 0.5f); - vkvg_stroke(ctx); + 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.5f, 0, 0, 0.5f); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } void test2() { - VkvgContext ctx = vkvg_create(surf); + VkvgContext ctx = vkvg_create(surf); - vkvg_move_to(ctx, 100, 400); - vkvg_curve_to(ctx, 100, 100, 600, 700, 600, 400); - vkvg_curve_to(ctx, 1000, 100, 100, 800, 1000, 800); - vkvg_curve_to(ctx, 1000, 500, 700, 500, 700, 100); - vkvg_close_path(ctx); + vkvg_move_to(ctx, 100, 400); + vkvg_curve_to(ctx, 100, 100, 600, 700, 600, 400); + vkvg_curve_to(ctx, 1000, 100, 100, 800, 1000, 800); + vkvg_curve_to(ctx, 1000, 500, 700, 500, 700, 100); + vkvg_close_path(ctx); - //vkvg_set_source_rgba (ctx, 0.5,0.0,1.0,0.5); - //vkvg_fill_preserve(ctx); + // vkvg_set_source_rgba (ctx, 0.5,0.0,1.0,0.5); + // vkvg_fill_preserve(ctx); - vkvg_set_source_rgba(ctx, 1, 0, 0, 1); - vkvg_set_line_width(ctx, 40); - vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_set_line_width(ctx, 40); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } static bool fillAndStroke = true; -void random_curves_stroke () { - float w = (float)test_width; - float h = (float)test_height; +void random_curves_stroke() { + float w = (float)test_width; + float h = (float)test_height; - VkvgContext ctx = _initCtx(); + VkvgContext ctx = _initCtx(); - for (uint32_t i=0; i<test_size; i++) { - randomize_color(ctx); - float x1 = rndf() * w; - float y1 = rndf() * h; + for (uint32_t i = 0; i < test_size; i++) { + randomize_color(ctx); + float x1 = rndf() * w; + float y1 = rndf() * h; - vkvg_move_to (ctx, x1, y1); - draw_random_curve(ctx); + vkvg_move_to(ctx, x1, y1); + draw_random_curve(ctx); - vkvg_stroke (ctx); - } - vkvg_destroy(ctx); + vkvg_stroke(ctx); + } + vkvg_destroy(ctx); } -void _long_curv () { - float w = (float)test_width; - float h = (float)test_height; +void _long_curv() { + float w = (float)test_width; + float h = (float)test_height; - VkvgContext ctx = _initCtx(); + VkvgContext ctx = _initCtx(); - randomize_color(ctx); - float x1 = rndf() * w; - float y1 = rndf() * h; - vkvg_move_to (ctx, x1, y1); + randomize_color(ctx); + float x1 = rndf() * w; + float y1 = rndf() * h; + vkvg_move_to(ctx, x1, y1); - for (uint32_t i=0; i<test_size; i++) { - draw_random_curve(ctx); - } + for (uint32_t i = 0; i < test_size; i++) { + draw_random_curve(ctx); + } - if (fillAndStroke) { - vkvg_fill_preserve(ctx); - randomize_color(ctx); - vkvg_stroke (ctx); - }else - vkvg_fill (ctx); + if (fillAndStroke) { + vkvg_fill_preserve(ctx); + randomize_color(ctx); + vkvg_stroke(ctx); + } else + vkvg_fill(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void long_curv_fill_nz () { - fillAndStroke = false; - fill_rule = VKVG_FILL_RULE_NON_ZERO; - _long_curv (); +void long_curv_fill_nz() { + fillAndStroke = false; + fill_rule = VKVG_FILL_RULE_NON_ZERO; + _long_curv(); } -void long_curv_fill_eo () { - fillAndStroke = false; - fill_rule = VKVG_FILL_RULE_EVEN_ODD; - _long_curv (); +void long_curv_fill_eo() { + fillAndStroke = false; + fill_rule = VKVG_FILL_RULE_EVEN_ODD; + _long_curv(); } -void long_curv_fill_stroke_nz () { - fillAndStroke = true; - fill_rule = VKVG_FILL_RULE_NON_ZERO; - _long_curv (); +void long_curv_fill_stroke_nz() { + fillAndStroke = true; + fill_rule = VKVG_FILL_RULE_NON_ZERO; + _long_curv(); } -void long_curv_fill_stroke_eo () { - fillAndStroke = true; - fill_rule = VKVG_FILL_RULE_EVEN_ODD; - _long_curv (); +void long_curv_fill_stroke_eo() { + fillAndStroke = true; + fill_rule = VKVG_FILL_RULE_EVEN_ODD; + _long_curv(); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST(test3, argc, argv); - //return 0; - PERFORM_TEST(test, argc, argv); - PERFORM_TEST(test2, argc, argv); - PERFORM_TEST(curved_rect, argc, argv); - //PERFORM_TEST(long_curv_fill_nz, argc, argv); - no_test_size = false; - PERFORM_TEST(long_curv_fill_eo, argc, argv); - //PERFORM_TEST(long_curv_fill_stroke_nz, argc, argv); - PERFORM_TEST(long_curv_fill_stroke_eo, argc, argv); - PERFORM_TEST(random_curves_stroke, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(test3, argc, argv); + // return 0; + PERFORM_TEST(test, argc, argv); + PERFORM_TEST(test2, argc, argv); + PERFORM_TEST(curved_rect, argc, argv); + // PERFORM_TEST(long_curv_fill_nz, argc, argv); + no_test_size = false; + PERFORM_TEST(long_curv_fill_eo, argc, argv); + // PERFORM_TEST(long_curv_fill_stroke_nz, argc, argv); + PERFORM_TEST(long_curv_fill_stroke_eo, argc, argv); + PERFORM_TEST(random_curves_stroke, argc, argv); + return 0; } diff --git a/tests/dashes.c b/tests/dashes.c index 3fc0734..1f2ade4 100644 --- a/tests/dashes.c +++ b/tests/dashes.c @@ -1,116 +1,109 @@ #include "test.h" -void test(){ - dash_offset += 0.2f; +void test() { + dash_offset += 0.2f; - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); - vkvg_set_source_rgb(ctx, 1, 1, 1); - vkvg_paint(ctx); - //const float dashes[] = {160.0f, 80}; - //float dashes[] = {7.0f, 3}; - float dashes[] = {100, 20, 20, 20}; - vkvg_set_line_cap(ctx, VKVG_LINE_CAP_ROUND); - vkvg_set_line_join(ctx, VKVG_LINE_JOIN_ROUND); - vkvg_set_dash(ctx, dashes, 4, dash_offset); - vkvg_set_line_width(ctx, 4); - vkvg_set_source_rgb(ctx, 0, 0, 1); + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); + vkvg_set_source_rgb(ctx, 1, 1, 1); + vkvg_paint(ctx); + // const float dashes[] = {160.0f, 80}; + // float dashes[] = {7.0f, 3}; + float dashes[] = {100, 20, 20, 20}; + vkvg_set_line_cap(ctx, VKVG_LINE_CAP_ROUND); + vkvg_set_line_join(ctx, VKVG_LINE_JOIN_ROUND); + vkvg_set_dash(ctx, dashes, 4, dash_offset); + vkvg_set_line_width(ctx, 4); + vkvg_set_source_rgb(ctx, 0, 0, 1); - vkvg_move_to (ctx, 50, 50); - vkvg_rel_line_to (ctx, 500, 0); - vkvg_rel_line_to (ctx, 0, 200); - vkvg_rel_line_to (ctx, 200, 0); - vkvg_rel_line_to (ctx, 0, 500); - vkvg_rel_line_to (ctx, -700, 0); - vkvg_close_path(ctx); - vkvg_stroke (ctx); + vkvg_move_to(ctx, 50, 50); + vkvg_rel_line_to(ctx, 500, 0); + vkvg_rel_line_to(ctx, 0, 200); + vkvg_rel_line_to(ctx, 200, 0); + vkvg_rel_line_to(ctx, 0, 500); + vkvg_rel_line_to(ctx, -700, 0); + vkvg_close_path(ctx); + vkvg_stroke(ctx); - dashes[0] = 0; - dashes[1] = 20; - vkvg_set_dash(ctx, dashes, 2, dash_offset); + dashes[0] = 0; + dashes[1] = 20; + vkvg_set_dash(ctx, dashes, 2, dash_offset); - vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_set_source_rgb(ctx, 0, 1, 0); - vkvg_move_to (ctx, 100, 100); - vkvg_rel_line_to (ctx, 400, 0); - vkvg_rel_line_to (ctx, 0, 200); - vkvg_rel_line_to (ctx, 200, 0); - vkvg_rel_line_to (ctx, 0, 400); - vkvg_rel_line_to (ctx, -600, 0); - vkvg_close_path(ctx); - vkvg_stroke (ctx); + vkvg_move_to(ctx, 100, 100); + vkvg_rel_line_to(ctx, 400, 0); + vkvg_rel_line_to(ctx, 0, 200); + vkvg_rel_line_to(ctx, 200, 0); + vkvg_rel_line_to(ctx, 0, 400); + vkvg_rel_line_to(ctx, -600, 0); + vkvg_close_path(ctx); + vkvg_stroke(ctx); - dashes[0] = 80; - dashes[1] = 20; + dashes[0] = 80; + dashes[1] = 20; - vkvg_set_line_width(ctx, 10); - vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_set_line_width(ctx, 10); + vkvg_set_source_rgb(ctx, 1, 0, 0); - vkvg_set_dash(ctx, dashes, 2, dash_offset); + vkvg_set_dash(ctx, dashes, 2, dash_offset); - vkvg_rectangle(ctx, 200,300,200,200); - /*vkvg_move_to(ctx, 200,300); - vkvg_rel_line_to(ctx,200,0);*/ - vkvg_stroke (ctx); + vkvg_rectangle(ctx, 200, 300, 200, 200); + /*vkvg_move_to(ctx, 200,300); + vkvg_rel_line_to(ctx,200,0);*/ + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } +void _long_curve() { + float w = (float)test_width; + float h = (float)test_height; -void _long_curve () { - float w = (float)test_width; - float h = (float)test_height; + VkvgContext ctx = _initCtx(); - VkvgContext ctx = _initCtx(); + randomize_color(ctx); + float x1 = w * rand() / RAND_MAX; + float y1 = h * rand() / RAND_MAX; + vkvg_move_to(ctx, x1, y1); - randomize_color(ctx); - float x1 = w*rand()/RAND_MAX; - float y1 = h*rand()/RAND_MAX; - vkvg_move_to (ctx, x1, y1); - - for (uint32_t i=0; i<test_size; i++) - draw_random_curve(ctx); - - vkvg_stroke (ctx); - vkvg_destroy(ctx); + for (uint32_t i = 0; i < test_size; i++) + draw_random_curve(ctx); + vkvg_stroke(ctx); + vkvg_destroy(ctx); } void _long_path() { - float w = (float)test_width-10; - float h = (float)test_height-10; + float w = (float)test_width - 10; + float h = (float)test_height - 10; - VkvgContext ctx = _initCtx(); + VkvgContext ctx = _initCtx(); - randomize_color(ctx); - float x1 = w*rndf(); - float y1 = h*rndf(); - vkvg_move_to (ctx, x1, y1); - for (uint32_t i=0; i<test_size; i++) { - x1 = w*rndf(); - y1 = h*rndf(); - vkvg_line_to (ctx, x1, y1); - } - vkvg_stroke (ctx); - vkvg_destroy(ctx); -} - -void path () { - _long_path (); -} -void curve () { - _long_curve (); + randomize_color(ctx); + float x1 = w * rndf(); + float y1 = h * rndf(); + vkvg_move_to(ctx, x1, y1); + for (uint32_t i = 0; i < test_size; i++) { + x1 = w * rndf(); + y1 = h * rndf(); + vkvg_line_to(ctx, x1, y1); + } + vkvg_stroke(ctx); + vkvg_destroy(ctx); } +void path() { _long_path(); } +void curve() { _long_curve(); } -int main(int argc, char *argv[]) { - dashes_count = 2; - dashes[0] = 0; - dashes[1] = 10; - line_width = 4; - //test_size = 50; - line_cap = VKVG_LINE_CAP_ROUND; - PERFORM_TEST(test, argc, argv); - PERFORM_TEST(path, argc, argv); - PERFORM_TEST(curve, argc, argv); - return 0; +int main(int argc, char *argv[]) { + dashes_count = 2; + dashes[0] = 0; + dashes[1] = 10; + line_width = 4; + // test_size = 50; + line_cap = VKVG_LINE_CAP_ROUND; + PERFORM_TEST(test, argc, argv); + PERFORM_TEST(path, argc, argv); + PERFORM_TEST(curve, argc, argv); + return 0; } diff --git a/tests/fill.c b/tests/fill.c index 5c5223e..1da164e 100644 --- a/tests/fill.c +++ b/tests/fill.c @@ -1,25 +1,25 @@ #include "test.h" -void test(){ - VkvgContext ctx = _initCtx(surf); +void test() { + VkvgContext ctx = _initCtx(surf); - vkvg_set_source_rgba(ctx,0.1f,0.9f,0.1f,1.0f); - vkvg_move_to(ctx,100,100); - vkvg_rel_line_to(ctx,50,200); - vkvg_rel_line_to(ctx,150,-100); - vkvg_rel_line_to(ctx,100,200); - vkvg_rel_line_to(ctx,-100,100); - vkvg_rel_line_to(ctx,-10,-100); - vkvg_rel_line_to(ctx,-190,-50); - vkvg_close_path(ctx); + vkvg_set_source_rgba(ctx, 0.1f, 0.9f, 0.1f, 1.0f); + vkvg_move_to(ctx, 100, 100); + vkvg_rel_line_to(ctx, 50, 200); + vkvg_rel_line_to(ctx, 150, -100); + vkvg_rel_line_to(ctx, 100, 200); + vkvg_rel_line_to(ctx, -100, 100); + vkvg_rel_line_to(ctx, -10, -100); + vkvg_rel_line_to(ctx, -190, -50); + vkvg_close_path(ctx); - vkvg_fill(ctx); + vkvg_fill(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (test, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(test, argc, argv); + return 0; } diff --git a/tests/fill_and_stroke.c b/tests/fill_and_stroke.c index 6e3e21e..e051b26 100644 --- a/tests/fill_and_stroke.c +++ b/tests/fill_and_stroke.c @@ -1,30 +1,30 @@ #include "test.h" -void test(){ - VkvgContext ctx = vkvg_create(surf); +void test() { + VkvgContext ctx = vkvg_create(surf); - vkvg_move_to (ctx, 100, 100); - vkvg_rel_line_to (ctx, 50, -80); - vkvg_rel_line_to (ctx, 50, 80); - vkvg_close_path (ctx); + vkvg_move_to(ctx, 100, 100); + vkvg_rel_line_to(ctx, 50, -80); + vkvg_rel_line_to(ctx, 50, 80); + vkvg_close_path(ctx); - vkvg_move_to (ctx, 300, 100); - vkvg_rel_line_to (ctx, 50, -80); - vkvg_rel_line_to (ctx, 50, 80); - vkvg_close_path (ctx); + vkvg_move_to(ctx, 300, 100); + vkvg_rel_line_to(ctx, 50, -80); + vkvg_rel_line_to(ctx, 50, 80); + vkvg_close_path(ctx); - vkvg_set_line_width (ctx, 10.0); - vkvg_set_source_rgb (ctx, 0, 0, 1); - vkvg_fill_preserve (ctx); - //vkvg_fill(ctx); - vkvg_set_source_rgb (ctx, 1, 0, 0); - vkvg_stroke (ctx); + vkvg_set_line_width(ctx, 10.0); + vkvg_set_source_rgb(ctx, 0, 0, 1); + vkvg_fill_preserve(ctx); + // vkvg_fill(ctx); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (test, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(test, argc, argv); + return 0; } diff --git a/tests/fill_non_zero.c b/tests/fill_non_zero.c index b70c7ee..9c6eb91 100644 --- a/tests/fill_non_zero.c +++ b/tests/fill_non_zero.c @@ -1,31 +1,31 @@ #include "test.h" -void test(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_save(ctx); - vkvg_set_line_width(ctx,30); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); +void test() { + VkvgContext ctx = vkvg_create(surf); + vkvg_save(ctx); + vkvg_set_line_width(ctx, 30); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); - vkvg_set_source_rgba(ctx,0.1f,0.9f,0.1f,1.0f); - vkvg_move_to(ctx,100,100); - vkvg_rel_line_to(ctx,200,0); - vkvg_rel_line_to(ctx,0,150); - vkvg_rel_line_to(ctx,-200,0); - vkvg_close_path(ctx); + vkvg_set_source_rgba(ctx, 0.1f, 0.9f, 0.1f, 1.0f); + vkvg_move_to(ctx, 100, 100); + vkvg_rel_line_to(ctx, 200, 0); + vkvg_rel_line_to(ctx, 0, 150); + vkvg_rel_line_to(ctx, -200, 0); + vkvg_close_path(ctx); - vkvg_move_to(ctx,150,150); - vkvg_rel_line_to(ctx,0,50); - vkvg_rel_line_to(ctx,100,0); - vkvg_rel_line_to(ctx,0,-50); - vkvg_close_path(ctx); + vkvg_move_to(ctx, 150, 150); + vkvg_rel_line_to(ctx, 0, 50); + vkvg_rel_line_to(ctx, 100, 0); + vkvg_rel_line_to(ctx, 0, -50); + vkvg_close_path(ctx); - vkvg_fill(ctx); + vkvg_fill(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (test, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(test, argc, argv); + return 0; } diff --git a/tests/gradient.c b/tests/gradient.c index 9f40b62..e42882a 100644 --- a/tests/gradient.c +++ b/tests/gradient.c @@ -1,159 +1,158 @@ #include "test.h" -VkvgPattern create_grad (VkvgContext ctx, float x) { - VkvgPattern pat = vkvg_pattern_create_linear(x,0,300,0); - vkvg_pattern_add_color_stop(pat, 0, 1, 0, 0, 1); - vkvg_pattern_add_color_stop(pat, 0.5f, 0, 1, 0, 1); - vkvg_pattern_add_color_stop(pat, 1, 0, 0, 1, 1); - return pat; +VkvgPattern create_grad(VkvgContext ctx, float x) { + VkvgPattern pat = vkvg_pattern_create_linear(x, 0, 300, 0); + vkvg_pattern_add_color_stop(pat, 0, 1, 0, 0, 1); + vkvg_pattern_add_color_stop(pat, 0.5f, 0, 1, 0, 1); + vkvg_pattern_add_color_stop(pat, 1, 0, 0, 1, 1); + return pat; } -void paint(){ - VkvgContext ctx = _initCtx (surf); - //vkvg_translate(ctx,100,100); - VkvgPattern pat = create_grad(ctx,0); - //vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); - vkvg_rectangle(ctx, 0,0,400,460); - vkvg_set_source (ctx, pat); - vkvg_pattern_destroy (pat); - vkvg_fill(ctx); +void paint() { + VkvgContext ctx = _initCtx(surf); + // vkvg_translate(ctx,100,100); + VkvgPattern pat = create_grad(ctx, 0); + // vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); + vkvg_rectangle(ctx, 0, 0, 400, 460); + vkvg_set_source(ctx, pat); + vkvg_pattern_destroy(pat); + vkvg_fill(ctx); - float x = 100; - pat = create_grad(ctx,x); - //vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); - vkvg_rectangle(ctx, x,200,50,50); - vkvg_set_source (ctx, pat); - vkvg_pattern_destroy (pat); - vkvg_fill(ctx); + float x = 100; + pat = create_grad(ctx, x); + // vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); + vkvg_rectangle(ctx, x, 200, 50, 50); + vkvg_set_source(ctx, pat); + vkvg_pattern_destroy(pat); + vkvg_fill(ctx); - x+=100; + x += 100; - pat = vkvg_pattern_create_linear(10,0,300,0); - vkvg_pattern_add_color_stop(pat, 0, 0, 0, 1, 0); - vkvg_pattern_add_color_stop(pat, 1, 1, 0, 0, 1); - //vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); - vkvg_rectangle(ctx, 10,10,300,50); - vkvg_set_source (ctx, pat); - vkvg_pattern_destroy (pat); - vkvg_fill(ctx); + pat = vkvg_pattern_create_linear(10, 0, 300, 0); + vkvg_pattern_add_color_stop(pat, 0, 0, 0, 1, 0); + vkvg_pattern_add_color_stop(pat, 1, 1, 0, 0, 1); + // vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); + vkvg_rectangle(ctx, 10, 10, 300, 50); + vkvg_set_source(ctx, pat); + vkvg_pattern_destroy(pat); + vkvg_fill(ctx); - x+=200; + x += 200; - pat = create_grad(ctx,x); - //vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); - vkvg_rectangle(ctx, x,200,50,50); - vkvg_set_source (ctx, pat); - vkvg_pattern_destroy (pat); - vkvg_fill(ctx); + pat = create_grad(ctx, x); + // vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); + vkvg_rectangle(ctx, x, 200, 50, 50); + vkvg_set_source(ctx, pat); + vkvg_pattern_destroy(pat); + vkvg_fill(ctx); - x+=100; + x += 100; - pat = create_grad(ctx,x); - //vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); - vkvg_rectangle(ctx, x,200,50,50); - vkvg_set_source (ctx, pat); - vkvg_pattern_destroy (pat); - vkvg_fill(ctx); + pat = create_grad(ctx, x); + // vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); + vkvg_rectangle(ctx, x, 200, 50, 50); + vkvg_set_source(ctx, pat); + vkvg_pattern_destroy(pat); + vkvg_fill(ctx); - /*vkvg_set_source_rgb(ctx, 0,1,0); - vkvg_rectangle(ctx, 100,100,200,160); - vkvg_fill_preserve(ctx); - vkvg_set_source_rgb(ctx, 0,0,0); - vkvg_set_line_width(ctx,1.0f); - vkvg_stroke(ctx);*/ + /*vkvg_set_source_rgb(ctx, 0,1,0); + vkvg_rectangle(ctx, 100,100,200,160); + vkvg_fill_preserve(ctx); + vkvg_set_source_rgb(ctx, 0,0,0); + vkvg_set_line_width(ctx,1.0f); + vkvg_stroke(ctx);*/ - - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void paint_repeat(){ - VkvgContext ctx = _initCtx (surf); - VkvgPattern pat = create_grad(ctx,0); - vkvg_pattern_set_extend(pat,VKVG_EXTEND_REPEAT); - vkvg_set_source (ctx, pat); - vkvg_pattern_destroy (pat); - vkvg_paint(ctx); +void paint_repeat() { + VkvgContext ctx = _initCtx(surf); + VkvgPattern pat = create_grad(ctx, 0); + vkvg_pattern_set_extend(pat, VKVG_EXTEND_REPEAT); + vkvg_set_source(ctx, pat); + vkvg_pattern_destroy(pat); + vkvg_paint(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void test(){ - VkvgContext ctx = _initCtx (surf); - VkvgPattern pat = create_grad(ctx,0); - vkvg_set_source (ctx, pat); - vkvg_rectangle(ctx,100,100,200,200); - vkvg_set_line_width(ctx, 20); - //vkvg_fill (ctx); - //vkvg_paint(ctx); - vkvg_stroke (ctx); - vkvg_pattern_destroy (pat); +void test() { + VkvgContext ctx = _initCtx(surf); + VkvgPattern pat = create_grad(ctx, 0); + vkvg_set_source(ctx, pat); + vkvg_rectangle(ctx, 100, 100, 200, 200); + vkvg_set_line_width(ctx, 20); + // vkvg_fill (ctx); + // vkvg_paint(ctx); + vkvg_stroke(ctx); + vkvg_pattern_destroy(pat); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void test2(){ - VkvgContext ctx = _initCtx (surf); +void test2() { + VkvgContext ctx = _initCtx(surf); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_paint(ctx); - VkvgPattern pat = vkvg_pattern_create_linear(100,0,300,0); - vkvg_set_line_width(ctx, 20); - vkvg_pattern_add_color_stop(pat, 0, 1, 1, 1, 1); - vkvg_pattern_add_color_stop(pat, 1, 1, 1, 0, 0); - vkvg_set_source (ctx, pat); - vkvg_rectangle(ctx,100,100,200,200); - vkvg_fill (ctx); - //vkvg_stroke (ctx); - vkvg_pattern_destroy (pat); + VkvgPattern pat = vkvg_pattern_create_linear(100, 0, 300, 0); + vkvg_set_line_width(ctx, 20); + vkvg_pattern_add_color_stop(pat, 0, 1, 1, 1, 1); + vkvg_pattern_add_color_stop(pat, 1, 1, 1, 0, 0); + vkvg_set_source(ctx, pat); + vkvg_rectangle(ctx, 100, 100, 200, 200); + vkvg_fill(ctx); + // vkvg_stroke (ctx); + vkvg_pattern_destroy(pat); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } void gradient_transform() { - VkvgContext ctx = _initCtx (surf); + VkvgContext ctx = _initCtx(surf); - //vkvg_translate(ctx,-100,-100); + // vkvg_translate(ctx,-100,-100); - vkvg_translate(ctx, 200, 100); - vkvg_rotate(ctx, 0.5f); + vkvg_translate(ctx, 200, 100); + vkvg_rotate(ctx, 0.5f); - //vkvg_scale(ctx,2,2); - VkvgPattern pat = vkvg_pattern_create_linear(0, 0, 400, 0); - vkvg_pattern_set_extend(pat, VKVG_EXTEND_NONE); - vkvg_set_line_width(ctx, 20); - vkvg_pattern_add_color_stop(pat, 0, 1, 0, 0, 1); - vkvg_pattern_add_color_stop(pat, 0.5f, 0, 1, 0, 1); - vkvg_pattern_add_color_stop(pat, 1, 0, 0, 1, 1); - vkvg_set_source(ctx, pat); - vkvg_rectangle(ctx, 0, 0, 400, 200); - //vkvg_fill (ctx); - vkvg_stroke(ctx); - //vkvg_paint(ctx); - vkvg_pattern_destroy(pat); + // vkvg_scale(ctx,2,2); + VkvgPattern pat = vkvg_pattern_create_linear(0, 0, 400, 0); + vkvg_pattern_set_extend(pat, VKVG_EXTEND_NONE); + vkvg_set_line_width(ctx, 20); + vkvg_pattern_add_color_stop(pat, 0, 1, 0, 0, 1); + vkvg_pattern_add_color_stop(pat, 0.5f, 0, 1, 0, 1); + vkvg_pattern_add_color_stop(pat, 1, 0, 0, 1, 1); + vkvg_set_source(ctx, pat); + vkvg_rectangle(ctx, 0, 0, 400, 200); + // vkvg_fill (ctx); + vkvg_stroke(ctx); + // vkvg_paint(ctx); + vkvg_pattern_destroy(pat); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } void gradient_alpha() { - VkvgContext ctx = _initCtx (surf); - vkvg_set_source_rgb(ctx,0,1,0); - vkvg_paint (ctx); + VkvgContext ctx = _initCtx(surf); + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_paint(ctx); - VkvgPattern pat = vkvg_pattern_create_linear(10,0,300,0); - vkvg_pattern_add_color_stop(pat, 1, 1, 0, 0, 0.5); - vkvg_pattern_add_color_stop(pat, 1, 1, 0, 0, 0.5); + VkvgPattern pat = vkvg_pattern_create_linear(10, 0, 300, 0); + vkvg_pattern_add_color_stop(pat, 1, 1, 0, 0, 0.5); + vkvg_pattern_add_color_stop(pat, 1, 1, 0, 0, 0.5); - vkvg_set_source (ctx, pat); - vkvg_pattern_destroy (pat); - vkvg_rectangle (ctx, 10, 10, 300, 200); - vkvg_fill (ctx); + vkvg_set_source(ctx, pat); + vkvg_pattern_destroy(pat); + vkvg_rectangle(ctx, 10, 10, 300, 200); + vkvg_fill(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST(gradient_alpha, argc, argv); - PERFORM_TEST(paint, argc, argv); - PERFORM_TEST(paint_repeat, argc, argv); - PERFORM_TEST(gradient_transform, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(gradient_alpha, argc, argv); + PERFORM_TEST(paint, argc, argv); + PERFORM_TEST(paint_repeat, argc, argv); + PERFORM_TEST(gradient_transform, argc, argv); + return 0; } diff --git a/tests/gradient2.c b/tests/gradient2.c index 1867f3b..21ffbac 100644 --- a/tests/gradient2.c +++ b/tests/gradient2.c @@ -1,181 +1,166 @@ #include "test.h" #include "vectors.h" -vkvg_fill_rule_t fillrule = VKVG_FILL_RULE_NON_ZERO; -static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; -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; +vkvg_fill_rule_t fillrule = VKVG_FILL_RULE_NON_ZERO; +static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; +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; -int ptsCount = 2; -int initPtsCount = 4; -vec2 pts[] = { - {150,150}, - {250,150}, - {125,125}, - {145,125}, +int ptsCount = 2; +int initPtsCount = 4; +vec2 pts[] = { + {150, 150}, + {250, 150}, + {125, 125}, + {145, 125}, }; -int hoverPt = -1; +int hoverPt = -1; double pointSize = 7; static vkvg_pattern_type_t patternType = VKVG_PATTERN_TYPE_LINEAR; -static VkEngine e; +static VkEngine e; -void draw (){ +void draw() { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - VkvgPattern pat; + VkvgPattern pat; - switch (patternType) { - case VKVG_PATTERN_TYPE_LINEAR: - pat = vkvg_pattern_create_linear(pts[0].x,pts[0].y, pts[1].x,pts[1].y); - break; - case VKVG_PATTERN_TYPE_RADIAL: - pat = vkvg_pattern_create_radial( - pts[2].x,pts[2].y, vec2_length(vec2_sub(pts[3], pts[2])), - pts[0].x,pts[0].y, vec2_length(vec2_sub(pts[1], pts[0])) - ); - break; - } + switch (patternType) { + case VKVG_PATTERN_TYPE_LINEAR: + pat = vkvg_pattern_create_linear(pts[0].x, pts[0].y, pts[1].x, pts[1].y); + break; + case VKVG_PATTERN_TYPE_RADIAL: + pat = vkvg_pattern_create_radial(pts[2].x, pts[2].y, vec2_length(vec2_sub(pts[3], pts[2])), pts[0].x, pts[0].y, + vec2_length(vec2_sub(pts[1], pts[0]))); + break; + } - /**/ + /**/ - vkvg_pattern_add_color_stop(pat, 0.0, 1 ,0 ,0, 0.5); - vkvg_pattern_add_color_stop(pat, 0.3, 0 ,1 ,0, 0.5); - vkvg_pattern_add_color_stop(pat, 0.6, 0 ,0 ,1, 0.5); - vkvg_pattern_add_color_stop(pat, 1.0, 0 ,0 ,0, 0.5); + vkvg_pattern_add_color_stop(pat, 0.0, 1, 0, 0, 0.5); + vkvg_pattern_add_color_stop(pat, 0.3, 0, 1, 0, 0.5); + vkvg_pattern_add_color_stop(pat, 0.6, 0, 0, 1, 0.5); + vkvg_pattern_add_color_stop(pat, 1.0, 0, 0, 0, 0.5); - vkvg_set_source (ctx, pat); - vkvg_paint (ctx); + vkvg_set_source(ctx, pat); + vkvg_paint(ctx); - vkvg_set_dash(ctx, NULL, 0, 0); - vkvg_set_line_width(ctx,1); - for (int i=0; i<ptsCount; i++) { - if (hoverPt == i) - vkvg_set_source_rgba(ctx,0.5f,0.5f,1.0f,0.7f); - else - vkvg_set_source_rgba(ctx,1.0f,0.5f,0.5f,0.9f); - vkvg_arc(ctx, pts[i].x, pts[i].y, pointSize, 0, M_PIF*2); - vkvg_fill_preserve(ctx); - vkvg_stroke(ctx); - } + vkvg_set_dash(ctx, NULL, 0, 0); + vkvg_set_line_width(ctx, 1); + for (int i = 0; i < ptsCount; i++) { + if (hoverPt == i) + vkvg_set_source_rgba(ctx, 0.5f, 0.5f, 1.0f, 0.7f); + else + vkvg_set_source_rgba(ctx, 1.0f, 0.5f, 0.5f, 0.9f); + vkvg_arc(ctx, pts[i].x, pts[i].y, pointSize, 0, M_PIF * 2); + vkvg_fill_preserve(ctx); + vkvg_stroke(ctx); + } - - vkvg_pattern_destroy (pat); - vkvg_destroy (ctx); + vkvg_pattern_destroy(pat); + vkvg_destroy(ctx); } -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { - if (action != GLFW_PRESS) - return; - switch (key) { - case GLFW_KEY_ESCAPE : - glfwSetWindowShouldClose(window, GLFW_TRUE); - break; - case GLFW_KEY_P : - patternType++; - if (patternType > VKVG_PATTERN_TYPE_RADIAL) - patternType = VKVG_PATTERN_TYPE_LINEAR; - break; - case GLFW_KEY_S : - vkengine_wait_idle(e); - vkvg_surface_write_to_png(surf, "/home/jp/test.png"); - break; - case GLFW_KEY_KP_ADD : - if (ptsCount < initPtsCount) - ptsCount++; - break; - case GLFW_KEY_KP_SUBTRACT : - if (ptsCount > 1) - ptsCount--; - break; - } +static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) { + if (action != GLFW_PRESS) + return; + switch (key) { + case GLFW_KEY_ESCAPE: + glfwSetWindowShouldClose(window, GLFW_TRUE); + break; + case GLFW_KEY_P: + patternType++; + if (patternType > VKVG_PATTERN_TYPE_RADIAL) + patternType = VKVG_PATTERN_TYPE_LINEAR; + break; + case GLFW_KEY_S: + vkengine_wait_idle(e); + vkvg_surface_write_to_png(surf, "/home/jp/test.png"); + break; + case GLFW_KEY_KP_ADD: + if (ptsCount < initPtsCount) + ptsCount++; + break; + case GLFW_KEY_KP_SUBTRACT: + if (ptsCount > 1) + ptsCount--; + break; + } } -static void mouse_move_callback(GLFWwindow* window, double x, double y){ - if (mouseDown) { - if (hoverPt < 0) - return; - pts[hoverPt].x = x; - pts[hoverPt].y = y; - } else { - for (int i=0; i<ptsCount; i++) { - if (x > pts[i].x - pointSize && - x < pts[i].x + pointSize && - y > pts[i].y - pointSize && - y < pts[i].y + pointSize) { - hoverPt = i; - return; - } - } - hoverPt = -1; - } +static void mouse_move_callback(GLFWwindow *window, double x, double y) { + if (mouseDown) { + if (hoverPt < 0) + return; + pts[hoverPt].x = x; + pts[hoverPt].y = y; + } else { + for (int i = 0; i < ptsCount; i++) { + if (x > pts[i].x - pointSize && x < pts[i].x + pointSize && y > pts[i].y - pointSize && + y < pts[i].y + pointSize) { + hoverPt = i; + return; + } + } + hoverPt = -1; + } } -static void scroll_callback(GLFWwindow* window, double x, double y){ - if (y<0.f) - zoom *= 0.5f; - else - zoom *= 2.0f; +static void scroll_callback(GLFWwindow *window, double x, double y) { + if (y < 0.f) + zoom *= 0.5f; + else + zoom *= 2.0f; } -static void mouse_button_callback(GLFWwindow* window, int but, int state, int modif){ - if (but != GLFW_MOUSE_BUTTON_1) - return; - if (state == GLFW_TRUE) - mouseDown = true; - else - mouseDown = false; +static void mouse_button_callback(GLFWwindow *window, int but, int state, int modif) { + if (but != GLFW_MOUSE_BUTTON_1) + return; + if (state == GLFW_TRUE) + mouseDown = true; + else + mouseDown = false; } +int main(int argc, char *argv[]) { + _parse_args(argc, argv); -int main(int argc, char* argv[]) { - - _parse_args (argc, argv); - - e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); + e = vkengine_create(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); - VkhPresenter r = e->renderer; - vkengine_set_key_callback (e, key_callback); - vkengine_set_mouse_but_callback(e, mouse_button_callback); - vkengine_set_cursor_pos_callback(e, mouse_move_callback); - vkengine_set_scroll_callback(e, scroll_callback); + VkhPresenter r = e->renderer; + vkengine_set_key_callback(e, key_callback); + vkengine_set_mouse_but_callback(e, mouse_button_callback); + vkengine_set_cursor_pos_callback(e, mouse_move_callback); + vkengine_set_scroll_callback(e, scroll_callback); - vkvg_device_create_info_t info = { - samples, - false, - vkh_app_get_inst(e->app), - r->dev->phy, - r->dev->dev, - r->qFam, - 0 - }; - device = vkvg_device_create(&info); - surf = vkvg_surface_create(device, test_width, test_height); + vkvg_device_create_info_t info = {samples, false, vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0}; + device = vkvg_device_create(&info); + surf = vkvg_surface_create(device, test_width, test_height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); - while (!vkengine_should_close (e)) { - glfwPollEvents(); + while (!vkengine_should_close(e)) { + glfwPollEvents(); - draw (); + draw(); - if (!vkh_presenter_draw (r)){ - vkh_presenter_get_size (r, &test_width, &test_height); - vkvg_surface_destroy (surf); - surf = vkvg_surface_create(device, test_width, test_height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); - vkDeviceWaitIdle(r->dev->dev); - continue; - } - } - vkDeviceWaitIdle(e->dev->dev); + if (!vkh_presenter_draw(r)) { + vkh_presenter_get_size(r, &test_width, &test_height); + vkvg_surface_destroy(surf); + surf = vkvg_surface_create(device, test_width, test_height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); + vkDeviceWaitIdle(r->dev->dev); + continue; + } + } + vkDeviceWaitIdle(e->dev->dev); - vkvg_surface_destroy (surf); + vkvg_surface_destroy(surf); - vkvg_device_destroy (device); + vkvg_device_destroy(device); - vkengine_destroy (e); + vkengine_destroy(e); - return 0; + return 0; } diff --git a/tests/img_surf.c b/tests/img_surf.c index bffc65c..66d66b7 100644 --- a/tests/img_surf.c +++ b/tests/img_surf.c @@ -1,174 +1,174 @@ #include "test.h" -const char* imgPath = "data/miroir.jpg"; -void paint () { - VkvgContext ctx = vkvg_create(surf); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); +const char *imgPath = "data/miroir.jpg"; +void paint() { + VkvgContext ctx = vkvg_create(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - vkvg_set_source_surface(ctx, imgSurf, 0, 0); - vkvg_paint(ctx); + vkvg_set_source_surface(ctx, imgSurf, 0, 0); + vkvg_paint(ctx); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } -void paint_offset () { - VkvgContext ctx = vkvg_create(surf); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); +void paint_offset() { + VkvgContext ctx = vkvg_create(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - vkvg_set_source_surface(ctx, imgSurf, 100, 100); - vkvg_paint(ctx); + vkvg_set_source_surface(ctx, imgSurf, 100, 100); + vkvg_paint(ctx); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } -void paint_with_scale(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_scale (ctx, 0.2f,0.2f); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - vkvg_set_source_surface(ctx, imgSurf, 0, 0); +void paint_with_scale() { + VkvgContext ctx = vkvg_create(surf); + vkvg_scale(ctx, 0.2f, 0.2f); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); + vkvg_set_source_surface(ctx, imgSurf, 0, 0); - vkvg_paint(ctx); + vkvg_paint(ctx); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } -void translate(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_translate (ctx, 150,50); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - vkvg_set_source_surface(ctx, imgSurf, 0, 0); +void translate() { + VkvgContext ctx = vkvg_create(surf); + vkvg_translate(ctx, 150, 50); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); + vkvg_set_source_surface(ctx, imgSurf, 0, 0); - vkvg_paint(ctx); + vkvg_paint(ctx); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } -void offset_and_scale(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_scale (ctx, 0.2f,0.2f); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - vkvg_set_source_surface(ctx, imgSurf, 100, 100); +void offset_and_scale() { + VkvgContext ctx = vkvg_create(surf); + vkvg_scale(ctx, 0.2f, 0.2f); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); + vkvg_set_source_surface(ctx, imgSurf, 100, 100); - vkvg_paint(ctx); + vkvg_paint(ctx); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } static float angle = 0; -void paint_with_rot(){ - angle += 0.005; - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); +void paint_with_rot() { + angle += 0.005; + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - vkvg_rotate (ctx, angle); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - vkvg_set_source_surface(ctx, imgSurf, 0, 0); + vkvg_rotate(ctx, angle); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); + vkvg_set_source_surface(ctx, imgSurf, 0, 0); - vkvg_paint(ctx); + vkvg_paint(ctx); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } -void offset_and_rot(){ - angle += 0.005; - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); +void offset_and_rot() { + angle += 0.005; + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - vkvg_rotate (ctx, angle); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - vkvg_set_source_surface(ctx, imgSurf, 100, 100); + vkvg_rotate(ctx, angle); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); + vkvg_set_source_surface(ctx, imgSurf, 100, 100); - vkvg_paint(ctx); + vkvg_paint(ctx); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } -void paint_pattern () { - VkvgContext ctx = vkvg_create(surf); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); - vkvg_set_source(ctx, pat); - vkvg_paint(ctx); - vkvg_pattern_destroy(pat); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); +void paint_pattern() { + VkvgContext ctx = vkvg_create(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); + VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); + vkvg_set_source(ctx, pat); + vkvg_paint(ctx); + vkvg_pattern_destroy(pat); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } -void paint_patt_repeat () { - VkvgContext ctx = vkvg_create(surf); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); - vkvg_pattern_set_extend(pat,VKVG_EXTEND_REPEAT); - vkvg_set_source(ctx, pat); - vkvg_paint(ctx); - vkvg_pattern_destroy(pat); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); +void paint_patt_repeat() { + VkvgContext ctx = vkvg_create(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); + VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); + vkvg_pattern_set_extend(pat, VKVG_EXTEND_REPEAT); + vkvg_set_source(ctx, pat); + vkvg_paint(ctx); + vkvg_pattern_destroy(pat); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } -void paint_patt_repeat_scalled () { - VkvgContext ctx = vkvg_create(surf); - vkvg_scale (ctx, 0.2f,0.2f); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); - vkvg_pattern_set_extend(pat,VKVG_EXTEND_REPEAT); - vkvg_set_source(ctx, pat); - vkvg_paint(ctx); - vkvg_pattern_destroy(pat); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); +void paint_patt_repeat_scalled() { + VkvgContext ctx = vkvg_create(surf); + vkvg_scale(ctx, 0.2f, 0.2f); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); + VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); + vkvg_pattern_set_extend(pat, VKVG_EXTEND_REPEAT); + vkvg_set_source(ctx, pat); + vkvg_paint(ctx); + vkvg_pattern_destroy(pat); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } -void paint_patt_pad () { - VkvgContext ctx = vkvg_create(surf); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); - vkvg_pattern_set_extend(pat,VKVG_EXTEND_PAD); - vkvg_set_source(ctx, pat); - vkvg_paint(ctx); - vkvg_pattern_destroy(pat); - vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); +void paint_patt_pad() { + VkvgContext ctx = vkvg_create(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); + VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); + vkvg_pattern_set_extend(pat, VKVG_EXTEND_PAD); + vkvg_set_source(ctx, pat); + vkvg_paint(ctx); + vkvg_pattern_destroy(pat); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); } -void test(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx,VKVG_FILL_RULE_EVEN_ODD); - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); +void test() { + VkvgContext ctx = vkvg_create(surf); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - vkvg_translate(ctx,200,200); - //vkvg_rotate(ctx,M_PI_4); + vkvg_translate(ctx, 200, 200); + // vkvg_rotate(ctx,M_PI_4); - vkvg_set_line_width(ctx,20.f); - //vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_arc(ctx,200,200,200,0,2.f*M_PIF); - vkvg_new_sub_path(ctx); - vkvg_arc(ctx,200,200,100,0,2.f*M_PIF); + vkvg_set_line_width(ctx, 20.f); + // vkvg_set_source_rgba(ctx,1,0,0,1); + vkvg_arc(ctx, 200, 200, 200, 0, 2.f * M_PIF); + vkvg_new_sub_path(ctx); + vkvg_arc(ctx, 200, 200, 100, 0, 2.f * M_PIF); - vkvg_set_source_surface(ctx, imgSurf, 0, 0); - vkvg_fill_preserve(ctx); - vkvg_set_source_rgba(ctx,0.2f,0.3f,0.8f,1); + vkvg_set_source_surface(ctx, imgSurf, 0, 0); + vkvg_fill_preserve(ctx); + vkvg_set_source_rgba(ctx, 0.2f, 0.3f, 0.8f, 1); - vkvg_stroke(ctx); + vkvg_stroke(ctx); - vkvg_surface_destroy(imgSurf); + vkvg_surface_destroy(imgSurf); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (paint, argc, argv); - PERFORM_TEST (paint_offset, argc, argv); - PERFORM_TEST (paint_with_scale, argc, argv); - PERFORM_TEST (offset_and_scale, argc, argv); - PERFORM_TEST (translate, argc, argv); - PERFORM_TEST (paint_with_rot, argc, argv); - PERFORM_TEST (offset_and_rot, argc, argv); - PERFORM_TEST (paint_pattern, argc, argv); - PERFORM_TEST (paint_patt_repeat, argc, argv); - PERFORM_TEST (paint_patt_repeat_scalled, argc, argv); - PERFORM_TEST (paint_patt_pad, argc, argv); - PERFORM_TEST (test, argc, argv); + no_test_size = true; + PERFORM_TEST(paint, argc, argv); + PERFORM_TEST(paint_offset, argc, argv); + PERFORM_TEST(paint_with_scale, argc, argv); + PERFORM_TEST(offset_and_scale, argc, argv); + PERFORM_TEST(translate, argc, argv); + PERFORM_TEST(paint_with_rot, argc, argv); + PERFORM_TEST(offset_and_rot, argc, argv); + PERFORM_TEST(paint_pattern, argc, argv); + PERFORM_TEST(paint_patt_repeat, argc, argv); + PERFORM_TEST(paint_patt_repeat_scalled, argc, argv); + PERFORM_TEST(paint_patt_pad, argc, argv); + PERFORM_TEST(test, argc, argv); - return 0; + return 0; } diff --git a/tests/inverse_colinear.c b/tests/inverse_colinear.c index 38b4adc..2b5735c 100644 --- a/tests/inverse_colinear.c +++ b/tests/inverse_colinear.c @@ -1,227 +1,209 @@ #include "test.h" #include "vectors.h" -vkvg_fill_rule_t fillrule = VKVG_FILL_RULE_NON_ZERO; -static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; -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; +vkvg_fill_rule_t fillrule = VKVG_FILL_RULE_NON_ZERO; +static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; +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 = 5; -vec2 pts[] = { - {150,150}, - {200,300}, - {250,150}, - {280,350}, - {300,100}, +int ptsCount = 4; +int initPtsCount = 5; +vec2 pts[] = { + {150, 150}, {200, 300}, {250, 150}, {280, 350}, {300, 100}, }; /*vec2 pts[] = { - {150,150}, - {250,150}, - {100,150}, - {150,200}, + {150,150}, + {250,150}, + {100,150}, + {150,200}, };*/ -int hoverPt = -1; +int hoverPt = -1; double pointSize = 7; -float dash[] = {0, 60}; +float dash[] = {0, 60}; uint32_t dashCountInit = 2; -uint32_t dashCount = 0; -float miterLimit = 10.0f; +uint32_t dashCount = 0; +float miterLimit = 10.0f; +void draw() { + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); + if (dashCount > 0) + vkvg_set_dash(ctx, dash, dashCount, 0); + vkvg_set_source_rgba(ctx, 1, 0, 0, 0.3f); + vkvg_set_line_width(ctx, lineWidth); + vkvg_set_line_join(ctx, lineJoin); + vkvg_set_line_cap(ctx, lineCap); + vkvg_set_miter_limit(ctx, miterLimit); -void draw (){ + if (startWithArc) + vkvg_arc_negative(ctx, pts[0].x, pts[0].y, 200, M_PIF * 1.5f, 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_negative(ctx, pts[ptsCount - 1].x, pts[ptsCount - 1].y, 200, M_PIF * 1.5f, M_PIF); + else + vkvg_line_to(ctx, pts[ptsCount - 1].x, pts[ptsCount - 1].y); - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); - if (dashCount > 0) - vkvg_set_dash(ctx, dash, dashCount,0); - vkvg_set_source_rgba (ctx,1,0,0,0.3f); - vkvg_set_line_width (ctx,lineWidth); - vkvg_set_line_join (ctx, lineJoin); - vkvg_set_line_cap (ctx, lineCap); - vkvg_set_miter_limit (ctx, miterLimit); + if (isClosed) + vkvg_close_path(ctx); - if (startWithArc) - vkvg_arc_negative(ctx,pts[0].x,pts[0].y,200, M_PIF*1.5f, 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_negative(ctx,pts[ptsCount-1].x,pts[ptsCount-1].y,200, M_PIF*1.5f, M_PIF); - else - vkvg_line_to(ctx,pts[ptsCount-1].x,pts[ptsCount-1].y); + if (hoverPt >= 0) { + vkvg_stroke_preserve(ctx); + vkvg_set_dash(ctx, NULL, 0, 0); + vkvg_set_line_width(ctx, 2); + vkvg_set_source_rgba(ctx, 0, 0, 0, 1); + vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 0.5f, 0.5f, 1.0f, 0.7f); + vkvg_arc(ctx, pts[hoverPt].x, pts[hoverPt].y, pointSize, 0, M_PIF * 2); + vkvg_fill_preserve(ctx); + vkvg_stroke(ctx); + } else + vkvg_stroke(ctx); - if (isClosed) - vkvg_close_path(ctx); - - if (hoverPt>=0) { - vkvg_stroke_preserve(ctx); - vkvg_set_dash(ctx, NULL, 0, 0); - vkvg_set_line_width(ctx,2); - vkvg_set_source_rgba(ctx,0,0,0,1); - vkvg_stroke(ctx); - vkvg_set_source_rgba(ctx,0.5f,0.5f,1.0f,0.7f); - vkvg_arc (ctx, pts[hoverPt].x, pts[hoverPt].y, pointSize, 0, M_PIF*2); - vkvg_fill_preserve(ctx); - vkvg_stroke(ctx); - } else - vkvg_stroke(ctx); - - //draw_v(ctx, 200, 20, VKVG_LINE_JOIN_BEVEL); - //draw_v(ctx, 300, 80, VKVG_LINE_JOIN_ROUND); - vkvg_destroy(ctx); + // draw_v(ctx, 200, 20, VKVG_LINE_JOIN_BEVEL); + // draw_v(ctx, 300, 80, VKVG_LINE_JOIN_ROUND); + vkvg_destroy(ctx); } -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { - if (action == GLFW_RELEASE) - return; - switch (key) { - case GLFW_KEY_ESCAPE : - glfwSetWindowShouldClose(window, GLFW_TRUE); - break; - 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) - lineJoin = 0; - break; - case GLFW_KEY_C : - lineCap++; - if (lineCap > 2) - lineCap = 0; - break; - case GLFW_KEY_D : - if (dashCount == 0) - dashCount = dashCountInit; - else - dashCount = 0; - break; - case GLFW_KEY_E : - if (dash[0] > 0) - dash[0] = 0; - else - dash[0] = 80; - break; - case GLFW_KEY_L : - if (mods & GLFW_MOD_SHIFT) - miterLimit /= 2.0f; - else - miterLimit *= 2.0f; - break; - case GLFW_KEY_P : - if (mods & GLFW_MOD_SHIFT) { - if (ptsCount > 1) - ptsCount--; - } else { - if (ptsCount < initPtsCount) - ptsCount++; - } - break; - case GLFW_KEY_KP_ADD : - lineWidth++; - break; - case GLFW_KEY_KP_SUBTRACT : - if (lineWidth > 1) - lineWidth--; - break; - } +static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) { + if (action == GLFW_RELEASE) + return; + switch (key) { + case GLFW_KEY_ESCAPE: + glfwSetWindowShouldClose(window, GLFW_TRUE); + break; + 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) + lineJoin = 0; + break; + case GLFW_KEY_C: + lineCap++; + if (lineCap > 2) + lineCap = 0; + break; + case GLFW_KEY_D: + if (dashCount == 0) + dashCount = dashCountInit; + else + dashCount = 0; + break; + case GLFW_KEY_E: + if (dash[0] > 0) + dash[0] = 0; + else + dash[0] = 80; + break; + case GLFW_KEY_L: + if (mods & GLFW_MOD_SHIFT) + miterLimit /= 2.0f; + else + miterLimit *= 2.0f; + break; + case GLFW_KEY_P: + if (mods & GLFW_MOD_SHIFT) { + if (ptsCount > 1) + ptsCount--; + } else { + if (ptsCount < initPtsCount) + ptsCount++; + } + break; + case GLFW_KEY_KP_ADD: + lineWidth++; + break; + case GLFW_KEY_KP_SUBTRACT: + if (lineWidth > 1) + lineWidth--; + break; + } } -static void mouse_move_callback(GLFWwindow* window, double x, double y){ - if (mouseDown) { - if (hoverPt < 0) - return; - pts[hoverPt].x = x; - pts[hoverPt].y = y; - } else { - for (int i=0; i<ptsCount; i++) { - if (x > pts[i].x - pointSize && - x < pts[i].x + pointSize && - y > pts[i].y - pointSize && - y < pts[i].y + pointSize) { - hoverPt = i; - return; - } - } - hoverPt = -1; - } +static void mouse_move_callback(GLFWwindow *window, double x, double y) { + if (mouseDown) { + if (hoverPt < 0) + return; + pts[hoverPt].x = x; + pts[hoverPt].y = y; + } else { + for (int i = 0; i < ptsCount; i++) { + if (x > pts[i].x - pointSize && x < pts[i].x + pointSize && y > pts[i].y - pointSize && + y < pts[i].y + pointSize) { + hoverPt = i; + return; + } + } + hoverPt = -1; + } } -static void scroll_callback(GLFWwindow* window, double x, double y){ - if (y<0.f) - zoom *= 0.5f; - else - zoom *= 2.0f; +static void scroll_callback(GLFWwindow *window, double x, double y) { + if (y < 0.f) + zoom *= 0.5f; + else + zoom *= 2.0f; } -static void mouse_button_callback(GLFWwindow* window, int but, int state, int modif){ - if (but != GLFW_MOUSE_BUTTON_1) - return; - if (state == GLFW_TRUE) - mouseDown = true; - else - mouseDown = false; +static void mouse_button_callback(GLFWwindow *window, int but, int state, int modif) { + if (but != GLFW_MOUSE_BUTTON_1) + return; + if (state == GLFW_TRUE) + mouseDown = true; + else + mouseDown = false; } +int main(int argc, char *argv[]) { + _parse_args(argc, argv); + VkEngine e; + e = vkengine_create(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); -int main(int argc, char* argv[]) { - - _parse_args (argc, argv); - VkEngine e; - e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); - - VkhPresenter r = e->renderer; - vkengine_set_key_callback (e, key_callback); - vkengine_set_mouse_but_callback(e, mouse_button_callback); - vkengine_set_cursor_pos_callback(e, mouse_move_callback); - vkengine_set_scroll_callback(e, scroll_callback); + VkhPresenter r = e->renderer; + vkengine_set_key_callback(e, key_callback); + vkengine_set_mouse_but_callback(e, mouse_button_callback); + vkengine_set_cursor_pos_callback(e, mouse_move_callback); + vkengine_set_scroll_callback(e, scroll_callback); - vkvg_device_create_info_t info = { - samples, - false, - vkh_app_get_inst(e->app), - r->dev->phy, - r->dev->dev, - r->qFam, - 0 - }; - device = vkvg_device_create(&info); - surf = vkvg_surface_create(device, test_width, test_height); + vkvg_device_create_info_t info = {samples, false, vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0}; + device = vkvg_device_create(&info); + surf = vkvg_surface_create(device, test_width, test_height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); - while (!vkengine_should_close (e)) { - glfwPollEvents(); + while (!vkengine_should_close(e)) { + glfwPollEvents(); - draw (); + draw(); - if (!vkh_presenter_draw (r)){ - vkh_presenter_get_size (r, &test_width, &test_height); - vkvg_surface_destroy (surf); - surf = vkvg_surface_create(device, test_width, test_height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); - vkDeviceWaitIdle(r->dev->dev); - continue; - } - } - vkDeviceWaitIdle(e->dev->dev); + if (!vkh_presenter_draw(r)) { + vkh_presenter_get_size(r, &test_width, &test_height); + vkvg_surface_destroy(surf); + surf = vkvg_surface_create(device, test_width, test_height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); + vkDeviceWaitIdle(r->dev->dev); + continue; + } + } + vkDeviceWaitIdle(e->dev->dev); - vkvg_surface_destroy (surf); + vkvg_surface_destroy(surf); - vkvg_device_destroy (device); + vkvg_device_destroy(device); - vkengine_destroy (e); + vkengine_destroy(e); - return 0; + return 0; } diff --git a/tests/line_caps.c b/tests/line_caps.c index 2ad0129..82a33dc 100644 --- a/tests/line_caps.c +++ b/tests/line_caps.c @@ -1,58 +1,58 @@ #include "test.h" -void test(){ - VkvgContext ctx = vkvg_create(surf); - vkvg_set_source_rgba(ctx,0.9f,0.9f,0.9f,1); - vkvg_paint(ctx); +void test() { + VkvgContext ctx = vkvg_create(surf); + vkvg_set_source_rgba(ctx, 0.9f, 0.9f, 0.9f, 1); + vkvg_paint(ctx); - float x = 20, y = 20, dx = 40, dy = 60; + float x = 20, y = 20, dx = 40, dy = 60; - //vkvg_scale(ctx,5,5); - vkvg_set_line_width(ctx,30); - vkvg_set_source_rgba(ctx,0.0,0.0,0,1); - vkvg_move_to(ctx,x,y); - vkvg_rel_line_to(ctx,0,dy); - vkvg_stroke(ctx); - vkvg_set_line_cap(ctx,VKVG_LINE_CAP_SQUARE); - vkvg_move_to(ctx,x+dx,y); - vkvg_rel_line_to(ctx,0,dy); - vkvg_stroke(ctx); - vkvg_set_line_cap(ctx,VKVG_LINE_CAP_ROUND); - vkvg_move_to(ctx,x+2*dx,y); - vkvg_rel_line_to(ctx,0,dy); - vkvg_rel_move_to(ctx,dx,-dy); - vkvg_rel_line_to(ctx,dx,dy); - vkvg_rel_move_to(ctx,dx,-dy/2.f); - vkvg_rel_line_to(ctx,dx,0); - vkvg_rel_move_to(ctx,dx,dy/2.f); - vkvg_rel_line_to(ctx,dx,-dy); - vkvg_rel_move_to(ctx,dx,dy); - vkvg_rel_line_to(ctx,0,-dy); - vkvg_rel_move_to(ctx,dx*2.f,dy); - vkvg_rel_line_to(ctx,-dx,-dy); - vkvg_rel_move_to(ctx,dx*3.f,dy/2.f); - vkvg_rel_line_to(ctx,-dx,0); - //vkvg_rel_line_to(ctx,0,-dy); - //vkvg_rel_move_to(ctx,dx,dy/2); - //vkvg_rel_line_to(ctx,dx,0); - vkvg_stroke(ctx); + // vkvg_scale(ctx,5,5); + vkvg_set_line_width(ctx, 30); + vkvg_set_source_rgba(ctx, 0.0, 0.0, 0, 1); + vkvg_move_to(ctx, x, y); + vkvg_rel_line_to(ctx, 0, dy); + vkvg_stroke(ctx); + vkvg_set_line_cap(ctx, VKVG_LINE_CAP_SQUARE); + vkvg_move_to(ctx, x + dx, y); + vkvg_rel_line_to(ctx, 0, dy); + vkvg_stroke(ctx); + vkvg_set_line_cap(ctx, VKVG_LINE_CAP_ROUND); + vkvg_move_to(ctx, x + 2 * dx, y); + vkvg_rel_line_to(ctx, 0, dy); + vkvg_rel_move_to(ctx, dx, -dy); + vkvg_rel_line_to(ctx, dx, dy); + vkvg_rel_move_to(ctx, dx, -dy / 2.f); + vkvg_rel_line_to(ctx, dx, 0); + vkvg_rel_move_to(ctx, dx, dy / 2.f); + vkvg_rel_line_to(ctx, dx, -dy); + vkvg_rel_move_to(ctx, dx, dy); + vkvg_rel_line_to(ctx, 0, -dy); + vkvg_rel_move_to(ctx, dx * 2.f, dy); + vkvg_rel_line_to(ctx, -dx, -dy); + vkvg_rel_move_to(ctx, dx * 3.f, dy / 2.f); + vkvg_rel_line_to(ctx, -dx, 0); + // vkvg_rel_line_to(ctx,0,-dy); + // vkvg_rel_move_to(ctx,dx,dy/2); + // vkvg_rel_line_to(ctx,dx,0); + vkvg_stroke(ctx); - vkvg_set_line_cap(ctx,VKVG_LINE_CAP_BUTT); - vkvg_set_line_width(ctx,1); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_move_to(ctx,x,y); - vkvg_rel_line_to(ctx,0,dy); - vkvg_rel_move_to(ctx,dx,-dy); - vkvg_rel_line_to(ctx,0,dy); - vkvg_rel_move_to(ctx,dx,-dy); - vkvg_rel_line_to(ctx,0,dy); - vkvg_stroke(ctx); + vkvg_set_line_cap(ctx, VKVG_LINE_CAP_BUTT); + vkvg_set_line_width(ctx, 1); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_move_to(ctx, x, y); + vkvg_rel_line_to(ctx, 0, dy); + vkvg_rel_move_to(ctx, dx, -dy); + vkvg_rel_line_to(ctx, 0, dy); + vkvg_rel_move_to(ctx, dx, -dy); + vkvg_rel_line_to(ctx, 0, dy); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (test, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(test, argc, argv); + return 0; } diff --git a/tests/line_join.c b/tests/line_join.c index 779b8cc..f34ad70 100644 --- a/tests/line_join.c +++ b/tests/line_join.c @@ -1,182 +1,180 @@ #include "test.h" -void test(){ - VkvgContext ctx = vkvg_create(surf); +void test() { + VkvgContext ctx = vkvg_create(surf); - float x = 250, y = 150; + float x = 250, y = 150; - //vkvg_scale(ctx,2,2); + // vkvg_scale(ctx,2,2); - vkvg_set_line_width(ctx,100); - vkvg_set_source_rgba(ctx,0,1,0,1); + vkvg_set_line_width(ctx, 100); + 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_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, 0, 60); + vkvg_rel_line_to(ctx, 50, 30); + /* + 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_close_path(ctx); + vkvg_stroke(ctx); - vkvg_move_to(ctx,x,y); - vkvg_rel_line_to(ctx,-50,30); - vkvg_rel_line_to(ctx,0,60); - vkvg_rel_line_to(ctx,50,30); - /* - 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_close_path(ctx); - vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx,1,0,0,1); + vkvg_move_to(ctx,x+200,y); + vkvg_rel_line_to(ctx,50,70); + vkvg_rel_line_to(ctx,50,0); + vkvg_rel_line_to(ctx,50,-70); + vkvg_rel_line_to(ctx,0,-60); + vkvg_rel_line_to(ctx,-50,-30); + vkvg_rel_line_to(ctx,-50,0); + vkvg_rel_line_to(ctx,-50,30);*/ + vkvg_close_path(ctx); + vkvg_stroke(ctx); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_move_to(ctx,x+200,y); - vkvg_rel_line_to(ctx,50,70); - vkvg_rel_line_to(ctx,50,0); - vkvg_rel_line_to(ctx,50,-70); - vkvg_rel_line_to(ctx,0,-60); - vkvg_rel_line_to(ctx,-50,-30); - vkvg_rel_line_to(ctx,-50,0); - vkvg_rel_line_to(ctx,-50,30);*/ - vkvg_close_path(ctx); - vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 0, 0, 1, 1); + vkvg_move_to(ctx, x + 250, 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_close_path(ctx); + vkvg_stroke(ctx); - vkvg_set_source_rgba(ctx,0,0,1,1); - vkvg_move_to(ctx,x+250,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_close_path(ctx); - vkvg_stroke(ctx); + // float dx = 150, dy = 140; + // vkvg_rel_line_to(ctx,dx,-dy); + // vkvg_rel_line_to(ctx,dx,dy); + // vkvg_stroke(ctx); + // vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL); + // vkvg_rel_move_to(ctx,-dx*2,abs(dy*1.5)); + // vkvg_rel_line_to(ctx,dx,-dy); + // vkvg_rel_line_to(ctx,dx,dy); + // vkvg_stroke(ctx); + // vkvg_set_line_join(ctx,VKVG_LINE_JOIN_ROUND); + // vkvg_rel_move_to(ctx,-dx*2,abs(dy*1.5)); + // vkvg_rel_line_to(ctx,dx,-dy); + // vkvg_rel_line_to(ctx,dx,dy); + // vkvg_stroke(ctx); + // vkvg_set_line_join(ctx,VKVG_LINE_JOIN_MITER); -// float dx = 150, dy = 140; -// vkvg_rel_line_to(ctx,dx,-dy); -// vkvg_rel_line_to(ctx,dx,dy); -// vkvg_stroke(ctx); -// vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL); -// vkvg_rel_move_to(ctx,-dx*2,abs(dy*1.5)); -// vkvg_rel_line_to(ctx,dx,-dy); -// vkvg_rel_line_to(ctx,dx,dy); -// vkvg_stroke(ctx); -// vkvg_set_line_join(ctx,VKVG_LINE_JOIN_ROUND); -// vkvg_rel_move_to(ctx,-dx*2,abs(dy*1.5)); -// vkvg_rel_line_to(ctx,dx,-dy); -// vkvg_rel_line_to(ctx,dx,dy); -// vkvg_stroke(ctx); -// vkvg_set_line_join(ctx,VKVG_LINE_JOIN_MITER); - - vkvg_destroy(ctx); + vkvg_destroy(ctx); } void test2() { - VkvgContext ctx = vkvg_create(surf); + VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); - vkvg_set_line_width(ctx, 30); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_line_width(ctx, 30); - vkvg_set_line_join(ctx, VKVG_LINE_JOIN_ROUND); + vkvg_set_line_join(ctx, VKVG_LINE_JOIN_ROUND); - //vkvg_arc (ctx, 200, 500, 100, 0, M_PI); + // vkvg_arc (ctx, 200, 500, 100, 0, M_PI); - vkvg_translate(ctx, -50, -50); + vkvg_translate(ctx, -50, -50); - vkvg_set_source_rgb(ctx, 0.5, 0, 0); + vkvg_set_source_rgb(ctx, 0.5, 0, 0); - for (int j = 0; j < 2; j++) { - int i = 0; - vkvg_move_to(ctx, 100, 100); - for (i = 0; i < 5; i++) { - vkvg_rel_line_to(ctx, 70, 50); - vkvg_rel_line_to(ctx, -70, 50); - } - vkvg_stroke(ctx); + for (int j = 0; j < 2; j++) { + int i = 0; + vkvg_move_to(ctx, 100, 100); + for (i = 0; i < 5; i++) { + vkvg_rel_line_to(ctx, 70, 50); + vkvg_rel_line_to(ctx, -70, 50); + } + vkvg_stroke(ctx); - vkvg_move_to(ctx, 200, 600); - for (i = 0; i < 5; i++) { - vkvg_rel_line_to(ctx, 70, -50); - vkvg_rel_line_to(ctx, -70, -50); - } - vkvg_stroke(ctx); + vkvg_move_to(ctx, 200, 600); + for (i = 0; i < 5; i++) { + vkvg_rel_line_to(ctx, 70, -50); + vkvg_rel_line_to(ctx, -70, -50); + } + vkvg_stroke(ctx); - vkvg_move_to(ctx, 400, 100); - for (i = 0; i < 5; i++) { - vkvg_rel_line_to(ctx, -70, 50); - vkvg_rel_line_to(ctx, 70, 50); - } - vkvg_stroke(ctx); + vkvg_move_to(ctx, 400, 100); + for (i = 0; i < 5; i++) { + vkvg_rel_line_to(ctx, -70, 50); + vkvg_rel_line_to(ctx, 70, 50); + } + vkvg_stroke(ctx); - vkvg_move_to(ctx, 500, 600); - for (i = 0; i < 5; i++) { - vkvg_rel_line_to(ctx, -70, -50); - vkvg_rel_line_to(ctx, 70, -50); - } - vkvg_stroke(ctx); - vkvg_set_line_join(ctx, VKVG_LINE_JOIN_BEVEL); - vkvg_translate(ctx, 500, 0); - } + vkvg_move_to(ctx, 500, 600); + for (i = 0; i < 5; i++) { + vkvg_rel_line_to(ctx, -70, -50); + vkvg_rel_line_to(ctx, 70, -50); + } + vkvg_stroke(ctx); + vkvg_set_line_join(ctx, VKVG_LINE_JOIN_BEVEL); + vkvg_translate(ctx, 500, 0); + } - vkvg_destroy(ctx); + vkvg_destroy(ctx); } void test3() { - VkvgContext ctx = vkvg_create(surf); + VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); - vkvg_set_line_width(ctx, 30); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_line_width(ctx, 30); - vkvg_set_line_join(ctx, VKVG_LINE_JOIN_ROUND); + vkvg_set_line_join(ctx, VKVG_LINE_JOIN_ROUND); - //vkvg_arc (ctx, 200, 500, 100, 0, M_PI); + // vkvg_arc (ctx, 200, 500, 100, 0, M_PI); - vkvg_translate(ctx, -50, -50); + vkvg_translate(ctx, -50, -50); - vkvg_set_source_rgb(ctx, 0.5, 0, 0); + vkvg_set_source_rgb(ctx, 0.5, 0, 0); - for (int j = 0; j < 2; j++) { - int i = 0; - vkvg_move_to(ctx, 100, 100); - for (i = 0; i < 4; i++) { - vkvg_rel_line_to(ctx, 50, 70); - vkvg_rel_line_to(ctx, 50, -70); - } - vkvg_stroke(ctx); + for (int j = 0; j < 2; j++) { + int i = 0; + vkvg_move_to(ctx, 100, 100); + for (i = 0; i < 4; i++) { + vkvg_rel_line_to(ctx, 50, 70); + vkvg_rel_line_to(ctx, 50, -70); + } + vkvg_stroke(ctx); - vkvg_move_to(ctx, 500, 200); - for (i = 0; i < 4; i++) { - vkvg_rel_line_to(ctx, -50, 70); - vkvg_rel_line_to(ctx, -50, -70); - } - vkvg_stroke(ctx); + vkvg_move_to(ctx, 500, 200); + for (i = 0; i < 4; i++) { + vkvg_rel_line_to(ctx, -50, 70); + vkvg_rel_line_to(ctx, -50, -70); + } + vkvg_stroke(ctx); - vkvg_move_to(ctx, 100, 400); - for (i = 0; i < 4; i++) { - vkvg_rel_line_to(ctx, 50, -70); - vkvg_rel_line_to(ctx, 50, 70); - } - vkvg_stroke(ctx); + vkvg_move_to(ctx, 100, 400); + for (i = 0; i < 4; i++) { + vkvg_rel_line_to(ctx, 50, -70); + vkvg_rel_line_to(ctx, 50, 70); + } + vkvg_stroke(ctx); - vkvg_move_to(ctx, 500, 500); - for (i = 0; i < 4; i++) { - vkvg_rel_line_to(ctx, -50, -70); - vkvg_rel_line_to(ctx, -50, 70); - } - vkvg_stroke(ctx); - vkvg_set_line_join(ctx, VKVG_LINE_JOIN_BEVEL); - vkvg_translate(ctx, 450, 0); - } + vkvg_move_to(ctx, 500, 500); + for (i = 0; i < 4; i++) { + vkvg_rel_line_to(ctx, -50, -70); + vkvg_rel_line_to(ctx, -50, 70); + } + vkvg_stroke(ctx); + vkvg_set_line_join(ctx, VKVG_LINE_JOIN_BEVEL); + vkvg_translate(ctx, 450, 0); + } - vkvg_destroy(ctx); + vkvg_destroy(ctx); } - int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST(test, argc, argv); - PERFORM_TEST(test2, argc, argv); - PERFORM_TEST(test3, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(test, argc, argv); + PERFORM_TEST(test2, argc, argv); + PERFORM_TEST(test3, argc, argv); + return 0; } diff --git a/tests/lines.c b/tests/lines.c index ef26d85..efd7e3d 100644 --- a/tests/lines.c +++ b/tests/lines.c @@ -1,110 +1,110 @@ #include "test.h" void horizontal() { - float w = (float)test_width; - float h = (float)test_height; + float w = (float)test_width; + float h = (float)test_height; - VkvgContext ctx = _initCtx(); + VkvgContext ctx = _initCtx(); - for (uint32_t i=0; i<test_size; i++) { - randomize_color(ctx); - float x1 = w*rndf(); - float y1 = h*rndf(); - float v = 500.f*rndf(); + for (uint32_t i = 0; i < test_size; i++) { + randomize_color(ctx); + float x1 = w * rndf(); + float y1 = h * rndf(); + float v = 500.f * rndf(); - vkvg_move_to (ctx, x1, y1); - vkvg_line_to (ctx, x1 + v, y1); - vkvg_stroke (ctx); - } - vkvg_destroy(ctx); + vkvg_move_to(ctx, x1, y1); + vkvg_line_to(ctx, x1 + v, y1); + vkvg_stroke(ctx); + } + vkvg_destroy(ctx); } void vertical() { - float w = (float)test_width; - float h = (float)test_height; + float w = (float)test_width; + float h = (float)test_height; - VkvgContext ctx = _initCtx(); + VkvgContext ctx = _initCtx(); - for (uint32_t i=0; i<test_size; i++) { - randomize_color(ctx); - float x1 = w*rndf(); - float y1 = h*rndf(); - float v = 500.f*rndf(); + for (uint32_t i = 0; i < test_size; i++) { + randomize_color(ctx); + float x1 = w * rndf(); + float y1 = h * rndf(); + float v = 500.f * rndf(); - vkvg_move_to (ctx, x1, y1); - vkvg_line_to (ctx, x1, y1 + v); - vkvg_stroke (ctx); - } - vkvg_destroy(ctx); + vkvg_move_to(ctx, x1, y1); + vkvg_line_to(ctx, x1, y1 + v); + vkvg_stroke(ctx); + } + vkvg_destroy(ctx); } -void horzAndVert(){ - float w = (float)test_width; - float h = (float)test_height; +void horzAndVert() { + float w = (float)test_width; + float h = (float)test_height; - VkvgContext ctx = _initCtx(); + VkvgContext ctx = _initCtx(); - for (uint32_t i=0; i<test_size; i++) { - randomize_color(ctx); + for (uint32_t i = 0; i < test_size; i++) { + randomize_color(ctx); - float x1 = w*rndf(); - float y1 = h*rndf(); - float x2 = (w*rndf()) + 1; - float y2 = (h*rndf()) + 1; + float x1 = w * rndf(); + float y1 = h * rndf(); + float x2 = (w * rndf()) + 1; + float y2 = (h * rndf()) + 1; - vkvg_move_to (ctx, x1, y1); - vkvg_line_to (ctx, x2, y2); - vkvg_stroke (ctx); - } - vkvg_destroy(ctx); + vkvg_move_to(ctx, x1, y1); + vkvg_line_to(ctx, x2, y2); + vkvg_stroke(ctx); + } + vkvg_destroy(ctx); } -void multilines(){ - float w = (float)test_width; - float h = (float)test_height; +void multilines() { + float w = (float)test_width; + float h = (float)test_height; - VkvgContext ctx = _initCtx(); + VkvgContext ctx = _initCtx(); - randomize_color(ctx); + randomize_color(ctx); - for (uint32_t i=0; i<test_size; i++) { + for (uint32_t i = 0; i < test_size; i++) { - float x1 = w*rndf(); - float y1 = h*rndf(); - float x2 = (w*rndf()) + 1; - float y2 = (h*rndf()) + 1; + float x1 = w * rndf(); + float y1 = h * rndf(); + float x2 = (w * rndf()) + 1; + float y2 = (h * rndf()) + 1; - vkvg_move_to (ctx, x1, y1); - vkvg_line_to (ctx, x2, y2); - } - vkvg_stroke (ctx); - vkvg_destroy(ctx); + vkvg_move_to(ctx, x1, y1); + vkvg_line_to(ctx, x2, y2); + } + vkvg_stroke(ctx); + vkvg_destroy(ctx); } void multi_segments() { - float w = (float)test_width-10; - float h = (float)test_height-10; + float w = (float)test_width - 10; + float h = (float)test_height - 10; VkvgContext ctx = _initCtx(); randomize_color(ctx); - float x1 = w*rndf(); - float y1 = h*rndf(); - vkvg_move_to (ctx, x1, y1); - for (uint32_t i=0; i<test_size; i++) { - x1 = w*rndf(); - y1 = h*rndf(); - vkvg_line_to (ctx, x1, y1); + float x1 = w * rndf(); + float y1 = h * rndf(); + vkvg_move_to(ctx, x1, y1); + for (uint32_t i = 0; i < test_size; i++) { + x1 = w * rndf(); + y1 = h * rndf(); + vkvg_line_to(ctx, x1, y1); } - vkvg_stroke (ctx); + vkvg_stroke(ctx); vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - struct timeval currentTime; - gettimeofday(¤tTime, NULL); + struct timeval currentTime; + gettimeofday(¤tTime, NULL); - srand((unsigned) currentTime.tv_usec); + srand((unsigned)currentTime.tv_usec); PERFORM_TEST(horizontal, argc, argv); - PERFORM_TEST(vertical, argc, argv); - PERFORM_TEST(horzAndVert, argc, argv); + PERFORM_TEST(vertical, argc, argv); + PERFORM_TEST(horzAndVert, argc, argv); PERFORM_TEST(multilines, argc, argv); PERFORM_TEST(multi_segments, argc, argv); return 0; diff --git a/tests/multithreading/multithreaded.c b/tests/multithreading/multithreaded.c index 05ee038..280261d 100644 --- a/tests/multithreading/multithreaded.c +++ b/tests/multithreading/multithreaded.c @@ -7,70 +7,69 @@ #define THREAD_COUNT 32 +static int finishedThreadCount = 0; +static mtx_t *pmutex; -static int finishedThreadCount = 0; -static mtx_t* pmutex; +void drawRandomRect(VkvgContext ctx, float s) { + float w = (float)test_width; + float h = (float)test_height; + randomize_color(ctx); -void drawRandomRect (VkvgContext ctx, float s) { - float w = (float)test_width; - float h = (float)test_height; - randomize_color(ctx); + float x = truncf(w * rndf()); + float y = truncf(h * rndf()); - float x = truncf(w*rndf()); - float y = truncf(h*rndf()); - - vkvg_rectangle(ctx, x, y, s, s); + vkvg_rectangle(ctx, x, y, s, s); } -int drawRectsThread () { +int drawRectsThread() { - VkvgSurface s = vkvg_surface_create(device, test_width, test_height); - VkvgContext ctx = vkvg_create(s); - for (uint32_t i=0; i<test_size; i++) { - drawRandomRect(ctx, 14.0f); - vkvg_fill (ctx); - } - vkvg_destroy(ctx); + VkvgSurface s = vkvg_surface_create(device, test_width, test_height); + VkvgContext ctx = vkvg_create(s); + for (uint32_t i = 0; i < test_size; i++) { + drawRandomRect(ctx, 14.0f); + vkvg_fill(ctx); + } + vkvg_destroy(ctx); - mtx_lock(pmutex); + mtx_lock(pmutex); - ctx = vkvg_create(surf); - vkvg_set_source_surface (ctx, s, 0, 0); - vkvg_paint(ctx); - vkvg_destroy(ctx); + ctx = vkvg_create(surf); + vkvg_set_source_surface(ctx, s, 0, 0); + vkvg_paint(ctx); + vkvg_destroy(ctx); - finishedThreadCount++; - mtx_unlock(pmutex); + finishedThreadCount++; + mtx_unlock(pmutex); - vkvg_surface_destroy (s); - return 0; + vkvg_surface_destroy(s); + return 0; } -void fixedSizeRects(){ - mtx_t mutex; - pmutex = &mutex; +void fixedSizeRects() { + mtx_t mutex; + pmutex = &mutex; - vkvg_device_set_thread_aware (device, 1); + vkvg_device_set_thread_aware(device, 1); - thrd_t threads[THREAD_COUNT]; + thrd_t threads[THREAD_COUNT]; - finishedThreadCount = 0; - mtx_init (pmutex, mtx_plain); - for (uint32_t i=0; i<THREAD_COUNT; i++) - thrd_create (&threads[i], drawRectsThread, NULL); + finishedThreadCount = 0; + mtx_init(pmutex, mtx_plain); + for (uint32_t i = 0; i < THREAD_COUNT; i++) + thrd_create(&threads[i], drawRectsThread, NULL); - const struct timespec ts = {1,0}; - while (finishedThreadCount < THREAD_COUNT) - thrd_sleep(&ts, NULL); + const struct timespec ts = {1, 0}; + while (finishedThreadCount < THREAD_COUNT) + thrd_sleep(&ts, NULL); - mtx_lock(pmutex); - mtx_unlock(pmutex); - mtx_destroy (pmutex); - pmutex = NULL; + mtx_lock(pmutex); + mtx_unlock(pmutex); + mtx_destroy(pmutex); + pmutex = NULL; - vkvg_device_set_thread_aware (device, 0); + vkvg_device_set_thread_aware(device, 0); } int main(int argc, char *argv[]) { - PERFORM_TEST (fixedSizeRects, argc, argv); - return 0; + PERFORM_TEST(fixedSizeRects, argc, argv); + return 0; } diff --git a/tests/multithreading/multithreaded2.c b/tests/multithreading/multithreaded2.c index a29e006..7eff7a0 100644 --- a/tests/multithreading/multithreaded2.c +++ b/tests/multithreading/multithreaded2.c @@ -6,58 +6,57 @@ #define THREAD_COUNT 32 +static int finishedThreadCount = 0; +static mtx_t *pmutex; -static int finishedThreadCount = 0; -static mtx_t* pmutex; +void drawRandomRect(VkvgContext ctx, float s) { + float w = (float)test_width; + float h = (float)test_height; + randomize_color(ctx); -void drawRandomRect (VkvgContext ctx, float s) { - float w = (float)test_width; - float h = (float)test_height; - randomize_color(ctx); + float x = truncf(w * rndf()); + float y = truncf(h * rndf()); - float x = truncf(w*rndf()); - float y = truncf(h*rndf()); - - vkvg_rectangle(ctx, x, y, s, s); + vkvg_rectangle(ctx, x, y, s, s); } -int drawRectsThread () { - VkvgContext ctx = vkvg_create(surf); - for (uint32_t i=0; i<test_size; i++) { - drawRandomRect(ctx, 14.0f); - vkvg_fill (ctx); - } - vkvg_destroy (ctx); - mtx_lock (pmutex); - finishedThreadCount++; - mtx_unlock (pmutex); - return 0; +int drawRectsThread() { + VkvgContext ctx = vkvg_create(surf); + for (uint32_t i = 0; i < test_size; i++) { + drawRandomRect(ctx, 14.0f); + vkvg_fill(ctx); + } + vkvg_destroy(ctx); + mtx_lock(pmutex); + finishedThreadCount++; + mtx_unlock(pmutex); + return 0; } -void fixedSizeRects(){ - mtx_t mutex; - pmutex = &mutex; +void fixedSizeRects() { + mtx_t mutex; + pmutex = &mutex; - vkvg_device_set_thread_aware (device, 1); + vkvg_device_set_thread_aware(device, 1); - thrd_t threads[THREAD_COUNT]; + thrd_t threads[THREAD_COUNT]; - finishedThreadCount = 0; - mtx_init (pmutex, mtx_plain); - for (uint32_t i=0; i<THREAD_COUNT; i++) - thrd_create (&threads[i], drawRectsThread, NULL); + finishedThreadCount = 0; + mtx_init(pmutex, mtx_plain); + for (uint32_t i = 0; i < THREAD_COUNT; i++) + thrd_create(&threads[i], drawRectsThread, NULL); - const struct timespec ts = {1,0}; - while (finishedThreadCount < THREAD_COUNT) - thrd_sleep(&ts, NULL); + const struct timespec ts = {1, 0}; + while (finishedThreadCount < THREAD_COUNT) + thrd_sleep(&ts, NULL); - mtx_lock(pmutex); - mtx_unlock(pmutex); - mtx_destroy (pmutex); - pmutex = NULL; + mtx_lock(pmutex); + mtx_unlock(pmutex); + mtx_destroy(pmutex); + pmutex = NULL; - vkvg_device_set_thread_aware (device, 0); + vkvg_device_set_thread_aware(device, 0); } int main(int argc, char *argv[]) { - PERFORM_TEST (fixedSizeRects, argc, argv); - return 0; + PERFORM_TEST(fixedSizeRects, argc, argv); + return 0; } diff --git a/tests/multithreading/threaded_create_surf.c b/tests/multithreading/threaded_create_surf.c index 9789565..f7e8d80 100644 --- a/tests/multithreading/threaded_create_surf.c +++ b/tests/multithreading/threaded_create_surf.c @@ -3,48 +3,47 @@ #define THREAD_COUNT 16 +static int finishedThreadCount = 0; +static mtx_t *pmutex; -static int finishedThreadCount = 0; -static mtx_t* pmutex; +int create_surfs() { + for (uint32_t i = 0; i < test_size; i++) { + VkvgSurface s = vkvg_surface_create(device, test_width, test_height); + vkvg_surface_destroy(s); + } -int create_surfs () { - for (uint32_t i=0; i<test_size; i++) { - VkvgSurface s = vkvg_surface_create(device, test_width, test_height); - vkvg_surface_destroy (s); - } - - mtx_lock(pmutex); - finishedThreadCount++; - mtx_unlock(pmutex); - return 0; + mtx_lock(pmutex); + finishedThreadCount++; + mtx_unlock(pmutex); + return 0; } -void fixedSizeRects(){ - mtx_t mutex; - pmutex = &mutex; +void fixedSizeRects() { + mtx_t mutex; + pmutex = &mutex; - vkvg_device_set_thread_aware (device, 1); + vkvg_device_set_thread_aware(device, 1); - thrd_t threads[THREAD_COUNT]; + thrd_t threads[THREAD_COUNT]; - finishedThreadCount = 0; - mtx_init (pmutex, mtx_plain); - for (uint32_t i=0; i<THREAD_COUNT; i++) - thrd_create (&threads[i], create_surfs, NULL); + finishedThreadCount = 0; + mtx_init(pmutex, mtx_plain); + for (uint32_t i = 0; i < THREAD_COUNT; i++) + thrd_create(&threads[i], create_surfs, NULL); - const struct timespec ts = {1,0}; - while (finishedThreadCount < THREAD_COUNT) - thrd_sleep(&ts, NULL); + const struct timespec ts = {1, 0}; + while (finishedThreadCount < THREAD_COUNT) + thrd_sleep(&ts, NULL); - mtx_lock(pmutex); - mtx_unlock(pmutex); - mtx_destroy (pmutex); - pmutex = NULL; + mtx_lock(pmutex); + mtx_unlock(pmutex); + mtx_destroy(pmutex); + pmutex = NULL; - vkvg_device_set_thread_aware (device, 0); + vkvg_device_set_thread_aware(device, 0); } int main(int argc, char *argv[]) { - PERFORM_TEST (fixedSizeRects, argc, argv); - return 0; + PERFORM_TEST(fixedSizeRects, argc, argv); + return 0; } diff --git a/tests/multithreading/threaded_text.c b/tests/multithreading/threaded_text.c index bacf597..8ae18a9 100644 --- a/tests/multithreading/threaded_text.c +++ b/tests/multithreading/threaded_text.c @@ -7,77 +7,75 @@ #define THREAD_COUNT 16 -static int finishedThreadCount = 0; -static mtx_t* pmutex; +static int finishedThreadCount = 0; +static mtx_t *pmutex; -void drawRandomRect (VkvgContext ctx, float s) { - float w = (float)test_width; - float h = (float)test_height; - randomize_color(ctx); +void drawRandomRect(VkvgContext ctx, float s) { + float w = (float)test_width; + float h = (float)test_height; + randomize_color(ctx); - float x = truncf(w*rndf()); - float y = truncf(h*rndf()); + float x = truncf(w * rndf()); + float y = truncf(h * rndf()); - vkvg_rectangle(ctx, x, y, s, s); + vkvg_rectangle(ctx, x, y, s, s); } -int _single_font_and_size () { - VkvgSurface s = vkvg_surface_create(device, test_width, test_height); - VkvgContext ctx = vkvg_create(s); - vkvg_clear(ctx); - for (uint32_t i=0; i<test_size/THREAD_COUNT; i++) { - randomize_color(ctx); - float x = rndf() * test_width; - float y = rndf() * test_height; - vkvg_select_font_face(ctx,"mono"); - vkvg_set_font_size(ctx, 20); - vkvg_move_to(ctx,x,y); - vkvg_show_text(ctx,"This is a test string!"); - } - vkvg_destroy(ctx); +int _single_font_and_size() { + VkvgSurface s = vkvg_surface_create(device, test_width, test_height); + VkvgContext ctx = vkvg_create(s); + vkvg_clear(ctx); + for (uint32_t i = 0; i < test_size / THREAD_COUNT; i++) { + randomize_color(ctx); + float x = rndf() * test_width; + float y = rndf() * test_height; + vkvg_select_font_face(ctx, "mono"); + vkvg_set_font_size(ctx, 20); + vkvg_move_to(ctx, x, y); + vkvg_show_text(ctx, "This is a test string!"); + } + vkvg_destroy(ctx); - mtx_lock(pmutex); + mtx_lock(pmutex); - ctx = vkvg_create(surf); - vkvg_set_source_surface (ctx, s, 0, 0); - vkvg_paint(ctx); - vkvg_destroy(ctx); + ctx = vkvg_create(surf); + vkvg_set_source_surface(ctx, s, 0, 0); + vkvg_paint(ctx); + vkvg_destroy(ctx); - finishedThreadCount++; - mtx_unlock(pmutex); + finishedThreadCount++; + mtx_unlock(pmutex); - vkvg_surface_destroy (s); - return 0; + vkvg_surface_destroy(s); + return 0; } -void threaded_text(int(*testfunc)(void*)){ - mtx_t mutex; - pmutex = &mutex; +void threaded_text(int (*testfunc)(void *)) { + mtx_t mutex; + pmutex = &mutex; - vkvg_device_set_thread_aware (device, 1); + vkvg_device_set_thread_aware(device, 1); - thrd_t threads[THREAD_COUNT]; + thrd_t threads[THREAD_COUNT]; - finishedThreadCount = 0; - mtx_init (pmutex, mtx_plain); - for (uint32_t i=0; i<THREAD_COUNT; i++) - thrd_create (&threads[i], testfunc, NULL); + finishedThreadCount = 0; + mtx_init(pmutex, mtx_plain); + for (uint32_t i = 0; i < THREAD_COUNT; i++) + thrd_create(&threads[i], testfunc, NULL); - const struct timespec ts = {1,0}; - while (finishedThreadCount < THREAD_COUNT) - thrd_sleep(&ts, NULL); + const struct timespec ts = {1, 0}; + while (finishedThreadCount < THREAD_COUNT) + thrd_sleep(&ts, NULL); - mtx_lock(pmutex); - mtx_unlock(pmutex); - mtx_destroy (pmutex); - pmutex = NULL; + mtx_lock(pmutex); + mtx_unlock(pmutex); + mtx_destroy(pmutex); + pmutex = NULL; - vkvg_device_set_thread_aware (device, 0); -} -void single_font_and_size() { - threaded_text (_single_font_and_size); + vkvg_device_set_thread_aware(device, 0); } +void single_font_and_size() { threaded_text(_single_font_and_size); } int main(int argc, char *argv[]) { - PERFORM_TEST (single_font_and_size, argc, argv); - return 0; + PERFORM_TEST(single_font_and_size, argc, argv); + return 0; } diff --git a/tests/offscreen.c b/tests/offscreen.c index 895d1e0..55fde10 100644 --- a/tests/offscreen.c +++ b/tests/offscreen.c @@ -1,23 +1,21 @@ #include "vkvg.h" int main(int argc, char *argv[]) { - vkvg_device_create_info_t info = { - VK_SAMPLE_COUNT_1_BIT, false - }; - VkvgDevice dev = vkvg_device_create(&info); - VkvgSurface surf = vkvg_surface_create(dev, 512,512); - VkvgContext ctx = vkvg_create(surf); + vkvg_device_create_info_t info = {VK_SAMPLE_COUNT_1_BIT, false}; + VkvgDevice dev = vkvg_device_create(&info); + VkvgSurface surf = vkvg_surface_create(dev, 512, 512); + VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); - vkvg_rectangle(ctx, 10, 10, 250, 200); - vkvg_set_source_rgb(ctx, 1, 0, 0); - vkvg_fill(ctx); + vkvg_clear(ctx); + vkvg_rectangle(ctx, 10, 10, 250, 200); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_fill(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); - vkvg_surface_write_to_png(surf, "offscreen.png"); - vkvg_surface_destroy(surf); + vkvg_surface_write_to_png(surf, "offscreen.png"); + vkvg_surface_destroy(surf); - vkvg_device_destroy(dev); - return 0; + vkvg_device_destroy(dev); + return 0; } diff --git a/tests/paint_surf.c b/tests/paint_surf.c index 996c410..211d1e6 100644 --- a/tests/paint_surf.c +++ b/tests/paint_surf.c @@ -2,104 +2,104 @@ float lineWidth = 10.f; -VkvgSurface createSurf (uint32_t width, uint32_t height) { - VkvgSurface s = vkvg_surface_create(device, width, height); - VkvgContext ctx = vkvg_create (s); - vkvg_set_line_width(ctx,lineWidth); - float hlw = lineWidth/2.f; - /* - vkvg_set_source_rgba(ctx,0,1,0,0.5); - vkvg_fill_preserve(ctx);*/ - vkvg_set_source_rgba(ctx,1,0,0,0.5); - vkvg_paint(ctx); - vkvg_set_source_rgba(ctx,0,0,1,0.5); - vkvg_rectangle(ctx,hlw,hlw,(float)width-lineWidth,(float)height-lineWidth); - vkvg_stroke(ctx); - vkvg_destroy(ctx); - return s; +VkvgSurface createSurf(uint32_t width, uint32_t height) { + VkvgSurface s = vkvg_surface_create(device, width, height); + VkvgContext ctx = vkvg_create(s); + vkvg_set_line_width(ctx, lineWidth); + float hlw = lineWidth / 2.f; + /* + vkvg_set_source_rgba(ctx,0,1,0,0.5); + vkvg_fill_preserve(ctx);*/ + vkvg_set_source_rgba(ctx, 1, 0, 0, 0.5); + vkvg_paint(ctx); + vkvg_set_source_rgba(ctx, 0, 0, 1, 0.5); + vkvg_rectangle(ctx, hlw, hlw, (float)width - lineWidth, (float)height - lineWidth); + vkvg_stroke(ctx); + vkvg_destroy(ctx); + return s; } -void paint(){ - VkvgSurface src = createSurf(256,256); - VkvgContext ctx = _initCtx(surf); - vkvg_set_source_surface(ctx, src, 0, 0); - vkvg_paint(ctx); - vkvg_destroy(ctx); - vkvg_surface_destroy(src); +void paint() { + VkvgSurface src = createSurf(256, 256); + VkvgContext ctx = _initCtx(surf); + vkvg_set_source_surface(ctx, src, 0, 0); + vkvg_paint(ctx); + vkvg_destroy(ctx); + vkvg_surface_destroy(src); } -void paint_with_offset(){ - VkvgSurface src = createSurf(256,256); - VkvgContext ctx = _initCtx(surf); - vkvg_set_source_rgba(ctx,0,1,0,0.5); - vkvg_paint(ctx); - vkvg_set_source_surface(ctx, src, 100, 100); - vkvg_paint(ctx); - vkvg_destroy(ctx); - vkvg_surface_destroy(src); +void paint_with_offset() { + VkvgSurface src = createSurf(256, 256); + VkvgContext ctx = _initCtx(surf); + vkvg_set_source_rgba(ctx, 0, 1, 0, 0.5); + vkvg_paint(ctx); + vkvg_set_source_surface(ctx, src, 100, 100); + vkvg_paint(ctx); + vkvg_destroy(ctx); + vkvg_surface_destroy(src); } -void paint_multiple(){ - VkvgSurface src = createSurf(256,256); - VkvgContext ctx = _initCtx(surf); - for(int i=0;i<10;i++) { - vkvg_set_source_surface(ctx, src, i * 20, i * 20); - vkvg_paint(ctx); - } - vkvg_destroy(ctx); - vkvg_surface_destroy(src); +void paint_multiple() { + VkvgSurface src = createSurf(256, 256); + VkvgContext ctx = _initCtx(surf); + for (int i = 0; i < 10; i++) { + vkvg_set_source_surface(ctx, src, i * 20, i * 20); + vkvg_paint(ctx); + } + vkvg_destroy(ctx); + vkvg_surface_destroy(src); } -void paint_with_rotation(){ - VkvgSurface src = createSurf(256,256); - VkvgContext ctx = _initCtx(surf); - vkvg_set_source_surface(ctx, src, 0, 0); - vkvg_rotate(ctx, 45); - vkvg_paint(ctx); - vkvg_destroy(ctx); - vkvg_surface_destroy(src); +void paint_with_rotation() { + VkvgSurface src = createSurf(256, 256); + VkvgContext ctx = _initCtx(surf); + vkvg_set_source_surface(ctx, src, 0, 0); + vkvg_rotate(ctx, 45); + vkvg_paint(ctx); + vkvg_destroy(ctx); + vkvg_surface_destroy(src); } -void paint_with_scale(){ - VkvgSurface src = createSurf(256,256); - VkvgContext ctx = _initCtx(surf); - vkvg_set_source_surface(ctx, src, 0, 0); - vkvg_scale (ctx, 0.2f,0.2f); - vkvg_paint(ctx); - vkvg_destroy(ctx); - vkvg_surface_destroy(src); +void paint_with_scale() { + VkvgSurface src = createSurf(256, 256); + VkvgContext ctx = _initCtx(surf); + vkvg_set_source_surface(ctx, src, 0, 0); + vkvg_scale(ctx, 0.2f, 0.2f); + vkvg_paint(ctx); + vkvg_destroy(ctx); + vkvg_surface_destroy(src); } -void paint_rect(){ - VkvgSurface src = createSurf(256,256); - VkvgContext ctx = _initCtx(surf); - vkvg_set_source_surface(ctx, src, 0, 0); - vkvg_rectangle(ctx,100,100,300,200); - vkvg_paint(ctx); - vkvg_destroy(ctx); - vkvg_surface_destroy(src); +void paint_rect() { + VkvgSurface src = createSurf(256, 256); + VkvgContext ctx = _initCtx(surf); + vkvg_set_source_surface(ctx, src, 0, 0); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_paint(ctx); + vkvg_destroy(ctx); + vkvg_surface_destroy(src); } -//TODO:test failed: full screen paint instead of rotated rect -void paint_rect_with_rotation(){ - VkvgContext ctx = _initCtx(surf); - vkvg_rotate(ctx, 45); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_rectangle(ctx,100,100,300,200); - vkvg_paint(ctx); - vkvg_destroy(ctx); +// TODO:test failed: full screen paint instead of rotated rect +void paint_rect_with_rotation() { + VkvgContext ctx = _initCtx(surf); + vkvg_rotate(ctx, 45); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_paint(ctx); + vkvg_destroy(ctx); } -void paint_rect_with_scale(){ - VkvgContext ctx = _initCtx(surf); - vkvg_scale (ctx, 0.2f,0.2f); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_rectangle(ctx,100,100,300,200); - vkvg_paint(ctx); - vkvg_destroy(ctx); +void paint_rect_with_scale() { + VkvgContext ctx = _initCtx(surf); + vkvg_scale(ctx, 0.2f, 0.2f); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_paint(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (paint, argc, argv); - PERFORM_TEST (paint_with_offset, argc, argv); - PERFORM_TEST (paint_multiple, argc, argv); - PERFORM_TEST (paint_with_rotation, argc, argv); - PERFORM_TEST (paint_with_scale, argc, argv); - PERFORM_TEST (paint_rect, argc, argv); - PERFORM_TEST (paint_rect_with_rotation, argc, argv); - PERFORM_TEST (paint_rect_with_scale, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(paint, argc, argv); + PERFORM_TEST(paint_with_offset, argc, argv); + PERFORM_TEST(paint_multiple, argc, argv); + PERFORM_TEST(paint_with_rotation, argc, argv); + PERFORM_TEST(paint_with_scale, argc, argv); + PERFORM_TEST(paint_rect, argc, argv); + PERFORM_TEST(paint_rect_with_rotation, argc, argv); + PERFORM_TEST(paint_rect_with_scale, argc, argv); + return 0; } diff --git a/tests/path_extents.c b/tests/path_extents.c index 55c69de..8a31e01 100644 --- a/tests/path_extents.c +++ b/tests/path_extents.c @@ -1,192 +1,180 @@ #include "test.h" #include "vectors.h" -vkvg_fill_rule_t fillrule = VKVG_FILL_RULE_NON_ZERO; -static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; -float lineWidth = 4.0f; -vkvg_line_join_t lineJoin = VKVG_LINE_JOIN_MITER; -vkvg_line_cap_t lineCap = VKVG_LINE_CAP_BUTT; -bool isClosed = false, refresh = true; -bool startWithArc = false, endWithArc = false; +vkvg_fill_rule_t fillrule = VKVG_FILL_RULE_NON_ZERO; +static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; +float lineWidth = 4.0f; +vkvg_line_join_t lineJoin = VKVG_LINE_JOIN_MITER; +vkvg_line_cap_t lineCap = VKVG_LINE_CAP_BUTT; +bool isClosed = false, refresh = true; +bool startWithArc = false, endWithArc = false; -int ptsCount = 0; -vec2 pts[1024]; -int hoverPt = -1; +int ptsCount = 0; +vec2 pts[1024]; +int hoverPt = -1; double pointSize = 7; -float _dashes[] = {5.0f,3.0f}; -int _ndashes = 2; +float _dashes[] = {5.0f, 3.0f}; +int _ndashes = 2; -void emit_path (VkvgContext ctx) { - vkvg_move_to(ctx,pts[0].x,pts[0].y); - for (int i=1; i<ptsCount; i++) - vkvg_line_to(ctx,pts[i].x,pts[i].y); - if (isClosed) - vkvg_close_path(ctx); +void emit_path(VkvgContext ctx) { + vkvg_move_to(ctx, pts[0].x, pts[0].y); + for (int i = 1; i < ptsCount; i++) + vkvg_line_to(ctx, pts[i].x, pts[i].y); + if (isClosed) + vkvg_close_path(ctx); } -void draw (){ - refresh = false; +void draw() { + refresh = false; - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_set_line_width (ctx,lineWidth); - vkvg_set_line_join (ctx, lineJoin); - vkvg_set_line_cap (ctx, lineCap); + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_set_line_width(ctx, lineWidth); + vkvg_set_line_join(ctx, lineJoin); + vkvg_set_line_cap(ctx, lineCap); - emit_path(ctx); - float x1, y1, x2, y2; - vkvg_path_extents(ctx, &x1, &y1, &x2, &y2); - vkvg_set_source_rgba(ctx,0.2,0.2,1,0.5); - if (hoverPt>=0) { - if (isClosed) - vkvg_fill_preserve(ctx); - vkvg_set_source_rgba(ctx,1,0.2,0.2,0.5); - vkvg_stroke_preserve(ctx); - vkvg_set_dash(ctx, NULL, 0, 0); - vkvg_set_line_width(ctx,1); - vkvg_set_source_rgba(ctx,0,0,0,1); - vkvg_stroke(ctx); - vkvg_set_source_rgba(ctx,0.5f,0.5f,1.0f,0.7f); - vkvg_arc (ctx, pts[hoverPt].x, pts[hoverPt].y, pointSize, 0, M_PIF*2); - vkvg_fill_preserve(ctx); - vkvg_stroke(ctx); - } else { - if (isClosed) - vkvg_fill_preserve(ctx); - vkvg_set_source_rgba(ctx,1,0.2,0.2,0.5); - vkvg_stroke(ctx); - } + emit_path(ctx); + float x1, y1, x2, y2; + vkvg_path_extents(ctx, &x1, &y1, &x2, &y2); + vkvg_set_source_rgba(ctx, 0.2, 0.2, 1, 0.5); + if (hoverPt >= 0) { + if (isClosed) + vkvg_fill_preserve(ctx); + vkvg_set_source_rgba(ctx, 1, 0.2, 0.2, 0.5); + vkvg_stroke_preserve(ctx); + vkvg_set_dash(ctx, NULL, 0, 0); + vkvg_set_line_width(ctx, 1); + vkvg_set_source_rgba(ctx, 0, 0, 0, 1); + vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 0.5f, 0.5f, 1.0f, 0.7f); + vkvg_arc(ctx, pts[hoverPt].x, pts[hoverPt].y, pointSize, 0, M_PIF * 2); + vkvg_fill_preserve(ctx); + vkvg_stroke(ctx); + } else { + if (isClosed) + vkvg_fill_preserve(ctx); + vkvg_set_source_rgba(ctx, 1, 0.2, 0.2, 0.5); + vkvg_stroke(ctx); + } - vkvg_rectangle(ctx, x1, y1, x2 - x1, y2 - y1); - vkvg_set_dash(ctx, _dashes, _ndashes, 0); - vkvg_set_line_width(ctx,1); - vkvg_set_source_rgba(ctx,0,1,0,1); - vkvg_stroke(ctx); + vkvg_rectangle(ctx, x1, y1, x2 - x1, y2 - y1); + vkvg_set_dash(ctx, _dashes, _ndashes, 0); + vkvg_set_line_width(ctx, 1); + vkvg_set_source_rgba(ctx, 0, 1, 0, 1); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { - if (action != GLFW_PRESS) - return; - switch (key) { - case GLFW_KEY_ESCAPE : - glfwSetWindowShouldClose(window, GLFW_TRUE); - break; - case GLFW_KEY_W : - isClosed ^= true; - break; - case GLFW_KEY_DELETE : - ptsCount = 0; - break; - case GLFW_KEY_J : - lineJoin++; - if (lineJoin > 2) - lineJoin = 0; - break; - case GLFW_KEY_C : - lineCap++; - if (lineCap > 2) - lineCap = 0; - break; - case GLFW_KEY_KP_SUBTRACT : - if (ptsCount > 1) - ptsCount--; - break; - } - refresh = true; +static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) { + if (action != GLFW_PRESS) + return; + switch (key) { + case GLFW_KEY_ESCAPE: + glfwSetWindowShouldClose(window, GLFW_TRUE); + break; + case GLFW_KEY_W: + isClosed ^= true; + break; + case GLFW_KEY_DELETE: + ptsCount = 0; + break; + case GLFW_KEY_J: + lineJoin++; + if (lineJoin > 2) + lineJoin = 0; + break; + case GLFW_KEY_C: + lineCap++; + if (lineCap > 2) + lineCap = 0; + break; + case GLFW_KEY_KP_SUBTRACT: + if (ptsCount > 1) + ptsCount--; + break; + } + refresh = true; } static vec2 mousePos; -static void mouse_move_callback(GLFWwindow* window, double x, double y){ - mousePos = (vec2) {x, y}; - if (mouseDown) { - if (hoverPt < 0) - return; - pts[hoverPt] = mousePos; - refresh = true; - } else { - for (int i=0; i<ptsCount; i++) { - if (x > pts[i].x - pointSize && - x < pts[i].x + pointSize && - y > pts[i].y - pointSize && - y < pts[i].y + pointSize) { - hoverPt = i; - refresh = true; - return; - } - } - refresh = true; - hoverPt = -1; - } +static void mouse_move_callback(GLFWwindow *window, double x, double y) { + mousePos = (vec2){x, y}; + if (mouseDown) { + if (hoverPt < 0) + return; + pts[hoverPt] = mousePos; + refresh = true; + } else { + for (int i = 0; i < ptsCount; i++) { + if (x > pts[i].x - pointSize && x < pts[i].x + pointSize && y > pts[i].y - pointSize && + y < pts[i].y + pointSize) { + hoverPt = i; + refresh = true; + return; + } + } + refresh = true; + hoverPt = -1; + } } -static void scroll_callback(GLFWwindow* window, double x, double y){ - if (y<0.f) - zoom *= 0.5f; - else - zoom *= 2.0f; +static void scroll_callback(GLFWwindow *window, double x, double y) { + if (y < 0.f) + zoom *= 0.5f; + else + zoom *= 2.0f; } -static void mouse_button_callback(GLFWwindow* window, int but, int state, int modif){ - if (but != GLFW_MOUSE_BUTTON_1) - return; - if (state == GLFW_TRUE) - mouseDown = true; - else - mouseDown = false; - if (state == GLFW_TRUE && hoverPt < 0) - pts[ptsCount++] = mousePos; - refresh = true; +static void mouse_button_callback(GLFWwindow *window, int but, int state, int modif) { + if (but != GLFW_MOUSE_BUTTON_1) + return; + if (state == GLFW_TRUE) + mouseDown = true; + else + mouseDown = false; + if (state == GLFW_TRUE && hoverPt < 0) + pts[ptsCount++] = mousePos; + refresh = true; } +int main(int argc, char *argv[]) { + _parse_args(argc, argv); + VkEngine e; + e = vkengine_create(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); -int main(int argc, char* argv[]) { + VkhPresenter r = e->renderer; + vkengine_set_key_callback(e, key_callback); + vkengine_set_mouse_but_callback(e, mouse_button_callback); + vkengine_set_cursor_pos_callback(e, mouse_move_callback); + vkengine_set_scroll_callback(e, scroll_callback); - _parse_args (argc, argv); - VkEngine e; - e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); + vkvg_device_create_info_t info = {samples, false, vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0}; + device = vkvg_device_create(&info); + surf = vkvg_surface_create(device, test_width, test_height); - VkhPresenter r = e->renderer; - vkengine_set_key_callback (e, key_callback); - vkengine_set_mouse_but_callback(e, mouse_button_callback); - vkengine_set_cursor_pos_callback(e, mouse_move_callback); - vkengine_set_scroll_callback(e, scroll_callback); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); - vkvg_device_create_info_t info = { - samples, - false, - vkh_app_get_inst(e->app), - r->dev->phy, - r->dev->dev, - r->qFam, - 0 - }; - device = vkvg_device_create(&info); - surf = vkvg_surface_create(device, test_width, test_height); + while (!vkengine_should_close(e)) { + glfwPollEvents(); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); + if (refresh) + draw(); - while (!vkengine_should_close (e)) { - glfwPollEvents(); + if (!vkh_presenter_draw(r)) { + vkh_presenter_get_size(r, &test_width, &test_height); + vkvg_surface_destroy(surf); + surf = vkvg_surface_create(device, test_width, test_height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); + vkDeviceWaitIdle(r->dev->dev); + continue; + } + } + vkDeviceWaitIdle(e->dev->dev); - if (refresh) - draw (); + vkvg_surface_destroy(surf); - if (!vkh_presenter_draw (r)){ - vkh_presenter_get_size (r, &test_width, &test_height); - vkvg_surface_destroy (surf); - surf = vkvg_surface_create(device, test_width, test_height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); - vkDeviceWaitIdle(r->dev->dev); - continue; - } - } - vkDeviceWaitIdle(e->dev->dev); + vkvg_device_destroy(device); - vkvg_surface_destroy (surf); + vkengine_destroy(e); - vkvg_device_destroy (device); - - vkengine_destroy (e); - - return 0; + return 0; } diff --git a/tests/pattern_transforms.c b/tests/pattern_transforms.c index 18e528a..58651c9 100644 --- a/tests/pattern_transforms.c +++ b/tests/pattern_transforms.c @@ -1,93 +1,93 @@ #include "test.h" -float lineWidth = 10.f; -const char* imgPath = "data/miroir.jpg"; +float lineWidth = 10.f; +const char *imgPath = "data/miroir.jpg"; -VkvgPattern create_grad (VkvgContext ctx) { - VkvgPattern pat = vkvg_pattern_create_linear(0,0,200,0); - vkvg_pattern_add_color_stop(pat, 0, 1, 0, 0, 1); - vkvg_pattern_add_color_stop(pat, 0.5, 0, 1, 0, 1); - vkvg_pattern_add_color_stop(pat, 1.0, 0, 0, 1, 1); - return pat; +VkvgPattern create_grad(VkvgContext ctx) { + VkvgPattern pat = vkvg_pattern_create_linear(0, 0, 200, 0); + vkvg_pattern_add_color_stop(pat, 0, 1, 0, 0, 1); + vkvg_pattern_add_color_stop(pat, 0.5, 0, 1, 0, 1); + vkvg_pattern_add_color_stop(pat, 1.0, 0, 0, 1, 1); + return pat; } -VkvgSurface createSurf (uint32_t width, uint32_t height) { - VkvgSurface s = vkvg_surface_create(device, width, height); - VkvgContext ctx = _initCtx(surf); - vkvg_set_line_width(ctx,lineWidth); - float hlw = lineWidth/2.f; - /* - vkvg_set_source_rgba(ctx,0,1,0,0.5); - vkvg_fill_preserve(ctx);*/ - vkvg_set_source_rgba(ctx,1,0,0,0.5); - vkvg_paint(ctx); - vkvg_set_source_rgba(ctx,0,0,1,0.5); - vkvg_rectangle(ctx,hlw,hlw,(float)width-lineWidth,(float)height-lineWidth); - vkvg_stroke(ctx); - vkvg_destroy(ctx); - return s; +VkvgSurface createSurf(uint32_t width, uint32_t height) { + VkvgSurface s = vkvg_surface_create(device, width, height); + VkvgContext ctx = _initCtx(surf); + vkvg_set_line_width(ctx, lineWidth); + float hlw = lineWidth / 2.f; + /* + vkvg_set_source_rgba(ctx,0,1,0,0.5); + vkvg_fill_preserve(ctx);*/ + vkvg_set_source_rgba(ctx, 1, 0, 0, 0.5); + vkvg_paint(ctx); + vkvg_set_source_rgba(ctx, 0, 0, 1, 0.5); + vkvg_rectangle(ctx, hlw, hlw, (float)width - lineWidth, (float)height - lineWidth); + vkvg_stroke(ctx); + vkvg_destroy(ctx); + return s; } void img_scale() { - VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); - VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); - VkvgContext ctx = _initCtx(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, imgPath); + VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); + VkvgContext ctx = _initCtx(surf); - vkvg_translate(ctx, 100,100); + vkvg_translate(ctx, 100, 100); - vkvg_matrix_t mat; - vkvg_matrix_init_scale(&mat, 2.0, 2.0); - vkvg_pattern_set_matrix (pat, &mat); + vkvg_matrix_t mat; + vkvg_matrix_init_scale(&mat, 2.0, 2.0); + vkvg_pattern_set_matrix(pat, &mat); - vkvg_set_source (ctx, pat); - vkvg_rectangle(ctx, 0 , 0, 200, 140); - vkvg_fill(ctx); - vkvg_destroy(ctx); - vkvg_pattern_destroy(pat); - vkvg_surface_destroy(imgSurf); + vkvg_set_source(ctx, pat); + vkvg_rectangle(ctx, 0, 0, 200, 140); + vkvg_fill(ctx); + vkvg_destroy(ctx); + vkvg_pattern_destroy(pat); + vkvg_surface_destroy(imgSurf); } -void pat_scale(){ +void pat_scale() { - VkvgContext ctx = _initCtx(surf); - VkvgPattern pat = create_grad(ctx); + VkvgContext ctx = _initCtx(surf); + VkvgPattern pat = create_grad(ctx); - vkvg_translate(ctx, 100,100); + vkvg_translate(ctx, 100, 100); - vkvg_matrix_t mat; - vkvg_matrix_init_scale(&mat, 0.5, 0.5); - vkvg_pattern_set_matrix (pat, &mat); + vkvg_matrix_t mat; + vkvg_matrix_init_scale(&mat, 0.5, 0.5); + vkvg_pattern_set_matrix(pat, &mat); - vkvg_set_source (ctx, pat); - vkvg_rectangle(ctx, 0 , 0, 200, 140); - vkvg_fill(ctx); - vkvg_destroy(ctx); - vkvg_pattern_destroy(pat); + vkvg_set_source(ctx, pat); + vkvg_rectangle(ctx, 0, 0, 200, 140); + vkvg_fill(ctx); + vkvg_destroy(ctx); + vkvg_pattern_destroy(pat); } static float angle = 0; -void pat_rotate(){ - angle += 0.001f; +void pat_rotate() { + angle += 0.001f; - VkvgContext ctx = _initCtx(surf); - VkvgPattern pat = create_grad(ctx); + VkvgContext ctx = _initCtx(surf); + VkvgPattern pat = create_grad(ctx); - //vkvg_translate(ctx, 100,100); + // vkvg_translate(ctx, 100,100); - vkvg_matrix_t mat; - vkvg_matrix_init_translate(&mat, 100, 70); - vkvg_matrix_rotate(&mat, angle); - vkvg_pattern_set_matrix (pat, &mat); + vkvg_matrix_t mat; + vkvg_matrix_init_translate(&mat, 100, 70); + vkvg_matrix_rotate(&mat, angle); + vkvg_pattern_set_matrix(pat, &mat); - vkvg_set_source (ctx, pat); - vkvg_rectangle(ctx, 0 , 0, 200, 140); - vkvg_fill(ctx); - vkvg_destroy(ctx); - vkvg_pattern_destroy(pat); + vkvg_set_source(ctx, pat); + vkvg_rectangle(ctx, 0, 0, 200, 140); + vkvg_fill(ctx); + vkvg_destroy(ctx); + vkvg_pattern_destroy(pat); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (pat_scale, argc, argv); - PERFORM_TEST (pat_rotate, argc, argv); - PERFORM_TEST (img_scale, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(pat_scale, argc, argv); + PERFORM_TEST(pat_rotate, argc, argv); + PERFORM_TEST(img_scale, argc, argv); + return 0; } diff --git a/tests/perfs/random_rects.c b/tests/perfs/random_rects.c index e5b1dc4..4762b5e 100644 --- a/tests/perfs/random_rects.c +++ b/tests/perfs/random_rects.c @@ -1,25 +1,25 @@ #include "test.h" -void drawRandomRect (VkvgContext ctx, float s) { - float w = (float)test_width; - float h = (float)test_height; - randomize_color(ctx); +void drawRandomRect(VkvgContext ctx, float s) { + float w = (float)test_width; + float h = (float)test_height; + randomize_color(ctx); - float x = truncf(w*rndf()); - float y = truncf(h*rndf()); + float x = truncf(w * rndf()); + float y = truncf(h * rndf()); - vkvg_rectangle(ctx, x, y, s, s); + vkvg_rectangle(ctx, x, y, s, s); } -void fixedSizeRects(){ - VkvgContext ctx = _initCtx (); - for (uint32_t i=0; i<test_size; i++) { - drawRandomRect(ctx, 50.0f); - vkvg_fill (ctx); - } - vkvg_destroy(ctx); +void fixedSizeRects() { + VkvgContext ctx = _initCtx(); + for (uint32_t i = 0; i < test_size; i++) { + drawRandomRect(ctx, 50.0f); + vkvg_fill(ctx); + } + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - PERFORM_TEST (fixedSizeRects, argc, argv); - return 0; + PERFORM_TEST(fixedSizeRects, argc, argv); + return 0; } diff --git a/tests/perfs/randoms.c b/tests/perfs/randoms.c index a20f360..b535b68 100644 --- a/tests/perfs/randoms.c +++ b/tests/perfs/randoms.c @@ -1,112 +1,82 @@ #include "test.h" /*void drawRandomRect (VkvgContext ctx) { - float w = (float)test_width; - float h = (float)test_height; - randomize_color(ctx); + float w = (float)test_width; + float h = (float)test_height; + randomize_color(ctx); - float z = truncf((0.5f*w*rand()/RAND_MAX)+1.f); - float v = truncf((0.5f*w*rand()/RAND_MAX)+1.f); - float x = truncf((w-z)*rand()/RAND_MAX); - float y = truncf((h-v)*rand()/RAND_MAX); + float z = truncf((0.5f*w*rand()/RAND_MAX)+1.f); + float v = truncf((0.5f*w*rand()/RAND_MAX)+1.f); + float x = truncf((w-z)*rand()/RAND_MAX); + float y = truncf((h-v)*rand()/RAND_MAX); - vkvg_rectangle(ctx, x, y, z, v); + vkvg_rectangle(ctx, x, y, z, v); }*/ static float shape_size = 0.2f; -void _shape_fill(shape_t shape){ - VkvgContext ctx = _initCtx (); - for (uint32_t i=0; i<test_size; i++) { - draw_random_shape(ctx, shape, shape_size); - vkvg_fill(ctx); - } - vkvg_destroy(ctx); +void _shape_fill(shape_t shape) { + VkvgContext ctx = _initCtx(); + for (uint32_t i = 0; i < test_size; i++) { + draw_random_shape(ctx, shape, shape_size); + vkvg_fill(ctx); + } + vkvg_destroy(ctx); } -void _shape_stroke(shape_t shape){ - VkvgContext ctx = _initCtx (); - for (uint32_t i=0; i<test_size; i++) { - draw_random_shape(ctx, shape, shape_size); - vkvg_stroke (ctx); - } - vkvg_destroy(ctx); +void _shape_stroke(shape_t shape) { + VkvgContext ctx = _initCtx(); + for (uint32_t i = 0; i < test_size; i++) { + draw_random_shape(ctx, shape, shape_size); + vkvg_stroke(ctx); + } + vkvg_destroy(ctx); } -void _shape_fill_stroke(shape_t shape){ - VkvgContext ctx = _initCtx (); +void _shape_fill_stroke(shape_t shape) { + VkvgContext ctx = _initCtx(); - for (uint32_t i=0; i<test_size; i++) { - draw_random_shape(ctx, shape, shape_size); - vkvg_fill_preserve(ctx); - vkvg_stroke(ctx); - } - vkvg_destroy(ctx); + for (uint32_t i = 0; i < test_size; i++) { + draw_random_shape(ctx, shape, shape_size); + vkvg_fill_preserve(ctx); + vkvg_stroke(ctx); + } + vkvg_destroy(ctx); } -void rectangles_fill () { - _shape_fill(SHAPE_RECTANGLE); -} -void rectangles_stroke () { - _shape_stroke(SHAPE_RECTANGLE); -} -void rectangles_fill_stroke () { - _shape_fill_stroke(SHAPE_RECTANGLE); -} -void rounded_rects_fill () { - _shape_fill(SHAPE_ROUNDED_RECTANGLE); -} -void rounded_rects_stroke () { - _shape_stroke(SHAPE_ROUNDED_RECTANGLE); -} -void rounded_rects_fill_stroke () { - _shape_fill_stroke(SHAPE_ROUNDED_RECTANGLE); -} -void circles_fill () { - _shape_fill(SHAPE_CIRCLE); -} -void circles_stroke () { - _shape_stroke(SHAPE_CIRCLE); -} -void circles_fill_stroke () { - _shape_fill_stroke(SHAPE_CIRCLE); -} -void stars_fill () { - _shape_fill(SHAPE_STAR); -} -void stars_stroke () { - _shape_stroke(SHAPE_STAR); -} -void stars_fill_stroke () { - _shape_fill_stroke(SHAPE_STAR); -} -void random_fill () { - _shape_fill(SHAPE_RANDOM); -} -void random_stroke () { - _shape_stroke(SHAPE_RANDOM); -} -void random_fill_stroke () { - _shape_fill_stroke(SHAPE_RANDOM); -} +void rectangles_fill() { _shape_fill(SHAPE_RECTANGLE); } +void rectangles_stroke() { _shape_stroke(SHAPE_RECTANGLE); } +void rectangles_fill_stroke() { _shape_fill_stroke(SHAPE_RECTANGLE); } +void rounded_rects_fill() { _shape_fill(SHAPE_ROUNDED_RECTANGLE); } +void rounded_rects_stroke() { _shape_stroke(SHAPE_ROUNDED_RECTANGLE); } +void rounded_rects_fill_stroke() { _shape_fill_stroke(SHAPE_ROUNDED_RECTANGLE); } +void circles_fill() { _shape_fill(SHAPE_CIRCLE); } +void circles_stroke() { _shape_stroke(SHAPE_CIRCLE); } +void circles_fill_stroke() { _shape_fill_stroke(SHAPE_CIRCLE); } +void stars_fill() { _shape_fill(SHAPE_STAR); } +void stars_stroke() { _shape_stroke(SHAPE_STAR); } +void stars_fill_stroke() { _shape_fill_stroke(SHAPE_STAR); } +void random_fill() { _shape_fill(SHAPE_RANDOM); } +void random_stroke() { _shape_stroke(SHAPE_RANDOM); } +void random_fill_stroke() { _shape_fill_stroke(SHAPE_RANDOM); } int main(int argc, char *argv[]) { - PERFORM_TEST (rectangles_fill, argc, argv); - PERFORM_TEST (rectangles_stroke, argc, argv); - PERFORM_TEST (rectangles_fill_stroke, argc, argv); + PERFORM_TEST(rectangles_fill, argc, argv); + PERFORM_TEST(rectangles_stroke, argc, argv); + PERFORM_TEST(rectangles_fill_stroke, argc, argv); - PERFORM_TEST (rounded_rects_fill, argc, argv); - PERFORM_TEST (rounded_rects_stroke, argc, argv); - PERFORM_TEST (rounded_rects_fill_stroke, argc, argv); + PERFORM_TEST(rounded_rects_fill, argc, argv); + PERFORM_TEST(rounded_rects_stroke, argc, argv); + PERFORM_TEST(rounded_rects_fill_stroke, argc, argv); - PERFORM_TEST (circles_fill, argc, argv); - PERFORM_TEST (circles_stroke, argc, argv); - PERFORM_TEST (circles_fill_stroke, argc, argv); + PERFORM_TEST(circles_fill, argc, argv); + PERFORM_TEST(circles_stroke, argc, argv); + PERFORM_TEST(circles_fill_stroke, argc, argv); - PERFORM_TEST (stars_fill, argc, argv); - PERFORM_TEST (stars_stroke, argc, argv); - PERFORM_TEST (stars_fill_stroke, argc, argv); + PERFORM_TEST(stars_fill, argc, argv); + PERFORM_TEST(stars_stroke, argc, argv); + PERFORM_TEST(stars_fill_stroke, argc, argv); - PERFORM_TEST (random_fill, argc, argv); - PERFORM_TEST (random_stroke, argc, argv); - PERFORM_TEST (random_fill_stroke, argc, argv); + PERFORM_TEST(random_fill, argc, argv); + PERFORM_TEST(random_stroke, argc, argv); + PERFORM_TEST(random_fill_stroke, argc, argv); - return 0; + return 0; } diff --git a/tests/radial_gradient.c b/tests/radial_gradient.c index 1986f11..deaec5e 100644 --- a/tests/radial_gradient.c +++ b/tests/radial_gradient.c @@ -1,22 +1,22 @@ #include "test.h" -void test(){ - VkvgContext ctx = vkvg_create(surf); +void test() { + VkvgContext ctx = vkvg_create(surf); - VkvgPattern radial = vkvg_pattern_create_radial (250.0f,250.0f,0,300,300,260.0f); - vkvg_pattern_add_color_stop(radial, 0.0,1,0,0,1); - vkvg_pattern_add_color_stop(radial, 0.5,0,1,0,1); - vkvg_pattern_add_color_stop(radial, 1.0,0,0,0,1); - vkvg_set_source(ctx, radial); - vkvg_paint(ctx); - vkvg_pattern_destroy(radial); + VkvgPattern radial = vkvg_pattern_create_radial(250.0f, 250.0f, 0, 300, 300, 260.0f); + vkvg_pattern_add_color_stop(radial, 0.0, 1, 0, 0, 1); + vkvg_pattern_add_color_stop(radial, 0.5, 0, 1, 0, 1); + vkvg_pattern_add_color_stop(radial, 1.0, 0, 0, 0, 1); + vkvg_set_source(ctx, radial); + vkvg_paint(ctx); + vkvg_pattern_destroy(radial); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (test, argc, argv); + no_test_size = true; + PERFORM_TEST(test, argc, argv); - return 0; + return 0; } diff --git a/tests/recording.c b/tests/recording.c index 495ec4a..4fdf223 100644 --- a/tests/recording.c +++ b/tests/recording.c @@ -1,48 +1,47 @@ #include "test.h" #if VKVG_RECORDING -void test(){ - VkvgContext ctx = _initCtx(surf); +void test() { + VkvgContext ctx = _initCtx(surf); - vkvg_scale(ctx,0.5,0.5); - vkvg_start_recording(ctx); + vkvg_scale(ctx, 0.5, 0.5); + vkvg_start_recording(ctx); - vkvg_set_source_rgba(ctx,0.1f,0.9f,0.1f,1.0f); - vkvg_move_to(ctx,100,100); - vkvg_rel_line_to(ctx,50,200); - vkvg_rel_line_to(ctx,150,-100); - vkvg_rel_line_to(ctx,100,200); - vkvg_rel_line_to(ctx,-100,100); - vkvg_rel_line_to(ctx,-10,-100); - vkvg_rel_line_to(ctx,-190,-50); - vkvg_rel_line_to(ctx,300,50); - vkvg_rel_line_to(ctx,50,0); - vkvg_rel_line_to(ctx,0, 50); - vkvg_rel_line_to(ctx,50,0); - vkvg_rel_line_to(ctx,0, 50); - vkvg_rel_line_to(ctx,50,0); - vkvg_rel_line_to(ctx,0, 50); - vkvg_rel_line_to(ctx,50,0); - vkvg_rel_line_to(ctx,0, 50); - vkvg_close_path(ctx); + vkvg_set_source_rgba(ctx, 0.1f, 0.9f, 0.1f, 1.0f); + vkvg_move_to(ctx, 100, 100); + vkvg_rel_line_to(ctx, 50, 200); + vkvg_rel_line_to(ctx, 150, -100); + vkvg_rel_line_to(ctx, 100, 200); + vkvg_rel_line_to(ctx, -100, 100); + vkvg_rel_line_to(ctx, -10, -100); + vkvg_rel_line_to(ctx, -190, -50); + vkvg_rel_line_to(ctx, 300, 50); + vkvg_rel_line_to(ctx, 50, 0); + vkvg_rel_line_to(ctx, 0, 50); + vkvg_rel_line_to(ctx, 50, 0); + vkvg_rel_line_to(ctx, 0, 50); + vkvg_rel_line_to(ctx, 50, 0); + vkvg_rel_line_to(ctx, 0, 50); + vkvg_rel_line_to(ctx, 50, 0); + vkvg_rel_line_to(ctx, 0, 50); + vkvg_close_path(ctx); - vkvg_stroke_preserve(ctx); - vkvg_fill(ctx); + vkvg_stroke_preserve(ctx); + vkvg_fill(ctx); - VkvgRecording rec = vkvg_stop_recording(ctx); + VkvgRecording rec = vkvg_stop_recording(ctx); - vkvg_translate(ctx,400,0); - vkvg_replay(ctx, rec); + vkvg_translate(ctx, 400, 0); + vkvg_replay(ctx, rec); - vkvg_destroy(ctx); - vkvg_recording_destroy(rec); + vkvg_destroy(ctx); + vkvg_recording_destroy(rec); } #endif int main(int argc, char *argv[]) { - no_test_size = true; + no_test_size = true; #if VKVG_RECORDING - PERFORM_TEST (test, argc, argv); + PERFORM_TEST(test, argc, argv); #endif - return 0; + return 0; } - diff --git a/tests/rect_fill.c b/tests/rect_fill.c index 7959d34..be59976 100644 --- a/tests/rect_fill.c +++ b/tests/rect_fill.c @@ -1,39 +1,39 @@ #include "test.h" void draw(VkvgContext ctx) { - vkvg_set_source_rgba(ctx,0,0,1,0.5); - vkvg_rectangle(ctx,100,100,200,200); - vkvg_fill(ctx); + vkvg_set_source_rgba(ctx, 0, 0, 1, 0.5); + vkvg_rectangle(ctx, 100, 100, 200, 200); + vkvg_fill(ctx); - vkvg_rectangle(ctx,200,200,200,200); - vkvg_set_source_rgba(ctx,1,0,0,0.5); - vkvg_fill(ctx); + vkvg_rectangle(ctx, 200, 200, 200, 200); + vkvg_set_source_rgba(ctx, 1, 0, 0, 0.5); + vkvg_fill(ctx); } -void test(){ +void test() { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); - draw(ctx); + draw(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void test_evenodd(){ +void test_evenodd() { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); - draw(ctx); + draw(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (test, argc, argv); - PERFORM_TEST (test_evenodd, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(test, argc, argv); + PERFORM_TEST(test_evenodd, argc, argv); + return 0; } diff --git a/tests/save_restore.c b/tests/save_restore.c index b50861b..c51cf2c 100644 --- a/tests/save_restore.c +++ b/tests/save_restore.c @@ -1,34 +1,33 @@ #include "test.h" void recurse_draw(VkvgContext ctx, int depth) { - depth++; - vkvg_save(ctx); + depth++; + vkvg_save(ctx); - vkvg_translate (ctx, 5,5); - vkvg_rectangle(ctx, (float)depth,(float)depth,200,200); - /*vkvg_clip_preserve(ctx); - vkvg_set_source_rgb(ctx, 1.f/depth, 1.f / depth, 1.f / depth); - vkvg_fill_preserve(ctx);*/ - vkvg_set_source_rgb(ctx, 0,1,0); - vkvg_stroke(ctx); + vkvg_translate(ctx, 5, 5); + vkvg_rectangle(ctx, (float)depth, (float)depth, 200, 200); + /*vkvg_clip_preserve(ctx); + vkvg_set_source_rgb(ctx, 1.f/depth, 1.f / depth, 1.f / depth); + vkvg_fill_preserve(ctx);*/ + vkvg_set_source_rgb(ctx, 0, 1, 0); + vkvg_stroke(ctx); - if (depth < 20) - recurse_draw (ctx, depth); + if (depth < 20) + recurse_draw(ctx, depth); - vkvg_restore(ctx); + vkvg_restore(ctx); } +void test() { + VkvgContext ctx = vkvg_create(surf); -void test(){ - VkvgContext ctx = vkvg_create(surf); + recurse_draw(ctx, 0); - recurse_draw(ctx, 0); - - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (test, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(test, argc, argv); + return 0; } diff --git a/tests/simple_paint.c b/tests/simple_paint.c index 7dc47d1..ac726b3 100644 --- a/tests/simple_paint.c +++ b/tests/simple_paint.c @@ -1,56 +1,56 @@ #include "test.h" -void paint(){ - VkvgContext ctx = _initCtx(surf); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_paint(ctx); - vkvg_destroy(ctx); +void paint() { + VkvgContext ctx = _initCtx(surf); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_paint(ctx); + vkvg_destroy(ctx); } -void paint_with_rotation(){ - VkvgContext ctx = _initCtx(surf); - vkvg_rotate(ctx, 45); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_paint(ctx); - vkvg_destroy(ctx); +void paint_with_rotation() { + VkvgContext ctx = _initCtx(surf); + vkvg_rotate(ctx, 45); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_paint(ctx); + vkvg_destroy(ctx); } -void paint_with_scale(){ - VkvgContext ctx = _initCtx(surf); - vkvg_scale (ctx, 0.2f,0.2f); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_paint(ctx); - vkvg_destroy(ctx); +void paint_with_scale() { + VkvgContext ctx = _initCtx(surf); + vkvg_scale(ctx, 0.2f, 0.2f); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_paint(ctx); + vkvg_destroy(ctx); } -void paint_rect(){ - VkvgContext ctx = _initCtx(surf); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_rectangle(ctx,100,100,300,200); - vkvg_paint(ctx); - vkvg_destroy(ctx); +void paint_rect() { + VkvgContext ctx = _initCtx(surf); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_paint(ctx); + vkvg_destroy(ctx); } -//TODO:test failed: full screen paint instead of rotated rect -void paint_rect_with_rotation(){ - VkvgContext ctx = _initCtx(surf); - vkvg_rotate(ctx, 45); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_rectangle(ctx,100,100,300,200); - vkvg_paint(ctx); - vkvg_destroy(ctx); +// TODO:test failed: full screen paint instead of rotated rect +void paint_rect_with_rotation() { + VkvgContext ctx = _initCtx(surf); + vkvg_rotate(ctx, 45); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_paint(ctx); + vkvg_destroy(ctx); } -void paint_rect_with_scale(){ - VkvgContext ctx = _initCtx(surf); - vkvg_scale (ctx, 0.2f,0.2f); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_rectangle(ctx,100,100,300,200); - vkvg_paint(ctx); - vkvg_destroy(ctx); +void paint_rect_with_scale() { + VkvgContext ctx = _initCtx(surf); + vkvg_scale(ctx, 0.2f, 0.2f); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_rectangle(ctx, 100, 100, 300, 200); + vkvg_paint(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (paint, argc, argv); - PERFORM_TEST (paint_with_rotation, argc, argv); - PERFORM_TEST (paint_with_scale, argc, argv); - PERFORM_TEST (paint_rect, argc, argv); - PERFORM_TEST (paint_rect_with_rotation, argc, argv); - PERFORM_TEST (paint_rect_with_scale, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(paint, argc, argv); + PERFORM_TEST(paint_with_rotation, argc, argv); + PERFORM_TEST(paint_with_scale, argc, argv); + PERFORM_TEST(paint_rect, argc, argv); + PERFORM_TEST(paint_rect_with_rotation, argc, argv); + PERFORM_TEST(paint_rect_with_scale, argc, argv); + return 0; } diff --git a/tests/stroke.c b/tests/stroke.c index 5011881..09939cd 100644 --- a/tests/stroke.c +++ b/tests/stroke.c @@ -1,60 +1,60 @@ #include "test.h" -void test(){ - VkvgContext ctx = vkvg_create(surf); +void test() { + VkvgContext ctx = vkvg_create(surf); - vkvg_set_line_width(ctx, 1); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_move_to(ctx,200.5f,200.5f); - vkvg_line_to(ctx,400.5f,200.5f); - vkvg_line_to(ctx,400.5f,400.5f); - vkvg_line_to(ctx,200.5f,400.5f); - vkvg_close_path(ctx); - vkvg_stroke(ctx); + vkvg_set_line_width(ctx, 1); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_move_to(ctx, 200.5f, 200.5f); + vkvg_line_to(ctx, 400.5f, 200.5f); + vkvg_line_to(ctx, 400.5f, 400.5f); + vkvg_line_to(ctx, 200.5f, 400.5f); + vkvg_close_path(ctx); + vkvg_stroke(ctx); - vkvg_set_source_rgba(ctx,0,1,0,1); - vkvg_move_to(ctx,300.5f,300.5f); - vkvg_line_to(ctx,500.5f,300.5f); - vkvg_line_to(ctx,500.5f,500.5f); - vkvg_line_to(ctx,300.5f,500.5f); - vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 0, 1, 0, 1); + vkvg_move_to(ctx, 300.5f, 300.5f); + vkvg_line_to(ctx, 500.5f, 300.5f); + vkvg_line_to(ctx, 500.5f, 500.5f); + vkvg_line_to(ctx, 300.5f, 500.5f); + vkvg_stroke(ctx); - //vkvg_set_source_rgba(ctx,0,0.2,0.35,1); - //vkvg_fill(ctx); + // vkvg_set_source_rgba(ctx,0,0.2,0.35,1); + // vkvg_fill(ctx); - vkvg_set_source_rgba(ctx,0.5f,1,0,1); - vkvg_move_to(ctx,320.5f,320.5f); - vkvg_line_to(ctx,520.5f,320.5f); - vkvg_line_to(ctx,520.5f,520.5f); - vkvg_line_to(ctx,320.5f,520.5f); - //vkvg_close_path(ctx); - vkvg_stroke(ctx); - vkvg_set_line_width(ctx, 40); - vkvg_set_source_rgba(ctx,0.5f,0.6f,1,1.0f); - vkvg_move_to(ctx,700,475); - vkvg_line_to(ctx,400,475); - vkvg_stroke(ctx); - vkvg_set_source_rgba(ctx,0,0.5f,0.5f,0.5f); - vkvg_move_to(ctx,300,200); - vkvg_arc(ctx, 200,200,100,0, M_PIF); - vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 0.5f, 1, 0, 1); + vkvg_move_to(ctx, 320.5f, 320.5f); + vkvg_line_to(ctx, 520.5f, 320.5f); + vkvg_line_to(ctx, 520.5f, 520.5f); + vkvg_line_to(ctx, 320.5f, 520.5f); + // vkvg_close_path(ctx); + vkvg_stroke(ctx); + vkvg_set_line_width(ctx, 40); + vkvg_set_source_rgba(ctx, 0.5f, 0.6f, 1, 1.0f); + vkvg_move_to(ctx, 700, 475); + vkvg_line_to(ctx, 400, 475); + vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 0, 0.5f, 0.5f, 0.5f); + vkvg_move_to(ctx, 300, 200); + vkvg_arc(ctx, 200, 200, 100, 0, M_PIF); + vkvg_stroke(ctx); - vkvg_set_line_width(ctx, 20); - vkvg_set_source_rgba(ctx,0.1f,0.1f,0.1f,0.5f); - vkvg_move_to(ctx,100,60); - vkvg_line_to(ctx,400,600); - vkvg_stroke(ctx); + vkvg_set_line_width(ctx, 20); + vkvg_set_source_rgba(ctx, 0.1f, 0.1f, 0.1f, 0.5f); + vkvg_move_to(ctx, 100, 60); + vkvg_line_to(ctx, 400, 600); + vkvg_stroke(ctx); - vkvg_set_source_rgba(ctx,1,1,1,1); - vkvg_set_line_width(ctx, 1); - vkvg_rectangle(ctx,600.5f,200.5f,100,60); - vkvg_stroke(ctx); + vkvg_set_source_rgba(ctx, 1, 1, 1, 1); + vkvg_set_line_width(ctx, 1); + vkvg_rectangle(ctx, 600.5f, 200.5f, 100, 60); + vkvg_stroke(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (test, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(test, argc, argv); + return 0; } diff --git a/tests/surface.c b/tests/surface.c index 2438a44..6aa910c 100644 --- a/tests/surface.c +++ b/tests/surface.c @@ -1,22 +1,22 @@ #include "test.h" -void create_destroy_multi_512(){ - VkvgSurface* surfs = (VkvgSurface*)malloc(sizeof(VkvgSurface)*test_size); - for (uint32_t i = 0; i < test_size; i++) - surfs[i] = vkvg_surface_create (device, 512, 512); - for (uint32_t i = 0; i < test_size; i++) - vkvg_surface_destroy(surfs[i]); - free(surfs); +void create_destroy_multi_512() { + VkvgSurface *surfs = (VkvgSurface *)malloc(sizeof(VkvgSurface) * test_size); + for (uint32_t i = 0; i < test_size; i++) + surfs[i] = vkvg_surface_create(device, 512, 512); + for (uint32_t i = 0; i < test_size; i++) + vkvg_surface_destroy(surfs[i]); + free(surfs); } -void create_destroy_single_512(){ - VkvgSurface s = vkvg_surface_create (device, 512, 512); - vkvg_surface_destroy (s); +void create_destroy_single_512() { + VkvgSurface s = vkvg_surface_create(device, 512, 512); + vkvg_surface_destroy(s); } int main(int argc, char *argv[]) { - PERFORM_TEST (create_destroy_multi_512, argc, argv); - no_test_size = true; - PERFORM_TEST (create_destroy_single_512, argc, argv); - return 0; + PERFORM_TEST(create_destroy_multi_512, argc, argv); + no_test_size = true; + PERFORM_TEST(create_destroy_single_512, argc, argv); + return 0; } diff --git a/tests/svg.c b/tests/svg.c index f4f0569..7a40026 100644 --- a/tests/svg.c +++ b/tests/svg.c @@ -2,57 +2,56 @@ #include "vkvg-svg.h" -static float rotation = 0.f; -static const char* path = "data/tiger.svg"; -static const char* svgSubPath = "data/checkbox.svg"; - +static float rotation = 0.f; +static const char *path = "data/tiger.svg"; +static const char *svgSubPath = "data/checkbox.svg"; void svg_surface() { - VkvgSurface svgSurf = vkvg_surface_create_from_svg (device, test_width, test_height, path); + VkvgSurface svgSurf = vkvg_surface_create_from_svg(device, test_width, test_height, path); - VkvgContext ctx = _initCtx(surf); + VkvgContext ctx = _initCtx(surf); - vkvg_set_source_rgb(ctx,1,1,1); - vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 1, 1, 1); + vkvg_paint(ctx); - vkvg_set_source_surface(ctx, svgSurf, 0,0); - vkvg_paint(ctx); + vkvg_set_source_surface(ctx, svgSurf, 0, 0); + vkvg_paint(ctx); - vkvg_destroy(ctx); - vkvg_surface_destroy(svgSurf); + vkvg_destroy(ctx); + vkvg_surface_destroy(svgSurf); } -void vkvg_svg () { - VkvgSvg svg = vkvg_svg_load (path); - uint32_t w, h; - vkvg_svg_get_dimensions(svg, &w, &h); - VkvgContext ctx = _initCtx(surf); - vkvg_clear(ctx); +void vkvg_svg() { + VkvgSvg svg = vkvg_svg_load(path); + uint32_t w, h; + vkvg_svg_get_dimensions(svg, &w, &h); + VkvgContext ctx = _initCtx(surf); + vkvg_clear(ctx); - vkvg_svg_render (svg, ctx, NULL); + vkvg_svg_render(svg, ctx, NULL); - vkvg_destroy(ctx); - vkvg_svg_destroy (svg); + vkvg_destroy(ctx); + vkvg_svg_destroy(svg); } -void vkvg_svg_sub () { - VkvgSvg svg = vkvg_svg_load (svgSubPath); - uint32_t w, h; - vkvg_svg_get_dimensions(svg, &w, &h); - VkvgContext ctx = _initCtx(surf); - vkvg_clear(ctx); +void vkvg_svg_sub() { + VkvgSvg svg = vkvg_svg_load(svgSubPath); + uint32_t w, h; + vkvg_svg_get_dimensions(svg, &w, &h); + VkvgContext ctx = _initCtx(surf); + vkvg_clear(ctx); - vkvg_svg_render (svg, ctx, "#True"); - vkvg_translate(ctx, 200, 0); - vkvg_svg_render (svg, ctx, "#False"); + vkvg_svg_render(svg, ctx, "#True"); + vkvg_translate(ctx, 200, 0); + vkvg_svg_render(svg, ctx, "#False"); - vkvg_destroy(ctx); - vkvg_svg_destroy (svg); + vkvg_destroy(ctx); + vkvg_svg_destroy(svg); } int main(int argc, char *argv[]) { - no_test_size = true; + no_test_size = true; - PERFORM_TEST (svg_surface, argc, argv); - PERFORM_TEST (vkvg_svg, argc, argv); - PERFORM_TEST (vkvg_svg_sub, argc, argv); - return 0; + PERFORM_TEST(svg_surface, argc, argv); + PERFORM_TEST(vkvg_svg, argc, argv); + PERFORM_TEST(vkvg_svg_sub, argc, argv); + return 0; } diff --git a/tests/test1.c b/tests/test1.c index 302f8a7..60249aa 100644 --- a/tests/test1.c +++ b/tests/test1.c @@ -22,380 +22,378 @@ #include "test.h" -void cairo_test_fill_rule (VkvgContext cr){ - vkvg_set_line_width (cr, 6); +void cairo_test_fill_rule(VkvgContext cr) { + vkvg_set_line_width(cr, 6); - //vkvg_scale(cr,3,3); - vkvg_set_source_rgba(cr,1,0,0,1); - vkvg_move_to(cr,50,150); - vkvg_rel_line_to(cr,50,70); - vkvg_rel_line_to(cr,50,0); - vkvg_rel_line_to(cr,50,-70); - vkvg_rel_line_to(cr,0,-60); - vkvg_rel_line_to(cr,-50,-30); - vkvg_rel_line_to(cr,-50,0); - vkvg_rel_line_to(cr,-50,30); - vkvg_close_path(cr); + // vkvg_scale(cr,3,3); + vkvg_set_source_rgba(cr, 1, 0, 0, 1); + vkvg_move_to(cr, 50, 150); + vkvg_rel_line_to(cr, 50, 70); + vkvg_rel_line_to(cr, 50, 0); + vkvg_rel_line_to(cr, 50, -70); + vkvg_rel_line_to(cr, 0, -60); + vkvg_rel_line_to(cr, -50, -30); + vkvg_rel_line_to(cr, -50, 0); + vkvg_rel_line_to(cr, -50, 30); + vkvg_close_path(cr); + // vkvg_set_line_join(cr,VKVG_LINE_JOIN_ROUND); + vkvg_set_source_rgb(cr, 0, 0.7f, 0); + vkvg_rectangle(cr, 12, 12, 232, 70); + // vkvg_stroke (cr); + // vkvg_new_sub_path (cr); + vkvg_arc(cr, 64, 64, 40, 0, M_PIF * 2.f); + // vkvg_close_path(cr); -// vkvg_set_line_join(cr,VKVG_LINE_JOIN_ROUND); - vkvg_set_source_rgb (cr, 0, 0.7f, 0); - vkvg_rectangle (cr, 12, 12, 232, 70); - //vkvg_stroke (cr); -// vkvg_new_sub_path (cr); - vkvg_arc (cr, 64, 64, 40, 0, M_PIF*2.f); - //vkvg_close_path(cr); + vkvg_new_sub_path(cr); + vkvg_arc_negative(cr, 192, 64, 40, M_PIF * 2.f, 0); + // vkvg_close_path(cr); - vkvg_new_sub_path (cr); - vkvg_arc_negative (cr, 192, 64, 40, M_PIF*2.f, 0); - //vkvg_close_path(cr); + // vkvg_rectangle (cr, 30, 30, 20, 200); + // vkvg_rectangle (cr, 130, 30, 20, 200); + // vkvg_set_fill_rule (cr, vkvg_FILL_RULE_EVEN_ODD); - //vkvg_rectangle (cr, 30, 30, 20, 200); - //vkvg_rectangle (cr, 130, 30, 20, 200); - //vkvg_set_fill_rule (cr, vkvg_FILL_RULE_EVEN_ODD); + vkvg_fill_preserve(cr); - vkvg_fill_preserve(cr); - - vkvg_set_source_rgb (cr, 0, 0, 0); - vkvg_stroke (cr); + vkvg_set_source_rgb(cr, 0, 0, 0); + vkvg_stroke(cr); } -void cairo_test_text (VkvgContext cr) { - vkvg_text_extents_t extents; - vkvg_font_extents_t ft; +void cairo_test_text(VkvgContext cr) { + vkvg_text_extents_t extents; + vkvg_font_extents_t ft; - //vkvg_set_fill_rule(cr, VKVG_FILL_RULE_NON_ZERO); - const char *utf8 = "vkvg|Ãp"; - float x,y; + // vkvg_set_fill_rule(cr, VKVG_FILL_RULE_NON_ZERO); + const char *utf8 = "vkvg|Ãp"; + float x, y; - //vkvg_select_font_face (cr, "times"); - vkvg_select_font_face (cr, "linux biolinum keyboard"); - vkvg_set_font_size (cr, 50); - vkvg_font_extents(cr, &ft); - vkvg_text_extents (cr, utf8, &extents); - vkvg_set_source_rgb(cr,0,0,0); + // vkvg_select_font_face (cr, "times"); + vkvg_select_font_face(cr, "linux biolinum keyboard"); + vkvg_set_font_size(cr, 50); + vkvg_font_extents(cr, &ft); + vkvg_text_extents(cr, utf8, &extents); + vkvg_set_source_rgb(cr, 0, 0, 0); - x=25.0f; - y=150.0f; + x = 25.0f; + y = 150.0f; - vkvg_move_to (cr, x,y); - vkvg_show_text (cr, utf8); + vkvg_move_to(cr, x, y); + vkvg_show_text(cr, utf8); - /* draw helping lines */ - vkvg_set_source_rgba (cr, 0, 0.2f, 0.2f, 0.6f); - vkvg_set_line_width (cr, 1.0f); - vkvg_new_path(cr); - vkvg_arc (cr, x, y, 10.0f, 0, 2.f*M_PIF); - vkvg_fill (cr); - vkvg_move_to (cr, x,y); - //vkvg_rel_line_to (cr, 0, -30); - vkvg_rel_line_to (cr, 0, -ft.ascent); - vkvg_rel_line_to (cr, extents.width, 0); - vkvg_rel_line_to (cr, extents.x_bearing, -extents.y_bearing); + /* draw helping lines */ + vkvg_set_source_rgba(cr, 0, 0.2f, 0.2f, 0.6f); + vkvg_set_line_width(cr, 1.0f); + vkvg_new_path(cr); + vkvg_arc(cr, x, y, 10.0f, 0, 2.f * M_PIF); + vkvg_fill(cr); + vkvg_move_to(cr, x, y); + // vkvg_rel_line_to (cr, 0, -30); + vkvg_rel_line_to(cr, 0, -ft.ascent); + vkvg_rel_line_to(cr, extents.width, 0); + vkvg_rel_line_to(cr, extents.x_bearing, -extents.y_bearing); - vkvg_stroke (cr); + vkvg_stroke(cr); - vkvg_move_to (cr, x,y); - vkvg_rel_line_to (cr, extents.width, 0); - vkvg_set_source_rgba (cr, 0.0, 0.0, 0.9f, 0.6f); + vkvg_move_to(cr, x, y); + vkvg_rel_line_to(cr, extents.width, 0); + vkvg_set_source_rgba(cr, 0.0, 0.0, 0.9f, 0.6f); - vkvg_stroke (cr); + vkvg_stroke(cr); - vkvg_move_to (cr, x,y); - 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); + vkvg_move_to(cr, x, y); + 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); - vkvg_stroke (cr); + vkvg_stroke(cr); - vkvg_move_to (cr, x-10,y-ft.ascent); - vkvg_rel_line_to (cr, 0, ft.height); - vkvg_set_source_rgba (cr, 0.0, 0.1f, 0.0, 0.6f); + vkvg_move_to(cr, x - 10, y - ft.ascent); + vkvg_rel_line_to(cr, 0, ft.height); + vkvg_set_source_rgba(cr, 0.0, 0.1f, 0.0, 0.6f); - vkvg_stroke (cr); + vkvg_stroke(cr); } -void cairo_test_clip (VkvgContext cr){ - vkvg_arc (cr, 128.0f, 128.0f, 76.8f, 0, 2.f * M_PIF); - vkvg_clip (cr); - //vkvg_new_path (cr); /* current path is not - // consumed by vkvg_clip() */ - vkvg_set_source_rgba(cr, 0, 0, 0, 1); - vkvg_rectangle (cr, 0, 0, 256, 256); - vkvg_fill (cr); - vkvg_set_source_rgba (cr, 0, 1, 0, 1); - vkvg_move_to (cr, -100, -100); - vkvg_line_to (cr, 256, 256); - vkvg_move_to (cr, 356, -100); - vkvg_line_to (cr, 0, 256); - vkvg_set_line_width (cr, 10.0f); - vkvg_stroke (cr); +void cairo_test_clip(VkvgContext cr) { + vkvg_arc(cr, 128.0f, 128.0f, 76.8f, 0, 2.f * M_PIF); + vkvg_clip(cr); + // vkvg_new_path (cr); /* current path is not + // consumed by vkvg_clip() */ + vkvg_set_source_rgba(cr, 0, 0, 0, 1); + vkvg_rectangle(cr, 0, 0, 256, 256); + vkvg_fill(cr); + vkvg_set_source_rgba(cr, 0, 1, 0, 1); + vkvg_move_to(cr, -100, -100); + vkvg_line_to(cr, 256, 256); + vkvg_move_to(cr, 356, -100); + vkvg_line_to(cr, 0, 256); + vkvg_set_line_width(cr, 10.0f); + vkvg_stroke(cr); } -void cairo_test_curves (VkvgContext cr){ - float x=25.6f, y=128.0f; - float x1=102.4f, y1=230.4f, - x2=153.6f, y2=25.6f, - x3=230.4f, y3=128.0f; +void cairo_test_curves(VkvgContext cr) { + float x = 25.6f, y = 128.0f; + float x1 = 102.4f, y1 = 230.4f, x2 = 153.6f, y2 = 25.6f, x3 = 230.4f, y3 = 128.0f; - vkvg_set_source_rgb (cr, 0, 0, 0); - vkvg_move_to (cr, x, y); - vkvg_curve_to (cr, x1, y1, x2, y2, x3, y3); + vkvg_set_source_rgb(cr, 0, 0, 0); + vkvg_move_to(cr, x, y); + vkvg_curve_to(cr, x1, y1, x2, y2, x3, y3); - vkvg_set_line_width (cr, 10.0f); - vkvg_stroke (cr); + vkvg_set_line_width(cr, 10.0f); + vkvg_stroke(cr); - vkvg_set_source_rgba (cr, 1, 0.2f, 0.2f, 0.6f); - vkvg_set_line_width (cr, 6.0f); - vkvg_move_to (cr,x,y); vkvg_line_to (cr,x1,y1); - vkvg_move_to (cr,x2,y2); vkvg_line_to (cr,x3,y3); - vkvg_stroke (cr); + vkvg_set_source_rgba(cr, 1, 0.2f, 0.2f, 0.6f); + vkvg_set_line_width(cr, 6.0f); + vkvg_move_to(cr, x, y); + vkvg_line_to(cr, x1, y1); + vkvg_move_to(cr, x2, y2); + vkvg_line_to(cr, x3, y3); + vkvg_stroke(cr); } -void cairo_test_rounded_rect (VkvgContext cr) { - /* a custom shape that could be wrapped in a function */ - float x0 = 25.6f, /* parameters like vkvg_rectangle */ - y0 = 25.6f, - rect_width = 204.8f, - rect_height = 204.8f, - radius = 102.4f; /* and an approximate curvature radius */ +void cairo_test_rounded_rect(VkvgContext cr) { + /* a custom shape that could be wrapped in a function */ + float x0 = 25.6f, /* parameters like vkvg_rectangle */ + y0 = 25.6f, rect_width = 204.8f, rect_height = 204.8f, + radius = 102.4f; /* and an approximate curvature radius */ - float x1,y1; + float x1, y1; - x1=x0+rect_width; - y1=y0+rect_height; - if (!rect_width || !rect_height) - return; - if (rect_width/2<radius) { - if (rect_height/2<radius) { - vkvg_move_to (cr, x0, (y0 + y1)/2); - vkvg_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0); - vkvg_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2); - vkvg_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1); - vkvg_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2); - } else { - vkvg_move_to (cr, x0, y0 + radius); - vkvg_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0); - vkvg_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius); - vkvg_line_to (cr, x1 , y1 - radius); - vkvg_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1); - vkvg_curve_to (cr, x0, y1, x0, y1, x0, y1- radius); - } - } else { - if (rect_height/2<radius) { - vkvg_move_to (cr, x0, (y0 + y1)/2); - vkvg_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0); - vkvg_line_to (cr, x1 - radius, y0); - vkvg_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2); - vkvg_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1); - vkvg_line_to (cr, x0 + radius, y1); - vkvg_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2); - } else { - vkvg_move_to (cr, x0, y0 + radius); - vkvg_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0); - vkvg_line_to (cr, x1 - radius, y0); - vkvg_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius); - vkvg_line_to (cr, x1 , y1 - radius); - vkvg_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1); - vkvg_line_to (cr, x0 + radius, y1); - vkvg_curve_to (cr, x0, y1, x0, y1, x0, y1- radius); - } - } - vkvg_close_path (cr); + x1 = x0 + rect_width; + y1 = y0 + rect_height; + if (!rect_width || !rect_height) + return; + if (rect_width / 2 < radius) { + if (rect_height / 2 < radius) { + vkvg_move_to(cr, x0, (y0 + y1) / 2); + vkvg_curve_to(cr, x0, y0, x0, y0, (x0 + x1) / 2, y0); + vkvg_curve_to(cr, x1, y0, x1, y0, x1, (y0 + y1) / 2); + vkvg_curve_to(cr, x1, y1, x1, y1, (x1 + x0) / 2, y1); + vkvg_curve_to(cr, x0, y1, x0, y1, x0, (y0 + y1) / 2); + } else { + vkvg_move_to(cr, x0, y0 + radius); + vkvg_curve_to(cr, x0, y0, x0, y0, (x0 + x1) / 2, y0); + vkvg_curve_to(cr, x1, y0, x1, y0, x1, y0 + radius); + vkvg_line_to(cr, x1, y1 - radius); + vkvg_curve_to(cr, x1, y1, x1, y1, (x1 + x0) / 2, y1); + vkvg_curve_to(cr, x0, y1, x0, y1, x0, y1 - radius); + } + } else { + if (rect_height / 2 < radius) { + vkvg_move_to(cr, x0, (y0 + y1) / 2); + vkvg_curve_to(cr, x0, y0, x0, y0, x0 + radius, y0); + vkvg_line_to(cr, x1 - radius, y0); + vkvg_curve_to(cr, x1, y0, x1, y0, x1, (y0 + y1) / 2); + vkvg_curve_to(cr, x1, y1, x1, y1, x1 - radius, y1); + vkvg_line_to(cr, x0 + radius, y1); + vkvg_curve_to(cr, x0, y1, x0, y1, x0, (y0 + y1) / 2); + } else { + vkvg_move_to(cr, x0, y0 + radius); + vkvg_curve_to(cr, x0, y0, x0, y0, x0 + radius, y0); + vkvg_line_to(cr, x1 - radius, y0); + vkvg_curve_to(cr, x1, y0, x1, y0, x1, y0 + radius); + vkvg_line_to(cr, x1, y1 - radius); + vkvg_curve_to(cr, x1, y1, x1, y1, x1 - radius, y1); + vkvg_line_to(cr, x0 + radius, y1); + vkvg_curve_to(cr, x0, y1, x0, y1, x0, y1 - radius); + } + } + vkvg_close_path(cr); - vkvg_set_source_rgb (cr, 0.5f, 0.5f, 1); - vkvg_fill_preserve (cr); - vkvg_set_source_rgba (cr, 0.5f, 0, 0, 0.5f); - vkvg_set_line_width (cr, 10.0f); - vkvg_stroke (cr); + vkvg_set_source_rgb(cr, 0.5f, 0.5f, 1); + vkvg_fill_preserve(cr); + vkvg_set_source_rgba(cr, 0.5f, 0, 0, 0.5f); + vkvg_set_line_width(cr, 10.0f); + vkvg_stroke(cr); } -void cairo_test_fill_and_stroke2 (VkvgContext cr){ - vkvg_move_to (cr, 128.0f, 25.6f); - vkvg_line_to (cr, 230.4f, 230.4f); - vkvg_rel_line_to (cr, -102.4f, 0.0); - vkvg_curve_to (cr, 51.2f, 230.4f, 51.2f, 128.0f, 128.0f, 128.0f); - vkvg_close_path (cr); - - vkvg_move_to (cr, 64.0f, 25.6f); - vkvg_rel_line_to (cr, 51.2f, 51.2f); - vkvg_rel_line_to (cr, -51.2f, 51.2f); - vkvg_rel_line_to (cr, -51.2f, -51.2f); - vkvg_close_path (cr); +void cairo_test_fill_and_stroke2(VkvgContext cr) { + vkvg_move_to(cr, 128.0f, 25.6f); + vkvg_line_to(cr, 230.4f, 230.4f); + vkvg_rel_line_to(cr, -102.4f, 0.0); + vkvg_curve_to(cr, 51.2f, 230.4f, 51.2f, 128.0f, 128.0f, 128.0f); + vkvg_close_path(cr); - /*vkvg_translate(cr,100,100); - vkvg_move_to (cr, 100, 100); - vkvg_line_to(cr,300,300); - vkvg_line_to(cr,100,300);*/ + vkvg_move_to(cr, 64.0f, 25.6f); + vkvg_rel_line_to(cr, 51.2f, 51.2f); + vkvg_rel_line_to(cr, -51.2f, 51.2f); + vkvg_rel_line_to(cr, -51.2f, -51.2f); + vkvg_close_path(cr); + /*vkvg_translate(cr,100,100); + vkvg_move_to (cr, 100, 100); + vkvg_line_to(cr,300,300); + vkvg_line_to(cr,100,300);*/ - vkvg_set_line_width (cr, 10.0f); - vkvg_set_source_rgb (cr, 0, 0, 1); - vkvg_fill_preserve (cr); - vkvg_set_source_rgb (cr, 0, 0, 0); - vkvg_stroke (cr); + vkvg_set_line_width(cr, 10.0f); + vkvg_set_source_rgb(cr, 0, 0, 1); + vkvg_fill_preserve(cr); + vkvg_set_source_rgb(cr, 0, 0, 0); + vkvg_stroke(cr); } -void cairo_print_arc_neg (VkvgContext cr){ - float xc = 128.0f; - float yc = 128.0f; - float radius = 100.0f; - float angle1 = 45.0f * (M_PIF/180.0f); /* angles are specified */ - float angle2 = 180.0f * (M_PIF/180.0f); /* in radians */ - - vkvg_set_source_rgba(cr, 0, 0, 0, 1); - vkvg_set_line_width (cr, 10.0f); - vkvg_arc_negative (cr, xc, yc, radius, angle1, angle2); - vkvg_stroke (cr); +void cairo_print_arc_neg(VkvgContext cr) { + float xc = 128.0f; + float yc = 128.0f; + float radius = 100.0f; + float angle1 = 45.0f * (M_PIF / 180.0f); /* angles are specified */ + float angle2 = 180.0f * (M_PIF / 180.0f); /* in radians */ - /* draw helping lines */ - vkvg_set_source_rgba (cr, 1, 0.2f, 0.2f, 0.6f); - vkvg_set_line_width (cr, 6.0f); + vkvg_set_source_rgba(cr, 0, 0, 0, 1); + vkvg_set_line_width(cr, 10.0f); + vkvg_arc_negative(cr, xc, yc, radius, angle1, angle2); + vkvg_stroke(cr); - vkvg_arc (cr, xc, yc, 10.0f, 0, 2.f*M_PIF); - vkvg_fill (cr); + /* draw helping lines */ + vkvg_set_source_rgba(cr, 1, 0.2f, 0.2f, 0.6f); + vkvg_set_line_width(cr, 6.0f); - 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); + vkvg_arc(cr, xc, yc, 10.0f, 0, 2.f * M_PIF); + vkvg_fill(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_test_line_caps (VkvgContext cr) { - vkvg_set_source_rgb (cr, 0, 0, 0); - vkvg_set_line_width (cr, 30.0f); - vkvg_set_line_cap (cr, VKVG_LINE_CAP_BUTT); /* default */ - vkvg_move_to (cr, 64.0f, 50.0f); vkvg_line_to (cr, 64.0f, 200.0f); - vkvg_stroke (cr); - vkvg_set_line_cap (cr, VKVG_LINE_CAP_ROUND); - vkvg_move_to (cr, 128.0f, 50.0f); vkvg_line_to (cr, 128.0f, 200.0f); - vkvg_stroke (cr); - vkvg_set_line_cap (cr, VKVG_LINE_CAP_SQUARE); - vkvg_move_to (cr, 192.0f, 50.0f); vkvg_line_to (cr, 192.0f, 200.0f); - vkvg_stroke (cr); +void cairo_test_line_caps(VkvgContext cr) { + vkvg_set_source_rgb(cr, 0, 0, 0); + vkvg_set_line_width(cr, 30.0f); + vkvg_set_line_cap(cr, VKVG_LINE_CAP_BUTT); /* default */ + vkvg_move_to(cr, 64.0f, 50.0f); + vkvg_line_to(cr, 64.0f, 200.0f); + vkvg_stroke(cr); + vkvg_set_line_cap(cr, VKVG_LINE_CAP_ROUND); + vkvg_move_to(cr, 128.0f, 50.0f); + vkvg_line_to(cr, 128.0f, 200.0f); + vkvg_stroke(cr); + vkvg_set_line_cap(cr, VKVG_LINE_CAP_SQUARE); + vkvg_move_to(cr, 192.0f, 50.0f); + vkvg_line_to(cr, 192.0f, 200.0f); + vkvg_stroke(cr); - /* draw helping lines */ - vkvg_set_source_rgb (cr, 1, 0.2f, 0.2f); - vkvg_set_line_width (cr, 2.56f); - vkvg_move_to (cr, 64.0f, 50.0f); vkvg_line_to (cr, 64.0f, 200.0f); - vkvg_move_to (cr, 128.0f, 50.0f); vkvg_line_to (cr, 128.0f, 200.0f); - vkvg_move_to (cr, 192.0f, 50.0f); vkvg_line_to (cr, 192.0f, 200.0f); - vkvg_stroke (cr); + /* draw helping lines */ + vkvg_set_source_rgb(cr, 1, 0.2f, 0.2f); + vkvg_set_line_width(cr, 2.56f); + vkvg_move_to(cr, 64.0f, 50.0f); + vkvg_line_to(cr, 64.0f, 200.0f); + vkvg_move_to(cr, 128.0f, 50.0f); + vkvg_line_to(cr, 128.0f, 200.0f); + vkvg_move_to(cr, 192.0f, 50.0f); + vkvg_line_to(cr, 192.0f, 200.0f); + vkvg_stroke(cr); } -void cairo_test_line_joins (VkvgContext cr) { - vkvg_set_source_rgb (cr, 0, 0, 0); - vkvg_set_line_width (cr, 40.96f); - vkvg_move_to (cr, 76.8f, 84.48f); - vkvg_rel_line_to (cr, 51.2f, -51.2f); - vkvg_rel_line_to (cr, 51.2f, 51.2f); - vkvg_set_line_join (cr, VKVG_LINE_JOIN_MITER); /* default */ - vkvg_stroke (cr); +void cairo_test_line_joins(VkvgContext cr) { + vkvg_set_source_rgb(cr, 0, 0, 0); + vkvg_set_line_width(cr, 40.96f); + vkvg_move_to(cr, 76.8f, 84.48f); + vkvg_rel_line_to(cr, 51.2f, -51.2f); + vkvg_rel_line_to(cr, 51.2f, 51.2f); + vkvg_set_line_join(cr, VKVG_LINE_JOIN_MITER); /* default */ + vkvg_stroke(cr); - vkvg_move_to (cr, 76.8f, 161.28f); - vkvg_rel_line_to (cr, 51.2f, -51.2f); - vkvg_rel_line_to (cr, 51.2f, 51.2f); - vkvg_set_line_join (cr, VKVG_LINE_JOIN_BEVEL); - vkvg_stroke (cr); + vkvg_move_to(cr, 76.8f, 161.28f); + vkvg_rel_line_to(cr, 51.2f, -51.2f); + vkvg_rel_line_to(cr, 51.2f, 51.2f); + vkvg_set_line_join(cr, VKVG_LINE_JOIN_BEVEL); + vkvg_stroke(cr); - vkvg_move_to (cr, 76.8f, 238.08f); - vkvg_rel_line_to (cr, 51.2f, -51.2f); - vkvg_rel_line_to (cr, 51.2f, 51.2f); - vkvg_set_line_join (cr, VKVG_LINE_JOIN_ROUND); - vkvg_stroke (cr); + vkvg_move_to(cr, 76.8f, 238.08f); + vkvg_rel_line_to(cr, 51.2f, -51.2f); + vkvg_rel_line_to(cr, 51.2f, 51.2f); + vkvg_set_line_join(cr, VKVG_LINE_JOIN_ROUND); + vkvg_stroke(cr); - /* draw helping lines */ - vkvg_set_source_rgb (cr, 1, 0.2f, 0.2f); - vkvg_set_line_width (cr, 2.56f); - vkvg_set_line_join (cr, VKVG_LINE_JOIN_MITER); - vkvg_move_to (cr, 76.8f, 84.48f); - vkvg_rel_line_to (cr, 51.2f, -51.2f); - vkvg_rel_line_to (cr, 51.2f, 51.2f); - vkvg_move_to (cr, 76.8f, 161.28f); - vkvg_rel_line_to (cr, 51.2f, -51.2f); - vkvg_rel_line_to (cr, 51.2f, 51.2f); - vkvg_move_to (cr, 76.8f, 238.08f); - vkvg_rel_line_to (cr, 51.2f, -51.2f); - vkvg_rel_line_to (cr, 51.2f, 51.2f); - - vkvg_stroke (cr); + /* draw helping lines */ + vkvg_set_source_rgb(cr, 1, 0.2f, 0.2f); + vkvg_set_line_width(cr, 2.56f); + vkvg_set_line_join(cr, VKVG_LINE_JOIN_MITER); + vkvg_move_to(cr, 76.8f, 84.48f); + vkvg_rel_line_to(cr, 51.2f, -51.2f); + vkvg_rel_line_to(cr, 51.2f, 51.2f); + vkvg_move_to(cr, 76.8f, 161.28f); + vkvg_rel_line_to(cr, 51.2f, -51.2f); + vkvg_rel_line_to(cr, 51.2f, 51.2f); + vkvg_move_to(cr, 76.8f, 238.08f); + vkvg_rel_line_to(cr, 51.2f, -51.2f); + vkvg_rel_line_to(cr, 51.2f, 51.2f); + vkvg_stroke(cr); } -void cairo_print_arc (VkvgContext cr) { - float xc = 128.0f; - float yc = 128.0f; - float radius = 100.0f; - float angle1 = 45.0f * (M_PIF/180.0f); /* angles are specified */ - float angle2 = 180.0f * (M_PIF/180.0f); /* in radians */ +void cairo_print_arc(VkvgContext cr) { + float xc = 128.0f; + float yc = 128.0f; + float radius = 100.0f; + float angle1 = 45.0f * (M_PIF / 180.0f); /* angles are specified */ + float angle2 = 180.0f * (M_PIF / 180.0f); /* in radians */ - vkvg_set_source_rgba(cr, 0, 0, 0, 1); - vkvg_set_line_width (cr, 10.0f); - vkvg_arc (cr, xc, yc, radius, angle1, angle2); - vkvg_stroke (cr); + vkvg_set_source_rgba(cr, 0, 0, 0, 1); + vkvg_set_line_width(cr, 10.0f); + vkvg_arc(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, 6.0f); + /* draw helping lines */ + vkvg_set_source_rgba(cr, 1, 0.2f, 0.2f, 0.6f); + vkvg_set_line_width(cr, 6.0f); - vkvg_arc (cr, xc, yc, 10.0f, 0, 2.f*M_PIF); - vkvg_fill (cr); + vkvg_arc(cr, xc, yc, 10.0f, 0, 2.f * M_PIF); + vkvg_fill(cr); - vkvg_arc (cr, xc, yc, radius, angle1, angle1); - vkvg_line_to (cr, xc, yc); - vkvg_arc (cr, xc, yc, radius, angle2, angle2); - vkvg_stroke (cr); + vkvg_arc(cr, xc, yc, radius, angle1, angle1); + vkvg_line_to(cr, xc, yc); + vkvg_arc(cr, xc, yc, radius, angle2, angle2); + vkvg_stroke(cr); } static float rotation = 0.f; -void cairo_tests () { - rotation+=0.002f; - - vkvg_matrix_t mat; - vkvg_matrix_init_translate (&mat, panX,panY); - vkvg_matrix_scale(&mat,zoom,zoom); - vkvg_matrix_translate (&mat, 400,400); - vkvg_matrix_rotate(&mat,rotation); - vkvg_matrix_translate(&mat,-400.f,-400.f); +void cairo_tests() { + rotation += 0.002f; + vkvg_matrix_t mat; + vkvg_matrix_init_translate(&mat, panX, panY); + vkvg_matrix_scale(&mat, zoom, zoom); + vkvg_matrix_translate(&mat, 400, 400); + vkvg_matrix_rotate(&mat, rotation); + vkvg_matrix_translate(&mat, -400.f, -400.f); - VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); - vkvg_set_source_rgba(ctx,1.0f,1.0f,1.0f,1); - vkvg_paint(ctx); + VkvgContext ctx = vkvg_create(surf); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_source_rgba(ctx, 1.0f, 1.0f, 1.0f, 1); + vkvg_paint(ctx); - //vkvg_set_matrix(ctx,&mat); - vkvg_translate (ctx, panX,panY); - vkvg_scale(ctx,zoom,zoom); - vkvg_translate (ctx, 400,400); - vkvg_rotate(ctx,rotation); - vkvg_translate(ctx,-400.f,-400.f); + // vkvg_set_matrix(ctx,&mat); + vkvg_translate(ctx, panX, panY); + vkvg_scale(ctx, zoom, zoom); + vkvg_translate(ctx, 400, 400); + vkvg_rotate(ctx, rotation); + vkvg_translate(ctx, -400.f, -400.f); - cairo_print_arc(ctx); + cairo_print_arc(ctx); - vkvg_translate(ctx,200,0); - cairo_test_fill_rule(ctx); + vkvg_translate(ctx, 200, 0); + cairo_test_fill_rule(ctx); - vkvg_translate(ctx,250,0); - cairo_test_rounded_rect(ctx); + vkvg_translate(ctx, 250, 0); + cairo_test_rounded_rect(ctx); - vkvg_translate(ctx,-450,250); - cairo_test_fill_and_stroke2(ctx); + vkvg_translate(ctx, -450, 250); + cairo_test_fill_and_stroke2(ctx); - vkvg_translate(ctx,250,0); - cairo_print_arc_neg(ctx); + vkvg_translate(ctx, 250, 0); + cairo_print_arc_neg(ctx); - vkvg_translate(ctx,250,0); - cairo_test_text(ctx); + vkvg_translate(ctx, 250, 0); + cairo_test_text(ctx); - vkvg_translate(ctx,-500,250); - cairo_test_curves(ctx); + vkvg_translate(ctx, -500, 250); + cairo_test_curves(ctx); - vkvg_translate(ctx,250,0); - cairo_test_line_joins(ctx); + vkvg_translate(ctx, 250, 0); + cairo_test_line_joins(ctx); - vkvg_translate(ctx,250,0); - cairo_test_line_caps(ctx); + vkvg_translate(ctx, 250, 0); + cairo_test_line_caps(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } - int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (cairo_tests, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(cairo_tests, argc, argv); + return 0; } diff --git a/tests/text.c b/tests/text.c index 51e5a9f..7087ba6 100644 --- a/tests/text.c +++ b/tests/text.c @@ -1,283 +1,280 @@ #include "test.h" -static const char* txt = "The quick brown fox jumps over the lazy dog"; +static const char *txt = "The quick brown fox jumps over the lazy dog"; void print(VkvgContext ctx, float penY, uint32_t size) { - vkvg_set_font_size(ctx,size); - vkvg_move_to(ctx, 10, penY); - vkvg_show_text (ctx,txt); + vkvg_set_font_size(ctx, size); + vkvg_move_to(ctx, 10, penY); + vkvg_show_text(ctx, txt); } -void print_boxed(VkvgContext ctx, const char* text, float penX, float penY, uint32_t size) { - vkvg_set_font_size(ctx,size); - vkvg_text_extents_t te = {0}; - vkvg_text_extents(ctx,text,&te); - vkvg_font_extents_t fe = {0}; - vkvg_font_extents(ctx, &fe); +void print_boxed(VkvgContext ctx, const char *text, float penX, float penY, uint32_t size) { + vkvg_set_font_size(ctx, size); + vkvg_text_extents_t te = {0}; + vkvg_text_extents(ctx, text, &te); + vkvg_font_extents_t fe = {0}; + vkvg_font_extents(ctx, &fe); - vkvg_move_to(ctx, penX, penY); - vkvg_rectangle(ctx, penX, penY -fe.ascent, te.width, fe.height); - vkvg_set_source_rgb(ctx,0.2f,0.2f,0.7f); - vkvg_fill(ctx); + vkvg_move_to(ctx, penX, penY); + vkvg_rectangle(ctx, penX, penY - fe.ascent, te.width, fe.height); + vkvg_set_source_rgb(ctx, 0.2f, 0.2f, 0.7f); + vkvg_fill(ctx); - vkvg_move_to(ctx, penX, penY); - vkvg_set_source_rgb(ctx,1,1,1); - vkvg_show_text (ctx,text); + vkvg_move_to(ctx, penX, penY); + vkvg_set_source_rgb(ctx, 1, 1, 1); + vkvg_show_text(ctx, text); } -void print_unboxed(VkvgContext ctx, const char* text, float penX, float penY, uint32_t size) { - vkvg_set_font_size(ctx,size); - vkvg_move_to(ctx, penX, penY); - vkvg_set_source_rgb(ctx,1,1,1); - vkvg_show_text (ctx,text); +void print_unboxed(VkvgContext ctx, const char *text, float penX, float penY, uint32_t size) { + vkvg_set_font_size(ctx, size); + vkvg_move_to(ctx, penX, penY); + vkvg_set_source_rgb(ctx, 1, 1, 1); + vkvg_show_text(ctx, text); } void test2() { - VkvgContext ctx = vkvg_create(surf); + VkvgContext ctx = vkvg_create(surf); - vkvg_color_t bg = {0.0,0.0,0.0,1}; - vkvg_color_t fg = {1.0f,1.0f,1.0f,1}; + vkvg_color_t bg = {0.0, 0.0, 0.0, 1}; + vkvg_color_t fg = {1.0f, 1.0f, 1.0f, 1}; - vkvg_set_source_rgba(ctx,bg.r,bg.g,bg.b,bg.a); - vkvg_paint(ctx); - vkvg_set_source_rgba(ctx,fg.r,fg.g,fg.b,fg.a); - //vkvg_select_font_face(ctx, "droid"); - vkvg_select_font_face(ctx, "times"); + vkvg_set_source_rgba(ctx, bg.r, bg.g, bg.b, bg.a); + vkvg_paint(ctx); + vkvg_set_source_rgba(ctx, fg.r, fg.g, fg.b, fg.a); + // vkvg_select_font_face(ctx, "droid"); + vkvg_select_font_face(ctx, "times"); + float penY = 10.f; - float penY = 10.f; + for (uint32_t size = 4; size < 39; size++) { + print(ctx, (float)penY, size); + penY += size; + } - for (uint32_t size = 4; size < 39; size++) { - print(ctx,(float)penY,size); - penY+=size; - } - - vkvg_destroy(ctx); + vkvg_destroy(ctx); } void test1() { - VkvgContext ctx = vkvg_create(surf); + VkvgContext ctx = vkvg_create(surf); - vkvg_color_t fg = {0.0,0.0,0.0,1}; - vkvg_color_t bg = {0.9f,0.9f,0.9f,1}; + vkvg_color_t fg = {0.0, 0.0, 0.0, 1}; + vkvg_color_t bg = {0.9f, 0.9f, 0.9f, 1}; - vkvg_set_source_rgba(ctx,bg.r,bg.g,bg.b,bg.a); - vkvg_paint(ctx); - vkvg_set_source_rgba(ctx,fg.r,fg.g,fg.b,fg.a); + vkvg_set_source_rgba(ctx, bg.r, bg.g, bg.b, bg.a); + vkvg_paint(ctx); + vkvg_set_source_rgba(ctx, fg.r, fg.g, fg.b, fg.a); - uint32_t size = 8; - float penY = 100.f; + uint32_t size = 8; + float penY = 100.f; - vkvg_set_font_size(ctx,size); + vkvg_set_font_size(ctx, size); - vkvg_select_font_face(ctx, "mono"); - vkvg_move_to(ctx, 100.f,penY); - vkvg_show_text (ctx,txt); + vkvg_select_font_face(ctx, "mono"); + vkvg_move_to(ctx, 100.f, penY); + vkvg_show_text(ctx, txt); - penY += 1.2f * size; + penY += 1.2f * size; - vkvg_select_font_face(ctx, "times"); - vkvg_move_to(ctx, 100.f, penY); - vkvg_show_text (ctx,txt); + vkvg_select_font_face(ctx, "times"); + vkvg_move_to(ctx, 100.f, penY); + vkvg_show_text(ctx, txt); - penY += 1.2f * size; + penY += 1.2f * size; - vkvg_select_font_face(ctx, "arial:italic"); - vkvg_move_to(ctx, 100.f, penY); - vkvg_show_text (ctx,txt); + vkvg_select_font_face(ctx, "arial:italic"); + vkvg_move_to(ctx, 100.f, penY); + vkvg_show_text(ctx, txt); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void test(){ - VkvgContext ctx = vkvg_create(surf); +void test() { + VkvgContext ctx = vkvg_create(surf); - //vkvg_color_t fg = {0.2,0.2,0.2,1}; - vkvg_color_t fg = {0.0,0.0,0.0,1}; - vkvg_color_t bg = {1.0f,1.0f,1.0f,1}; - vkvg_set_source_rgba(ctx,bg.r,bg.g,bg.b,bg.a); - vkvg_paint(ctx); + // vkvg_color_t fg = {0.2,0.2,0.2,1}; + vkvg_color_t fg = {0.0, 0.0, 0.0, 1}; + vkvg_color_t bg = {1.0f, 1.0f, 1.0f, 1}; + vkvg_set_source_rgba(ctx, bg.r, bg.g, bg.b, bg.a); + vkvg_paint(ctx); - float size = 19; - float penY = 50; - float penX = 10; + float size = 19; + float penY = 50; + float penX = 10; - /*vkvg_rectangle(ctx,30,0,100,400); - vkvg_clip(ctx);*/ + /*vkvg_rectangle(ctx,30,0,100,400); + vkvg_clip(ctx);*/ - //vkvg_select_font_face(ctx, "/usr/local/share/fonts/DroidSansMono.ttf"); - //vkvg_select_font_face(ctx, "/usr/share/fonts/truetype/unifont/unifont.ttf"); + // vkvg_select_font_face(ctx, "/usr/local/share/fonts/DroidSansMono.ttf"); + // vkvg_select_font_face(ctx, "/usr/share/fonts/truetype/unifont/unifont.ttf"); - vkvg_set_font_size (ctx, 12); - vkvg_select_font_face (ctx, "droid"); - vkvg_font_extents_t fe; - vkvg_font_extents (ctx, &fe); - vkvg_move_to (ctx, penX,penY); - vkvg_set_source_rgba (ctx, fg.r, fg.g, fg.b, fg.a); - vkvg_text_extents_t te; - vkvg_text_extents (ctx, "abcdefghijk", &te); - vkvg_show_text (ctx, "abcdefghijk"); - penX += te.x_advance; - vkvg_move_to(ctx, penX,penY); - vkvg_show_text (ctx,"*abcdefghijk2"); - penY += 2.f*size; + vkvg_set_font_size(ctx, 12); + vkvg_select_font_face(ctx, "droid"); + vkvg_font_extents_t fe; + vkvg_font_extents(ctx, &fe); + vkvg_move_to(ctx, penX, penY); + vkvg_set_source_rgba(ctx, fg.r, fg.g, fg.b, fg.a); + vkvg_text_extents_t te; + vkvg_text_extents(ctx, "abcdefghijk", &te); + vkvg_show_text(ctx, "abcdefghijk"); + penX += te.x_advance; + vkvg_move_to(ctx, penX, penY); + vkvg_show_text(ctx, "*abcdefghijk2"); + penY += 2.f * size; - vkvg_select_font_face(ctx, "times"); - vkvg_move_to(ctx, penX,penY); - vkvg_show_text (ctx,"abcdefghijklmnopqrstuvwxyz"); - penY+=size; + vkvg_select_font_face(ctx, "times"); + vkvg_move_to(ctx, penX, penY); + vkvg_show_text(ctx, "abcdefghijklmnopqrstuvwxyz"); + penY += size; - vkvg_select_font_face(ctx, "droid"); - vkvg_move_to(ctx, penX,penY); - vkvg_show_text (ctx,"lmnopqrstuvwxyz123456789"); - penY+=size; + vkvg_select_font_face(ctx, "droid"); + vkvg_move_to(ctx, penX, penY); + vkvg_show_text(ctx, "lmnopqrstuvwxyz123456789"); + penY += size; - vkvg_select_font_face(ctx, "times:bold"); - vkvg_move_to(ctx, penX,penY); - vkvg_show_text (ctx,"abcdefghijklmnopqrstuvwxyz"); - penY+=size; + vkvg_select_font_face(ctx, "times:bold"); + vkvg_move_to(ctx, penX, penY); + vkvg_show_text(ctx, "abcdefghijklmnopqrstuvwxyz"); + penY += size; - vkvg_select_font_face(ctx, "droid"); - vkvg_move_to(ctx, penX,penY); - vkvg_show_text (ctx,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - penY+=size; + vkvg_select_font_face(ctx, "droid"); + vkvg_move_to(ctx, penX, penY); + vkvg_show_text(ctx, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + penY += size; - vkvg_select_font_face(ctx, "arial:italic"); - vkvg_move_to(ctx, penX,penY); - vkvg_show_text (ctx,"abcdefghijklmnopqrstuvwxyz"); - penY+=size; + vkvg_select_font_face(ctx, "arial:italic"); + vkvg_move_to(ctx, penX, penY); + vkvg_show_text(ctx, "abcdefghijklmnopqrstuvwxyz"); + penY += size; - vkvg_select_font_face(ctx, "arial"); - vkvg_move_to(ctx, penX,penY); - vkvg_show_text (ctx,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - penY+=size; - vkvg_move_to(ctx, penX,penY); - vkvg_show_text (ctx,"this is a test"); - penY+=size; - vkvg_move_to(ctx, penX,penY); - vkvg_show_text (ctx,"this is another test to see if label is working"); - penY+=size; + vkvg_select_font_face(ctx, "arial"); + vkvg_move_to(ctx, penX, penY); + vkvg_show_text(ctx, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + penY += size; + vkvg_move_to(ctx, penX, penY); + vkvg_show_text(ctx, "this is a test"); + penY += size; + vkvg_move_to(ctx, penX, penY); + vkvg_show_text(ctx, "this is another test to see if label is working"); + penY += size; - vkvg_select_font_face(ctx, "mono"); - vkvg_move_to(ctx, penX,penY); - vkvg_show_text (ctx,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - penY+=size; + vkvg_select_font_face(ctx, "mono"); + vkvg_move_to(ctx, penX, penY); + vkvg_show_text(ctx, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + penY += size; - vkvg_move_to(ctx, 80,400); - vkvg_show_text (ctx,"Ленивый рыжий кот"); + vkvg_move_to(ctx, 80, 400); + vkvg_show_text(ctx, "Ленивый рыжий кот"); - vkvg_move_to(ctx, 150,250); - vkvg_show_text (ctx,"test string é€"); - vkvg_move_to(ctx, 150,300); - vkvg_show_text (ctx,"كسول الزنجبيل القط"); - vkvg_move_to(ctx, 150,350); - vkvg_show_text (ctx,"懶惰的姜貓"); + vkvg_move_to(ctx, 150, 250); + vkvg_show_text(ctx, "test string é€"); + vkvg_move_to(ctx, 150, 300); + vkvg_show_text(ctx, "كسول الزنجبيل القط"); + vkvg_move_to(ctx, 150, 350); + vkvg_show_text(ctx, "懶惰的姜貓"); - //vkvg_show_text (ctx,"ABCDABCD"); - //vkvg_show_text (ctx,"j"); + // vkvg_show_text (ctx,"ABCDABCD"); + // vkvg_show_text (ctx,"j"); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -void single_font_and_size () { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); - for (uint32_t i=0; i<test_size; i++) { - randomize_color(ctx); - float x = rndf() * test_width; - float y = rndf() * test_height; - vkvg_select_font_face(ctx,"mono"); - vkvg_set_font_size(ctx, 20); - vkvg_move_to(ctx,x,y); - vkvg_show_text(ctx,"This is a test string!"); - } - vkvg_destroy(ctx); +void single_font_and_size() { + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); + for (uint32_t i = 0; i < test_size; i++) { + randomize_color(ctx); + float x = rndf() * test_width; + float y = rndf() * test_height; + vkvg_select_font_face(ctx, "mono"); + vkvg_set_font_size(ctx, 20); + vkvg_move_to(ctx, x, y); + vkvg_show_text(ctx, "This is a test string!"); + } + vkvg_destroy(ctx); } -void simple_text () { - VkvgContext ctx = vkvg_create(surf); - - vkvg_set_source_rgb (ctx, 0, 0, 0); - vkvg_paint (ctx); - vkvg_set_source_rgb (ctx, 1, 1, 1); +void simple_text() { + VkvgContext ctx = vkvg_create(surf); - vkvg_load_font_from_path (ctx, "data/DancingScript-Regular.ttf", "dancing"); - print_boxed (ctx, "abcdefghijklmnopqrstuvwxyz", 20,60,20); - print_boxed (ctx, "ABC", 20,160,60); - vkvg_select_font_face (ctx, "mono"); - print_boxed (ctx, "This is a test string!", 20, 250, 20); - print_boxed (ctx, "ANOTHER ONE TO CHECK..", 20, 350, 20); + vkvg_set_source_rgb(ctx, 0, 0, 0); + vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 1, 1, 1); - vkvg_destroy (ctx); + vkvg_load_font_from_path(ctx, "data/DancingScript-Regular.ttf", "dancing"); + print_boxed(ctx, "abcdefghijklmnopqrstuvwxyz", 20, 60, 20); + print_boxed(ctx, "ABC", 20, 160, 60); + vkvg_select_font_face(ctx, "mono"); + print_boxed(ctx, "This is a test string!", 20, 250, 20); + print_boxed(ctx, "ANOTHER ONE TO CHECK..", 20, 350, 20); + vkvg_destroy(ctx); } -void font_file_path () { - VkvgContext ctx = vkvg_create(surf); +void font_file_path() { + VkvgContext ctx = vkvg_create(surf); - vkvg_set_source_rgb (ctx, 0, 0, 0); - vkvg_paint (ctx); - vkvg_set_source_rgb (ctx, 1, 1, 1); - vkvg_load_font_from_path (ctx, "data/DancingScript-Regular.ttf", "droid"); - print_boxed (ctx, "This is a test string!", 50,20,12); - print_boxed (ctx, "This is a test string!", 50,50,20); - print_boxed (ctx, "ANOTHER ONE TO CHECK..", 50,80,20); - print_boxed (ctx, "this is another string to check if ligature are well set", 10,120,20); - vkvg_destroy (ctx); + vkvg_set_source_rgb(ctx, 0, 0, 0); + vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 1, 1, 1); + vkvg_load_font_from_path(ctx, "data/DancingScript-Regular.ttf", "droid"); + print_boxed(ctx, "This is a test string!", 50, 20, 12); + print_boxed(ctx, "This is a test string!", 50, 50, 20); + print_boxed(ctx, "ANOTHER ONE TO CHECK..", 50, 80, 20); + print_boxed(ctx, "this is another string to check if ligature are well set", 10, 120, 20); + vkvg_destroy(ctx); } -void random_size () { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); - vkvg_select_font_face(ctx,"mono"); - for (uint32_t i=0; i<test_size; i++) { - randomize_color(ctx); - float x = rndf() * test_width; - float y = rndf() * test_height; - uint32_t c = (uint32_t)(rndf() * 120)+1; +void random_size() { + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); + vkvg_select_font_face(ctx, "mono"); + for (uint32_t i = 0; i < test_size; i++) { + randomize_color(ctx); + float x = rndf() * test_width; + float y = rndf() * test_height; + uint32_t c = (uint32_t)(rndf() * 120) + 1; - vkvg_set_font_size(ctx, c); - vkvg_move_to(ctx,x,y); - vkvg_show_text(ctx,"This is a test string!"); - } - vkvg_destroy(ctx); + vkvg_set_font_size(ctx, c); + vkvg_move_to(ctx, x, y); + vkvg_show_text(ctx, "This is a test string!"); + } + vkvg_destroy(ctx); } -const char* const fonts[] = - { "mono", "droid", "times", "arial", "times:bold"}; +const char *const fonts[] = {"mono", "droid", "times", "arial", "times:bold"}; -void random_font_and_size () { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); +void random_font_and_size() { + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - for (uint32_t i=0; i<test_size; i++) { - randomize_color(ctx); - float x = rndf() * test_width; - float y = rndf() * test_height; - uint32_t c = (uint32_t)(rndf() * 80)+1; - uint32_t f = (uint32_t)(rndf() * 4); + for (uint32_t i = 0; i < test_size; i++) { + randomize_color(ctx); + float x = rndf() * test_width; + float y = rndf() * test_height; + uint32_t c = (uint32_t)(rndf() * 80) + 1; + uint32_t f = (uint32_t)(rndf() * 4); - vkvg_set_font_size(ctx, c); - vkvg_select_font_face(ctx, fonts[f]); - vkvg_move_to(ctx,x,y); - vkvg_show_text(ctx,"This is a test string!"); - } - vkvg_destroy(ctx); + vkvg_set_font_size(ctx, c); + vkvg_select_font_face(ctx, fonts[f]); + vkvg_move_to(ctx, x, y); + vkvg_show_text(ctx, "This is a test string!"); + } + vkvg_destroy(ctx); } -void proto_sinaitic () { - VkvgContext ctx = vkvg_create(surf); +void proto_sinaitic() { + VkvgContext ctx = vkvg_create(surf); - vkvg_set_source_rgb (ctx, 0, 0, 0); - vkvg_paint (ctx); - vkvg_set_source_rgb (ctx, 1, 1, 1); + vkvg_set_source_rgb(ctx, 0, 0, 0); + vkvg_paint(ctx); + vkvg_set_source_rgb(ctx, 1, 1, 1); - vkvg_load_font_from_path (ctx, "data/Proto-Sinaitic15.ttf", "sinaitic"); - print_boxed (ctx, "hwhy", 100, 150, 60); + vkvg_load_font_from_path(ctx, "data/Proto-Sinaitic15.ttf", "sinaitic"); + print_boxed(ctx, "hwhy", 100, 150, 60); - vkvg_destroy (ctx); + vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (simple_text, argc, argv); - PERFORM_TEST (font_file_path, argc, argv); - PERFORM_TEST (single_font_and_size, argc, argv); - PERFORM_TEST (random_size, argc, argv); - PERFORM_TEST (random_font_and_size, argc, argv); - PERFORM_TEST (test, argc, argv); - PERFORM_TEST (test1, argc, argv); - PERFORM_TEST (test2, argc, argv); - PERFORM_TEST (proto_sinaitic, argc, argv); + no_test_size = true; + PERFORM_TEST(simple_text, argc, argv); + PERFORM_TEST(font_file_path, argc, argv); + PERFORM_TEST(single_font_and_size, argc, argv); + PERFORM_TEST(random_size, argc, argv); + PERFORM_TEST(random_font_and_size, argc, argv); + PERFORM_TEST(test, argc, argv); + PERFORM_TEST(test1, argc, argv); + PERFORM_TEST(test2, argc, argv); + PERFORM_TEST(proto_sinaitic, argc, argv); - return 0; + return 0; } diff --git a/tests/tmp/getarcstep.c b/tests/tmp/getarcstep.c index dd47a24..2156a3b 100644 --- a/tests/tmp/getarcstep.c +++ b/tests/tmp/getarcstep.c @@ -2,157 +2,156 @@ #include "vectors.h" #include "vkvg_context_internal.h" -vkvg_fill_rule_t fillrule = VKVG_FILL_RULE_NON_ZERO; -static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; -float lineWidth = 3.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; -float angle = 0; -float r; -vec2 mouse; +vkvg_fill_rule_t fillrule = VKVG_FILL_RULE_NON_ZERO; +static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; +float lineWidth = 3.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; +float angle = 0; +float r; +vec2 mouse; -void draw (){ - angle += 0.001f; +void draw() { + angle += 0.001f; - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); + VkvgContext ctx = vkvg_create(surf); + vkvg_clear(ctx); - float r = fabsf(test_width/2 - mouse.x)/zoom; + float r = fabsf(test_width / 2 - mouse.x) / zoom; - vkvg_new_path(ctx); - vkvg_set_source_rgba(ctx,1,0,0,1); - vkvg_set_line_width (ctx,lineWidth/zoom); + vkvg_new_path(ctx); + vkvg_set_source_rgba(ctx, 1, 0, 0, 1); + vkvg_set_line_width(ctx, lineWidth / zoom); - vkvg_translate(ctx, test_width/2, test_height/2); - vkvg_scale(ctx, zoom, zoom); - //vkvg_rotate (ctx, angle); + vkvg_translate(ctx, test_width / 2, test_height / 2); + vkvg_scale(ctx, zoom, zoom); + // vkvg_rotate (ctx, angle); - vkvg_matrix_t mat; - vkvg_get_matrix(ctx, &mat); - float sx, sy; - vkvg_matrix_get_scale(&mat, &sx, &sy); + vkvg_matrix_t mat; + vkvg_get_matrix(ctx, &mat); + float sx, sy; + vkvg_matrix_get_scale(&mat, &sx, &sy); - vkvg_arc (ctx,0,0,r, 0, M_PIF*2); - vkvg_fill(ctx); + vkvg_arc(ctx, 0, 0, r, 0, M_PIF * 2); + vkvg_fill(ctx); - float steps = _get_arc_step(ctx, r); - vkvg_identity_matrix(ctx); + float steps = _get_arc_step(ctx, r); + vkvg_identity_matrix(ctx); - vkvg_set_source_rgba(ctx,1,1,1,1); - char txt[100]; - sprintf(txt, "scale: %f, %f", sx, sy); - vkvg_move_to(ctx,10,10); - vkvg_show_text(ctx,txt); - sprintf(txt, "angle: %f", angle); - vkvg_move_to(ctx,10,25); - vkvg_show_text(ctx,txt); - sprintf(txt, "radius: %f", r); - vkvg_move_to(ctx,10,40); - vkvg_show_text(ctx,txt); - sprintf(txt, "zoom: %f", zoom); - vkvg_move_to(ctx,10,55); - vkvg_show_text(ctx,txt); - sprintf(txt, "arc step: %f", steps); - vkvg_move_to(ctx,10,70); - vkvg_show_text(ctx,txt); - sprintf(txt, "steps: %d", (int)roundf(2.0f*M_PI / steps)); - vkvg_move_to(ctx,10,85); - vkvg_show_text(ctx,txt); + vkvg_set_source_rgba(ctx, 1, 1, 1, 1); + char txt[100]; + sprintf(txt, "scale: %f, %f", sx, sy); + vkvg_move_to(ctx, 10, 10); + vkvg_show_text(ctx, txt); + sprintf(txt, "angle: %f", angle); + vkvg_move_to(ctx, 10, 25); + vkvg_show_text(ctx, txt); + sprintf(txt, "radius: %f", r); + vkvg_move_to(ctx, 10, 40); + vkvg_show_text(ctx, txt); + sprintf(txt, "zoom: %f", zoom); + vkvg_move_to(ctx, 10, 55); + vkvg_show_text(ctx, txt); + sprintf(txt, "arc step: %f", steps); + vkvg_move_to(ctx, 10, 70); + vkvg_show_text(ctx, txt); + sprintf(txt, "steps: %d", (int)roundf(2.0f * M_PI / steps)); + vkvg_move_to(ctx, 10, 85); + vkvg_show_text(ctx, txt); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { - if (action != GLFW_PRESS) - return; - switch (key) { - case GLFW_KEY_ESCAPE : - glfwSetWindowShouldClose(window, GLFW_TRUE); - break; - case GLFW_KEY_KP_ADD : - zoom *= 2.0f; - break; - case GLFW_KEY_KP_SUBTRACT : - zoom *= 0.5f; - break; +static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) { + if (action != GLFW_PRESS) + return; + switch (key) { + case GLFW_KEY_ESCAPE: + glfwSetWindowShouldClose(window, GLFW_TRUE); + break; + case GLFW_KEY_KP_ADD: + zoom *= 2.0f; + break; + case GLFW_KEY_KP_SUBTRACT: + zoom *= 0.5f; + break; #ifdef VKVG_WIRED_DEBUG - case GLFW_KEY_F1: - vkvg_wired_debug ^= (1U << 0); - break; - case GLFW_KEY_F2: - vkvg_wired_debug ^= (1U << 1); - break; - case GLFW_KEY_F3: - vkvg_wired_debug ^= (1U << 2); - break; + case GLFW_KEY_F1: + vkvg_wired_debug ^= (1U << 0); + break; + case GLFW_KEY_F2: + vkvg_wired_debug ^= (1U << 1); + break; + case GLFW_KEY_F3: + vkvg_wired_debug ^= (1U << 2); + break; #endif - } + } } -static void mouse_move_callback(GLFWwindow* window, double x, double y){ - if (mouseDown) { - mouse = (vec2) {x, y}; - } +static void mouse_move_callback(GLFWwindow *window, double x, double y) { + if (mouseDown) { + mouse = (vec2){x, y}; + } } -static void scroll_callback(GLFWwindow* window, double x, double y){ - if (y<0.f) - zoom *= 0.5f; - else - zoom *= 2.0f; +static void scroll_callback(GLFWwindow *window, double x, double y) { + if (y < 0.f) + zoom *= 0.5f; + else + zoom *= 2.0f; } -static void mouse_button_callback(GLFWwindow* window, int but, int state, int modif){ - if (but != GLFW_MOUSE_BUTTON_1) - return; - if (state == GLFW_TRUE) - mouseDown = true; - else - mouseDown = false; +static void mouse_button_callback(GLFWwindow *window, int but, int state, int modif) { + if (but != GLFW_MOUSE_BUTTON_1) + return; + if (state == GLFW_TRUE) + mouseDown = true; + else + mouseDown = false; } +int main(int argc, char *argv[]) { + _parse_args(argc, argv); + VkEngine e; + e = vkengine_create(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); -int main(int argc, char* argv[]) { + VkhPresenter r = e->renderer; + vkengine_set_key_callback(e, key_callback); + vkengine_set_mouse_but_callback(e, mouse_button_callback); + vkengine_set_cursor_pos_callback(e, mouse_move_callback); + vkengine_set_scroll_callback(e, scroll_callback); - _parse_args (argc, argv); - VkEngine e; - e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); + bool deferredResolve = false; - VkhPresenter r = e->renderer; - vkengine_set_key_callback (e, key_callback); - vkengine_set_mouse_but_callback(e, mouse_button_callback); - vkengine_set_cursor_pos_callback(e, mouse_move_callback); - vkengine_set_scroll_callback(e, scroll_callback); + device = vkvg_device_create_from_vk_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, + samples, deferredResolve); + surf = vkvg_surface_create(device, test_width, test_height); - bool deferredResolve = false; + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); - device = vkvg_device_create_from_vk_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, samples, deferredResolve); - surf = vkvg_surface_create(device, test_width, test_height); + mouse = (vec2){test_width * 0.75, test_height * 0.5f}; - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); + while (!vkengine_should_close(e)) { + glfwPollEvents(); - mouse = (vec2){test_width*0.75,test_height*0.5f}; + draw(); - while (!vkengine_should_close (e)) { - glfwPollEvents(); + if (!vkh_presenter_draw(r)) { + vkh_presenter_get_size(r, &test_width, &test_height); + vkvg_surface_destroy(surf); + surf = vkvg_surface_create(device, test_width, test_height); + vkh_presenter_build_blit_cmd(r, vkvg_surface_get_vk_image(surf), test_width, test_height); + vkDeviceWaitIdle(r->dev->dev); + continue; + } + } + vkDeviceWaitIdle(e->dev->dev); - draw (); + vkvg_surface_destroy(surf); - if (!vkh_presenter_draw (r)){ - vkh_presenter_get_size (r, &test_width, &test_height); - vkvg_surface_destroy (surf); - surf = vkvg_surface_create(device, test_width, test_height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); - vkDeviceWaitIdle(r->dev->dev); - continue; - } - } - vkDeviceWaitIdle(e->dev->dev); + vkvg_device_destroy(device); - vkvg_surface_destroy (surf); + vkengine_destroy(e); - vkvg_device_destroy (device); - - vkengine_destroy (e); - - return 0; + return 0; } diff --git a/tests/transform.c b/tests/transform.c index b89db50..cc282b0 100644 --- a/tests/transform.c +++ b/tests/transform.c @@ -22,95 +22,89 @@ #include "test.h" +void _test_rounded_rect(VkvgContext cr) { + /* a custom shape that could be wrapped in a function */ + float x0 = -100, /* parameters like vkvg_rectangle */ + y0 = -100, rect_width = 200, rect_height = 200, radius = 102.4f; /* and an approximate curvature radius */ -void _test_rounded_rect (VkvgContext cr) { - /* a custom shape that could be wrapped in a function */ - float x0 = -100, /* parameters like vkvg_rectangle */ - y0 = -100, - rect_width = 200, - rect_height = 200, - radius = 102.4f; /* and an approximate curvature radius */ + float x1, y1; - float x1,y1; + x1 = x0 + rect_width; + y1 = y0 + rect_height; + if (!rect_width || !rect_height) + return; + if (rect_width / 2 < radius) { + if (rect_height / 2 < radius) { + vkvg_move_to(cr, x0, (y0 + y1) / 2); + vkvg_curve_to(cr, x0, y0, x0, y0, (x0 + x1) / 2, y0); + vkvg_curve_to(cr, x1, y0, x1, y0, x1, (y0 + y1) / 2); + vkvg_curve_to(cr, x1, y1, x1, y1, (x1 + x0) / 2, y1); + vkvg_curve_to(cr, x0, y1, x0, y1, x0, (y0 + y1) / 2); + } else { + vkvg_move_to(cr, x0, y0 + radius); + vkvg_curve_to(cr, x0, y0, x0, y0, (x0 + x1) / 2, y0); + vkvg_curve_to(cr, x1, y0, x1, y0, x1, y0 + radius); + vkvg_line_to(cr, x1, y1 - radius); + vkvg_curve_to(cr, x1, y1, x1, y1, (x1 + x0) / 2, y1); + vkvg_curve_to(cr, x0, y1, x0, y1, x0, y1 - radius); + } + } else { + if (rect_height / 2 < radius) { + vkvg_move_to(cr, x0, (y0 + y1) / 2); + vkvg_curve_to(cr, x0, y0, x0, y0, x0 + radius, y0); + vkvg_line_to(cr, x1 - radius, y0); + vkvg_curve_to(cr, x1, y0, x1, y0, x1, (y0 + y1) / 2); + vkvg_curve_to(cr, x1, y1, x1, y1, x1 - radius, y1); + vkvg_line_to(cr, x0 + radius, y1); + vkvg_curve_to(cr, x0, y1, x0, y1, x0, (y0 + y1) / 2); + } else { + vkvg_move_to(cr, x0, y0 + radius); + vkvg_curve_to(cr, x0, y0, x0, y0, x0 + radius, y0); + vkvg_line_to(cr, x1 - radius, y0); + vkvg_curve_to(cr, x1, y0, x1, y0, x1, y0 + radius); + vkvg_line_to(cr, x1, y1 - radius); + vkvg_curve_to(cr, x1, y1, x1, y1, x1 - radius, y1); + vkvg_line_to(cr, x0 + radius, y1); + vkvg_curve_to(cr, x0, y1, x0, y1, x0, y1 - radius); + } + } + vkvg_close_path(cr); - x1=x0+rect_width; - y1=y0+rect_height; - if (!rect_width || !rect_height) - return; - if (rect_width/2<radius) { - if (rect_height/2<radius) { - vkvg_move_to (cr, x0, (y0 + y1)/2); - vkvg_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0); - vkvg_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2); - vkvg_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1); - vkvg_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2); - } else { - vkvg_move_to (cr, x0, y0 + radius); - vkvg_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0); - vkvg_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius); - vkvg_line_to (cr, x1 , y1 - radius); - vkvg_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1); - vkvg_curve_to (cr, x0, y1, x0, y1, x0, y1- radius); - } - } else { - if (rect_height/2<radius) { - vkvg_move_to (cr, x0, (y0 + y1)/2); - vkvg_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0); - vkvg_line_to (cr, x1 - radius, y0); - vkvg_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2); - vkvg_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1); - vkvg_line_to (cr, x0 + radius, y1); - vkvg_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2); - } else { - vkvg_move_to (cr, x0, y0 + radius); - vkvg_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0); - vkvg_line_to (cr, x1 - radius, y0); - vkvg_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius); - vkvg_line_to (cr, x1 , y1 - radius); - vkvg_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1); - vkvg_line_to (cr, x0 + radius, y1); - vkvg_curve_to (cr, x0, y1, x0, y1, x0, y1- radius); - } - } - vkvg_close_path (cr); - - vkvg_set_source_rgb (cr, 0.5f, 0.5f, 1); - vkvg_fill_preserve (cr); - vkvg_set_source_rgba (cr, 0.5f, 0, 0, 0.5f); - vkvg_set_line_width (cr, 10.0f); - vkvg_stroke (cr); + vkvg_set_source_rgb(cr, 0.5f, 0.5f, 1); + vkvg_fill_preserve(cr); + vkvg_set_source_rgba(cr, 0.5f, 0, 0, 0.5f); + vkvg_set_line_width(cr, 10.0f); + vkvg_stroke(cr); } - static float rotation = 0.f; -void cairo_tests () { - rotation+=0.002f; +void cairo_tests() { + rotation += 0.002f; - VkvgContext ctx = vkvg_create(surf); - vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); - vkvg_set_source_rgba(ctx,1.0f,1.0f,1.0f,1); - vkvg_paint(ctx); + VkvgContext ctx = vkvg_create(surf); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_source_rgba(ctx, 1.0f, 1.0f, 1.0f, 1); + vkvg_paint(ctx); - vkvg_set_line_width(ctx,10); + vkvg_set_line_width(ctx, 10); - vkvg_set_source_rgb(ctx,0,0,1); + vkvg_set_source_rgb(ctx, 0, 0, 1); - vkvg_translate (ctx, test_width/2,test_height/2); - vkvg_rotate(ctx, rotation); - //vkvg_scale(ctx, 200,200); + vkvg_translate(ctx, test_width / 2, test_height / 2); + vkvg_rotate(ctx, rotation); + // vkvg_scale(ctx, 200,200); - vkvg_arc (ctx, 0, 0, 150, 0, M_PI*1.5); - vkvg_stroke(ctx); + vkvg_arc(ctx, 0, 0, 150, 0, M_PI * 1.5); + vkvg_stroke(ctx); - _test_rounded_rect(ctx); + _test_rounded_rect(ctx); - vkvg_destroy(ctx); + vkvg_destroy(ctx); } - int main(int argc, char *argv[]) { - no_test_size = true; - PERFORM_TEST (cairo_tests, argc, argv); - return 0; + no_test_size = true; + PERFORM_TEST(cairo_tests, argc, argv); + return 0; } diff --git a/tests/vkvg-svg/svg-viewer.c b/tests/vkvg-svg/svg-viewer.c index de18cde..e7bafbb 100644 --- a/tests/vkvg-svg/svg-viewer.c +++ b/tests/vkvg-svg/svg-viewer.c @@ -13,357 +13,353 @@ #include <stdarg.h> #include <ctype.h> -static VkvgDevice dev; +static VkvgDevice dev; static VkvgSurface svgSurf = NULL; -static double scale = 1; - - -static char* filename = NULL; -static char* directory = NULL; -static DIR * pCurrentDir = NULL; -struct dirent *dir = NULL; -static int iconSize = -1; -static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; -static uint32_t width=512, height=512, margin = 10; -static double scrollX, scrollY; -static bool paused = false, repaintIconList = true; +static double scale = 1; +static char *filename = NULL; +static char *directory = NULL; +static DIR *pCurrentDir = NULL; +struct dirent *dir = NULL; +static int iconSize = -1; +static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; +static uint32_t width = 512, height = 512, margin = 10; +static double scrollX, scrollY; +static bool paused = false, repaintIconList = true; struct stat file_stat; -#define NORMAL_COLOR "\x1B[0m" -#define GREEN "\x1B[32m" -#define BLUE "\x1B[34m" +#define NORMAL_COLOR "\x1B[0m" +#define GREEN "\x1B[32m" +#define BLUE "\x1B[34m" -static int svg_file_count; +static int svg_file_count; static float maxScroll; /* not defined in c11, ok to define here only for sample */ #ifndef DT_DIR - # define DT_DIR 4 +#define DT_DIR 4 #endif -int _count_svg_files () { - struct dirent *de; - rewinddir (pCurrentDir); - int i = 0; - while ((de = readdir(pCurrentDir)) != NULL) { - if(de->d_type != DT_DIR && !strcasecmp(strrchr(de->d_name, '\0') - 4, ".svg")) - i++; - } - return i; +int _count_svg_files() { + struct dirent *de; + rewinddir(pCurrentDir); + int i = 0; + while ((de = readdir(pCurrentDir)) != NULL) { + if (de->d_type != DT_DIR && !strcasecmp(strrchr(de->d_name, '\0') - 4, ".svg")) + i++; + } + return i; } -void readSVG (VkEngine e) { - struct stat sb; - VkvgSurface newSvgSurf = NULL; - if (iconSize > 0 && pCurrentDir) { - if (!repaintIconList) - return; - char tmp[FILENAME_MAX]; - double x = 0, y = 0; - int cellSize = iconSize + margin; - int iconPerLine = ceil((double)(width-iconSize) / cellSize); - int lineToSkip = floor(scrollY / cellSize); - int iconToSkip = lineToSkip * iconPerLine; +void readSVG(VkEngine e) { + struct stat sb; + VkvgSurface newSvgSurf = NULL; + if (iconSize > 0 && pCurrentDir) { + if (!repaintIconList) + return; + char tmp[FILENAME_MAX]; + double x = 0, y = 0; + int cellSize = iconSize + margin; + int iconPerLine = ceil((double)(width - iconSize) / cellSize); + int lineToSkip = floor(scrollY / cellSize); + int iconToSkip = lineToSkip * iconPerLine; - y = (lineToSkip * cellSize) - scrollY; + y = (lineToSkip * cellSize) - scrollY; - newSvgSurf = vkvg_surface_create(dev, width, height); - VkvgContext ctx = vkvg_create(newSvgSurf); + newSvgSurf = vkvg_surface_create(dev, width, height); + VkvgContext ctx = vkvg_create(newSvgSurf); - struct dirent *de; - rewinddir (pCurrentDir); - int i = 0; - while ((de = readdir(pCurrentDir)) != NULL) { - if(de->d_type != DT_DIR) { - if (!strcasecmp(strrchr(de->d_name, '\0') - 4, ".svg")) { - if (i >= iconToSkip) { - sprintf(tmp, "%s%s", directory, de->d_name); - VkvgSurface surf = vkvg_surface_create_from_svg (dev, iconSize, iconSize, tmp); + struct dirent *de; + rewinddir(pCurrentDir); + int i = 0; + while ((de = readdir(pCurrentDir)) != NULL) { + if (de->d_type != DT_DIR) { + if (!strcasecmp(strrchr(de->d_name, '\0') - 4, ".svg")) { + if (i >= iconToSkip) { + sprintf(tmp, "%s%s", directory, de->d_name); + VkvgSurface surf = vkvg_surface_create_from_svg(dev, iconSize, iconSize, tmp); - if (surf) { - vkvg_set_source_surface(ctx, surf, x, y); - vkvg_paint(ctx); - vkvg_surface_destroy(surf); - } - x += iconSize + margin; - if (x > width - iconSize) { - x = 0; - y += iconSize + margin; - if (y >= height) - break; - } - } - i++; - } - } - } - vkvg_destroy(ctx); - repaintIconList = false; - }else if (filename) { - vkengine_set_title(e, filename); - if (stat(filename, &sb) == -1) { - printf ("Unable to stat file: %s\n", filename); - exit(EXIT_FAILURE); - } - if (sb.st_mtime == file_stat.st_mtime) - return; - file_stat = sb; - newSvgSurf = vkvg_surface_create_from_svg(dev, width, height, filename); - } else if (dir) { - char tmp[FILENAME_MAX]; - sprintf(tmp, "%s/%s", directory, dir->d_name); - vkengine_set_title(e, tmp); - if (stat(tmp, &sb) == -1) { - printf ("Unable to stat file: %s\n", tmp); - exit(EXIT_FAILURE); - } - if (sb.st_mtime == file_stat.st_mtime) - return; - file_stat = sb; - newSvgSurf = vkvg_surface_create_from_svg(dev, width, height, tmp); - } + if (surf) { + vkvg_set_source_surface(ctx, surf, x, y); + vkvg_paint(ctx); + vkvg_surface_destroy(surf); + } + x += iconSize + margin; + if (x > width - iconSize) { + x = 0; + y += iconSize + margin; + if (y >= height) + break; + } + } + i++; + } + } + } + vkvg_destroy(ctx); + repaintIconList = false; + } else if (filename) { + vkengine_set_title(e, filename); + if (stat(filename, &sb) == -1) { + printf("Unable to stat file: %s\n", filename); + exit(EXIT_FAILURE); + } + if (sb.st_mtime == file_stat.st_mtime) + return; + file_stat = sb; + newSvgSurf = vkvg_surface_create_from_svg(dev, width, height, filename); + } else if (dir) { + char tmp[FILENAME_MAX]; + sprintf(tmp, "%s/%s", directory, dir->d_name); + vkengine_set_title(e, tmp); + if (stat(tmp, &sb) == -1) { + printf("Unable to stat file: %s\n", tmp); + exit(EXIT_FAILURE); + } + if (sb.st_mtime == file_stat.st_mtime) + return; + file_stat = sb; + newSvgSurf = vkvg_surface_create_from_svg(dev, width, height, tmp); + } - //vkengine_wait_idle(e); + // vkengine_wait_idle(e); - if (svgSurf) - vkvg_surface_destroy(svgSurf); - svgSurf = newSvgSurf; + if (svgSurf) + vkvg_surface_destroy(svgSurf); + svgSurf = newSvgSurf; - //vkengine_wait_idle(e); + // vkengine_wait_idle(e); #ifdef VKVG_DBG_STATS - vkvg_debug_stats_t dbgStats = vkvg_device_get_stats (dev); - vkvg_device_reset_stats (dev); - printf("maximum point array size = %d\n", dbgStats.sizePoints); - printf("maximum path array size = %d\n", dbgStats.sizePathes); - printf("maximum size of host vertice cache = %d\n", dbgStats.sizeVertices); - printf("maximum size of host index cache = %d\n", dbgStats.sizeIndices); - printf("maximum size of vulkan vertex buffer = %d\n", dbgStats.sizeVBO); - printf("maximum size of vulkan index buffer = %d\n", dbgStats.sizeIBO); + vkvg_debug_stats_t dbgStats = vkvg_device_get_stats(dev); + vkvg_device_reset_stats(dev); + printf("maximum point array size = %d\n", dbgStats.sizePoints); + printf("maximum path array size = %d\n", dbgStats.sizePathes); + printf("maximum size of host vertice cache = %d\n", dbgStats.sizeVertices); + printf("maximum size of host index cache = %d\n", dbgStats.sizeIndices); + printf("maximum size of vulkan vertex buffer = %d\n", dbgStats.sizeVBO); + printf("maximum size of vulkan index buffer = %d\n", dbgStats.sizeIBO); #endif - } -struct dirent *get_next_svg_file_in_current_directory (bool cycle) { - struct dirent *de; - while ((de = readdir(pCurrentDir)) != NULL) { - if(de->d_type != DT_DIR) { - if (!strcasecmp(strrchr(de->d_name, '\0') - 4, ".svg")) - return de; - } - } - if (!cycle) - return NULL; - rewinddir (pCurrentDir); - return get_next_svg_file_in_current_directory (false); +struct dirent *get_next_svg_file_in_current_directory(bool cycle) { + struct dirent *de; + while ((de = readdir(pCurrentDir)) != NULL) { + if (de->d_type != DT_DIR) { + if (!strcasecmp(strrchr(de->d_name, '\0') - 4, ".svg")) + return de; + } + } + if (!cycle) + return NULL; + rewinddir(pCurrentDir); + return get_next_svg_file_in_current_directory(false); } - -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { - if (action == GLFW_RELEASE) - return; - switch (key) { - case GLFW_KEY_SPACE: - paused = !paused; - break; - case GLFW_KEY_R: - //recording = !recording; - file_stat = (struct stat){0}; - break; - case GLFW_KEY_ESCAPE : - glfwSetWindowShouldClose(window, GLFW_TRUE); - break; - case GLFW_KEY_ENTER : - if (!pCurrentDir) - break; - dir = get_next_svg_file_in_current_directory(true); - file_stat = (struct stat){0}; - break; - case GLFW_KEY_KP_ADD: - scale*=2.0; - file_stat = (struct stat){0}; - break; - case GLFW_KEY_KP_SUBTRACT: - scale/=2.0; - file_stat = (struct stat){0}; - break; - } +static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) { + if (action == GLFW_RELEASE) + return; + switch (key) { + case GLFW_KEY_SPACE: + paused = !paused; + break; + case GLFW_KEY_R: + // recording = !recording; + file_stat = (struct stat){0}; + break; + case GLFW_KEY_ESCAPE: + glfwSetWindowShouldClose(window, GLFW_TRUE); + break; + case GLFW_KEY_ENTER: + if (!pCurrentDir) + break; + dir = get_next_svg_file_in_current_directory(true); + file_stat = (struct stat){0}; + break; + case GLFW_KEY_KP_ADD: + scale *= 2.0; + file_stat = (struct stat){0}; + break; + case GLFW_KEY_KP_SUBTRACT: + scale /= 2.0; + file_stat = (struct stat){0}; + break; + } } -static void scroll_callback(GLFWwindow* window, double x, double y) { - if (iconSize == 0) - return; - scrollX -= x * 25; - scrollY -= y * 25; - if (scrollX < 0) - scrollX = 0; - if (scrollY < 0) - scrollY = 0; - else if (scrollY > maxScroll) - scrollY = maxScroll; - repaintIconList = true; +static void scroll_callback(GLFWwindow *window, double x, double y) { + if (iconSize == 0) + return; + scrollX -= x * 25; + scrollY -= y * 25; + if (scrollX < 0) + scrollX = 0; + if (scrollY < 0) + scrollY = 0; + else if (scrollY > maxScroll) + scrollY = maxScroll; + repaintIconList = true; } -void print_help_and_exit () { - printf("\nUsage: svgviewer [options] [svgfilepath]\n\n"); - printf("\t-o file.png:\toutput result to file then exit.\n"); - printf("\t-d directory:\tdirectory containing svg files, cycle pressing Enter.\n"); - printf("\t\t\tif the -d option is not specified, svgfile path is mandatory.\n"); - printf("\t-i size:\tif -d option is present, display all svg files as a list with the size specified.\n"); - printf("\t-m margin:\tset margin for the -i option\n"); - printf("\t-w width:\tset output surface width.\n"); - printf("\t-h height:\tset output surface height.\n"); - printf("\t-s samples:\tset sample count, set to 1 to disable multisampling.\n"); - printf("\n"); - exit(-1); +void print_help_and_exit() { + printf("\nUsage: svgviewer [options] [svgfilepath]\n\n"); + printf("\t-o file.png:\toutput result to file then exit.\n"); + printf("\t-d directory:\tdirectory containing svg files, cycle pressing Enter.\n"); + printf("\t\t\tif the -d option is not specified, svgfile path is mandatory.\n"); + printf("\t-i size:\tif -d option is present, display all svg files as a list with the size specified.\n"); + printf("\t-m margin:\tset margin for the -i option\n"); + printf("\t-w width:\tset output surface width.\n"); + printf("\t-h height:\tset output surface height.\n"); + printf("\t-s samples:\tset sample count, set to 1 to disable multisampling.\n"); + printf("\n"); + exit(-1); } +int main(int argc, char *argv[]) { + int i = 1; + char *output = NULL; -int main (int argc, char *argv[]){ - int i = 1; - char* output = NULL; - - while (i < argc) { - int argLen = strlen(argv[i]); - if (argv[i][0] == '-') { - - if (argLen < 2) print_help_and_exit (); - - switch (argv[i][1]) { - case 'd': - if (argc < ++i + 1) print_help_and_exit(); - directory = argv[i]; - break; - case 'w': - if (argc < ++i + 1) print_help_and_exit(); - width = atoi(argv[i]); - break; - case 'h': - if (argc < ++i + 1) print_help_and_exit(); - height = atoi(argv[i]); - break; - case 's': - if (argc < ++i + 1) print_help_and_exit(); - samples = (VkSampleCountFlags)atoi(argv[i]); - break; - case 'i': - if (argc < ++i + 1) print_help_and_exit(); - iconSize = atoi(argv[i]); - break; - case 'm': - if (argc < ++i + 1) print_help_and_exit(); - margin = atoi(argv[i]); - break; - case 'o': - if (argc < ++i + 1) print_help_and_exit(); - output = argv[i]; - break; - default: - print_help_and_exit(); - } - } else - filename = argv[i]; - i++; - } - if (!filename && !directory) - print_help_and_exit(); - - VkEngine e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU,VK_PRESENT_MODE_FIFO_KHR, width, height); - vkengine_set_key_callback (e, key_callback); - vkengine_set_scroll_callback(e, scroll_callback); - vkvg_device_create_info_t info = { - samples, - false, - vkh_app_get_inst(e->app), - vkengine_get_physical_device(e), - vkengine_get_device(e), - vkengine_get_queue_fam_idx(e), - 0 - }; - dev = vkvg_device_create(&info); - - VkvgSurface surf = NULL; - - if (output) { - surf = vkvg_surface_create_from_svg(dev, width, height, filename); - vkvg_surface_write_to_png (surf, output); - } else { + while (i < argc) { + int argLen = strlen(argv[i]); + if (argv[i][0] == '-') { - surf = vkvg_surface_create(dev, width, height); + if (argLen < 2) + print_help_and_exit(); - vkh_presenter_build_blit_cmd (e->renderer, vkvg_surface_get_vk_image(surf), width, height); + switch (argv[i][1]) { + case 'd': + if (argc < ++i + 1) + print_help_and_exit(); + directory = argv[i]; + break; + case 'w': + if (argc < ++i + 1) + print_help_and_exit(); + width = atoi(argv[i]); + break; + case 'h': + if (argc < ++i + 1) + print_help_and_exit(); + height = atoi(argv[i]); + break; + case 's': + if (argc < ++i + 1) + print_help_and_exit(); + samples = (VkSampleCountFlags)atoi(argv[i]); + break; + case 'i': + if (argc < ++i + 1) + print_help_and_exit(); + iconSize = atoi(argv[i]); + break; + case 'm': + if (argc < ++i + 1) + print_help_and_exit(); + margin = atoi(argv[i]); + break; + case 'o': + if (argc < ++i + 1) + print_help_and_exit(); + output = argv[i]; + break; + default: + print_help_and_exit(); + } + } else + filename = argv[i]; + i++; + } + if (!filename && !directory) + print_help_and_exit(); - if (directory) { - pCurrentDir = opendir(directory); - if(!pCurrentDir) { - printf ("Directory not found: %s\n", directory); - exit(EXIT_FAILURE); - } - dir = get_next_svg_file_in_current_directory(false); - if (!dir) { - printf ("No .svg file found in %s\n", directory); - closedir(pCurrentDir); - exit(EXIT_FAILURE); - } - if (iconSize > 0) { - svg_file_count = _count_svg_files(); - int cellSize = iconSize + margin; - int iconPerLine = ceil((double)(width-iconSize) / cellSize); - int visibleLines = ceil((double)(height) / cellSize); - int totLines = ceil((double)svg_file_count / iconPerLine); - maxScroll = (totLines-visibleLines) * cellSize; - } - } + VkEngine e = vkengine_create(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, width, height); + vkengine_set_key_callback(e, key_callback); + vkengine_set_scroll_callback(e, scroll_callback); + vkvg_device_create_info_t info = {samples, + false, + vkh_app_get_inst(e->app), + vkengine_get_physical_device(e), + vkengine_get_device(e), + vkengine_get_queue_fam_idx(e), + 0}; + dev = vkvg_device_create(&info); + VkvgSurface surf = NULL; + if (output) { + surf = vkvg_surface_create_from_svg(dev, width, height, filename); + vkvg_surface_write_to_png(surf, output); + } else { - while (!vkengine_should_close (e)) { - //vkvg_log_level = VKVG_LOG_INFO_CMD; - readSVG (e); - //vkvg_log_level = VKVG_LOG_ERR; + surf = vkvg_surface_create(dev, width, height); - VkvgContext ctx = vkvg_create(surf); - vkvg_set_source_rgb(ctx,0.1,0.1,0.1); - vkvg_paint(ctx); + vkh_presenter_build_blit_cmd(e->renderer, vkvg_surface_get_vk_image(surf), width, height); - if (svgSurf) { - vkvg_set_source_surface(ctx, svgSurf, 0, 0); - vkvg_paint(ctx); - } else { - vkvg_set_line_width(ctx,10); - vkvg_set_source_rgb(ctx,1,0,0); - vkvg_move_to(ctx, 0,0); - vkvg_line_to(ctx, 512,512); - vkvg_move_to(ctx, 0,512); - vkvg_line_to(ctx, 512,0); - vkvg_stroke(ctx); + if (directory) { + pCurrentDir = opendir(directory); + if (!pCurrentDir) { + printf("Directory not found: %s\n", directory); + exit(EXIT_FAILURE); + } + dir = get_next_svg_file_in_current_directory(false); + if (!dir) { + printf("No .svg file found in %s\n", directory); + closedir(pCurrentDir); + exit(EXIT_FAILURE); + } + if (iconSize > 0) { + svg_file_count = _count_svg_files(); + int cellSize = iconSize + margin; + int iconPerLine = ceil((double)(width - iconSize) / cellSize); + int visibleLines = ceil((double)(height) / cellSize); + int totLines = ceil((double)svg_file_count / iconPerLine); + maxScroll = (totLines - visibleLines) * cellSize; + } + } - } - vkvg_destroy(ctx); + while (!vkengine_should_close(e)) { + // vkvg_log_level = VKVG_LOG_INFO_CMD; + readSVG(e); + // vkvg_log_level = VKVG_LOG_ERR; - glfwPollEvents(); + VkvgContext ctx = vkvg_create(surf); + vkvg_set_source_rgb(ctx, 0.1, 0.1, 0.1); + vkvg_paint(ctx); - if (!vkh_presenter_draw (e->renderer)){ - vkh_presenter_get_size (e->renderer, &width, &height); - vkvg_surface_destroy (surf); - surf = vkvg_surface_create(dev, width, height); - vkh_presenter_build_blit_cmd (e->renderer, vkvg_surface_get_vk_image(surf), width, height); - vkengine_wait_idle(e); - repaintIconList = true; - continue; - } + if (svgSurf) { + vkvg_set_source_surface(ctx, svgSurf, 0, 0); + vkvg_paint(ctx); + } else { + vkvg_set_line_width(ctx, 10); + vkvg_set_source_rgb(ctx, 1, 0, 0); + vkvg_move_to(ctx, 0, 0); + vkvg_line_to(ctx, 512, 512); + vkvg_move_to(ctx, 0, 512); + vkvg_line_to(ctx, 512, 0); + vkvg_stroke(ctx); + } + vkvg_destroy(ctx); - } + glfwPollEvents(); - vkengine_wait_idle(e); + if (!vkh_presenter_draw(e->renderer)) { + vkh_presenter_get_size(e->renderer, &width, &height); + vkvg_surface_destroy(surf); + surf = vkvg_surface_create(dev, width, height); + vkh_presenter_build_blit_cmd(e->renderer, vkvg_surface_get_vk_image(surf), width, height); + vkengine_wait_idle(e); + repaintIconList = true; + continue; + } + } - } + vkengine_wait_idle(e); + } - if (svgSurf) - vkvg_surface_destroy(svgSurf); - vkvg_surface_destroy(surf); - vkvg_device_destroy(dev); - vkengine_destroy(e); + if (svgSurf) + vkvg_surface_destroy(svgSurf); + vkvg_surface_destroy(surf); + vkvg_device_destroy(dev); + vkengine_destroy(e); - if (pCurrentDir) - closedir(pCurrentDir); + if (pCurrentDir) + closedir(pCurrentDir); } |