A simple 2D camera module, for use with rendering plots
npm i camera-2d
Creates a new camera object. The options
object contains the following parameters:
scale
- the amount to rescale the view by (dimensionless unit)angle
- the amount to rotate by in radianscenterX
- x center of translation in screen coordinate pixelscenterY
- y center of translation in screen coordinate pixelswidth
- width of view portheight
- height of view port
Returns A new camera object
The width of the viewport of the camera
The height of the viewport of the camera
Retrieves the current state of the camera matrix
out
is a length 9 array which receives the result of the computation if not otherwise specified.
Returns The resulting camera matrix
Applies a scale/roation to the camera about some point
dscale
is the amount to rescale the cameradangle
is the change in camera rotation in degreescenterX
is the x-component of the center of the scale/rotationcenterY
is the y-component of the center of the scale/rotation
Pans the camera by some amount
dx,dy
are the components of the pan vector
(c) 2015 Mikola Lysenko. MIT License