..
This commit is contained in:
parent
9689bfcc18
commit
62a385e4c9
1 changed files with 2649 additions and 809 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import type { FlooringPiece, Point, SkirtingPiece } from './types';
|
||||
import { cutMm, degree } from './format';
|
||||
|
||||
export interface PreviewBox {
|
||||
x: number;
|
||||
|
|
@ -6,8 +7,6 @@ export interface PreviewBox {
|
|||
width: number;
|
||||
height: number;
|
||||
}
|
||||
export const exactMm = (value: number) =>
|
||||
new Intl.NumberFormat('en-GB', { maximumFractionDigits: 3 }).format(value);
|
||||
export const viewBox = (box: PreviewBox) => `${box.x} ${box.y} ${box.width} ${box.height}`;
|
||||
|
||||
export interface EdgeDimension {
|
||||
|
|
@ -73,12 +72,12 @@ 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 = exactMm(edge.length);
|
||||
const text = cutMm(edge.length);
|
||||
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
|
||||
: undefined;
|
||||
const angleText = angle === undefined ? '' : `${exactMm(angle)}°`;
|
||||
const angleText = angle === undefined ? '' : degree(angle);
|
||||
const width = Math.max(font * 1.2, Math.max(text.length, angleText.length) * font * 0.64),
|
||||
height = font * (angle === undefined ? 1.3 : 2.5);
|
||||
const outside = Math.max(
|
||||
|
|
|
|||
Loading…
Reference in a new issue