Manually in what way? In construct we deal with positions in layout coordinates, and construct converts those to canvas coordinates using scrollx/scrolly, layout scale, layout rotation, canvas size, and layer scale, parallax, etc… to draw.
Well, maybe you are asking how viewportMidX(“ui”) is calculated… that could also be calculated with:
ViewportLeft(“ui”)+viewportWidth(“ui”)/2
Or
(ViewportRight(“ui”)-ViewportLeft(“ui”))/2
Or presumably if the ui layer has a parallax of 0,0 then you could just use:
viewportWidth(“ui”)/2
If the ui had a parallax of 100,100, and the layout had unbounded scrolling checked, then you could also just use:
Scrollx
With bounded scrolling the scrollx gets clamped but you can also clamp it manually if you’re so inclined:
Clamp(scrollx, viewportWidth/2, layoutWidth-viewportWidth/2)
But it would behave oddly if the view was smaller than the layout.
If you set the canvas width the the window.innerWidth and had no layer or layout scaling then you could use:
PlatformInfo.InnerWidth/2
Of course all of those could be used with int() to round away the 0.5s from odd sizes. Also to manually handle the transformations that layers let you have then the formulas would get more involved and you may as well just use the expressions construct offers.
Anyways, based on your previous posts you could get an unscaled pixel perfect viewport covering the window by setting the fullscreen scaling in your project properties to “none”, the set the canvas size in events to the innerWidth/height of the window. As long as the canvas is the only thing on the window there shouldn’t be any page scrolling. Then you’d just center with viewportMidX like you did above. There really isn’t a whole lot of benefit to calculating it more manually unless you encounter something that the engine doesn’t recalculate until drawing.