animations are back
This commit is contained in:
parent
b95b7659c3
commit
a1ae6462b6
2 changed files with 25 additions and 70 deletions
|
|
@ -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..<animation.matrix_count {
|
||||
// animation_progress := f32(i + 1) / f32(animation.matrix_count)
|
||||
// previous := rectangle_corners_transform_mat3(shape, transform)
|
||||
// transform *= matrices[i]
|
||||
// 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)
|
||||
|
||||
// if f32(i) == math.floor(animation.matrix_index) {
|
||||
// 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)
|
||||
// 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)
|
||||
// }
|
||||
if f32(i) == math.floor(animation.matrix_index) {
|
||||
animation_current_progress_fraction := ease.ease(animation.ease, fract(animation.matrix_index))
|
||||
animation_current_progress := (math.trunc(animation.matrix_index) + animation_current_progress_fraction) / f32(animation.matrix_count)
|
||||
shape_previous := rectangle_corners_transform_mat3(transform_previous, shape)
|
||||
shape_previous_world := rectangle_corners_transform_mat3(global_transform, shape_previous)
|
||||
shape_current_world := rectangle_corners_lerp(shape_previous_world, shape_next_world, animation_current_progress_fraction)
|
||||
shape_current_color := linalg.lerp(color_origin, color_end, animation_current_progress)
|
||||
draw_animation_rectangle_corners(shape_current_world, rl.Color(shape_current_color))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
animation_get_center :: proc(animation: Animation) -> v2 {
|
||||
|
|
|
|||
|
|
@ -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}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue