diff options
Diffstat (limited to 'examples/graph.c')
-rw-r--r-- | examples/graph.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/examples/graph.c b/examples/graph.c index c1c84f2..75f83fa 100644 --- a/examples/graph.c +++ b/examples/graph.c @@ -61,11 +61,13 @@ void draw_node(i64 node_index) { color = (vec4_f32) { 0.f, .5f, 0.f, 1.f }; // green color fill_ellipse( - (Brush) { .color = color }, - n.x - n.radius, - n.y - n.radius, - n.radius * 2, - n.radius * 2 + color, + (Box) { + n.x - n.radius, + n.y - n.radius, + n.radius * 2, + n.radius * 2, + } ); } @@ -85,11 +87,11 @@ void draw_edge(i64 edge_index) { color = (vec4_f32) { 0.f, .5f, 0.f, 1.f }; // green color fill_line( - (Brush) { .color = color }, - n0.x, - n0.y, - n1.x, - n1.y, + color, + (vec2[2]) { + { n0.x, n0.y }, + { n1.x, n1.y }, + }, e.width ); } @@ -112,13 +114,14 @@ void update_node(i64 node_index) { Node n = world.nodes[node_index]; - world.nodes[node_index].hover = ellipse_contains( - n.x - n.radius, - n.y - n.radius, - n.radius * 2, - n.radius * 2, - g_platform.cursor_x, - g_platform.cursor_y + world.nodes[node_index].hover = hit_ellipse( + (Box) { + n.x - n.radius, + n.y - n.radius, + n.radius * 2, + n.radius * 2, + }, + (vec2) { g_platform.cursor_x, g_platform.cursor_y } ); } @@ -130,14 +133,13 @@ void update_edge(i64 edge_index) { Node n0 = world.nodes[e.src]; Node n1 = world.nodes[e.dst]; - world.edges[edge_index].hover = line_contains( - n0.x, - n0.y, - n1.x, - n1.y, + world.edges[edge_index].hover = hit_line( + (vec2[2]) { + { n0.x, n0.y }, + { n1.x, n1.y }, + }, e.width, - g_platform.cursor_x, - g_platform.cursor_y + (vec2) { g_platform.cursor_x, g_platform.cursor_y } ); } @@ -502,7 +504,7 @@ void update_and_render_frame(void) { // Render - fill_rectangle((Brush) { .color = { .7f, .8f, .9f, 1.f } }, 0, 0, g_platform.real_width, g_platform.real_height); + fill_rectangle_quick((vec4_f32) { .7f, .8f, .9f, 1.f }, (Box) { 0, 0, g_platform.real_width, g_platform.real_height }); if (adding_edge) { f64 x0 = world.nodes[adding_src].x; @@ -515,7 +517,7 @@ void update_and_render_frame(void) { y1 = world.nodes[adding_dst].y; } - fill_line((Brush) { .color = { .5f, 0.f, .5f, 1.f } }, x0, y0, x1, y1, 30); + fill_line((vec4_f32) { .5f, 0.f, .5f, 1.f }, (vec2[2]) { { x0, y0 }, { x1, y1 } }, 30); } draw_graph(); |