|
@@ -75,9 +75,16 @@ export class ObjsContainer {
|
|
|
|
|
|
if (n == 1) { //单对象
|
|
|
let obj = selected[0];
|
|
|
- //构建当前对象的转换矩阵
|
|
|
- let rect = new Rectangle(0, 0, obj.width, obj.height);
|
|
|
+
|
|
|
+ const s = obj.worldTransform.getScale();
|
|
|
+ let rect = new Rectangle(0, 0, obj.width * s.x, obj.height*s.y);
|
|
|
this.rect = rect;
|
|
|
+ obj.transform.scale.x = 1;
|
|
|
+ obj.transform.scale.y = 1;
|
|
|
+ obj.width = rect.width;
|
|
|
+ obj.height = rect.height;
|
|
|
+ obj.updateTransform();
|
|
|
+
|
|
|
this.parent.transform.setFromMatrix(obj.worldTransform);
|
|
|
this.parent.updateTransform();
|
|
|
this.parent.addChildWorldNoChange(obj);
|
|
@@ -85,6 +92,7 @@ export class ObjsContainer {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
while (n--) {
|
|
|
let obj = selected[n];
|
|
|
let box = obj.calculateBounds();
|
|
@@ -98,6 +106,7 @@ export class ObjsContainer {
|
|
|
|
|
|
this.rect = rect;
|
|
|
|
|
|
+
|
|
|
//设置位置
|
|
|
let p = this.parent.position;
|
|
|
p.x = center.x;
|
|
@@ -110,6 +119,8 @@ export class ObjsContainer {
|
|
|
|
|
|
//设置旋转
|
|
|
this.parent.scale = { x: 1, y: 1 } as any;
|
|
|
+ this.parent.width = rect.width;
|
|
|
+ this.parent.height = rect.height;
|
|
|
|
|
|
//设置旋转
|
|
|
this.parent.rotation = selectedRotation;
|
|
@@ -155,7 +166,8 @@ export class ObjsContainer {
|
|
|
this.parent.updateTransform();
|
|
|
|
|
|
this.pivotIndex = index;
|
|
|
- return { x: point.x * 0.5, y: point.y * 0.5 };
|
|
|
+
|
|
|
+ return { x: point.x, y: point.y};
|
|
|
}
|
|
|
|
|
|
getPivotXY(index:number) {
|
|
@@ -189,8 +201,8 @@ export class ObjsContainer {
|
|
|
let pX = { x: pointX.x, y: pointX.y } as any;
|
|
|
this.parent.worldTransform.apply(pX, pX);
|
|
|
|
|
|
- let xVec = { x: (pX.x - point.x) * 0.5, y: (pX.y - point.y) * 0.5 };
|
|
|
- let yVec = { x: (pY.x - point.x) * 0.5, y: (pY.y - point.y) * 0.5 };
|
|
|
+ let xVec = { x: (pX.x - point.x), y: (pX.y - point.y) };
|
|
|
+ let yVec = { x: (pY.x - point.x), y: (pY.y - point.y) };
|
|
|
|
|
|
return { x: xVec, y: yVec };
|
|
|
}
|
|
@@ -199,21 +211,56 @@ export class ObjsContainer {
|
|
|
this.parent.scale.x = x;
|
|
|
this.parent.scale.y = y;
|
|
|
this.parent.updateTransform();
|
|
|
-
|
|
|
this.updateCompState();
|
|
|
}
|
|
|
|
|
|
scaleX(x:number) {
|
|
|
this.parent.scale.x = x;
|
|
|
+
|
|
|
this.parent.updateTransform();
|
|
|
this.updateCompState();
|
|
|
}
|
|
|
+
|
|
|
scaleY(y:number) {
|
|
|
this.parent.scale.y = y;
|
|
|
this.parent.updateTransform();
|
|
|
this.updateCompState();
|
|
|
}
|
|
|
|
|
|
+ // scaleSize(w:number, h:number) {
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ scaleWidth(w:number) {
|
|
|
+
|
|
|
+ //怎么改对应的偏移值
|
|
|
+ this.parent.scale.x = w / this.rect.width
|
|
|
+
|
|
|
+
|
|
|
+ this.rect.width = w;
|
|
|
+ this.selected[0].width = w;
|
|
|
+ }
|
|
|
+ // scaleHeight(w:number) {
|
|
|
+
|
|
|
+ // }
|
|
|
+ //清除当前元素的缩放 改为类容的宽度
|
|
|
+ applyScaleToChildSize() {
|
|
|
+ if (this.selected.length != 1 ) return;
|
|
|
+
|
|
|
+ const w = this.width *this.parent.scale.x;
|
|
|
+ const h = this.height *this.parent.scale.y;
|
|
|
+ this.parent.scale.x = 1;
|
|
|
+ this.parent.scale.y = 1;
|
|
|
+ this.parent.updateTransform();
|
|
|
+
|
|
|
+ this.rect.width = w;
|
|
|
+ this.rect.height = h;
|
|
|
+ this.selected[0].width = w;
|
|
|
+ this.selected[0].height = h;
|
|
|
+
|
|
|
+ this.updateCompState();
|
|
|
+ }
|
|
|
+
|
|
|
translate(x:number, y:number) {
|
|
|
this.parent.x += x;
|
|
|
this.parent.y += y;
|