Is there a way to get the size of the application itself?

I don’t mean the sprite size, or anything like that. I mean the window Aseprite is contained in. I can probably find a library, or hack in some AHK to do it for me, but I’m hoping the app itself has the size of the window.

There is a trick that @lampysprites showed me where you can leverage the fact that a new dialog is always perfectly centered to calculate the size of the window.

Here’s a script I wrote that shows how to achieve it.

if not app.isUIAvailable then return end

local dialog = Dialog {title = "Window Size"}
dialog:show{wait = false}

local windowWidth = dialog.bounds.x * 2 + dialog.bounds.width
local windowHeight = dialog.bounds.y * 2 + dialog.bounds.height

dialog:close()

dialog --
:label{label = "Width", text = windowWidth} --
:label{label = "Height", text = windowHeight}

local scale = {
    screen = app.preferences.general.screen_scale,
    ui = app.preferences.general.ui_scale
}

dialog --
:label{label = "Real Width", text = windowWidth * scale.screen} --
:label{label = "Real Height", text = windowHeight * scale.screen}

local bounds = dialog.bounds
bounds.x = windowWidth * 0.618 - bounds.width * 0.5
bounds.y = windowHeight * 0.382 - bounds.height * 0.5
dialog.bounds = bounds

dialog:show()
2 Likes

it’s sad that we can’t read everything from aseprite.ini (unless we load ini directly), so you can’t get this just by using app.preferences.GfxMode.Frame

3 Likes

Thank you so much for this! I actually ended up making a really cool function before I read this that uses phi to make perfect boxes.

Now that I have this, I can get rid of the assumption that everyone is using 1920 × 1080 and not only have perfect boxes, but perfectly centered boxes.

…(maniacal laugh)…

2 Likes