mirror of
https://gitee.com/onvia/ccc-tnt-psd2ui
synced 2026-03-15 10:41:41 +00:00
移除 @scale @size,调整为自动计算 scale
This commit is contained in:
@@ -42,7 +42,7 @@ export class PsdImage extends PsdLayer {
|
||||
this.md5 = fileUtils.getMD5(this.imgBuffer);
|
||||
|
||||
this.textureSize = new Size(canvas.width, canvas.height);
|
||||
this.scale = new Vec3((this.isFilpX() ? -1 : 1) * this.scale.x, (this.isFilpY() ? -1 : 1) * this.scale.y, 1);
|
||||
this.scale = new Vec3((this.isFlipX() ? -1 : 1) * this.scale.x, (this.isFlipY() ? -1 : 1) * this.scale.y, 1);
|
||||
}
|
||||
|
||||
onCtor() {
|
||||
@@ -64,12 +64,12 @@ export class PsdImage extends PsdLayer {
|
||||
}
|
||||
|
||||
/** 是否是 x 方向镜像图片 */
|
||||
isFilpX() {
|
||||
isFlipX() {
|
||||
return typeof this.attr.comps.flipX?.bind !== 'undefined';
|
||||
}
|
||||
|
||||
/** 是否是 y 方向镜像图片 */
|
||||
isFilpY() {
|
||||
isFlipY() {
|
||||
return typeof this.attr.comps.flipY?.bind !== 'undefined';
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ export class PsdImage extends PsdLayer {
|
||||
// this.position.x = this.position.x - this.parent.size.width * this.parent.anchorPoint.x + this.size.width * this.anchorPoint.x;
|
||||
// this.position.y = this.position.y - this.parent.size.height * this.parent.anchorPoint.y + this.size.height * this.anchorPoint.y;
|
||||
// 如果是镜像图片,则特殊处理
|
||||
let arX = (this.isFilpX() ? (1 - this.anchorPoint.x) : this.anchorPoint.x);
|
||||
let arY = (this.isFilpY() ? (1 - this.anchorPoint.y) : this.anchorPoint.y);
|
||||
let arX = (this.isFlipX() ? (1 - this.anchorPoint.x) : this.anchorPoint.x);
|
||||
let arY = (this.isFlipY() ? (1 - this.anchorPoint.y) : this.anchorPoint.y);
|
||||
this.position.x = this.position.x - this.rootDoc.size.width * this.rootDoc.anchorPoint.x + this.size.width * arX;
|
||||
this.position.y = this.position.y - this.rootDoc.size.height * this.rootDoc.anchorPoint.y + this.size.height * arY;
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ export interface PsdAttr {
|
||||
igimg?: {};
|
||||
|
||||
full?: {};
|
||||
size?: { w?: number, h?: number };
|
||||
scale?: { x?: number, y?: number };
|
||||
// size?: { w?: number, h?: number };
|
||||
// scale?: { x?: number, y?: number };
|
||||
img?: { id?: number, name?: string, bind?: number }
|
||||
flip?: { bind: number, x?: number, y?: number }
|
||||
flipX?: { bind: number }
|
||||
@@ -93,8 +93,9 @@ export abstract class PsdLayer {
|
||||
this.name = this.chineseToPinyin(this.attr?.name || this.name);
|
||||
|
||||
// 使用配置的缩放系数
|
||||
let _scale = this.attr?.comps.scale;
|
||||
this.scale = new Vec3(_scale?.x ?? 1, _scale?.y ?? 1, 1);
|
||||
// let _scale = this.attr?.comps.scale;
|
||||
// this.scale = new Vec3(_scale?.x ?? 1, _scale?.y ?? 1, 1);
|
||||
this.scale = new Vec3(1, 1, 1);
|
||||
}
|
||||
|
||||
abstract onCtor();
|
||||
@@ -195,10 +196,10 @@ export abstract class PsdLayer {
|
||||
}
|
||||
|
||||
|
||||
// 检查冲突
|
||||
if (obj.comps.full && obj.comps.size) {
|
||||
console.warn(`PsdLayer->${obj.name} 同时存在 @full 和 @size`);
|
||||
}
|
||||
// // 检查冲突
|
||||
// if (obj.comps.full && obj.comps.size) {
|
||||
// console.warn(`PsdLayer->${obj.name} 同时存在 @full 和 @size`);
|
||||
// }
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user