UNPKG

@prismadev/webmarine2d

Version:

Core utils for 2D verson of game engine Webmarine

27 lines 796 B
import { Vector2 } from "../core/vector/Vector2"; /** Camera class */ export class RenderCamera { /** Make camera */ constructor() { this._position = new Vector2(0, 0); this._scale = new Vector2(1, 1); } /** Position vector getter */ get position() { return this._position; } /** Scale vector getter */ get scale() { return this._scale; } /** Set transformations on canvas */ transform(ctx) { if (this._position.value != [0, 0]) { ctx.translate(this._position.value[0], this._position.value[1]); } if (this._scale.value != [1, 1]) { ctx.scale(this._scale.value[0], this._scale.value[1]); } } } //# sourceMappingURL=RenderCamera.js.map