summaryrefslogtreecommitdiff
path: root/examples/graph.c
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2025-02-14 17:30:28 +0100
committerMitya Selivanov <automainint@guattari.tech>2025-02-14 17:30:28 +0100
commit7d92468a5d298ec6dd6455482ff0521efecf9541 (patch)
treea060fa81ed5b9187f8b98178582f7abbca69e29f /examples/graph.c
parent9eb170e70a7be9ed418152ad1b679473fbe0c35a (diff)
downloadreduced_system_layer-7d92468a5d298ec6dd6455482ff0521efecf9541.zip
Adjust wasm code and examples for new features
Diffstat (limited to 'examples/graph.c')
-rw-r--r--examples/graph.c54
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();