@bitbybit-dev/base 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +24 -0
- package/README.md +3 -1
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +20 -0
- package/lib/api/inputs/base-inputs.js +22 -0
- package/lib/api/inputs/io-inputs.d.ts +408 -8
- package/lib/api/inputs/io-inputs.js +344 -7
- package/lib/api/inputs/mesh-inputs.d.ts +20 -1
- package/lib/api/inputs/mesh-inputs.js +23 -0
- package/lib/api/inputs/recipes-inputs.d.ts +13 -5
- package/lib/api/inputs/recipes-inputs.js +10 -5
- package/lib/api/kernel-calls/index.d.ts +1 -0
- package/lib/api/kernel-calls/index.js +1 -0
- package/lib/api/kernel-calls/resolve-dto.d.ts +3 -1
- package/lib/api/kernel-calls/resolve-dto.js +7 -2
- package/lib/api/kernel-calls/settings.d.ts +19 -0
- package/lib/api/kernel-calls/up-axis-aliases.d.ts +25 -0
- package/lib/api/kernel-calls/up-axis-aliases.js +70 -0
- package/lib/api/models/simplex.d.ts +2 -0
- package/lib/api/models/simplex.js +10 -1
- package/lib/api/resolved-inputs/index.d.ts +11 -2
- package/lib/api/services/helpers/curves/conic-arcs.d.ts +3 -1
- package/lib/api/services/helpers/curves/conic-arcs.js +4 -2
- package/lib/api/services/helpers/files/drawing/drawing-budget.js +16 -6
- package/lib/api/services/helpers/files/drawing/drawing-dimension.constants.d.ts +14 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.constants.js +14 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.d.ts +4 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.js +271 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +3 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.js +28 -11
- package/lib/api/services/helpers/files/drawing/drawing-hatch.d.ts +10 -0
- package/lib/api/services/helpers/files/drawing/drawing-hatch.js +123 -0
- package/lib/api/services/helpers/files/drawing/drawing-loops.d.ts +3 -0
- package/lib/api/services/helpers/files/drawing/drawing-loops.js +91 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +6 -1
- package/lib/api/services/helpers/files/drawing/drawing-model.js +97 -13
- package/lib/api/services/helpers/files/drawing/drawing-scale.d.ts +2 -0
- package/lib/api/services/helpers/files/drawing/drawing-scale.js +47 -0
- package/lib/api/services/helpers/files/drawing/drawing-text.d.ts +9 -0
- package/lib/api/services/helpers/files/drawing/drawing-text.js +25 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +57 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +13 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.js +17 -0
- package/lib/api/services/helpers/files/dxf/dxf-annotations.d.ts +5 -0
- package/lib/api/services/helpers/files/dxf/dxf-annotations.js +96 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.d.ts +5 -1
- package/lib/api/services/helpers/files/dxf/dxf-entities.js +5 -2
- package/lib/api/services/helpers/files/dxf/dxf-generator.js +26 -10
- package/lib/api/services/helpers/files/dxf/dxf-reader-annotations.d.ts +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-annotations.js +312 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +37 -3
- package/lib/api/services/helpers/files/dxf/dxf-reader-segments.d.ts +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-segments.js +151 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-types.d.ts +27 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.d.ts +63 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +17 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +1 -1
- package/lib/api/services/helpers/files/dxf/dxf-reader.js +71 -181
- package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +2 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.js +5 -4
- package/lib/api/services/helpers/files/dxf/dxf-tokens.d.ts +2 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.js +25 -1
- package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +11 -0
- package/lib/api/services/helpers/files/dxf/dxf.constants.js +13 -0
- package/lib/api/services/helpers/files/svg/svg-strokes.d.ts +1 -1
- package/lib/api/services/helpers/files/svg/svg-strokes.js +47 -23
- package/lib/api/services/helpers/files/svg/svg-writer.d.ts +2 -0
- package/lib/api/services/helpers/files/svg/svg-writer.js +100 -23
- package/lib/api/services/helpers/files/svg/svg.constants.d.ts +2 -1
- package/lib/api/services/helpers/files/svg/svg.constants.js +2 -1
- package/lib/api/services/helpers/geometry/loop-fill.d.ts +2 -0
- package/lib/api/services/helpers/geometry/loop-fill.js +37 -0
- package/lib/api/services/helpers/helper-types.d.ts +33 -0
- package/lib/api/services/helpers/text/stroke-font.d.ts +6 -0
- package/lib/api/services/helpers/text/stroke-font.js +177 -0
- package/lib/api/services/helpers/text/stroke-letters.constants.d.ts +2 -0
- package/lib/api/services/helpers/text/stroke-letters.constants.js +18 -0
- package/lib/api/services/helpers/text/stroke-marks.constants.d.ts +14 -0
- package/lib/api/services/helpers/text/stroke-marks.constants.js +34 -0
- package/lib/api/services/io/drawing.d.ts +198 -0
- package/lib/api/services/io/drawing.js +242 -0
- package/lib/api/services/io/dxf.d.ts +3 -3
- package/lib/api/services/io/dxf.js +4 -4
- package/lib/api/services/io/svg.d.ts +13 -11
- package/lib/api/services/io/svg.js +15 -12
- package/lib/api/services/mesh.d.ts +19 -0
- package/lib/api/services/mesh.js +40 -0
- package/lib/api/services/recipes.js +3 -2
- package/lib/api/services/text.d.ts +3 -3
- package/lib/api/services/text.js +7 -25
- package/package.json +1 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { STROKE_LETTERS } from "./stroke-letters.constants";
|
|
2
|
+
import { BASELINE_REACH, FIRST_COMPOSED, FULL_MARK_ADVANCE, LAST_UNIT, LEAST_RISE_SHARE, MARK_GAP, MARK_RISE, MOST_UNITS, OGONEK, SOFT_DOTTED, SOFT_DOT_FLOOR, STROKE_MARKS, UNKNOWN_GLYPH } from "./stroke-marks.constants";
|
|
3
|
+
const HALF = 2;
|
|
4
|
+
const facts = new WeakMap();
|
|
5
|
+
function strokesOf(points) {
|
|
6
|
+
const strokes = [];
|
|
7
|
+
let stroke = [];
|
|
8
|
+
let at = 0;
|
|
9
|
+
while (at < points.length) {
|
|
10
|
+
const x = points[at];
|
|
11
|
+
if (x === undefined) {
|
|
12
|
+
strokes.push(stroke);
|
|
13
|
+
stroke = [];
|
|
14
|
+
at += 1;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
stroke.push([x, points[at + 1]]);
|
|
18
|
+
at += 2;
|
|
19
|
+
}
|
|
20
|
+
if (stroke.length > 0) {
|
|
21
|
+
strokes.push(stroke);
|
|
22
|
+
}
|
|
23
|
+
return strokes;
|
|
24
|
+
}
|
|
25
|
+
function readGlyph(font, code) {
|
|
26
|
+
const [advance = 0, ...points] = font[code];
|
|
27
|
+
return { advance, strokes: strokesOf(points) };
|
|
28
|
+
}
|
|
29
|
+
function factsOf(font) {
|
|
30
|
+
const known = facts.get(font);
|
|
31
|
+
if (known !== undefined) {
|
|
32
|
+
return known;
|
|
33
|
+
}
|
|
34
|
+
let highest = -Infinity;
|
|
35
|
+
let lowest = Infinity;
|
|
36
|
+
for (const key of Object.keys(font)) {
|
|
37
|
+
const code = Number(key);
|
|
38
|
+
if (!Number.isInteger(code)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
for (const stroke of readGlyph(font, code).strokes) {
|
|
42
|
+
for (const point of stroke) {
|
|
43
|
+
highest = Math.max(highest, point[1]);
|
|
44
|
+
lowest = Math.min(lowest, point[1]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const read = { lowest, highest, glyphs: new Map() };
|
|
49
|
+
facts.set(font, read);
|
|
50
|
+
return read;
|
|
51
|
+
}
|
|
52
|
+
function compositionOf(font, code) {
|
|
53
|
+
if (!Number.isInteger(code) || code < FIRST_COMPOSED || code > LAST_UNIT) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const units = String.fromCharCode(code).normalize("NFD");
|
|
57
|
+
if (units.length < 2 || units.length > MOST_UNITS) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const base = units.charCodeAt(0);
|
|
61
|
+
if (font[base] === undefined) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
let above;
|
|
65
|
+
let below;
|
|
66
|
+
for (let at = 1; at < units.length; at += 1) {
|
|
67
|
+
const mark = units.charCodeAt(at);
|
|
68
|
+
if (above === undefined && STROKE_MARKS.above[mark] !== undefined) {
|
|
69
|
+
above = mark;
|
|
70
|
+
}
|
|
71
|
+
else if (below === undefined && STROKE_MARKS.below[mark] !== undefined) {
|
|
72
|
+
below = mark;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { base, above, below };
|
|
79
|
+
}
|
|
80
|
+
function placed(mark, x, y, wide, tall) {
|
|
81
|
+
return strokesOf(mark).map(stroke => stroke.map((point) => [x + point[0] * wide, y + point[1] * tall]));
|
|
82
|
+
}
|
|
83
|
+
function middleOf(points) {
|
|
84
|
+
let least = Infinity;
|
|
85
|
+
let most = -Infinity;
|
|
86
|
+
for (const point of points) {
|
|
87
|
+
least = Math.min(least, point[0]);
|
|
88
|
+
most = Math.max(most, point[0]);
|
|
89
|
+
}
|
|
90
|
+
return (least + most) / HALF;
|
|
91
|
+
}
|
|
92
|
+
function composedGlyph(font, composition) {
|
|
93
|
+
const base = readGlyph(font, composition.base);
|
|
94
|
+
const unit = font.height / STROKE_MARKS.height;
|
|
95
|
+
const dotless = composition.above !== undefined && SOFT_DOTTED.has(composition.base);
|
|
96
|
+
const kept = dotless ? base.strokes.filter(stroke => stroke.some(point => point[1] < SOFT_DOT_FLOOR * unit)) : base.strokes;
|
|
97
|
+
const ink = kept.flat();
|
|
98
|
+
if (ink.length === 0) {
|
|
99
|
+
return base;
|
|
100
|
+
}
|
|
101
|
+
const strokes = [...kept];
|
|
102
|
+
if (composition.above !== undefined) {
|
|
103
|
+
const top = ink.reduce((most, point) => Math.max(most, point[1]), -Infinity);
|
|
104
|
+
const floor = top + MARK_GAP * unit;
|
|
105
|
+
const rise = Math.min(1, Math.max(LEAST_RISE_SHARE, (factsOf(font).highest - floor) / (MARK_RISE * unit)));
|
|
106
|
+
const narrow = Math.min(1, base.advance / (FULL_MARK_ADVANCE * unit));
|
|
107
|
+
strokes.push(...placed(STROKE_MARKS.above[composition.above], middleOf(ink), floor, unit * narrow, unit * rise));
|
|
108
|
+
}
|
|
109
|
+
if (composition.below !== undefined) {
|
|
110
|
+
const mark = STROKE_MARKS.below[composition.below];
|
|
111
|
+
const feet = ink.filter(point => Math.abs(point[1]) <= BASELINE_REACH * unit);
|
|
112
|
+
const stood = feet.length > 0 ? feet : ink;
|
|
113
|
+
const x = composition.below === OGONEK ? stood.reduce((most, point) => Math.max(most, point[0]), -Infinity) : middleOf(stood);
|
|
114
|
+
const reach = strokesOf(mark).flat();
|
|
115
|
+
const right = reach.reduce((most, point) => Math.max(most, point[0]), 0) * unit;
|
|
116
|
+
const left = reach.reduce((least, point) => Math.min(least, point[0]), 0) * unit;
|
|
117
|
+
const narrow = Math.min(1, right > 0 ? (base.advance - x) / right : 1, left < 0 ? x / -left : 1);
|
|
118
|
+
strokes.push(...placed(mark, x, 0, unit * narrow, unit));
|
|
119
|
+
}
|
|
120
|
+
return { advance: base.advance, strokes };
|
|
121
|
+
}
|
|
122
|
+
function heldLetter(font, code) {
|
|
123
|
+
const overlay = STROKE_LETTERS.overlaid[code];
|
|
124
|
+
return STROKE_LETTERS.drawn[code] !== undefined || (overlay !== undefined && font[overlay.base] !== undefined);
|
|
125
|
+
}
|
|
126
|
+
function letterGlyph(font, code) {
|
|
127
|
+
const unit = font.height / STROKE_LETTERS.height;
|
|
128
|
+
const { lowest, highest } = factsOf(font);
|
|
129
|
+
const inked = (points) => placed(points, 0, 0, unit, unit)
|
|
130
|
+
.map(stroke => stroke.map((point) => [point[0], Math.min(highest, Math.max(lowest, point[1]))]));
|
|
131
|
+
const drawn = STROKE_LETTERS.drawn[code];
|
|
132
|
+
if (drawn !== undefined) {
|
|
133
|
+
const [advance = 0, ...points] = drawn;
|
|
134
|
+
return { advance: advance * unit, strokes: inked(points) };
|
|
135
|
+
}
|
|
136
|
+
const overlay = STROKE_LETTERS.overlaid[code];
|
|
137
|
+
const base = readGlyph(font, overlay.base);
|
|
138
|
+
return { advance: base.advance, strokes: [...base.strokes, ...inked(overlay.strokes)] };
|
|
139
|
+
}
|
|
140
|
+
export function strokeGlyph(font, code) {
|
|
141
|
+
const glyphs = factsOf(font).glyphs;
|
|
142
|
+
const own = Number.isFinite(code) && code !== 0 && font[code] !== undefined;
|
|
143
|
+
const lettered = !own && heldLetter(font, code);
|
|
144
|
+
const composition = own || lettered ? undefined : compositionOf(font, code);
|
|
145
|
+
const key = own || lettered || composition !== undefined ? code : UNKNOWN_GLYPH;
|
|
146
|
+
const cached = glyphs.get(key);
|
|
147
|
+
if (cached !== undefined) {
|
|
148
|
+
return cached;
|
|
149
|
+
}
|
|
150
|
+
const glyph = lettered ? letterGlyph(font, code) : composition === undefined ? readGlyph(font, key) : composedGlyph(font, composition);
|
|
151
|
+
glyphs.set(key, glyph);
|
|
152
|
+
return glyph;
|
|
153
|
+
}
|
|
154
|
+
export function strokeFontInk(font) {
|
|
155
|
+
const { lowest, highest } = factsOf(font);
|
|
156
|
+
return { lowest: lowest / font.height, highest: highest / font.height };
|
|
157
|
+
}
|
|
158
|
+
export function strokeTextAdvance(font, text) {
|
|
159
|
+
let advance = 0;
|
|
160
|
+
for (let unit = 0; unit < text.length; unit += 1) {
|
|
161
|
+
advance += strokeGlyph(font, text.charCodeAt(unit)).advance;
|
|
162
|
+
}
|
|
163
|
+
return advance / font.height;
|
|
164
|
+
}
|
|
165
|
+
export function strokeTextStrokes(font, text) {
|
|
166
|
+
const strokes = [];
|
|
167
|
+
let left = 0;
|
|
168
|
+
for (let unit = 0; unit < text.length; unit += 1) {
|
|
169
|
+
const glyph = strokeGlyph(font, text.charCodeAt(unit));
|
|
170
|
+
const start = left;
|
|
171
|
+
for (const stroke of glyph.strokes) {
|
|
172
|
+
strokes.push(stroke.map((point) => [(start + point[0]) / font.height, point[1] / font.height]));
|
|
173
|
+
}
|
|
174
|
+
left += glyph.advance;
|
|
175
|
+
}
|
|
176
|
+
return strokes;
|
|
177
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const STROKE_LETTERS = {
|
|
2
|
+
height: 21,
|
|
3
|
+
overlaid: {
|
|
4
|
+
216: { base: 79, strokes: [4, -1, 18, 22] },
|
|
5
|
+
248: { base: 111, strokes: [3, -1, 16, 15] },
|
|
6
|
+
272: { base: 68, strokes: [1, 11, 10, 11] },
|
|
7
|
+
273: { base: 100, strokes: [11, 18, 18, 18] },
|
|
8
|
+
321: { base: 76, strokes: [1, 8, 9, 13] },
|
|
9
|
+
322: { base: 108, strokes: [1, 9, 7, 13] },
|
|
10
|
+
},
|
|
11
|
+
drawn: {
|
|
12
|
+
198: [23, 10, 21, 1, 0, undefined, 10, 21, 10, 0, undefined, 10, 21, 21, 21, undefined, 6, 11, 18, 11, undefined, 10, 0, 21, 0],
|
|
13
|
+
223: [20, 4, 0, 4, 17, 5, 20, 7, 21, 10, 21, 12, 20, 13, 19, 14, 17, 13, 15, 10, 13, 13, 13, 15, 12, 16, 11, 17, 8, 17, 6, 16, 3, 14, 1, 11, 0, 8, 0],
|
|
14
|
+
230: [30, 15, 14, 15, 0, undefined, 15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3, undefined, 15, 8, 27, 8, 27, 10, 26, 12, 25, 13, 23, 14, 20, 14, 18, 13, 16, 11, 15, 8, undefined, 15, 6, 16, 3, 18, 1, 20, 0, 23, 0, 25, 1, 27, 3],
|
|
15
|
+
338: [26, 13, 21, 9, 21, 7, 20, 5, 18, 4, 16, 3, 13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0, 13, 0, undefined, 13, 21, 13, 0, undefined, 13, 21, 24, 21, undefined, 13, 11, 21, 11, undefined, 13, 0, 24, 0],
|
|
16
|
+
339: [31, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3, 16, 6, 16, 8, 15, 11, 13, 13, 11, 14, 8, 14, undefined, 16, 8, 28, 8, 28, 10, 27, 12, 26, 13, 24, 14, 21, 14, 19, 13, 17, 11, 16, 8, undefined, 16, 6, 17, 3, 19, 1, 21, 0, 24, 0, 26, 1, 28, 3],
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StrokeFontMarks } from "../helper-types";
|
|
2
|
+
export declare const UNKNOWN_GLYPH = 63;
|
|
3
|
+
export declare const FIRST_COMPOSED = 128;
|
|
4
|
+
export declare const LAST_UNIT = 65535;
|
|
5
|
+
export declare const MOST_UNITS = 3;
|
|
6
|
+
export declare const SOFT_DOTTED: ReadonlySet<number>;
|
|
7
|
+
export declare const SOFT_DOT_FLOOR = 15;
|
|
8
|
+
export declare const MARK_GAP = 1.25;
|
|
9
|
+
export declare const MARK_RISE = 4;
|
|
10
|
+
export declare const LEAST_RISE_SHARE = 0.25;
|
|
11
|
+
export declare const FULL_MARK_ADVANCE = 10;
|
|
12
|
+
export declare const BASELINE_REACH = 1;
|
|
13
|
+
export declare const OGONEK = 808;
|
|
14
|
+
export declare const STROKE_MARKS: StrokeFontMarks;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const UNKNOWN_GLYPH = 63;
|
|
2
|
+
export const FIRST_COMPOSED = 0x80;
|
|
3
|
+
export const LAST_UNIT = 0xFFFF;
|
|
4
|
+
export const MOST_UNITS = 3;
|
|
5
|
+
export const SOFT_DOTTED = new Set([105, 106]);
|
|
6
|
+
export const SOFT_DOT_FLOOR = 15;
|
|
7
|
+
export const MARK_GAP = 1.25;
|
|
8
|
+
export const MARK_RISE = 4;
|
|
9
|
+
export const LEAST_RISE_SHARE = 0.25;
|
|
10
|
+
export const FULL_MARK_ADVANCE = 10;
|
|
11
|
+
export const BASELINE_REACH = 1;
|
|
12
|
+
export const OGONEK = 808;
|
|
13
|
+
export const STROKE_MARKS = {
|
|
14
|
+
height: 21,
|
|
15
|
+
above: {
|
|
16
|
+
768: [-2.5, 4, 1, 0],
|
|
17
|
+
769: [-1, 0, 2.5, 4],
|
|
18
|
+
770: [-3, 0, 0, 4, 3, 0],
|
|
19
|
+
771: [-4, 1, -3, 3, -1.5, 3.5, 1.5, 0.5, 3, 1, 4, 3],
|
|
20
|
+
772: [-3.5, 2, 3.5, 2],
|
|
21
|
+
774: [-3, 4, -2.5, 1.5, -1, 0, 1, 0, 2.5, 1.5, 3, 4],
|
|
22
|
+
775: [0, 3, -1, 2, 0, 1, 1, 2, 0, 3],
|
|
23
|
+
776: [-3, 3, -4, 2, -3, 1, -2, 2, -3, 3, undefined, 3, 3, 2, 2, 3, 1, 4, 2, 3, 3],
|
|
24
|
+
778: [-1, 4, -2, 3, -2, 1, -1, 0, 1, 0, 2, 1, 2, 3, 1, 4, -1, 4],
|
|
25
|
+
779: [-3, 0, -0.5, 4, undefined, 0.5, 0, 3, 4],
|
|
26
|
+
780: [-3, 4, 0, 0, 3, 4],
|
|
27
|
+
},
|
|
28
|
+
below: {
|
|
29
|
+
803: [0, -2, -1, -3, 0, -4, 1, -3, 0, -2],
|
|
30
|
+
806: [0, -2, 0.5, -3.5, -1, -5.5],
|
|
31
|
+
807: [0, 0, 0, -2, 1.5, -2.5, 1.5, -4.5, 0, -5.5, -2, -5],
|
|
32
|
+
808: [0, 0, -2, -2, -2.5, -3.5, -1.5, -5, 0.5, -5.5, 2, -5],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -129,6 +129,204 @@ export declare class Drawing {
|
|
|
129
129
|
* ```
|
|
130
130
|
*/
|
|
131
131
|
part(inputs: Inputs.IO.DrawingPartDto): Inputs.IO.DrawingPartDto;
|
|
132
|
+
/**
|
|
133
|
+
* Scales drawing parts about the origin, returning new parts and leaving the given ones unchanged.
|
|
134
|
+
*
|
|
135
|
+
* Points, radii, axes, text heights, hatch spacings and line weights are multiplied by `factor`;
|
|
136
|
+
* angles, bulges, knots and weights stay. Scale before writing with `io.dxf.dxfCreate` or
|
|
137
|
+
* `io.svg.svgCreate`: their `unit` labels the drawing and never scales it. A factor not above 0
|
|
138
|
+
* throws.
|
|
139
|
+
* @param inputs - The parts and the factor
|
|
140
|
+
* @returns New parts, scaled
|
|
141
|
+
* @group drawing
|
|
142
|
+
* @shortname scale parts
|
|
143
|
+
* @drawable false
|
|
144
|
+
* @beta
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const plate = bitbybit.io.drawing.part({ layer: "cut", paths: [{ segments: [{ center: [0, 0], radius: 25.4 }] }], lineWeight: 0.5 });
|
|
148
|
+
* const inches = bitbybit.io.drawing.scaleParts({ parts: [plate], factor: 1 / 25.4 });
|
|
149
|
+
* const dxf = bitbybit.io.dxf.dxfCreate({ dxfPathsParts: inches, unit: Bit.Inputs.Base.unitOfLengthEnum.inch });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
scaleParts(inputs: Inputs.IO.DrawingScalePartsDto): Inputs.IO.DrawingPartDto[];
|
|
153
|
+
/**
|
|
154
|
+
* Makes a line of text for a drawing part's `texts`, in the single-line stroke font.
|
|
155
|
+
*
|
|
156
|
+
* The text is placed by a point on its baseline; `anchor` says whether that point is its start,
|
|
157
|
+
* middle or end, `rotation` turns it and `widthFactor` narrows or widens its letters.
|
|
158
|
+
* @param inputs - The text, its position and height, its anchor, its angle and its width factor
|
|
159
|
+
* @returns The text
|
|
160
|
+
* @group drawing
|
|
161
|
+
* @shortname text
|
|
162
|
+
* @drawable false
|
|
163
|
+
* @beta
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const title = bitbybit.io.drawing.text({ text: "BRACKET", position: [20, 10], height: 5 });
|
|
167
|
+
* const notes = bitbybit.io.drawing.part({ layer: "text", paths: [], texts: [title], lineWeight: 0.35 });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
text(inputs: Inputs.IO.DrawingTextDto): Inputs.IO.DrawingTextDto;
|
|
171
|
+
/**
|
|
172
|
+
* Makes a hatched region for a drawing part's `hatches`: what the boundaries enclose, filled with
|
|
173
|
+
* a pattern of lines or with solid ink.
|
|
174
|
+
*
|
|
175
|
+
* A boundary inside another cuts a hole, and a boundary whose ends do not meet is closed by a
|
|
176
|
+
* straight line.
|
|
177
|
+
* @param inputs - The boundary paths, the pattern, and the angle and spacing of its lines
|
|
178
|
+
* @returns The hatch
|
|
179
|
+
* @group drawing
|
|
180
|
+
* @shortname hatch
|
|
181
|
+
* @drawable false
|
|
182
|
+
* @beta
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
186
|
+
* const bore = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
187
|
+
* const cut = bitbybit.io.drawing.hatch({ boundaries: [{ segments: [outline] }, { segments: [bore] }], angle: 45, spacing: 3 });
|
|
188
|
+
* const section = bitbybit.io.drawing.part({ layer: "hatch", paths: [], hatches: [cut], lineWeight: 0.18 });
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
hatch(inputs: Inputs.IO.DrawingHatchDto): Inputs.IO.DrawingHatchDto;
|
|
192
|
+
/**
|
|
193
|
+
* Gives the lines of a hatch's pattern, each from side to side of the box around its
|
|
194
|
+
* boundaries, for a renderer that draws them itself and clips them to the region.
|
|
195
|
+
*
|
|
196
|
+
* The lines stand where `io.svg.svgCreate` and `io.dxf.dxfCreate` put them, each whole. `solid`
|
|
197
|
+
* gives none, and a spacing too fine for the region throws.
|
|
198
|
+
* @param inputs - The boundary paths, the pattern, and the angle and spacing of its lines
|
|
199
|
+
* @returns The lines, each a start and an end point
|
|
200
|
+
* @group drawing
|
|
201
|
+
* @shortname hatch lines
|
|
202
|
+
* @drawable false
|
|
203
|
+
* @beta
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
207
|
+
* const lines = bitbybit.io.drawing.hatchLines({ boundaries: [{ segments: [outline] }], angle: 45, spacing: 3 });
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
hatchLines(inputs: Inputs.IO.DrawingHatchDto): Inputs.Base.Segment2[];
|
|
211
|
+
/**
|
|
212
|
+
* Gives the lines of a hatch's pattern clipped to its region, for a renderer that draws them
|
|
213
|
+
* itself.
|
|
214
|
+
*
|
|
215
|
+
* Inside follows the even-odd rule over every boundary, as `io.svg.svgCreate` fills a hatch, and
|
|
216
|
+
* curves are followed within `tolerance`. The lines stand where `hatchLines` puts them. `solid`
|
|
217
|
+
* gives none; a spacing too fine for the region throws.
|
|
218
|
+
* @param inputs - The boundary paths, the pattern, the angle and spacing of its lines, and the tolerance for curves
|
|
219
|
+
* @returns The pieces of the lines inside the region, each a start and an end point
|
|
220
|
+
* @group drawing
|
|
221
|
+
* @shortname clipped hatch lines
|
|
222
|
+
* @drawable false
|
|
223
|
+
* @beta
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
227
|
+
* const bore = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
228
|
+
* const lines = bitbybit.io.drawing.clippedHatchLines({ boundaries: [{ segments: [outline] }, { segments: [bore] }], angle: 45, spacing: 3, tolerance: 0.01 });
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
clippedHatchLines(inputs: Inputs.IO.DrawingHatchRegionDto): Inputs.Base.Segment2[];
|
|
232
|
+
/**
|
|
233
|
+
* Gives the outlines of a hatch's region as closed loops of points, curves followed within
|
|
234
|
+
* `tolerance`, for a renderer that fills the region itself.
|
|
235
|
+
*
|
|
236
|
+
* Each loop lists every corner once. Fill them under the even-odd rule, as
|
|
237
|
+
* `mesh.triangulateLoops` does, to keep the holes open.
|
|
238
|
+
* Example: a circle of radius 5 at tolerance 0.01 -> one loop of 50 points
|
|
239
|
+
* @param inputs - The boundary paths and the tolerance for curves; the pattern, angle and spacing play no part
|
|
240
|
+
* @returns The loops, each a list of points
|
|
241
|
+
* @group drawing
|
|
242
|
+
* @shortname hatch outlines
|
|
243
|
+
* @drawable false
|
|
244
|
+
* @beta
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
248
|
+
* const bore = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
249
|
+
* const loops = bitbybit.io.drawing.hatchOutlines({ boundaries: [{ segments: [outline] }, { segments: [bore] }], tolerance: 0.01 });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
hatchOutlines(inputs: Inputs.IO.DrawingHatchRegionDto): Inputs.Base.Point2[][];
|
|
253
|
+
/**
|
|
254
|
+
* Measures a drawing text: its length along the baseline, and how far the font's ink reaches
|
|
255
|
+
* above and below it.
|
|
256
|
+
*
|
|
257
|
+
* The width is what `io.svg.svgCreate` draws and `io.dxf.dxfCreate` fits the text to; the
|
|
258
|
+
* position is not needed to measure it. A text that is not one line throws.
|
|
259
|
+
* Example: 'I' at height 21 -> width 8, above 25, below 7
|
|
260
|
+
* @param inputs - The text with its height and width factor
|
|
261
|
+
* @returns The width, and the reach of the font's ink above and below the baseline
|
|
262
|
+
* @group drawing
|
|
263
|
+
* @shortname text size
|
|
264
|
+
* @drawable false
|
|
265
|
+
* @beta
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* const size = bitbybit.io.drawing.textSize({ text: "SECTION A-A", position: [0, 0], height: 3.5 });
|
|
269
|
+
* const cellWidth = size.width + 2;
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
textSize(inputs: Inputs.IO.DrawingTextDto): Inputs.IO.DrawingTextSizeDto;
|
|
273
|
+
/**
|
|
274
|
+
* Draws a drawing text as the strokes of its letters, each a list of points in the drawing's
|
|
275
|
+
* coordinates, placed, turned and narrowed as the text says.
|
|
276
|
+
*
|
|
277
|
+
* These are the strokes `io.svg.svgCreate` writes. A text that is not one line throws.
|
|
278
|
+
* Example: 'I' at height 21 from [10, 20] -> one stroke, [[14, 41, 0], [14, 20, 0]]
|
|
279
|
+
* @param inputs - The text, its position and height, its anchor, its angle and its width factor
|
|
280
|
+
* @returns The strokes, each a list of points
|
|
281
|
+
* @group drawing
|
|
282
|
+
* @shortname text strokes
|
|
283
|
+
* @drawable false
|
|
284
|
+
* @beta
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* const strokes = bitbybit.io.drawing.textStrokes({ text: "A-A", position: [0, 0], height: 5, anchor: "middle" });
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
textStrokes(inputs: Inputs.IO.DrawingTextDto): Inputs.Base.Point3[][];
|
|
291
|
+
/**
|
|
292
|
+
* Draws a dimension in the drawing's plane: its dimension line or arc, its extension lines, filled
|
|
293
|
+
* arrowheads touching them, and its value in the stroke font.
|
|
294
|
+
*
|
|
295
|
+
* The text reads from left to right or from bottom to top, past the line's end when the line is
|
|
296
|
+
* too short for it; arrows go outside a span too short for them.
|
|
297
|
+
* @param inputs - What the dimension measures, its points, its tolerance and the size of its text and arrows
|
|
298
|
+
* @returns The lines, the arrowheads to fill, the text as strokes and as a drawing text, and the box they fill
|
|
299
|
+
* @group drawing
|
|
300
|
+
* @shortname dimension picture
|
|
301
|
+
* @drawable false
|
|
302
|
+
* @beta
|
|
303
|
+
* @example
|
|
304
|
+
* ```typescript
|
|
305
|
+
* const picture = bitbybit.io.drawing.dimensionPicture({ kind: Bit.Inputs.IO.dimensionKindEnum.linear, start: [0, 0], end: [60, 0], offset: 12, upperTolerance: 0.1, lowerTolerance: 0.1 });
|
|
306
|
+
* const edges = bitbybit.io.drawing.part({ layer: "dimensions", paths: [...picture.lines, ...picture.textStrokes].map(points => ({ segments: [{ points }] })) });
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
dimensionPicture(inputs: Inputs.IO.DrawingDimensionDto): Inputs.IO.DrawingDimensionPictureDto;
|
|
310
|
+
/**
|
|
311
|
+
* Measures the box a dimension's picture fills, the box `dimensionPicture` gives, without drawing
|
|
312
|
+
* the letters.
|
|
313
|
+
*
|
|
314
|
+
* The box holds the whole height the stroke font's letters may reach, so a layout can make room
|
|
315
|
+
* before drawing.
|
|
316
|
+
* Example: a linear dimension from [0, 0] to [60, 0] at offset 12 -> min [0, 0.875], max [60, 17.04]
|
|
317
|
+
* @param inputs - What the dimension measures, its points, its tolerance and the size of its text and arrows
|
|
318
|
+
* @returns The lowest and highest corners of the box
|
|
319
|
+
* @group drawing
|
|
320
|
+
* @shortname dimension extent
|
|
321
|
+
* @drawable false
|
|
322
|
+
* @beta
|
|
323
|
+
* @example
|
|
324
|
+
* ```typescript
|
|
325
|
+
* const box = bitbybit.io.drawing.dimensionExtent({ kind: Bit.Inputs.IO.dimensionKindEnum.diameter, start: [0, 0], end: [5, 0] });
|
|
326
|
+
* const width = box.max[0] - box.min[0];
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
dimensionExtent(inputs: Inputs.IO.DrawingDimensionDto): Inputs.IO.DrawingExtentDto;
|
|
132
330
|
/**
|
|
133
331
|
* Converts an SVG file into a DXF file, reading it as `io.svg.svgRead` does and writing it as
|
|
134
332
|
* `io.dxf.dxfCreate` does.
|