Skip to content

1681-engine / ui / worldToScreen

Function: worldToScreen() ​

ts
function worldToScreen(
   layer, 
   wx, 
   wy, 
   out, 
   cssScale?
): object;

Defined in: src/ui/dom/worldToScreen.ts:13

Where a world point is on the overlay, in CSS pixels: through the world layer's own transform (so the camera's zoom, scroll and shake are all in it), times how much CSS stretches the canvas (cssScale, 1 normally). Writes into out: called for every placed element every frame.

Parameters ​

ParameterTypeDefault value
layerLayerTransformundefined
wxnumberundefined
wynumberundefined
out{ x: number; y: number; }undefined
out.xnumberundefined
out.ynumberundefined
cssScalenumber1

Returns ​

object

x ​

ts
x: number;

y ​

ts
y: number;

Released under the MIT License.