[Bindings/Odin] Move repeated rounding into proc

This commit is contained in:
Rats 2025-04-30 20:16:50 -05:00
parent f422f4d5b3
commit 220a52b6d3

View file

@ -121,9 +121,9 @@ clay_raylib_render :: proc(render_commands: ^clay.ClayArray(clay.RenderCommand),
// Rounded Borders // Rounded Borders
if config.cornerRadius.topLeft > 0 { if config.cornerRadius.topLeft > 0 {
draw_arc( draw_arc(
math.round(bounds.x + config.cornerRadius.topLeft), bounds.x + config.cornerRadius.topLeft,
math.round(bounds.y + config.cornerRadius.topLeft), bounds.y + config.cornerRadius.topLeft,
math.round(config.cornerRadius.topLeft - f32(config.width.top)), config.cornerRadius.topLeft - f32(config.width.top),
config.cornerRadius.topLeft, config.cornerRadius.topLeft,
180, 180,
270, 270,
@ -132,9 +132,9 @@ clay_raylib_render :: proc(render_commands: ^clay.ClayArray(clay.RenderCommand),
} }
if config.cornerRadius.topRight > 0 { if config.cornerRadius.topRight > 0 {
draw_arc( draw_arc(
math.round(bounds.x + bounds.width - config.cornerRadius.topRight), bounds.x + bounds.width - config.cornerRadius.topRight,
math.round(bounds.y + config.cornerRadius.topRight), bounds.y + config.cornerRadius.topRight,
math.round(config.cornerRadius.topRight - f32(config.width.top)), config.cornerRadius.topRight - f32(config.width.top),
config.cornerRadius.topRight, config.cornerRadius.topRight,
270, 270,
360, 360,
@ -143,9 +143,9 @@ clay_raylib_render :: proc(render_commands: ^clay.ClayArray(clay.RenderCommand),
} }
if config.cornerRadius.bottomLeft > 0 { if config.cornerRadius.bottomLeft > 0 {
draw_arc( draw_arc(
math.round(bounds.x + config.cornerRadius.bottomLeft), bounds.x + config.cornerRadius.bottomLeft,
math.round(bounds.y + bounds.height - config.cornerRadius.bottomLeft), bounds.y + bounds.height - config.cornerRadius.bottomLeft,
math.round(config.cornerRadius.bottomLeft - f32(config.width.top)), config.cornerRadius.bottomLeft - f32(config.width.top),
config.cornerRadius.bottomLeft, config.cornerRadius.bottomLeft,
90, 90,
180, 180,
@ -154,9 +154,9 @@ clay_raylib_render :: proc(render_commands: ^clay.ClayArray(clay.RenderCommand),
} }
if config.cornerRadius.bottomRight > 0 { if config.cornerRadius.bottomRight > 0 {
draw_arc( draw_arc(
math.round(bounds.x + bounds.width - config.cornerRadius.bottomRight), bounds.x + bounds.width - config.cornerRadius.bottomRight,
math.round(bounds.y + bounds.height - config.cornerRadius.bottomRight), bounds.y + bounds.height - config.cornerRadius.bottomRight,
math.round(config.cornerRadius.bottomRight - f32(config.width.bottom)), config.cornerRadius.bottomRight - f32(config.width.bottom),
config.cornerRadius.bottomRight, config.cornerRadius.bottomRight,
0.1, 0.1,
90, 90,
@ -169,13 +169,13 @@ clay_raylib_render :: proc(render_commands: ^clay.ClayArray(clay.RenderCommand),
} }
} }
// Helper functions, mainly for repeated conversions // Helper procs, mainly for repeated conversions
@(private = "file") @(private = "file")
draw_arc :: proc(x, y: f32, inner_rad, outer_rad: f32,start_angle, end_angle: f32, color: clay.Color){ draw_arc :: proc(x, y: f32, inner_rad, outer_rad: f32,start_angle, end_angle: f32, color: clay.Color){
rl.DrawRing( rl.DrawRing(
{x,y}, {math.round(x),math.round(y)},
inner_rad, math.round(inner_rad),
outer_rad, outer_rad,
start_angle, start_angle,
end_angle, end_angle,