2019-04-28 23:45:03 -05:00
|
|
|
import {compose, EventEmitter} from '@avocado/core';
|
2019-03-30 05:07:21 -05:00
|
|
|
|
|
|
|
const decorate = compose(
|
|
|
|
EventEmitter,
|
|
|
|
);
|
|
|
|
|
|
|
|
export class Renderable extends decorate(class {}) {
|
2019-03-18 20:06:47 -05:00
|
|
|
|
2019-03-19 21:02:43 -05:00
|
|
|
constructor() {
|
2019-03-30 05:07:21 -05:00
|
|
|
super();
|
2019-03-19 21:02:43 -05:00
|
|
|
this.parent = null;
|
|
|
|
this._zIndex = 0;
|
|
|
|
}
|
|
|
|
|
2019-04-19 16:23:26 -05:00
|
|
|
destroy() {
|
|
|
|
if (this.internal) {
|
|
|
|
this.internal.destroy();
|
|
|
|
delete this.internal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-18 20:06:47 -05:00
|
|
|
get alpha() {
|
|
|
|
return this.internal.alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
set alpha(alpha) {
|
|
|
|
this.internal.alpha = alpha;
|
|
|
|
}
|
|
|
|
|
2019-04-19 16:23:26 -05:00
|
|
|
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],
|
|
|
|
};
|
2019-03-19 18:29:11 -05:00
|
|
|
}
|
|
|
|
|
2019-03-18 20:06:47 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-03-25 18:55:06 -05:00
|
|
|
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],
|
2019-04-19 16:23:26 -05:00
|
|
|
y: scale[1],
|
2019-03-25 18:55:06 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-03-18 20:06:47 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-03-19 21:02:43 -05:00
|
|
|
get zIndex() {
|
|
|
|
return this._zIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
set zIndex(zIndex) {
|
|
|
|
this._zIndex = zIndex;
|
|
|
|
}
|
|
|
|
|
2019-03-18 20:06:47 -05:00
|
|
|
}
|
|
|
|
|