feat: 八个点的坐标记录

Re-1.0
咬轮猫 3 years ago
parent 3bf7170b54
commit 35b5db898c

@ -153,6 +153,40 @@
width: 0, width: 0,
height: 0 height: 0
}, },
point_coordinate: {
tl: {
x: 0,
y: 0
},
tc: {
x: 0,
y: 0
},
tr: {
x: 0,
y: 0
},
l: {
x: 0,
y: 0
},
r: {
x: 0,
y: 0
},
bl: {
x: 0,
y: 0
},
bc: {
x: 0,
y: 0
},
br: {
x: 0,
y: 0
}
},
...globalStore.create_svg_info ...globalStore.create_svg_info
}; };
globalStore.setHandleSvgInfo(done_item_json, globalStore.done_json.length); globalStore.setHandleSvgInfo(done_item_json, globalStore.done_json.length);

@ -0,0 +1,51 @@
import { useGlobalStore } from '../store/global';
import { calculateRotatedPointCoordinate } from '../utils';
export const useSetPointCoordinate = () => {
const globalStore = useGlobalStore();
if (globalStore.handle_svg_info) {
const item_point = globalStore.handle_svg_info.info;
globalStore.handle_svg_info.info.point_coordinate = {
tl: calculateRotatedPointCoordinate(
item_point.point_coordinate.tl,
item_point.client,
-item_point.rotate
),
tc: calculateRotatedPointCoordinate(
item_point.point_coordinate.tc,
item_point.client,
-item_point.rotate
),
tr: calculateRotatedPointCoordinate(
item_point.point_coordinate.tr,
item_point.client,
-item_point.rotate
),
l: calculateRotatedPointCoordinate(
item_point.point_coordinate.l,
item_point.client,
-item_point.rotate
),
r: calculateRotatedPointCoordinate(
item_point.point_coordinate.r,
item_point.client,
-item_point.rotate
),
bl: calculateRotatedPointCoordinate(
item_point.point_coordinate.bl,
item_point.client,
-item_point.rotate
),
bc: calculateRotatedPointCoordinate(
item_point.point_coordinate.bc,
item_point.client,
-item_point.rotate
),
br: calculateRotatedPointCoordinate(
item_point.point_coordinate.br,
item_point.client,
-item_point.rotate
)
};
}
};

@ -98,3 +98,6 @@ export const useGlobalStore = defineStore('global-store', {
} }
} }
}); });
useGlobalStore().$subscribe((mutation, state) => {
console.log(mutation, state, 102);
});

@ -14,10 +14,7 @@ export interface IDoneJson extends IConfigItem {
id: string; id: string;
x: number; x: number;
y: number; y: number;
client: { client: ICoordinate;
x: number;
y: number;
};
scale_x: number; scale_x: number;
scale_y: number; scale_y: number;
rotate: number; rotate: number;
@ -27,6 +24,16 @@ export interface IDoneJson extends IConfigItem {
width: number; width: number;
height: number; height: number;
}; };
point_coordinate: {
tl: ICoordinate;
tc: ICoordinate;
tr: ICoordinate;
l: ICoordinate;
r: ICoordinate;
bl: ICoordinate;
bc: ICoordinate;
br: ICoordinate;
};
} }
export enum EGlobalStoreIntention { export enum EGlobalStoreIntention {
None = 'None', None = 'None',
@ -91,3 +98,7 @@ export enum EScaleInfoType {
BottomCenter = 'BottomCenter', BottomCenter = 'BottomCenter',
BottomRight = 'BottomRight' BottomRight = 'BottomRight'
} }
export interface ICoordinate {
x: number;
y: number;
}

Loading…
Cancel
Save