@canvacord/beta
Version:
Simple & easy to use image manipulation module for beginners.
30 lines (29 loc) • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanvacordImageBuilder = void 0;
const canvas_1 = require("@napi-rs/canvas");
const Util_1 = require("../Utils/Util");
class CanvacordImageBuilder {
constructor(width, height) {
if (!Util_1.Util.is(width, 'number') || width < 1)
throw new TypeError(`Expected "width" to be a positive number, received ${width}!`);
if (!Util_1.Util.is(height, 'number') || height < 1)
throw new TypeError(`Expected "height" to be a positive number, received ${height}!`);
Object.defineProperty(this, 'internal', { enumerable: false, writable: true, configurable: true });
this.width = width;
this.height = height;
}
get canvas() {
var _a;
if (this.internal)
return (_a = this.internal.canvas) !== null && _a !== void 0 ? _a : null;
throw new Error('Canvas is not instantiated');
}
init() {
const canvas = canvas_1.createCanvas(this.width, this.height);
const ctx = canvas.getContext('2d');
this.internal = { canvas, ctx };
}
createRectangle() { }
}
exports.CanvacordImageBuilder = CanvacordImageBuilder;