From a1ae6462b62d6afa0f868ae0bf68eed2bbfa652c Mon Sep 17 00:00:00 2001 From: Synthasmagoria Date: Sun, 30 Aug 2026 15:26:33 +0200 Subject: [PATCH] animations are back --- src/animation.odin | 89 ++++++++++++---------------------------------- src/program.odin | 4 +-- 2 files changed, 24 insertions(+), 69 deletions(-) diff --git a/src/animation.odin b/src/animation.odin index d981ecc..acf2ed5 100644 --- a/src/animation.odin +++ b/src/animation.odin @@ -207,81 +207,36 @@ rectangle_corners_draw :: proc(corners: RectangleCorners, color: rl.Color) { rl.DrawLineV(corners.bl, corners.tl, rl.BLUE) } -animation_draw :: proc(animation: Animation, global_transform: mat3) { +animation_draw :: proc(animation: Animation, global_transform: mat3, temp_allocator := context.temp_allocator) { + color_origin := cast([4]f32)ANIMATION_COLOR_ORIGIN + color_end := cast([4]f32)ANIMATION_COLOR_END + switch animation.type { case .Rectangle: shape := animation.shapes.rectangle draw_animation_rectangle_corners(rectangle_corners_transform_mat3(global_transform, shape), ANIMATION_COLOR_ORIGIN) transform := linalg.identity(mat3) matrices := slice.reinterpret([]mat3, animation.matrices[:animation.matrix_count * 9]) - // for mat in matrices { - // transform *= mat - // shape_next := rectangle_corners_transform_mat3(transform, shape) - // shape_next_world := rectangle_corners_transform_mat3(global_transform, shape_next) - // draw_animation_rectangle_corners(shape_next_world, ANIMATION_COLOR_ORIGIN) - // } + for mat, i in matrices { + animation_progress := f32(i + 1) / f32(animation.matrix_count) + transform_previous := transform + transform *= mat + shape_next := rectangle_corners_transform_mat3(transform, shape) + shape_next_world := rectangle_corners_transform_mat3(global_transform, shape_next) + shape_next_color := linalg.lerp(color_origin, color_end, animation_progress) + draw_animation_rectangle_corners(shape_next_world, rl.Color(shape_next_color)) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // shape := animation.shapes.rectangle - // transform := linalg.identity(mat3) - // color_origin := cast([4]f32)(ANIMATION_COLOR_ORIGIN) - // color_end := cast([4]f32)(ANIMATION_COLOR_END) - // draw_animation_rectangle_corners(rectangle_corners_transform_mat3(shape, global_transform), ANIMATION_COLOR_ORIGIN) - - // matrices := slice.reinterpret([]mat3, animation.matrices) - // for i in 0.. v2 { diff --git a/src/program.odin b/src/program.odin index c8d8803..5ef882e 100644 --- a/src/program.odin +++ b/src/program.odin @@ -1191,8 +1191,8 @@ ui_mat3 :: proc(idx: int, mat: []f32, value_strings: []InputFloatField, dimensio matrix_input_dimensions := ui.Dimensions {ui.Size_Percentage(1.0 / 3.0), ui.Size_Percentage(1.0 / 3.0)} matrix_input_config := ui.ElementConfiguration {margin = 4.0} // column first matrices - #unroll for i in 0..<3 { - #unroll for j in 0..<3 { + #unroll for j in 0..<3 { + #unroll for i in 0..<3 { data := new(UiElementData_FloatInput, allocator) index := i * 3 + j data^ = {value = &mat[index], value_string = cstring(&value_strings[index][0]), tag = {.UpdateMatrix}}