import {compose, EventEmitter} from '@avocado/core'; const decorate = compose( EventEmitter, ); export class Renderable extends decorate(class {}) { constructor() { super(); this.parent = null; this._zIndex = 0; } destroy() { if (this.internal) { this.internal.destroy(); delete this.internal; } } get alpha() { return this.internal.alpha; } set alpha(alpha) { this.internal.alpha = alpha; } get anchor() { const anchor = this.internal.anchor || {x: 0, y: 0}; return [ anchor.x, anchor.y, ]; } set anchor(anchor) { this.internal.anchor = { x: anchor[0], y: anchor[1], }; } get position() { return [this.internal.x, this.internal.y]; } set position(position) { this.internal.x = position[0]; this.internal.y = position[1]; } get rotation() { return this.internal.rotation; } set rotation(rotation) { this.internal.rotation = rotation; } get scale() { const scale = this.internal.scale || {x: 1, y: 1}; return [ scale.x, scale.y, ]; } set scale(scale) { this.internal.scale = { x: scale[0], y: scale[1], }; } get visible() { return this.internal.visible; } set visible(isVisible) { this.internal.visible = isVisible; } get x() { return this.internal.x; } set x(x) { this.internal.x = x; } get y() { return this.internal.y; } set y(y) { this.internal.y = y; } get zIndex() { return this._zIndex; } set zIndex(zIndex) { this._zIndex = zIndex; } }