import { Sprite, Texture } from 'pixi.js'; import { WorkingAreaComponent } from '../working-area.component'; import { AxShape } from './axShape'; export class AxPreviewImageShape extends AxShape { image: Sprite = null; /** * */ constructor(workingArea: WorkingAreaComponent) { super(null, workingArea); this.image = new Sprite(); this.image.width = 32; this.image.height = 32; this.image.anchor.set(0.5); this.interactive = false; this.scale.set(1 / this.workingArea.backgroundImage.scale.x); this.addChild(this.image); } /** * 重新设置图片地址 * @param url 图片路径 */ setImageUrl(url: string) { this.image.texture = Texture.from(url); } }