diff --git a/buttons.zig b/buttons.zig index 7ac96f6..84a061b 100644 --- a/buttons.zig +++ b/buttons.zig @@ -1,9 +1,9 @@ const shapes = @import("shapes.zig"); const Vec2 = @Vector(2, f32); -const Color = [4] u8; +const Color = [4] u8; -const DEBUG = Color{255, 0, 255, 255}; +const DEBUG = Color{255, 0, 255, 255}; pub const Button = struct { hovering : bool, @@ -21,11 +21,14 @@ pub fn render_arrow_button(b : Button, arrow_is_pointing_left : bool) void { const dir : f32 = if (arrow_is_pointing_left) 1 else -1; const background_color = if (b.hovering) b.color1_hov else b.color1_def; const detail_color = if (b.hovering) b.color2_hov else b.color2_def; - // Background first. + + // Draw the background. shapes.draw_centered_rect(b.pos, b.width, b.height, background_color); - // Draw arrow body. + + // Draw the arrow body. shapes.draw_centered_rect(b.pos + Vec2{dir * 0.1 * b.width, 0}, 0.5 * b.width, 0.4 * b.height, detail_color); - // Draw arrowhead triangle. + + // Draw the arrowhead. const p1 = Vec2{b.pos[0] - dir * 0.4 * b.width, b.pos[1]}; const p2 = Vec2{b.pos[0] - dir * 0.1 * b.width, b.pos[1] - 0.4 * b.height}; const p3 = Vec2{b.pos[0] - dir * 0.1 * b.width, b.pos[1] + 0.4 * b.height}; @@ -42,8 +45,10 @@ pub fn render_menu_button(b : Button) void { }; const background_color = if (b.hovering) b.color1_hov else b.color1_def; const detail_color = if (b.hovering) b.color2_hov else b.color2_def; - // Background first. + + // Draw the background. shapes.draw_centered_rect(b.pos, b.width, b.height, background_color); + // Draw the three rectangles. for (rect_pos) |pos| { shapes.draw_centered_rect(pos, square_length, subrectangle_height, detail_color);