From 80892fe9c7097c070a29cf10d6e2c3cb0e0def98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=8C=AF=E5=8D=87?= <359059686@qq.com> Date: Mon, 1 Mar 2021 11:14:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98=20=20=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E6=8B=89=E5=8F=96=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/working-area/model/axImageShape.ts | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/app/working-area/model/axImageShape.ts b/src/app/working-area/model/axImageShape.ts index 2a91bd1..f8bf366 100644 --- a/src/app/working-area/model/axImageShape.ts +++ b/src/app/working-area/model/axImageShape.ts @@ -5,7 +5,7 @@ import { PaintMode } from './paintModel'; import * as PIXI from 'pixi.js'; import { PropertyInfo } from './PropertyInfo'; import { AxShape } from './axShape'; -import { Sprite } from 'pixi.js'; +import { Sprite, Point } from 'pixi.js'; import { AxArrowConnector } from './axArrowConnector'; /** @@ -72,11 +72,33 @@ export class AxImageShape extends AxShape { this.addChild(this.selectionBox); //// + var leftUpPos = new Point(0, 0); + var upLeftDrag = false; + var leftDownPos = new Point(0, 0); + var rightUpPos = new Point(0, 0); + var rightDownPos = new Point(0, 0); // up-left this.upLeft = new PIXI.Sprite(this.pointTexture); this.upLeft.anchor.set(0.5); this.addChild(this.upLeft); this.upLeft.interactive = true; + this.upLeft.on('pointerdown', event => { + event.stopPropagation(); + upLeftDrag = true; + // this.pivot.set(1); + var imageRect = this.image.getLocalBounds(); + rightDownPos = new Point(imageRect.right, imageRect.bottom); + + + }); + this.upLeft.on('pointermove', event => { + // 移动时调整形状大小,然后重绘边框 + // 检查右下角距离鼠标的位置, + event.stopPropagation(); + leftUpPos = this.toLocal(event.data.global); + this.image.width = Math.abs(leftUpPos.x - rightDownPos.x); + this.image.height = Math.abs(leftUpPos.y - rightDownPos.y); + }); this.upLeft.visible = false; // up-right this.upRight = new PIXI.Sprite(this.pointTexture);