Skip to content

1681-engine / index / parallaxOrigin

Function: parallaxOrigin() ​

ts
function parallaxOrigin(
   scroll, 
   factor, 
   offset?
): number;

Defined in: src/parallax/parallaxMath.ts:11

The world position a layer is drawn at so that, on screen, it moves factor times as far as the camera: 0 stays fixed to the screen (a sky at infinity), 1 moves with the world, 0.5 at half speed, above 1 faster (a foreground). The layer lives in the world layer, so the camera's zoom scales it like everything else.

Parameters ​

ParameterTypeDefault value
scrollnumberundefined
factornumberundefined
offsetnumber0

Returns ​

number

Released under the MIT License.