Moving animation shapes

This commit is contained in:
Synthasmagoria 2026-08-25 15:45:25 +02:00
commit 4918501712
2 changed files with 76 additions and 33 deletions

View file

@ -54,12 +54,8 @@ draw_animation_rectangle_corners :: proc(corners: RectangleCorners, color: rl.Co
as in 2d. But I'm not sure if that's actually how it works.
*/
AnimationShape_Rectangle :: struct {
origin: RectangleCorners,
}
AnimationShapes :: struct {
rectangle: AnimationShape_Rectangle,
rectangle: RectangleCorners,
}
Animation :: struct {
@ -94,17 +90,11 @@ animation_init :: proc(animation: ^Animation, matrices: []f32) {
type = .Rectangle,
matrices = matrices,
shapes = {
rectangle = {
origin = rectangle_corners_from_rect(rect2{-16, -16, 32, 32})
}
rectangle = rectangle_corners_from_rect(rect2{-16, -16, 32, 32})
},
}
}
animation_reset :: proc(animation: ^Animation) {
animation.matrix_index = 0.0
}
animation_is_finished :: proc(animation: Animation) -> bool {
return animation.matrix_index == f32(animation.matrix_count)
}
@ -116,14 +106,14 @@ animation_draw :: proc(animation: Animation, global_transform: mat3) {
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.origin, global_transform), ANIMATION_COLOR_ORIGIN)
draw_animation_rectangle_corners(rectangle_corners_transform_mat3(shape, global_transform), ANIMATION_COLOR_ORIGIN)
matrices := slice.reinterpret([]mat3, animation.matrices)
for i in 0..<animation.matrix_count {
animation_progress := f32(i + 1) / f32(animation.matrix_count)
previous := rectangle_corners_transform_mat3(shape.origin, transform)
previous := rectangle_corners_transform_mat3(shape, transform)
transform *= matrices[i]
next := rectangle_corners_transform_mat3(shape.origin, transform)
next := rectangle_corners_transform_mat3(shape, transform)
color_next := linalg.lerp(color_origin, color_end, animation_progress)
draw_animation_rectangle_corners(rectangle_corners_transform_mat3(next, global_transform), cast(rl.Color)color_next)
@ -138,11 +128,3 @@ animation_draw :: proc(animation: Animation, global_transform: mat3) {
}
}
}
animation_set_playback_speed :: proc(animation: ^Animation) {
}
animation_set_type :: proc(animation: ^Animation, type: AnimationType) {
animation.type = type
}