Browse Source

修正imageAngle = undefind 的时候不显示的的问题

zhuzhou
徐振升 4 years ago
parent
commit
e32e940c0d
  1. 16
      src/app/working-area/working-area.component.ts

16
src/app/working-area/working-area.component.ts

@ -109,11 +109,11 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
* *
*/ */
private enterPaintEndButton = PIXI.Sprite.from('assets/images/enterPaintButton.png'); private enterPaintEndButton = PIXI.Sprite.from('assets/images/enterPaintButton.png');
/** /**
* *
*/ */
editorPointTexture: PIXI.Texture = PIXI.Texture.from('assets/images/handle-main.png'); editorPointTexture: PIXI.Texture = PIXI.Texture.from('assets/images/handle-main.png');
backgroundTexture: PIXI.Texture = PIXI.Texture.from('assets/images/noImg.png');
/** /**
* *
*/ */
@ -888,15 +888,18 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
* *
*/ */
public async refreshBackgroundImage(imageUrl: string, imageAngle: number): Promise<void> { public async refreshBackgroundImage(imageUrl: string, imageAngle: number): Promise<void> {
if (imageUrl === undefined || imageUrl === null || imageUrl === '') { if (imageAngle === undefined || imageAngle === null) {
this.backgroundImage.visible = false; imageAngle = 0;
} else { }
this.backgroundImage.visible = false;
this.backgroundImage.scale.set(1); this.backgroundImage.scale.set(1);
this.backgroundImage.pivot.set(0); this.backgroundImage.pivot.set(0);
this.backgroundImage.x = this.app.view.width / 2; this.backgroundImage.x = this.app.view.width / 2;
this.backgroundImage.y = this.app.view.height / 2; this.backgroundImage.y = this.app.view.height / 2;
if (imageUrl === undefined || imageUrl === null || imageUrl === '') {
this.backgroundImage.texture = this.backgroundTexture;
} else {
this.backgroundImage.texture = await PIXI.Texture.fromURL(imageUrl); this.backgroundImage.texture = await PIXI.Texture.fromURL(imageUrl);
}
this.backgroundImage.angle = imageAngle; this.backgroundImage.angle = imageAngle;
// 等待图片加载完成 // 等待图片加载完成
const imageWidth = this.backgroundImage.texture.width; const imageWidth = this.backgroundImage.texture.width;
@ -908,14 +911,13 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
const scale = wScale < hScale ? wScale : hScale; const scale = wScale < hScale ? wScale : hScale;
// 设置图片缩放 // 设置图片缩放
this.backgroundImage.scale.set(scale); this.backgroundImage.scale.set(scale);
this.backgroundImage.visible = true; // this.backgroundImage.visible = true;
this.backgroundImage.children.forEach((item) => { this.backgroundImage.children.forEach((item) => {
if (item instanceof AxShape) { if (item instanceof AxShape) {
item.refresh(); item.refresh();
} }
}); });
} }
}
/** /**
* *
* @param imageUrl * @param imageUrl

Loading…
Cancel
Save