reviewed
This commit is contained in:
parent
62a385e4c9
commit
7959fe85cc
29 changed files with 1679 additions and 498 deletions
|
|
@ -35,7 +35,11 @@ const overlaps = (a: PreviewBox, b: PreviewBox, gap: number) =>
|
|||
a.y + a.height + gap > b.y;
|
||||
|
||||
/** Dimensions stay outside the outline. Short adjacent edges share a lane with staggered text. */
|
||||
export function dimensionedOutline(points: Point[], edges?: number[]) {
|
||||
export function dimensionedOutline(
|
||||
points: Point[],
|
||||
edges?: number[],
|
||||
blank: { length?: number; width?: number } = {},
|
||||
) {
|
||||
if (points.length < 3)
|
||||
return { dimensions: [] as EdgeDimension[], font: 1, box: fullPreviewBox(1, 1) };
|
||||
const span = Math.max(
|
||||
|
|
@ -72,7 +76,13 @@ export function dimensionedOutline(points: Point[], edges?: number[]) {
|
|||
};
|
||||
const normal = { x: orientation * direction.y, y: -orientation * direction.x };
|
||||
const center = { x: (edge.start.x + edge.end.x) / 2, y: (edge.start.y + edge.end.y) / 2 };
|
||||
const text = cutMm(edge.length);
|
||||
const limit =
|
||||
Math.abs(direction.y) < 1e-6
|
||||
? blank.length
|
||||
: Math.abs(direction.x) < 1e-6
|
||||
? blank.width
|
||||
: undefined;
|
||||
const text = cutMm(edge.length, limit);
|
||||
const angle =
|
||||
Math.abs(direction.x) > 0.000001 && Math.abs(direction.y) > 0.000001
|
||||
? (Math.atan2(Math.abs(direction.y), Math.abs(direction.x)) * 180) / Math.PI
|
||||
|
|
@ -178,18 +188,28 @@ export function fullPreviewBox(length: number, width: number): PreviewBox {
|
|||
export function skirtingEndBoxes(
|
||||
template: Point[],
|
||||
thickness: number,
|
||||
installed?: Point[],
|
||||
): { left: PreviewBox; right: PreviewBox } {
|
||||
const [backLeft, backRight, frontRight, frontLeft] = template;
|
||||
const left = [
|
||||
template[0].x,
|
||||
template[3].x,
|
||||
...(installed ? [installed[0].x, installed[3].x] : []),
|
||||
];
|
||||
const right = [
|
||||
template[1].x,
|
||||
template[2].x,
|
||||
...(installed ? [installed[1].x, installed[2].x] : []),
|
||||
];
|
||||
const side = Math.max(
|
||||
1,
|
||||
thickness * 3,
|
||||
Math.abs(backLeft.x - frontLeft.x) / 0.76,
|
||||
Math.abs(backRight.x - frontRight.x) / 0.76,
|
||||
(Math.max(...left) - Math.min(...left)) / 0.76,
|
||||
(Math.max(...right) - Math.min(...right)) / 0.76,
|
||||
);
|
||||
const padding = side * 0.12;
|
||||
const common = { y: (thickness - side) / 2, width: side, height: side };
|
||||
return {
|
||||
left: { ...common, x: Math.min(backLeft.x, frontLeft.x) - padding },
|
||||
right: { ...common, x: Math.max(backRight.x, frontRight.x) - side + padding },
|
||||
left: { ...common, x: Math.min(...left) - padding },
|
||||
right: { ...common, x: Math.max(...right) - side + padding },
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue