Files

27 lines
895 B
Plaintext

wallpaper_image = Image("splash.png");
screen_width = Window.GetWidth();
screen_height = Window.GetHeight();
# Scale the wallpaper to cover the whole screen, then center-crop the overflow.
# Works for both landscape (NUC) and portrait (rotated android) displays
# without distorting the artwork.
scale_x = screen_width / wallpaper_image.GetWidth();
scale_y = screen_height / wallpaper_image.GetHeight();
if (scale_x > scale_y) {
scale = scale_x;
} else {
scale = scale_y;
}
scaled_width = wallpaper_image.GetWidth() * scale;
scaled_height = wallpaper_image.GetHeight() * scale;
scaled_image = wallpaper_image.Scale(scaled_width, scaled_height);
crop_x = (scaled_width - screen_width) / 2;
crop_y = (scaled_height - screen_height) / 2;
cropped_image = scaled_image.Crop(crop_x, crop_y, screen_width, screen_height);
wallpaper_sprite = Sprite(cropped_image);
wallpaper_sprite.SetZ(-100);