diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 948efd4..263c66b 100644 --- a/src/app/working-area/working-area.component.ts +++ b/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'); - /** * 编辑点图片 */ editorPointTexture: PIXI.Texture = PIXI.Texture.from('assets/images/handle-main.png'); + backgroundTexture: PIXI.Texture = PIXI.Texture.from('assets/images/noImg.png'); /** * 框选工具图形 */ @@ -888,33 +888,35 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 刷新背景图 */ public async refreshBackgroundImage(imageUrl: string, imageAngle: number): Promise { + if (imageAngle === undefined || imageAngle === null) { + imageAngle = 0; + } + this.backgroundImage.scale.set(1); + this.backgroundImage.pivot.set(0); + this.backgroundImage.x = this.app.view.width / 2; + this.backgroundImage.y = this.app.view.height / 2; if (imageUrl === undefined || imageUrl === null || imageUrl === '') { - this.backgroundImage.visible = false; + this.backgroundImage.texture = this.backgroundTexture; } else { - this.backgroundImage.visible = false; - this.backgroundImage.scale.set(1); - this.backgroundImage.pivot.set(0); - this.backgroundImage.x = this.app.view.width / 2; - this.backgroundImage.y = this.app.view.height / 2; this.backgroundImage.texture = await PIXI.Texture.fromURL(imageUrl); - this.backgroundImage.angle = imageAngle; - // 等待图片加载完成 - const imageWidth = this.backgroundImage.texture.width; - const imageHeight = this.backgroundImage.texture.height; - const appWidth = this.app.view.width - 470; - const appHeight = this.app.view.height; - const wScale = appWidth / imageWidth; - const hScale = appHeight / imageHeight; - const scale = wScale < hScale ? wScale : hScale; - // 设置图片缩放 - this.backgroundImage.scale.set(scale); - this.backgroundImage.visible = true; - this.backgroundImage.children.forEach((item) => { - if (item instanceof AxShape) { - item.refresh(); - } - }); } + this.backgroundImage.angle = imageAngle; + // 等待图片加载完成 + const imageWidth = this.backgroundImage.texture.width; + const imageHeight = this.backgroundImage.texture.height; + const appWidth = this.app.view.width - 470; + const appHeight = this.app.view.height; + const wScale = appWidth / imageWidth; + const hScale = appHeight / imageHeight; + const scale = wScale < hScale ? wScale : hScale; + // 设置图片缩放 + this.backgroundImage.scale.set(scale); + // this.backgroundImage.visible = true; + this.backgroundImage.children.forEach((item) => { + if (item instanceof AxShape) { + item.refresh(); + } + }); } /** * 刷新