This commit is contained in:
Jorijn van der Graaf 2025-12-29 18:56:06 +01:00
commit c84504331b
12 changed files with 867 additions and 17 deletions

View file

@ -29,8 +29,19 @@ Window::Window(std::int_fast32_t width, std::int_fast32_t height) : width(width)
}
void Window::ScaleElement(Transform& element) {
element.scaled.width = MappedToPixel(element.anchor.width, width);
element.scaled.height = MappedToPixel(element.anchor.height, height);
if(element.anchor.maintainAspectRatio) {
if(width > height) {
element.scaled.width = MappedToPixel(element.anchor.width, height);
element.scaled.height = MappedToPixel(element.anchor.height, height);
} else {
element.scaled.width = MappedToPixel(element.anchor.width, width);
element.scaled.height = MappedToPixel(element.anchor.height, width);
}
} else {
element.scaled.width = MappedToPixel(element.anchor.width, width);
element.scaled.height = MappedToPixel(element.anchor.height, height);
}
element.scaled.x = MappedToPixel(element.anchor.x, width) - MappedToPixel(element.anchor.offsetX, element.scaled.width);
element.scaled.y = MappedToPixel(element.anchor.y, height) - MappedToPixel(element.anchor.offsetY, element.scaled.height);
}