Reprogrammed rectangle drawing to be on top of everything

This commit is contained in:
Synthasmagoria 2026-08-30 18:16:12 +02:00
commit 9614049610
2 changed files with 19 additions and 19 deletions

View file

@ -128,7 +128,7 @@ rectangle_corners_get_triangles :: proc (corners: RectangleCorners) -> [2]tri2 {
collection = &corners_slice,
len = proc(it: sort.Interface) -> int {
array := (cast(^[]AngleAndReference)it.collection)^
return 4
return len(array)
},
less = proc(it: sort.Interface, i, j: int) -> bool {
array := (cast(^[]AngleAndReference)it.collection)^
@ -213,29 +213,29 @@ animation_draw :: proc(animation: Animation, global_transform: mat3, temp_alloca
switch animation.type {
case .Rectangle:
shape := animation.shapes.rectangle
draw_animation_rectangle_corners(rectangle_corners_transform_mat3(global_transform, shape), ANIMATION_COLOR_ORIGIN)
rectangles := make([]RectangleCorners, animation.matrix_count + 1, temp_allocator)
rectangles[0] = rectangle_corners_transform_mat3(global_transform, animation.shapes.rectangle)
transform := linalg.identity(mat3)
matrices := slice.reinterpret([]mat3, animation.matrices[:animation.matrix_count * 9])
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))
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))
}
rectangle_transformed := rectangle_corners_transform_mat3(transform, animation.shapes.rectangle)
rectangles[i + 1] = rectangle_corners_transform_mat3(global_transform, rectangle_transformed)
}
for rectangle, i in rectangles {
color := linalg.lerp(color_origin, color_end, f32(i) / f32(animation.matrix_count))
draw_animation_rectangle_corners(rectangle, rl.Color(color))
}
animation_progress := math.clamp(animation.matrix_index, 0.0, f32(animation.matrix_count - 1))
animation_progress_frame := ease.ease(animation.ease, fract(animation.matrix_index))
animation_progress_total := animation_progress + animation_progress_frame
animation_progress_fraction := animation_progress_total / f32(animation.matrix_count)
rectangle_previous := rectangles[i32(animation_progress)]
rectangle_next := rectangles[i32(animation_progress + 1)]
rectangle_current := rectangle_corners_lerp(rectangle_previous, rectangle_next, animation_progress_frame)
rectangle_current_color := linalg.lerp(color_origin, color_end, animation_progress_fraction)
draw_animation_rectangle_corners(rectangle_current, rl.Color(rectangle_current_color))
}
}