Skip to content

Commit a484802

Browse files
committed
refactor: baseX/baseY去除
1 parent 793d181 commit a484802

File tree

4 files changed

+15
-39
lines changed

4 files changed

+15
-39
lines changed

src/format/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ export type RootProps = Props & {
215215
};
216216

217217
export type PageProps = Props & {
218-
rule?: {
219-
baseX: number;
220-
baseY: number;
221-
};
222218
};
223219

224220
export type BitmapProps = Props & {

src/format/sketch.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ async function convertPage(page: SketchFormat.Page, index: number, opt: Opt): Pr
182182
nameIsFixed: page.nameIsFixed,
183183
index,
184184
constrainProportions: page.frame.constrainProportions || false,
185-
// rule: {
186-
// baseX: page.horizontalRulerData?.base || 0,
187-
// baseY: page.verticalRulerData?.base || 0,
188-
// },
189185
style: {
190186
width: PAGE_W,
191187
height: PAGE_H,

src/tools/node.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,16 +1198,6 @@ export function getBasicMatrix(node: Node) {
11981198
return m;
11991199
}
12001200

1201-
export function getBaseCoords(node: Node) {
1202-
let baseX = 0,
1203-
baseY = 0;
1204-
if (!node.artBoard) {
1205-
baseX = (node.page?.props as PageProps).rule?.baseX || 0;
1206-
baseY = (node.page?.props as PageProps).rule?.baseY || 0;
1207-
}
1208-
return { baseX, baseY };
1209-
}
1210-
12111201
export function getBasicInfo(node: Node) {
12121202
const m = getBasicMatrix(node);
12131203
const rect = node._rect || node.rect;
@@ -1221,12 +1211,9 @@ export function getBasicInfo(node: Node) {
12211211
const x4 = t.x4;
12221212
const y4 = t.y4;
12231213
const { computedStyle } = node;
1224-
const { baseX, baseY } = getBaseCoords(node);
12251214
const res = {
1226-
baseX,
1227-
baseY,
1228-
x: Math.min(x1, x2, x3, x4) - baseX,
1229-
y: Math.min(y1, y2, y3, y4) - baseY,
1215+
x: Math.min(x1, x2, x3, x4),
1216+
y: Math.min(y1, y2, y3, y4),
12301217
w: rect[2] - rect[0],
12311218
h: rect[3] - rect[1],
12321219
isFlippedHorizontal: computedStyle.scaleX === -1,
@@ -1382,7 +1369,6 @@ export default {
13821369
resizeBottomLeftMultiArOperate,
13831370
resizeBottomRightMultiArOperate,
13841371
getBasicMatrix,
1385-
getBaseCoords,
13861372
getBasicInfo,
13871373
toBitmap,
13881374
};

src/tools/polyline.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { JPoint, Point } from '../format';
33
import Polyline from '../node/geom/Polyline';
44
import { calPoint, inverse4 } from '../math/matrix';
55
import { isConvexPolygonOverlapRect, pointInRect } from '../math/geom';
6-
import { getBaseCoords, getBasicMatrix } from './node';
6+
import { getBasicMatrix } from './node';
77

88
export function createRect() {
99
return new Polyline({
@@ -213,20 +213,19 @@ export function getPointsDspByAbs(node: Polyline, points?: Point | Point[]) {
213213
if (!points) {
214214
points = node.points;
215215
}
216-
const { baseX, baseY } = getBaseCoords(node);
217216
const pts = Array.isArray(points) ? points : [points];
218217
pts.forEach(item => {
219218
const p = calPoint({
220-
x: item.absX - baseX,
221-
y: item.absY - baseY,
219+
x: item.absX,
220+
y: item.absY,
222221
}, m);
223222
const f = calPoint({
224-
x: item.absFx - baseX,
225-
y: item.absFy - baseY,
223+
x: item.absFx,
224+
y: item.absFy,
226225
}, m);
227226
const t = calPoint({
228-
x: item.absTx - baseX,
229-
y: item.absTy - baseY,
227+
x: item.absTx,
228+
y: item.absTy,
230229
}, m);
231230
item.dspX = p.x;
232231
item.dspY = p.y;
@@ -243,20 +242,19 @@ export function getPointsAbsByDsp(node: Polyline, points?: Point | Point[]) {
243242
points = node.points;
244243
}
245244
const i = inverse4(m);
246-
const { baseX, baseY } = getBaseCoords(node);
247245
const pts = Array.isArray(points) ? points : [points];
248246
pts.forEach(item => {
249247
const p = calPoint({
250-
x: item.dspX + baseX,
251-
y: item.dspY + baseY,
248+
x: item.dspX,
249+
y: item.dspY,
252250
}, i);
253251
const f = calPoint({
254-
x: item.dspFx + baseX,
255-
y: item.dspFy + baseY,
252+
x: item.dspFx,
253+
y: item.dspFy,
256254
}, i);
257255
const t = calPoint({
258-
x: item.dspTx + baseX,
259-
y: item.dspTy + baseY,
256+
x: item.dspTx,
257+
y: item.dspTy,
260258
}, i);
261259
item.absX = p.x;
262260
item.absY = p.y;

0 commit comments

Comments
 (0)