@prismadev/webmarine2d
Version:
Core utils for 2D verson of game engine Webmarine
48 lines • 1.44 kB
JavaScript
import { Vector2 } from "../core/vector/Vector2";
import { IdentifierError } from "../core/errors/IdentifierError";
/** Any displaying object */
export class RenderTarget {
/** Make render target */
constructor(id) {
if (!(/[A-z0-9]/).test(id)) {
throw new IdentifierError('the identifier must use only the English alphabet, numbers, as well as the characters "-" and "_"');
}
if (!id) {
const dict = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890_-';
let result = '';
for (let i = 0; i < 32; i++) {
result += dict[Math.floor(Math.random() * dict.length)];
}
id = result;
}
this._id = id;
this._position = new Vector2(0, 0);
this._scale = new Vector2(1, 1);
this._rotation = 0;
}
/** Get render target id */
get id() {
return this._id;
}
/** Position vector getter */
get position() {
return this._position;
}
/** Scale vector getter */
get scale() {
return this._scale;
}
/** Rotation getter */
get rotation() {
return this._rotation;
}
/** Rotation setter */
set rotation(val) {
this._rotation = val;
}
/** Render */
render(ctx) {
ctx.restore();
}
}
//# sourceMappingURL=RenderTarget.js.map