refactor: semantics
This commit is contained in:
parent
ad99cd3f3f
commit
fd1c905351
|
@ -4,7 +4,6 @@ import {compose} from '@avocado/core';
|
|||
import {Vector} from '@avocado/math';
|
||||
|
||||
import {Image} from './image';
|
||||
import {Renderable} from './renderable';
|
||||
|
||||
const decorate = compose(
|
||||
Vector.Mixin('size', 'width', 'height', {
|
||||
|
@ -12,11 +11,10 @@ const decorate = compose(
|
|||
}),
|
||||
);
|
||||
|
||||
export class Canvas extends decorate(Renderable) {
|
||||
class CanvasBase {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.renderTexture = PIXI.RenderTexture.create(1, 1);
|
||||
constructor(size = [0, 0]) {
|
||||
this.renderTexture = PIXI.RenderTexture.create(size[0], size[1]);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
@ -31,6 +29,16 @@ export class Canvas extends decorate(Renderable) {
|
|||
renderer.render(renderable, this);
|
||||
}
|
||||
|
||||
toImage() {
|
||||
const image = new Image();
|
||||
image.texture = this.renderTexture.clone();
|
||||
return image;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class Canvas extends decorate(CanvasBase) {
|
||||
|
||||
get size() {
|
||||
return super.size;
|
||||
}
|
||||
|
@ -40,10 +48,4 @@ export class Canvas extends decorate(Renderable) {
|
|||
super.size = size;
|
||||
}
|
||||
|
||||
toImage() {
|
||||
const image = new Image();
|
||||
image.texture = this.renderTexture.clone();
|
||||
return image;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user