Animation sequence
This commit is contained in:
parent
d5793c836f
commit
7b980a699a
2 changed files with 20 additions and 13 deletions
|
|
@ -105,10 +105,6 @@ animation_reset :: proc(animation: ^Animation) {
|
|||
animation.matrix_index = 0.0
|
||||
}
|
||||
|
||||
animation_update :: proc(animation: ^Animation, speed: f32) {
|
||||
animation.matrix_index = min(animation.matrix_index + speed, f32(animation.matrix_count))
|
||||
}
|
||||
|
||||
animation_is_finished :: proc(animation: Animation) -> bool {
|
||||
return animation.matrix_index == f32(animation.matrix_count)
|
||||
}
|
||||
|
|
@ -118,26 +114,26 @@ animation_draw :: proc(animation: Animation, global_transform: mat3) {
|
|||
case .Rectangle:
|
||||
shape := animation.shapes.rectangle
|
||||
transform := linalg.identity(mat3)
|
||||
previous, next := shape.origin, shape.origin
|
||||
color_origin := cast([4]f32)(ANIMATION_COLOR_ORIGIN)
|
||||
color_end := cast([4]f32)(ANIMATION_COLOR_END)
|
||||
draw_animation_rectangle_corners(rectangle_corners_transform_mat3(next, global_transform), ANIMATION_COLOR_ORIGIN)
|
||||
draw_animation_rectangle_corners(rectangle_corners_transform_mat3(shape.origin, 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)
|
||||
transform *= matrices[i]
|
||||
previous = next
|
||||
next := rectangle_corners_transform_mat3(previous, transform)
|
||||
next := rectangle_corners_transform_mat3(shape.origin, 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)
|
||||
|
||||
if f32(i) == math.floor(animation.matrix_index) {
|
||||
color_previous := linalg.lerp(color_origin, color_end, animation_progress)
|
||||
progress := ease.ease(animation.ease, fract(animation.matrix_index))
|
||||
color_previous := linalg.lerp(color_origin, color_end, animation.matrix_index / f32(animation.matrix_count))
|
||||
color := linalg.lerp(color_previous, color_next, progress)
|
||||
corners := rectangle_corners_lerp(previous, next, progress)
|
||||
draw_animation_rectangle_corners(corners, cast(rl.Color)color)
|
||||
animated_corners := rectangle_corners_lerp(previous, next, progress)
|
||||
animated_corners_world := rectangle_corners_transform_mat3(animated_corners, global_transform)
|
||||
draw_animation_rectangle_corners(animated_corners_world, cast(rl.Color)color)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue