|
@@ -1,5 +1,4 @@
|
|
import { Pos } from "@/utils/math.ts";
|
|
import { Pos } from "@/utils/math.ts";
|
|
-import { themeColor, themeMouseColors } from "@/constant/help-style.ts";
|
|
|
|
import { getMouseColors } from "@/utils/colors.ts";
|
|
import { getMouseColors } from "@/utils/colors.ts";
|
|
import { onlyId } from "@/utils/shared.ts";
|
|
import { onlyId } from "@/utils/shared.ts";
|
|
import { BaseItem, generateSnapInfos, getBaseItem } from "../util.ts";
|
|
import { BaseItem, generateSnapInfos, getBaseItem } from "../util.ts";
|
|
@@ -13,11 +12,11 @@ export const shapeName = "矩形";
|
|
export const defaultStyle = {
|
|
export const defaultStyle = {
|
|
dash: [30, 0],
|
|
dash: [30, 0],
|
|
strokeWidth: 1,
|
|
strokeWidth: 1,
|
|
- stroke: '#000000',
|
|
|
|
|
|
+ stroke: "#000000",
|
|
fontSize: 16,
|
|
fontSize: 16,
|
|
align: "center",
|
|
align: "center",
|
|
fontStyle: "normal",
|
|
fontStyle: "normal",
|
|
- fontColor: '#000000',
|
|
|
|
|
|
+ fontColor: "#000000",
|
|
};
|
|
};
|
|
|
|
|
|
export const getMouseStyle = (data: RectangleData) => {
|
|
export const getMouseStyle = (data: RectangleData) => {
|
|
@@ -26,11 +25,18 @@ export const getMouseStyle = (data: RectangleData) => {
|
|
const strokeWidth = data.strokeWidth || defaultStyle.strokeWidth;
|
|
const strokeWidth = data.strokeWidth || defaultStyle.strokeWidth;
|
|
|
|
|
|
return {
|
|
return {
|
|
- default: { fill: data.fill , stroke: data.stroke || defaultStyle.stroke, strokeWidth },
|
|
|
|
|
|
+ default: {
|
|
|
|
+ fill: data.fill,
|
|
|
|
+ stroke: data.stroke || defaultStyle.stroke,
|
|
|
|
+ strokeWidth,
|
|
|
|
+ },
|
|
hover: { fill: fillStatus && fillStatus.hover, stroke: strokeStatus.hover },
|
|
hover: { fill: fillStatus && fillStatus.hover, stroke: strokeStatus.hover },
|
|
focus: { fill: fillStatus && fillStatus.hover, stroke: strokeStatus.hover },
|
|
focus: { fill: fillStatus && fillStatus.hover, stroke: strokeStatus.hover },
|
|
press: { fill: fillStatus && fillStatus.press, stroke: strokeStatus.press },
|
|
press: { fill: fillStatus && fillStatus.press, stroke: strokeStatus.press },
|
|
- select: { fill: fillStatus && fillStatus.select, stroke: strokeStatus.select },
|
|
|
|
|
|
+ select: {
|
|
|
|
+ fill: fillStatus && fillStatus.select,
|
|
|
|
+ stroke: strokeStatus.select,
|
|
|
|
+ },
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
@@ -47,16 +53,16 @@ export type RectangleData = Partial<typeof defaultStyle> &
|
|
stroke?: string;
|
|
stroke?: string;
|
|
fill?: string;
|
|
fill?: string;
|
|
strokeWidth?: number;
|
|
strokeWidth?: number;
|
|
- content?: string
|
|
|
|
|
|
+ content?: string;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+export const getSnapPoints = (data: RectangleData) => {
|
|
|
|
+ return data.points;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+export const getSnapInfos = (data: RectangleData) =>
|
|
|
|
+ generateSnapInfos(getSnapPoints(data), true, false);
|
|
|
|
|
|
- export const getSnapPoints = (data: RectangleData) => {
|
|
|
|
- return data.points
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- export const getSnapInfos = (data: RectangleData) => generateSnapInfos(getSnapPoints(data), true, false)
|
|
|
|
-
|
|
|
|
export const interactiveToData: InteractiveTo<"rectangle"> = ({
|
|
export const interactiveToData: InteractiveTo<"rectangle"> = ({
|
|
info,
|
|
info,
|
|
preset = {},
|
|
preset = {},
|
|
@@ -94,23 +100,28 @@ export const interactiveFixData: InteractiveFix<"rectangle"> = ({
|
|
return data;
|
|
return data;
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-export const matResponse = ({data, mat, increment}: MatResponseProps<'rectangle'>) => {
|
|
|
|
- let transfrom: Transform
|
|
|
|
|
|
+export const matResponse = ({
|
|
|
|
+ data,
|
|
|
|
+ mat,
|
|
|
|
+ increment,
|
|
|
|
+}: MatResponseProps<"rectangle">) => {
|
|
|
|
+ let transfrom: Transform;
|
|
const attitude = new Transform(data.attitude);
|
|
const attitude = new Transform(data.attitude);
|
|
if (!increment) {
|
|
if (!increment) {
|
|
const inverMat = attitude.copy().invert();
|
|
const inverMat = attitude.copy().invert();
|
|
transfrom = mat.copy().multiply(inverMat);
|
|
transfrom = mat.copy().multiply(inverMat);
|
|
} else {
|
|
} else {
|
|
- transfrom = mat
|
|
|
|
|
|
+ transfrom = mat;
|
|
}
|
|
}
|
|
|
|
|
|
data.points = data.points.map((v) => transfrom.point(v));
|
|
data.points = data.points.map((v) => transfrom.point(v));
|
|
data.attitude = transfrom.copy().multiply(attitude).m;
|
|
data.attitude = transfrom.copy().multiply(attitude).m;
|
|
return data;
|
|
return data;
|
|
-}
|
|
|
|
|
|
+};
|
|
export const getPredefine = (key: keyof RectangleData) => {
|
|
export const getPredefine = (key: keyof RectangleData) => {
|
|
- if (key === 'fill') {
|
|
|
|
- return { canun: true }
|
|
|
|
|
|
+ if (key === "fill") {
|
|
|
|
+ return { canun: true };
|
|
|
|
+ } else if (key === "strokeWidth") {
|
|
|
|
+ return { proportion: true };
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+};
|