Files
kryon/tests/loading_screen_layout_test.zi
T

34 lines
1.2 KiB
Ziran

LoadingScreen :: #import "kryon/loading_screen";
#import "geometry"
Fits :: (outer: Rectangle, inner: Rectangle) -> bool {
return inner.x >= outer.x && inner.y >= outer.y && inner.width >= 0.0 &&
inner.height >= 0.0 && inner.x + inner.width <= outer.x + outer.width &&
inner.y + inner.height <= outer.y + outer.height
}
#program_export
main :: () -> s32 {
sizes: [6]Rectangle = .[Rectangle.{0.0, 0.0, 360.0, 720.0},
Rectangle.{0.0, 0.0, 720.0, 260.0}, Rectangle.{12.0, 20.0, 120.0, 160.0},
Rectangle.{0.0, 0.0, 1440.0, 900.0}, Rectangle.{0.0, 0.0, 320.0, 480.0},
Rectangle.{0.0, 0.0, 1.0, 1.0}]
for area: sizes {
for zoom: cast(s32)5..25 {
layout := LoadingScreen.LoadingScreenLayoutFor(area, cast(float32)zoom / 10.0)
if layout.scale <= 0.0 || !Fits(area, layout.mark) || !Fits(area, layout.title) ||
!Fits(area, layout.detail) || !Fits(area, layout.progress) {
return 1
}
}
}
empty := LoadingScreen.LoadingScreenLayoutFor(Rectangle.{0.0, 0.0, 0.0, 10.0}, 1.0)
if empty.scale != 0.0 {
return 2
}
if LoadingScreen.LoadingScreenAngle(0.0) != -90.0 || LoadingScreen.LoadingScreenAngle(1.8) != -90.0 {
return 3
}
return 0
}