UNPKG

pencil.js

Version:

Nice modular interactive 2D drawing library.

83 lines (82 loc) 2.1 kB
/** * Scene class * @class * @extends OffscreenCanvas */ export default class Scene extends OffscreenCanvas { /** * @inheritDoc * @param {Object} definition - Scene definition * @return {Scene} */ static from(definition: any): Scene; /** * Build a canvas and set it to fill the entire document.body * @param {HTMLElement} container - Element holding the canvas * @inheritDoc */ static getDrawingContext(container?: HTMLElement): CanvasRenderingContext2D; /** * @typedef {Object} SceneOptions * @extends {OffscreenCanvasOptions} * @prop {String} [cursor=Component.cursors.defaultOptions] - Cursor on hover */ /** * @type {SceneOptions} */ static get defaultOptions(): any; /** * Scene constructor * @param {HTMLElement} [container=document.body] - Container of the renderer * @param {SceneOptions} [options] - Specific options */ constructor(container?: HTMLElement, options?: SceneOptions); /** * @type {Position} */ cursorPosition: Position; /** * @type {Position} */ containerPosition: Position; /** * @type {Boolean} */ isScene: boolean; /** * @type {Boolean} */ isLooped: boolean; /** * @type {Boolean} */ isClicked: boolean; /** * @type {Number} */ fps: number; /** * @type {Number} */ lastTick: number; /** * * @param {String} [cursor=Component.cursors.default] - Cursor string * @return {Scene} Itself */ setCursor(cursor?: string): Scene; /** * Start to render the scene each frame * @return {Scene} Itself */ startLoop(): Scene; /** * Stop scene from being rendered * @return {Scene} Itself */ stopLoop(): Scene; } export type SceneOptions = any; export type SceneEvents = any; import OffscreenCanvas from "@pencil.js/offscreen-canvas"; import Position from "@pencil.js/position";