Animation slider

This commit is contained in:
Synthasmagoria 2026-08-28 10:08:53 +02:00
commit 75602ea8d1
2 changed files with 31 additions and 12 deletions

View file

@ -6,7 +6,7 @@ import rl "libraries/raylib"
Grid :: struct {
cell_size_px: v2,
zoom_previous, zoom: v2,
world_position, world_size, offset: v2,
offset: v2,
}
grid_get_zoom :: proc(zoom: v2) -> v2 {
@ -44,20 +44,22 @@ grid_world_to_grid_matrix :: proc(zoom, offset: v2) -> mat3 {
linalg.matrix3_scale(v3{**zoom_amount, 1.0}))
}
draw_grid :: proc(grid: Grid, text_draw, text_clip: rect2) {
draw_grid :: proc(grid: Grid, area, text_draw, text_clip: rect2) {
world_to_grid_matrix := grid_world_to_grid_matrix(grid.zoom, grid.offset)
grid_to_world_matrix := linalg.inverse(world_to_grid_matrix)
grid_world_br := grid.world_position + grid.world_size
position := rect_get_tl(area)
size := rect_get_size(area)
grid_world_br := position + size
grid_color := rl.Color{64, 64, 64, 255}
sep := grid_get_line_separation(grid.zoom, grid.cell_size_px)
tl := (v3{**grid.world_position, 1.0} * world_to_grid_matrix).xy
tl := (v3{**position, 1.0} * world_to_grid_matrix).xy
tl = linalg.floor(tl / sep) * sep
br := (v3{**grid_world_br, 1.0} * world_to_grid_matrix).xy
for x: f32 = tl.x; x < br.x; x += sep.x {
world_position_x := (v3{x, 0.0, 1.0} * grid_to_world_matrix).x
p1 := v2{world_position_x, grid.world_position.y}
p1 := v2{world_position_x, position.y}
p2 := v2{world_position_x, grid_world_br.y}
rl.DrawLineV(p1, p2, grid_color)
if p1.x >= text_clip.x && p1.x < text_clip.x + text_clip.width {
@ -67,7 +69,7 @@ draw_grid :: proc(grid: Grid, text_draw, text_clip: rect2) {
for y: f32 = tl.y; y < br.y; y += sep.y {
world_position_y := (v3{0.0, y, 1.0} * grid_to_world_matrix).y
p1 := v2{grid.world_position.x, world_position_y}
p1 := v2{position.x, world_position_y}
p2 := v2{grid_world_br.x, world_position_y}
rl.DrawLineV(p1, p2, grid_color)
if p1.y >= text_clip.y && p1.y < text_clip.y + text_clip.height {