UNPKG

@nmmty/lazycanvas

Version:

A simple way to interact with @napi-rs/canvas in an advanced way!

72 lines (71 loc) 2.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AnimationManager = void 0; const enum_1 = require("../../types/enum"); class AnimationManager { opts; animated; debug; constructor(debug = false) { this.opts = { frameRate: 30, maxColors: 256, colorSpace: enum_1.ColorSpace.RGB565, loop: true, transparency: true, clear: true }; this.animated = false; this.debug = debug; } /** * Sets the frame rate of the animation. * @param frameRate {number} - The frame rate of the animation (by default 30). */ setFrameRate(frameRate) { this.opts.frameRate = frameRate; this.animated = true; return this; } /** * Sets the loop of the animation. * @param loop {boolean} - Whether the animation should loop or not (by default true). */ setLoop(loop) { this.opts.loop = loop; return this; } /** * Sets the transparency of the animation. * @param transparency {boolean} - Whether the animation should have transparency or not (by default true). */ setTransparent(transparency) { this.opts.transparency = transparency; return this; } /** * Sets the RGB format of the animation. * @param rgb {ColorSpace} - The RGB format of the animation (by default RGB565). */ setRGBFormat(rgb) { this.opts.colorSpace = rgb; return this; } /** * Sets the maximum colors of the animation. * @param maxColors {number} - The maximum colors of the animation (by default 256). */ setMaxColors(maxColors) { this.opts.maxColors = maxColors; return this; } /** * Sets whether the content of previous frames will be cleared. * @param clear {boolean} - Whether the animation should clear or not (by default true). */ setClear(clear) { this.opts.clear = clear; return this; } } exports.AnimationManager = AnimationManager;