UNPKG

pencil.js

Version:

Nice modular interactive 2D drawing library.

110 lines (109 loc) 2.45 kB
/** * Scene class * @class * @extends {module:OffscreenCanvas} */ export default class Scene { /** * @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=window.document.body] - Element holding the canvas * @inheritDoc */ static getDrawingContext(container?: HTMLElement): any; /** * @typedef {Object} SceneOptions * @extends OffscreenCanvasOptions * @prop {String} [cursor=Component.cursors.defaultOptions] - Cursor on hover */ /** * @type {SceneOptions} */ static get defaultOptions(): any; /** * @typedef {Object} SceneEvents * @extends ContainerEvent * @prop {String} change - */ /** * @type {SceneEvents} */ static get events(): any; /** * Scene constructor * @param {HTMLElement} [container=document.body] - Container of the renderer * @param {SceneOptions} [options] - Specific options */ constructor(container?: HTMLElement, options?: any); ctx: CanvasRenderingContext2D; /** * @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; /** * Draw the whole scene * @return {Scene} Itself */ render(): Scene; /** * Define if is hovered * @return {Boolean} */ isHover(): boolean; /** * Start to render the scene each frame * @return {Scene} Itself */ startLoop(): Scene; /** * Stop scene from being rendered * @return {Scene} Itself */ stopLoop(): Scene; /** * @inheritDoc * @return {Scene} Itself */ hide(): Scene; /** * @inheritDoc * @return {Scene} Itself */ show(): Scene; } import Position from "@pencil.js/position";