UNPKG

gibbon.js

Version:

Actor/Component system for use with pixi.js.

97 lines 2.27 kB
import { Sprite, Graphics } from 'pixi.js'; /** * Graphical information for rendering a PIXI DisplayObject. */ export class SkinData { /** * @property {} graphicsData */ graphicsData; /** * @property {number} lineWidth */ lineWidth = 1; /** * @property {number} lineColor */ lineColor = 0; /** * @property {number} lineAlpha */ lineAlpha = 1; /** * @property {boolean} fill */ fill = false; /** * @property {number} fillColor */ fillColor = 0; /** * @property {number} fillAlpha */ fillAlpha = 1; /** * @property {PIXI.Circle|PIXI.Rectangle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRect} shape - Optional Shape information. * Not that unlike in PIXI.GraphicsData, this is actually a shape object. */ shape; /** * @property {number} */ radius; /** * @property {number} width */ width; /** * @property {number} height */ height; /** * @property {number} type - A type from PIXI.Shapes */ get type() { return this.shape?.type ?? this._type ?? 0; } set type(v) { this._type = v; } /** * @property {PIXI.Point[]} points */ points; /** * @property {PIXI.Texture} texture */ texture; _type; /** * * @param opts */ constructor(opts) { if (opts) { this.graphicsData = opts.graphicsData; this.lineAlpha = opts.lineAlpha ?? 1; this.lineColor = opts.lineColor ?? 0; this.lineWidth = opts.lineWidth ?? 1; this.fill = opts.fill ?? false; } } /** * Create a DisplayObject based on the skin data. * @returns {DisplayObject} */ createDisplay() { if (this.texture) return new Sprite(this.texture); const g = new Graphics(); if (this.fill) g.beginFill(this.fillColor, this.fillAlpha); g.lineStyle(this.lineWidth, this.lineColor, this.lineAlpha); if (this.shape != null) { g.drawShape(this.shape); } if (this.fill) g.endFill(); return g; } } //# sourceMappingURL=skindata.js.map