1 | // Type definitions for Maker.js 0.14.0
|
2 | // Project: https://github.com/Microsoft/maker.js
|
3 | // Definitions by: Dan Marshall <https://github.com/danmarshall>
|
4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
5 |
|
6 | /// <reference types="@danmarshall/jscad-typings" />
|
7 | /// <reference types="opentype.js" />
|
8 | /// <reference types="pdfkit" />
|
9 | /// <reference types="bezier-js" />
|
10 | /**
|
11 | * Schema objects for Maker.js.
|
12 | *
|
13 | */
|
14 | declare namespace MakerJs {
|
15 | /**
|
16 | * An x-y point in a two-dimensional space.
|
17 | * Implemented as an array with 2 elements. The first element is x, the second element is y.
|
18 | *
|
19 | * Examples:
|
20 | * ```
|
21 | * var p: IPoint = [0, 0]; //typescript
|
22 | * var p = [0, 0]; //javascript
|
23 | * ```
|
24 | */
|
25 | interface IPoint {
|
26 | [index: number]: number;
|
27 | }
|
28 | /**
|
29 | * A line, curved line or other simple two dimensional shape.
|
30 | */
|
31 | interface IPath {
|
32 | /**
|
33 | * The type of the path, e.g. "line", "circle", or "arc". These strings are enumerated in pathType.
|
34 | */
|
35 | "type": string;
|
36 | /**
|
37 | * The main point of reference for this path.
|
38 | */
|
39 | origin: IPoint;
|
40 | /**
|
41 | * Optional layer of this path.
|
42 | */
|
43 | layer?: string;
|
44 | }
|
45 | /**
|
46 | * A line path.
|
47 | *
|
48 | * Examples:
|
49 | * ```
|
50 | * var line: IPathLine = { type: 'line', origin: [0, 0], end: [1, 1] }; //typescript
|
51 | * var line = { type: 'line', origin: [0, 0], end: [1, 1] }; //javascript
|
52 | * ```
|
53 | */
|
54 | interface IPathLine extends IPath {
|
55 | /**
|
56 | * The end point defining the line. The start point is the origin.
|
57 | */
|
58 | end: IPoint;
|
59 | }
|
60 | /**
|
61 | * A circle path.
|
62 | *
|
63 | * Examples:
|
64 | * ```
|
65 | * var circle: IPathCircle = { type: 'circle', origin: [0, 0], radius: 7 }; //typescript
|
66 | * var circle = { type: 'circle', origin: [0, 0], radius: 7 }; //javascript
|
67 | * ```
|
68 | */
|
69 | interface IPathCircle extends IPath {
|
70 | /**
|
71 | * The radius of the circle.
|
72 | */
|
73 | radius: number;
|
74 | }
|
75 | /**
|
76 | * An arc path.
|
77 | *
|
78 | * Examples:
|
79 | * ```
|
80 | * var arc: IPathArc = { type: 'arc', origin: [0, 0], radius: 7, startAngle: 0, endAngle: 45 }; //typescript
|
81 | * var arc = { type: 'arc', origin: [0, 0], radius: 7, startAngle: 0, endAngle: 45 }; //javascript
|
82 | * ```
|
83 | */
|
84 | interface IPathArc extends IPathCircle {
|
85 | /**
|
86 | * The angle (in degrees) to begin drawing the arc, in polar (counter-clockwise) direction.
|
87 | */
|
88 | startAngle: number;
|
89 | /**
|
90 | * The angle (in degrees) to end drawing the arc, in polar (counter-clockwise) direction. May be less than start angle if it past 360.
|
91 | */
|
92 | endAngle: number;
|
93 | }
|
94 | /**
|
95 | * A bezier seed defines the endpoints and control points of a bezier curve.
|
96 | */
|
97 | interface IPathBezierSeed extends IPathLine {
|
98 | /**
|
99 | * The bezier control points. One point for quadratic, 2 points for cubic.
|
100 | */
|
101 | controls: IPoint[];
|
102 | /**
|
103 | * T values of the parent if this is a child that represents a split.
|
104 | */
|
105 | parentRange?: IBezierRange;
|
106 | }
|
107 | /**
|
108 | * Bezier t values for an arc path segment in a bezier curve.
|
109 | */
|
110 | interface IBezierRange {
|
111 | /**
|
112 | * The bezier t-value at the starting point.
|
113 | */
|
114 | startT: number;
|
115 | /**
|
116 | * The bezier t-value at the end point.
|
117 | */
|
118 | endT: number;
|
119 | }
|
120 | /**
|
121 | * An arc path segment in a bezier curve.
|
122 | */
|
123 | interface IPathArcInBezierCurve extends IPath {
|
124 | bezierData: IBezierRange;
|
125 | }
|
126 | /**
|
127 | * Text annotation, diplayable natively to the output format.
|
128 | */
|
129 | interface ICaption {
|
130 | /**
|
131 | * Caption text.
|
132 | */
|
133 | text: string;
|
134 | /**
|
135 | * Invisible line to which the text is aligned.
|
136 | * The text will be horizontally and vertically centered on the center point of this line.
|
137 | * The text may be longer or shorter than the line, it is used only for position and angle.
|
138 | * The anchor line's endpoints may be omitted, in which the case the text will always remain non-angled, even if the model is rotated.
|
139 | */
|
140 | anchor: IPathLine;
|
141 | }
|
142 | /**
|
143 | * Path objects by id.
|
144 | */
|
145 | interface IPathMap {
|
146 | [id: string]: IPath | IPathArc | IPathCircle | IPathLine;
|
147 | }
|
148 | /**
|
149 | * Model objects by id.
|
150 | */
|
151 | interface IModelMap {
|
152 | [id: string]: IModel;
|
153 | }
|
154 | /**
|
155 | * A model is a composite object which may contain a map of paths, or a map of models recursively.
|
156 | *
|
157 | * Example:
|
158 | * ```
|
159 | * var m = {
|
160 | * paths: {
|
161 | * "line1": { type: 'line', origin: [0, 0], end: [1, 1] },
|
162 | * "line2": { type: 'line', origin: [0, 0], end: [-1, -1] }
|
163 | * }
|
164 | * };
|
165 | * ```
|
166 | */
|
167 | interface IModel {
|
168 | /**
|
169 | * Optional origin location of this model.
|
170 | */
|
171 | origin?: IPoint;
|
172 | /**
|
173 | * A model may want to specify its type, but this value is not employed yet.
|
174 | */
|
175 | "type"?: string;
|
176 | /**
|
177 | * Optional map of path objects in this model.
|
178 | */
|
179 | paths?: IPathMap;
|
180 | /**
|
181 | * Optional map of models within this model.
|
182 | */
|
183 | models?: IModelMap;
|
184 | /**
|
185 | * Optional unit system of this model. See UnitType for possible values.
|
186 | */
|
187 | units?: string;
|
188 | /**
|
189 | * An author may wish to add notes to this model instance.
|
190 | */
|
191 | notes?: string;
|
192 | /**
|
193 | * Optional layer of this model.
|
194 | */
|
195 | layer?: string;
|
196 | /**
|
197 | * Optional Caption object.
|
198 | */
|
199 | caption?: ICaption;
|
200 | /**
|
201 | * Optional exporter options for this model.
|
202 | */
|
203 | exporterOptions?: {
|
204 | [exporterName: string]: any;
|
205 | };
|
206 | }
|
207 | }
|
208 | /**
|
209 | * Root module for Maker.js.
|
210 | *
|
211 | * Example: get a reference to Maker.js
|
212 | * ```
|
213 | * var makerjs = require('makerjs');
|
214 | * ```
|
215 | *
|
216 | */
|
217 | declare namespace MakerJs {
|
218 | /**
|
219 | * Version info
|
220 | */
|
221 | var version: string;
|
222 | /**
|
223 | * Enumeration of environment types.
|
224 | */
|
225 | var environmentTypes: {
|
226 | BrowserUI: string;
|
227 | NodeJs: string;
|
228 | WebWorker: string;
|
229 | Unknown: string;
|
230 | };
|
231 | /**
|
232 | * Current execution environment type, should be one of environmentTypes.
|
233 | */
|
234 | var environment: string;
|
235 | /**
|
236 | * String-based enumeration of unit types: imperial, metric or otherwise.
|
237 | * A model may specify the unit system it is using, if any. When importing a model, it may have different units.
|
238 | * Unit conversion function is makerjs.units.conversionScale().
|
239 | * Important: If you add to this, you must also add a corresponding conversion ratio in the unit.ts file!
|
240 | */
|
241 | var unitType: {
|
242 | Centimeter: string;
|
243 | Foot: string;
|
244 | Inch: string;
|
245 | Meter: string;
|
246 | Millimeter: string;
|
247 | };
|
248 | /**
|
249 | * Split a decimal into its whole and fractional parts as strings.
|
250 | *
|
251 | * Example: get whole and fractional parts of 42.056
|
252 | * ```
|
253 | * makerjs.splitDecimal(42.056); //returns ["42", "056"]
|
254 | * ```
|
255 | *
|
256 | * @param n The number to split.
|
257 | * @returns Array of 2 strings when n contains a decimal point, or an array of one string when n is an integer.
|
258 | */
|
259 | function splitDecimal(n: number): string[];
|
260 | /**
|
261 | * Numeric rounding
|
262 | *
|
263 | * Example: round to 3 decimal places
|
264 | * ```
|
265 | * makerjs.round(3.14159, .001); //returns 3.142
|
266 | * ```
|
267 | *
|
268 | * @param n The number to round off.
|
269 | * @param accuracy Optional exemplar of number of decimal places.
|
270 | * @returns Rounded number.
|
271 | */
|
272 | function round(n: number, accuracy?: number): number;
|
273 | /**
|
274 | * Create a string representation of a route array.
|
275 | *
|
276 | * @param route Array of strings which are segments of a route.
|
277 | * @returns String of the flattened array.
|
278 | */
|
279 | function createRouteKey(route: string[]): string;
|
280 | /**
|
281 | * Travel along a route inside of a model to extract a specific node in its tree.
|
282 | *
|
283 | * @param modelContext Model to travel within.
|
284 | * @param route String of a flattened route, or a string array of route segments.
|
285 | * @returns Model or Path object within the modelContext tree.
|
286 | */
|
287 | function travel(modelContext: IModel, route: string | string[]): {
|
288 | result: IPath | IModel;
|
289 | offset: IPoint;
|
290 | };
|
291 | /**
|
292 | * Clone an object.
|
293 | *
|
294 | * @param objectToClone The object to clone.
|
295 | * @returns A new clone of the original object.
|
296 | */
|
297 | function cloneObject<T>(objectToClone: T): T;
|
298 | /**
|
299 | * Copy the properties from one object to another object.
|
300 | *
|
301 | * Example:
|
302 | * ```
|
303 | * makerjs.extendObject({ abc: 123 }, { xyz: 789 }); //returns { abc: 123, xyz: 789 }
|
304 | * ```
|
305 | *
|
306 | * @param target The object to extend. It will receive the new properties.
|
307 | * @param other An object containing properties to merge in.
|
308 | * @returns The original object after merging.
|
309 | */
|
310 | function extendObject(target: Object, other: Object): Object;
|
311 | /**
|
312 | * Test to see if a variable is a function.
|
313 | *
|
314 | * @param value The object to test.
|
315 | * @returns True if the object is a function type.
|
316 | */
|
317 | function isFunction(value: any): boolean;
|
318 | /**
|
319 | * Test to see if a variable is a number.
|
320 | *
|
321 | * @param value The object to test.
|
322 | * @returns True if the object is a number type.
|
323 | */
|
324 | function isNumber(value: any): boolean;
|
325 | /**
|
326 | * Test to see if a variable is an object.
|
327 | *
|
328 | * @param value The object to test.
|
329 | * @returns True if the object is an object type.
|
330 | */
|
331 | function isObject(value: any): boolean;
|
332 | /**
|
333 | * Test to see if an object implements the required properties of a point.
|
334 | *
|
335 | * @param item The item to test.
|
336 | */
|
337 | function isPoint(item: any): boolean;
|
338 | /**
|
339 | * A measurement of extents, the high and low points.
|
340 | */
|
341 | interface IMeasure {
|
342 | /**
|
343 | * The point containing both the lowest x and y values of the rectangle containing the item being measured.
|
344 | */
|
345 | low: IPoint;
|
346 | /**
|
347 | * The point containing both the highest x and y values of the rectangle containing the item being measured.
|
348 | */
|
349 | high: IPoint;
|
350 | }
|
351 | /**
|
352 | * A measurement of extents, with a center point.
|
353 | */
|
354 | interface IMeasureWithCenter extends IMeasure {
|
355 | /**
|
356 | * The center point of the rectangle containing the item being measured.
|
357 | */
|
358 | center: IPoint;
|
359 | /**
|
360 | * The width of the rectangle containing the item being measured.
|
361 | */
|
362 | width: number;
|
363 | /**
|
364 | * The height of the rectangle containing the item being measured.
|
365 | */
|
366 | height: number;
|
367 | }
|
368 | /**
|
369 | * A map of measurements.
|
370 | */
|
371 | interface IMeasureMap {
|
372 | [key: string]: IMeasure;
|
373 | }
|
374 | /**
|
375 | * A path that was removed in a combine operation.
|
376 | */
|
377 | interface IPathRemoved extends IPath {
|
378 | /**
|
379 | * Reason the path was removed.
|
380 | */
|
381 | reason: string;
|
382 | /**
|
383 | * Original routekey of the path, to identify where it came from.
|
384 | */
|
385 | routeKey: string;
|
386 | }
|
387 | /**
|
388 | * Options to pass to measure.isPointInsideModel().
|
389 | */
|
390 | interface IMeasurePointInsideOptions {
|
391 | /**
|
392 | * Optional point of reference which is outside the bounds of the modelContext.
|
393 | */
|
394 | farPoint?: IPoint;
|
395 | /**
|
396 | * Optional atlas of measurements of paths within the model (to prevent intersection calculations).
|
397 | */
|
398 | measureAtlas?: measure.Atlas;
|
399 | /**
|
400 | * Output variable which will contain an array of points where the ray intersected the model. The ray is a line from pointToCheck to options.farPoint.
|
401 | */
|
402 | out_intersectionPoints?: IPoint[];
|
403 | }
|
404 | /**
|
405 | * Test to see if an object implements the required properties of a path.
|
406 | *
|
407 | * @param item The item to test.
|
408 | */
|
409 | function isPath(item: any): boolean;
|
410 | /**
|
411 | * Test to see if an object implements the required properties of a line.
|
412 | *
|
413 | * @param item The item to test.
|
414 | */
|
415 | function isPathLine(item: any): boolean;
|
416 | /**
|
417 | * Test to see if an object implements the required properties of a circle.
|
418 | *
|
419 | * @param item The item to test.
|
420 | */
|
421 | function isPathCircle(item: any): boolean;
|
422 | /**
|
423 | * Test to see if an object implements the required properties of an arc.
|
424 | *
|
425 | * @param item The item to test.
|
426 | */
|
427 | function isPathArc(item: any): boolean;
|
428 | /**
|
429 | * Test to see if an object implements the required properties of an arc in a bezier curve.
|
430 | *
|
431 | * @param item The item to test.
|
432 | */
|
433 | function isPathArcInBezierCurve(item: any): boolean;
|
434 | /**
|
435 | * String-based enumeration of all paths types.
|
436 | *
|
437 | * Examples: use pathType instead of string literal when creating a circle.
|
438 | * ```
|
439 | * var circle: IPathCircle = { type: pathType.Circle, origin: [0, 0], radius: 7 }; //typescript
|
440 | * var circle = { type: pathType.Circle, origin: [0, 0], radius: 7 }; //javascript
|
441 | * ```
|
442 | */
|
443 | var pathType: {
|
444 | Line: string;
|
445 | Circle: string;
|
446 | Arc: string;
|
447 | BezierSeed: string;
|
448 | };
|
449 | /**
|
450 | * Slope and y-intercept of a line.
|
451 | */
|
452 | interface ISlope {
|
453 | /**
|
454 | * Boolean to see if line has slope or is vertical.
|
455 | */
|
456 | hasSlope: boolean;
|
457 | /**
|
458 | * Optional value of non-vertical slope.
|
459 | */
|
460 | slope?: number;
|
461 | /**
|
462 | * Line used to calculate this slope.
|
463 | */
|
464 | line: IPathLine;
|
465 | /**
|
466 | * Optional value of y when x = 0.
|
467 | */
|
468 | yIntercept?: number;
|
469 | }
|
470 | /**
|
471 | * Options to pass to path.intersection()
|
472 | */
|
473 | interface IPathIntersectionBaseOptions {
|
474 | /**
|
475 | * Optional boolean to only return deep intersections, i.e. not on an end point or tangent.
|
476 | */
|
477 | excludeTangents?: boolean;
|
478 | /**
|
479 | * Optional output variable which will be set to true if the paths are overlapped.
|
480 | */
|
481 | out_AreOverlapped?: boolean;
|
482 | }
|
483 | /**
|
484 | * Options to pass to path.intersection()
|
485 | */
|
486 | interface IPathIntersectionOptions extends IPathIntersectionBaseOptions {
|
487 | /**
|
488 | * Optional boolean to only return deep intersections, i.e. not on an end point or tangent.
|
489 | */
|
490 | path1Offset?: IPoint;
|
491 | /**
|
492 | * Optional output variable which will be set to true if the paths are overlapped.
|
493 | */
|
494 | path2Offset?: IPoint;
|
495 | }
|
496 | /**
|
497 | * An intersection of two paths.
|
498 | */
|
499 | interface IPathIntersection {
|
500 | /**
|
501 | * Array of points where the two paths intersected. The length of the array may be either 1 or 2 points.
|
502 | */
|
503 | intersectionPoints: IPoint[];
|
504 | /**
|
505 | * This Array property will only be defined if the first parameter passed to pathIntersection is either an Arc or a Circle.
|
506 | * It contains the angles of intersection relative to the first path parameter.
|
507 | * The length of the array may be either 1 or 2.
|
508 | */
|
509 | path1Angles?: number[];
|
510 | /**
|
511 | * This Array property will only be defined if the second parameter passed to pathIntersection is either an Arc or a Circle.
|
512 | * It contains the angles of intersection relative to the second path parameter.
|
513 | * The length of the array may be either 1 or 2.
|
514 | */
|
515 | path2Angles?: number[];
|
516 | }
|
517 | /**
|
518 | * Options when matching points
|
519 | */
|
520 | interface IPointMatchOptions {
|
521 | /**
|
522 | * Max distance to consider two points as the same.
|
523 | */
|
524 | pointMatchingDistance?: number;
|
525 | }
|
526 | /**
|
527 | * Options to pass to model.combine.
|
528 | */
|
529 | interface ICombineOptions extends IPointMatchOptions {
|
530 | /**
|
531 | * Flag to remove paths which are not part of a loop.
|
532 | */
|
533 | trimDeadEnds?: boolean;
|
534 | /**
|
535 | * Point which is known to be outside of the model.
|
536 | */
|
537 | farPoint?: IPoint;
|
538 | /**
|
539 | * Cached measurements for model A.
|
540 | */
|
541 | measureA?: measure.Atlas;
|
542 | /**
|
543 | * Cached measurements for model B.
|
544 | */
|
545 | measureB?: measure.Atlas;
|
546 | /**
|
547 | * Output array of 2 models (corresponding to the input models) containing paths that were deleted in the combination.
|
548 | * Each path will be of type IPathRemoved, which has a .reason property describing why it was removed.
|
549 | */
|
550 | out_deleted?: IModel[];
|
551 | }
|
552 | /**
|
553 | * Options to pass to measure.isPointOnPath.
|
554 | */
|
555 | interface IIsPointOnPathOptions {
|
556 | /**
|
557 | * The slope of the line, if applicable. This will be added to the options object if it did not exist.
|
558 | */
|
559 | cachedLineSlope?: ISlope;
|
560 | }
|
561 | /**
|
562 | * Options to pass to model.findLoops.
|
563 | */
|
564 | interface IFindLoopsOptions extends IPointMatchOptions {
|
565 | /**
|
566 | * Flag to remove looped paths from the original model.
|
567 | */
|
568 | removeFromOriginal?: boolean;
|
569 | }
|
570 | /**
|
571 | * Options to pass to model.simplify()
|
572 | */
|
573 | interface ISimplifyOptions extends IPointMatchOptions {
|
574 | /**
|
575 | * Optional
|
576 | */
|
577 | scalarMatchingDistance?: number;
|
578 | }
|
579 | /**
|
580 | * A path that may be indicated to "flow" in either direction between its endpoints.
|
581 | */
|
582 | interface IPathDirectional extends IPath {
|
583 | /**
|
584 | * The endpoints of the path.
|
585 | */
|
586 | endPoints: IPoint[];
|
587 | /**
|
588 | * Path flows forwards or reverse.
|
589 | */
|
590 | reversed?: boolean;
|
591 | }
|
592 | /**
|
593 | * Callback signature for model.walkPaths().
|
594 | */
|
595 | interface IModelPathCallback {
|
596 | (modelContext: IModel, pathId: string, pathContext: IPath): void;
|
597 | }
|
598 | /**
|
599 | * Test to see if an object implements the required properties of a model.
|
600 | */
|
601 | function isModel(item: any): boolean;
|
602 | /**
|
603 | * Reference to a path id within a model.
|
604 | */
|
605 | interface IRefPathIdInModel {
|
606 | modelContext: IModel;
|
607 | pathId: string;
|
608 | }
|
609 | /**
|
610 | * A route to either a path or a model, and the absolute offset of it.
|
611 | */
|
612 | interface IRouteOffset {
|
613 | layer: string;
|
614 | offset: IPoint;
|
615 | route: string[];
|
616 | routeKey: string;
|
617 | }
|
618 | /**
|
619 | * A path reference in a walk.
|
620 | */
|
621 | interface IWalkPath extends IRefPathIdInModel, IRouteOffset {
|
622 | pathContext: IPath;
|
623 | }
|
624 | /**
|
625 | * Callback signature for path in model.walk().
|
626 | */
|
627 | interface IWalkPathCallback {
|
628 | (context: IWalkPath): void;
|
629 | }
|
630 | /**
|
631 | * Callback for returning a boolean from an IWalkPath.
|
632 | */
|
633 | interface IWalkPathBooleanCallback {
|
634 | (context: IWalkPath): boolean;
|
635 | }
|
636 | /**
|
637 | * A link in a chain, with direction of flow.
|
638 | */
|
639 | interface IChainLink {
|
640 | /**
|
641 | * Reference to the path.
|
642 | */
|
643 | walkedPath: IWalkPath;
|
644 | /**
|
645 | * Path flows forwards or reverse.
|
646 | */
|
647 | reversed: boolean;
|
648 | /**
|
649 | * The endpoints of the path, in absolute coords.
|
650 | */
|
651 | endPoints: IPoint[];
|
652 | /**
|
653 | * Length of the path.
|
654 | */
|
655 | pathLength: number;
|
656 | }
|
657 | /**
|
658 | * A chain of paths which connect end to end.
|
659 | */
|
660 | interface IChain {
|
661 | /**
|
662 | * The links in this chain.
|
663 | */
|
664 | links: IChainLink[];
|
665 | /**
|
666 | * Flag if this chain forms a loop end to end.
|
667 | */
|
668 | endless: boolean;
|
669 | /**
|
670 | * Total length of all paths in the chain.
|
671 | */
|
672 | pathLength: number;
|
673 | /**
|
674 | * Chains that are contained within this chain. Populated when chains are found with the 'contain' option
|
675 | */
|
676 | contains?: IChain[];
|
677 | }
|
678 | /**
|
679 | * A map of chains by layer.
|
680 | */
|
681 | interface IChainsMap {
|
682 | [layer: string]: IChain[];
|
683 | }
|
684 | /**
|
685 | * Test to see if an object implements the required properties of a chain.
|
686 | *
|
687 | * @param item The item to test.
|
688 | */
|
689 | function isChain(item: any): boolean;
|
690 | /**
|
691 | * Callback to model.findChains() with resulting array of chains and unchained paths.
|
692 | */
|
693 | interface IChainCallback {
|
694 | (chains: IChain[], loose: IWalkPath[], layer: string, ignored?: IWalkPath[]): void;
|
695 | }
|
696 | /**
|
697 | * Options to pass to model.findChains.
|
698 | */
|
699 | interface IFindChainsOptions extends IPointMatchOptions {
|
700 | /**
|
701 | * Flag to separate chains by layers.
|
702 | */
|
703 | byLayers?: boolean;
|
704 | /**
|
705 | * Flag to not recurse models, look only within current model's immediate paths.
|
706 | */
|
707 | shallow?: boolean;
|
708 | /**
|
709 | * Flag to order chains in a heirarchy by their paths being within one another.
|
710 | */
|
711 | contain?: boolean | IContainChainsOptions;
|
712 | /**
|
713 | * Flag to flatten BezierCurve arc segments into IPathBezierSeeds.
|
714 | */
|
715 | unifyBeziers?: boolean;
|
716 | }
|
717 | /**
|
718 | * Sub-options to pass to model.findChains.contain option.
|
719 | */
|
720 | interface IContainChainsOptions {
|
721 | /**
|
722 | * Flag to alternate direction of contained chains.
|
723 | */
|
724 | alternateDirection?: boolean;
|
725 | }
|
726 | /**
|
727 | * Reference to a model within a model.
|
728 | */
|
729 | interface IRefModelInModel {
|
730 | parentModel: IModel;
|
731 | childId: string;
|
732 | childModel: IModel;
|
733 | }
|
734 | /**
|
735 | * A model reference in a walk.
|
736 | */
|
737 | interface IWalkModel extends IRefModelInModel, IRouteOffset {
|
738 | }
|
739 | /**
|
740 | * Callback signature for model.walk().
|
741 | */
|
742 | interface IWalkModelCallback {
|
743 | (context: IWalkModel): void;
|
744 | }
|
745 | /**
|
746 | * Callback signature for model.walk(), which may return false to halt any further walking.
|
747 | */
|
748 | interface IWalkModelCancellableCallback {
|
749 | (context: IWalkModel): boolean;
|
750 | }
|
751 | /**
|
752 | * Options to pass to model.walk().
|
753 | */
|
754 | interface IWalkOptions {
|
755 | /**
|
756 | * Callback for every path in every model.
|
757 | */
|
758 | onPath?: IWalkPathCallback;
|
759 | /**
|
760 | * Callback for every child model in every model. Return false to stop walking down further models.
|
761 | */
|
762 | beforeChildWalk?: IWalkModelCancellableCallback;
|
763 | /**
|
764 | * Callback for every child model in every model, after all of its children have been walked.
|
765 | */
|
766 | afterChildWalk?: IWalkModelCallback;
|
767 | }
|
768 | /**
|
769 | * A hexagon which surrounds a model.
|
770 | */
|
771 | interface IBoundingHex extends IModel {
|
772 | /**
|
773 | * Radius of the hexagon, which is also the length of a side.
|
774 | */
|
775 | radius: number;
|
776 | }
|
777 | /**
|
778 | * Describes a parameter and its limits.
|
779 | */
|
780 | interface IMetaParameter {
|
781 | /**
|
782 | * Display text of the parameter.
|
783 | */
|
784 | title: string;
|
785 | /**
|
786 | * Type of the parameter. Currently supports "range".
|
787 | */
|
788 | type: string;
|
789 | /**
|
790 | * Optional minimum value of the range.
|
791 | */
|
792 | min?: number;
|
793 | /**
|
794 | * Optional maximum value of the range.
|
795 | */
|
796 | max?: number;
|
797 | /**
|
798 | * Optional step value between min and max.
|
799 | */
|
800 | step?: number;
|
801 | /**
|
802 | * Initial sample value for this parameter.
|
803 | */
|
804 | value: any;
|
805 | }
|
806 | /**
|
807 | * An IKit is a model-producing class with some sample parameters. Think of it as a packaged model with instructions on how to best use it.
|
808 | */
|
809 | interface IKit {
|
810 | /**
|
811 | * The constructor. The kit must be "new-able" and it must produce an IModel.
|
812 | * It can have any number of any type of parameters.
|
813 | */
|
814 | new (...args: any[]): IModel;
|
815 | /**
|
816 | * Attached to the constructor is a property named metaParameters which is an array of IMetaParameter objects.
|
817 | * Each element of the array corresponds to a parameter of the constructor, in order.
|
818 | */
|
819 | metaParameters?: IMetaParameter[];
|
820 | /**
|
821 | * Information about this kit, in plain text or markdown format.
|
822 | */
|
823 | notes?: string;
|
824 | }
|
825 | /**
|
826 | * A container that allows a series of functions to be called upon an object.
|
827 | */
|
828 | interface ICascade {
|
829 | /**
|
830 | * The initial context object of the cascade.
|
831 | */
|
832 | $initial: any;
|
833 | /**
|
834 | * The current final value of the cascade.
|
835 | */
|
836 | $result: any;
|
837 | /**
|
838 | * Use the $original as the $result.
|
839 | */
|
840 | $reset: () => this;
|
841 | }
|
842 | /**
|
843 | * Create a container to cascade a series of functions upon a model. This allows JQuery-style method chaining, e.g.:
|
844 | * ```
|
845 | * makerjs.$(shape).center().rotate(45).$result
|
846 | * ```
|
847 | * The output of each function call becomes the first parameter input to the next function call.
|
848 | * The returned value of the last function call is available via the `.$result` property.
|
849 | *
|
850 | * @param modelContext The initial model to execute functions upon.
|
851 | * @returns A new cascade container with ICascadeModel methods.
|
852 | */
|
853 | function $(modelContext: IModel): ICascadeModel;
|
854 | /**
|
855 | * Create a container to cascade a series of functions upon a path. This allows JQuery-style method chaining, e.g.:
|
856 | * ```
|
857 | * makerjs.$(path).center().rotate(90).$result
|
858 | * ```
|
859 | * The output of each function call becomes the first parameter input to the next function call.
|
860 | * The returned value of the last function call is available via the `.$result` property.
|
861 | *
|
862 | * @param pathContext The initial path to execute functions upon.
|
863 | * @returns A new cascade container with ICascadePath methods.
|
864 | */
|
865 | function $(pathContext: IModel): ICascadePath;
|
866 | /**
|
867 | * Create a container to cascade a series of functions upon a point. This allows JQuery-style method chaining, e.g.:
|
868 | * ```
|
869 | * makerjs.$([1,0]).scale(5).rotate(60).$result
|
870 | * ```
|
871 | * The output of each function call becomes the first parameter input to the next function call.
|
872 | * The returned value of the last function call is available via the `.$result` property.
|
873 | *
|
874 | * @param pointContext The initial point to execute functions upon.
|
875 | * @returns A new cascade container with ICascadePoint methods.
|
876 | */
|
877 | function $(pointContext: IPoint): ICascadePoint;
|
878 | }
|
879 | declare module "makerjs" {
|
880 | export = MakerJs;
|
881 | }
|
882 | declare namespace MakerJs {
|
883 | interface ICascadeModel extends ICascade {
|
884 | /**
|
885 | * Add a Caption object to a model.
|
886 | *
|
887 | * @param text Text to add.
|
888 | * @param leftAnchorPoint Optional Point on left side middle of text.
|
889 | * @param rightAnchorPoint Optional Point on right side middle of text.
|
890 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
891 |
|
892 | */
|
893 | addCaption(text: string, leftAnchorPoint?: IPoint, rightAnchorPoint?: IPoint): ICascadeModel;
|
894 | /**
|
895 | * Add a model as a child. This is basically equivalent to:
|
896 | ```
|
897 | parentModel.models[childModelId] = childModel;
|
898 | ```
|
899 | with additional checks to make it safe for cascading.
|
900 | *
|
901 | * @param childModel The model to add.
|
902 | * @param childModelId The id of the child model.
|
903 | * @param overWrite (default false) Optional flag to overwrite any model referenced by childModelId. Default is false, which will create an id similar to childModelId.
|
904 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
905 |
|
906 | */
|
907 | addModel(childModel: IModel, childModelId: string, overWrite?: boolean): ICascadeModel;
|
908 | /**
|
909 | * Add a path as a child. This is basically equivalent to:
|
910 | ```
|
911 | parentModel.paths[childPathId] = childPath;
|
912 | ```
|
913 | with additional checks to make it safe for cascading.
|
914 | *
|
915 | * @param pathContext The path to add.
|
916 | * @param pathId The id of the path.
|
917 | * @param overWrite (default false) Optional flag to overwrite any path referenced by pathId. Default is false, which will create an id similar to pathId.
|
918 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
919 |
|
920 | */
|
921 | addPath(pathContext: IPath, pathId: string, overWrite?: boolean): ICascadeModel;
|
922 | /**
|
923 | * Add a model as a child of another model. This is basically equivalent to:
|
924 | ```
|
925 | parentModel.models[childModelId] = childModel;
|
926 | ```
|
927 | with additional checks to make it safe for cascading.
|
928 | *
|
929 | * @param parentModel The model to add to.
|
930 | * @param childModelId The id of the child model.
|
931 | * @param overWrite (default false) Optional flag to overwrite any model referenced by childModelId. Default is false, which will create an id similar to childModelId.
|
932 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
933 |
|
934 | */
|
935 | addTo(parentModel: IModel, childModelId: string, overWrite?: boolean): ICascadeModel;
|
936 | /**
|
937 | * DEPRECATED
|
938 | Break a model's paths everywhere they intersect with another path.
|
939 | *
|
940 | * @param modelToIntersect Optional model containing paths to look for intersection, or else the modelToBreak will be used.
|
941 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
942 |
|
943 | */
|
944 | breakPathsAtIntersections(modelToIntersect?: IModel): ICascadeModel;
|
945 | /**
|
946 | * Center a model at [0, 0].
|
947 | *
|
948 | * @param centerX (default true) Boolean to center on the x axis. Default is true.
|
949 | * @param centerY (default true) Boolean to center on the y axis. Default is true.
|
950 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
951 |
|
952 | */
|
953 | center(centerX?: boolean, centerY?: boolean): ICascadeModel;
|
954 | /**
|
955 | * Clone a model. Alias of makerjs.cloneObject(modelToClone)
|
956 | *
|
957 | * @returns this cascade container, this.$result will be A clone of the model you passed.
|
958 |
|
959 | */
|
960 | clone(): ICascadeModel;
|
961 | /**
|
962 | * Combine 2 models. Each model will be modified accordingly.
|
963 | *
|
964 | * @param modelB Second model to combine.
|
965 | * @param includeAInsideB (default false) Flag to include paths from modelA which are inside of modelB.
|
966 | * @param includeAOutsideB (default true) Flag to include paths from modelA which are outside of modelB.
|
967 | * @param includeBInsideA (default false) Flag to include paths from modelB which are inside of modelA.
|
968 | * @param includeBOutsideA (default true) Flag to include paths from modelB which are outside of modelA.
|
969 | * @param options Optional ICombineOptions object.
|
970 | * @returns this cascade container, this.$result will be A new model containing both of the input models as "a" and "b".
|
971 |
|
972 | */
|
973 | combine(modelB: IModel, includeAInsideB?: boolean, includeAOutsideB?: boolean, includeBInsideA?: boolean, includeBOutsideA?: boolean, options?: ICombineOptions): ICascadeModel;
|
974 | /**
|
975 | * Combine 2 models, resulting in a intersection. Each model will be modified accordingly.
|
976 | *
|
977 | * @param modelB Second model to combine.
|
978 | * @returns this cascade container, this.$result will be A new model containing both of the input models as "a" and "b".
|
979 |
|
980 | */
|
981 | combineIntersection(modelB: IModel): ICascadeModel;
|
982 | /**
|
983 | * Combine 2 models, resulting in a subtraction of B from A. Each model will be modified accordingly.
|
984 | *
|
985 | * @param modelB Second model to combine.
|
986 | * @returns this cascade container, this.$result will be A new model containing both of the input models as "a" and "b".
|
987 |
|
988 | */
|
989 | combineSubtraction(modelB: IModel): ICascadeModel;
|
990 | /**
|
991 | * Combine 2 models, resulting in a union. Each model will be modified accordingly.
|
992 | *
|
993 | * @param modelB Second model to combine.
|
994 | * @returns this cascade container, this.$result will be A new model containing both of the input models as "a" and "b".
|
995 |
|
996 | */
|
997 | combineUnion(modelB: IModel): ICascadeModel;
|
998 | /**
|
999 | * Convert a model to match a different unit system.
|
1000 | *
|
1001 | * @param destUnitType The unit system.
|
1002 | * @returns this cascade container, this.$result will be The scaled model (for cascading).
|
1003 |
|
1004 | */
|
1005 | convertUnits(destUnitType: string): ICascadeModel;
|
1006 | /**
|
1007 | * Create a distorted copy of a model - scale x and y individually.
|
1008 | *
|
1009 | * @param scaleX The amount of x scaling.
|
1010 | * @param scaleY The amount of y scaling.
|
1011 | * @param scaleOrigin (default false) Optional boolean to scale the origin point. Typically false for the root model.
|
1012 | * @param bezierAccuracy Optional accuracy of Bezier curves.
|
1013 | * @returns this cascade container, this.$result will be New model (for cascading).
|
1014 |
|
1015 | */
|
1016 | distort(scaleX: number, scaleY: number, scaleOrigin?: boolean, bezierAccuracy?: number): ICascadeModel;
|
1017 | /**
|
1018 | * Expand all paths in a model, then combine the resulting expansions.
|
1019 | *
|
1020 | * @param distance Distance to expand.
|
1021 | * @param joints (default 0) Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints.
|
1022 | * @param combineOptions (default {}) Optional object containing combine options.
|
1023 | * @returns this cascade container, this.$result will be Model which surrounds the paths of the original model.
|
1024 |
|
1025 | */
|
1026 | expandPaths(distance: number, joints?: number, combineOptions?: ICombineOptions): ICascadeModel;
|
1027 | /**
|
1028 | * Set the layer of a model. This is equivalent to:
|
1029 | ```
|
1030 | modelContext.layer = layer;
|
1031 | ```
|
1032 | *
|
1033 | * @param layer The layer name.
|
1034 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
1035 |
|
1036 | */
|
1037 | layer(layer: string): ICascadeModel;
|
1038 | /**
|
1039 | * Create a clone of a model, mirrored on either or both x and y axes.
|
1040 | *
|
1041 | * @param mirrorX Boolean to mirror on the x axis.
|
1042 | * @param mirrorY Boolean to mirror on the y axis.
|
1043 | * @returns this cascade container, this.$result will be Mirrored model.
|
1044 |
|
1045 | */
|
1046 | mirror(mirrorX: boolean, mirrorY: boolean): ICascadeModel;
|
1047 | /**
|
1048 | * Move a model to an absolute point. Note that this is also accomplished by directly setting the origin property. This function exists for cascading.
|
1049 | *
|
1050 | * @param origin The new position of the model.
|
1051 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
1052 |
|
1053 | */
|
1054 | move(origin: IPoint): ICascadeModel;
|
1055 | /**
|
1056 | * Move a model's origin by a relative amount.
|
1057 | *
|
1058 | * @param delta The x & y adjustments as a point object.
|
1059 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
1060 |
|
1061 | */
|
1062 | moveRelative(delta: IPoint): ICascadeModel;
|
1063 | /**
|
1064 | * Moves all of a model's children (models and paths, recursively) in reference to a single common origin. Useful when points between children need to connect to each other.
|
1065 | *
|
1066 | * @param origin Optional offset reference point.
|
1067 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
1068 |
|
1069 | */
|
1070 | originate(origin?: IPoint): ICascadeModel;
|
1071 | /**
|
1072 | * Outline a model by a specified distance. Useful for accommodating for kerf.
|
1073 | *
|
1074 | * @param distance Distance to outline.
|
1075 | * @param joints (default 0) Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints.
|
1076 | * @param inside (default false) Optional boolean to draw lines inside the model instead of outside.
|
1077 | * @param options (default {}) Options to send to combine() function.
|
1078 | * @returns this cascade container, this.$result will be Model which surrounds the paths outside of the original model.
|
1079 |
|
1080 | */
|
1081 | outline(distance: number, joints?: number, inside?: boolean, options?: ICombineOptions): ICascadeModel;
|
1082 | /**
|
1083 | * Prefix the ids of paths in a model.
|
1084 | *
|
1085 | * @param prefix The prefix to prepend on paths ids.
|
1086 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
1087 |
|
1088 | */
|
1089 | prefixPathIds(prefix: string): ICascadeModel;
|
1090 | /**
|
1091 | * Remove paths from a model which have endpoints that do not connect to other paths.
|
1092 | *
|
1093 | * @param pointMatchingDistance Optional max distance to consider two points as the same.
|
1094 | * @param keep Optional callback function (which should return a boolean) to decide if a dead end path should be kept instead.
|
1095 | * @param trackDeleted Optional callback function which will log discarded paths and the reason they were discarded.
|
1096 | * @returns this cascade container, this.$result will be The input model (for cascading).
|
1097 |
|
1098 | */
|
1099 | removeDeadEnds(pointMatchingDistance?: number, keep?: IWalkPathBooleanCallback, trackDeleted?: undefined): ICascadeModel;
|
1100 | /**
|
1101 | * Rotate a model.
|
1102 | *
|
1103 | * @param angleInDegrees The amount of rotation, in degrees.
|
1104 | * @param rotationOrigin (default [0, 0]) The center point of rotation.
|
1105 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
1106 |
|
1107 | */
|
1108 | rotate(angleInDegrees: number, rotationOrigin?: IPoint): ICascadeModel;
|
1109 | /**
|
1110 | * Scale a model.
|
1111 | *
|
1112 | * @param scaleValue The amount of scaling.
|
1113 | * @param scaleOrigin (default false) Optional boolean to scale the origin point. Typically false for the root model.
|
1114 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
1115 |
|
1116 | */
|
1117 | scale(scaleValue: number, scaleOrigin?: boolean): ICascadeModel;
|
1118 | /**
|
1119 | * Simplify a model's paths by reducing redundancy: combine multiple overlapping paths into a single path. The model must be originated.
|
1120 | *
|
1121 | * @param options Optional options object.
|
1122 | * @returns this cascade container, this.$result will be The simplified model (for cascading).
|
1123 |
|
1124 | */
|
1125 | simplify(options?: ISimplifyOptions): ICascadeModel;
|
1126 | /**
|
1127 | * Recursively walk through all child models and paths for a given model.
|
1128 | *
|
1129 | * @param options Object containing callbacks.
|
1130 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
1131 |
|
1132 | */
|
1133 | walk(options: IWalkOptions): ICascadeModel;
|
1134 | /**
|
1135 | * Move a model so its bounding box begins at [0, 0].
|
1136 | *
|
1137 | * @param zeroX (default true) Boolean to zero on the x axis. Default is true.
|
1138 | * @param zeroY (default true) Boolean to zero on the y axis. Default is true.
|
1139 | * @returns this cascade container, this.$result will be The original model (for cascading).
|
1140 |
|
1141 | */
|
1142 | zero(zeroX?: boolean, zeroY?: boolean): ICascadeModel;
|
1143 | }
|
1144 | interface ICascadePath extends ICascade {
|
1145 | /**
|
1146 | * Add a path to a model. This is basically equivalent to:
|
1147 | ```
|
1148 | parentModel.paths[pathId] = childPath;
|
1149 | ```
|
1150 | with additional checks to make it safe for cascading.
|
1151 | *
|
1152 | * @param parentModel The model to add to.
|
1153 | * @param pathId The id of the path.
|
1154 | * @param overwrite (default false) Optional flag to overwrite any path referenced by pathId. Default is false, which will create an id similar to pathId.
|
1155 | * @returns this cascade container, this.$result will be The original path (for cascading).
|
1156 |
|
1157 | */
|
1158 | addTo(parentModel: IModel, pathId: string, overwrite?: boolean): ICascadePath;
|
1159 | /**
|
1160 | * Alter a path by lengthening or shortening it.
|
1161 | *
|
1162 | * @param distance Numeric amount of length to add or remove from the path. Use a positive number to lengthen, negative to shorten. When shortening: this function will not alter the path and will return null if the resulting path length is less than or equal to zero.
|
1163 | * @param useOrigin (default false) Optional flag to alter from the origin instead of the end of the path.
|
1164 | * @returns this cascade container, this.$result will be The original path (for cascading), or null if the path could not be altered.
|
1165 |
|
1166 | */
|
1167 | alterLength(distance: number, useOrigin?: boolean): ICascadePath;
|
1168 | /**
|
1169 | * Breaks a path in two. The supplied path will end at the supplied pointOfBreak,
|
1170 | a new path is returned which begins at the pointOfBreak and ends at the supplied path's initial end point.
|
1171 | For Circle, the original path will be converted in place to an Arc, and null is returned.
|
1172 | *
|
1173 | * @param pointOfBreak The point at which to break the path.
|
1174 | * @returns this cascade container, this.$result will be A new path of the same type, when path type is line or arc. Returns null for circle.
|
1175 |
|
1176 | */
|
1177 | breakAtPoint(pointOfBreak: IPoint): ICascadePath;
|
1178 | /**
|
1179 | * Center a path at [0, 0].
|
1180 | *
|
1181 | * @returns this cascade container, this.$result will be The original path (for cascading).
|
1182 |
|
1183 | */
|
1184 | center(): ICascadePath;
|
1185 | /**
|
1186 | * Create a clone of a path. This is faster than cloneObject.
|
1187 | *
|
1188 | * @param offset Optional point to move path a relative distance.
|
1189 | * @returns this cascade container, this.$result will be Cloned path.
|
1190 |
|
1191 | */
|
1192 | clone(offset?: IPoint): ICascadePath;
|
1193 | /**
|
1194 | * Copy the schema properties of one path to another.
|
1195 | *
|
1196 | * @param destPath The destination path to copy property values to.
|
1197 | * @returns this cascade container, this.$result will be The source path.
|
1198 |
|
1199 | */
|
1200 | copyProps(destPath: IPath): ICascadePath;
|
1201 | /**
|
1202 | * Set the layer of a path. This is equivalent to:
|
1203 | ```
|
1204 | pathContext.layer = layer;
|
1205 | ```
|
1206 | *
|
1207 | * @param layer The layer name.
|
1208 | * @returns this cascade container, this.$result will be The original path (for cascading).
|
1209 |
|
1210 | */
|
1211 | layer(layer: string): ICascadePath;
|
1212 | /**
|
1213 | * Create a clone of a path, mirrored on either or both x and y axes.
|
1214 | *
|
1215 | * @param mirrorX Boolean to mirror on the x axis.
|
1216 | * @param mirrorY Boolean to mirror on the y axis.
|
1217 | * @returns this cascade container, this.$result will be Mirrored path.
|
1218 |
|
1219 | */
|
1220 | mirror(mirrorX: boolean, mirrorY: boolean): ICascadePath;
|
1221 | /**
|
1222 | * Move a path to an absolute point.
|
1223 | *
|
1224 | * @param origin The new origin for the path.
|
1225 | * @returns this cascade container, this.$result will be The original path (for cascading).
|
1226 |
|
1227 | */
|
1228 | move(origin: IPoint): ICascadePath;
|
1229 | /**
|
1230 | * Move a path's origin by a relative amount.
|
1231 | *
|
1232 | * @param delta The x & y adjustments as a point object.
|
1233 | * @param subtract Optional boolean to subtract instead of add.
|
1234 | * @returns this cascade container, this.$result will be The original path (for cascading).
|
1235 |
|
1236 | */
|
1237 | moveRelative(delta: IPoint, subtract?: boolean): ICascadePath;
|
1238 | /**
|
1239 | * Rotate a path.
|
1240 | *
|
1241 | * @param angleInDegrees The amount of rotation, in degrees.
|
1242 | * @param rotationOrigin (default [0, 0]) The center point of rotation.
|
1243 | * @returns this cascade container, this.$result will be The original path (for cascading).
|
1244 |
|
1245 | */
|
1246 | rotate(angleInDegrees: number, rotationOrigin?: IPoint): ICascadePath;
|
1247 | /**
|
1248 | * Scale a path.
|
1249 | *
|
1250 | * @param scaleValue The amount of scaling.
|
1251 | * @returns this cascade container, this.$result will be The original path (for cascading).
|
1252 |
|
1253 | */
|
1254 | scale(scaleValue: number): ICascadePath;
|
1255 | /**
|
1256 | * Move a path so its bounding box begins at [0, 0].
|
1257 | *
|
1258 | * @returns this cascade container, this.$result will be The original path (for cascading).
|
1259 |
|
1260 | */
|
1261 | zero(): ICascadePath;
|
1262 | }
|
1263 | interface ICascadePoint extends ICascade {
|
1264 | /**
|
1265 | * Add two points together and return the result as a new point object.
|
1266 | *
|
1267 | * @param b Second point.
|
1268 | * @param subtract Optional boolean to subtract instead of add.
|
1269 | * @returns this cascade container, this.$result will be A new point object.
|
1270 |
|
1271 | */
|
1272 | add(b: IPoint, subtract?: boolean): ICascadePoint;
|
1273 | /**
|
1274 | * Get the average of two points.
|
1275 | *
|
1276 | * @param b Second point.
|
1277 | * @returns this cascade container, this.$result will be New point object which is the average of a and b.
|
1278 |
|
1279 | */
|
1280 | average(b: IPoint): ICascadePoint;
|
1281 | /**
|
1282 | * Clone a point into a new point.
|
1283 | *
|
1284 | * @returns this cascade container, this.$result will be A new point with same values as the original.
|
1285 |
|
1286 | */
|
1287 | clone(): ICascadePoint;
|
1288 | /**
|
1289 | * From an array of points, find the closest point to a given reference point.
|
1290 | *
|
1291 | * @param pointOptions Array of points to choose from.
|
1292 | * @returns this cascade container, this.$result will be The first closest point from the pointOptions.
|
1293 |
|
1294 | */
|
1295 | closest(pointOptions: IPoint[]): ICascadePoint;
|
1296 | /**
|
1297 | * Distort a point's coordinates.
|
1298 | *
|
1299 | * @param scaleX The amount of x scaling.
|
1300 | * @param scaleY The amount of y scaling.
|
1301 | * @returns this cascade container, this.$result will be A new point.
|
1302 |
|
1303 | */
|
1304 | distort(scaleX: number, scaleY: number): ICascadePoint;
|
1305 | /**
|
1306 | * Create a clone of a point, mirrored on either or both x and y axes.
|
1307 | *
|
1308 | * @param mirrorX Boolean to mirror on the x axis.
|
1309 | * @param mirrorY Boolean to mirror on the y axis.
|
1310 | * @returns this cascade container, this.$result will be Mirrored point.
|
1311 |
|
1312 | */
|
1313 | mirror(mirrorX: boolean, mirrorY: boolean): ICascadePoint;
|
1314 | /**
|
1315 | * Rotate a point.
|
1316 | *
|
1317 | * @param angleInDegrees The amount of rotation, in degrees.
|
1318 | * @param rotationOrigin (default [0, 0]) The center point of rotation.
|
1319 | * @returns this cascade container, this.$result will be A new point.
|
1320 |
|
1321 | */
|
1322 | rotate(angleInDegrees: number, rotationOrigin?: IPoint): ICascadePoint;
|
1323 | /**
|
1324 | * Round the values of a point.
|
1325 | *
|
1326 | * @param accuracy Optional exemplar number of decimal places.
|
1327 | * @returns this cascade container, this.$result will be A new point with the values rounded.
|
1328 |
|
1329 | */
|
1330 | rounded(accuracy?: number): ICascadePoint;
|
1331 | /**
|
1332 | * Scale a point's coordinates.
|
1333 | *
|
1334 | * @param scaleValue The amount of scaling.
|
1335 | * @returns this cascade container, this.$result will be A new point.
|
1336 |
|
1337 | */
|
1338 | scale(scaleValue: number): ICascadePoint;
|
1339 | /**
|
1340 | * Subtract a point from another point, and return the result as a new point. Shortcut to Add(a, b, subtract = true).
|
1341 | *
|
1342 | * @param b Second point.
|
1343 | * @returns this cascade container, this.$result will be A new point object.
|
1344 |
|
1345 | */
|
1346 | subtract(b: IPoint): ICascadePoint;
|
1347 | }
|
1348 | }
|
1349 | declare namespace MakerJs.angle {
|
1350 | /**
|
1351 | * Ensures an angle is not greater than 360
|
1352 | *
|
1353 | * @param angleInDegrees Angle in degrees.
|
1354 | * @returns Same polar angle but not greater than 360 degrees.
|
1355 | */
|
1356 | function noRevolutions(angleInDegrees: number): number;
|
1357 | /**
|
1358 | * Convert an angle from degrees to radians.
|
1359 | *
|
1360 | * @param angleInDegrees Angle in degrees.
|
1361 | * @returns Angle in radians.
|
1362 | */
|
1363 | function toRadians(angleInDegrees: number): number;
|
1364 | /**
|
1365 | * Convert an angle from radians to degrees.
|
1366 | *
|
1367 | * @param angleInRadians Angle in radians.
|
1368 | * @returns Angle in degrees.
|
1369 | */
|
1370 | function toDegrees(angleInRadians: number): number;
|
1371 | /**
|
1372 | * Get an arc's end angle, ensured to be greater than its start angle.
|
1373 | *
|
1374 | * @param arc An arc path object.
|
1375 | * @returns End angle of arc.
|
1376 | */
|
1377 | function ofArcEnd(arc: IPathArc): number;
|
1378 | /**
|
1379 | * Get the angle in the middle of an arc's start and end angles.
|
1380 | *
|
1381 | * @param arc An arc path object.
|
1382 | * @param ratio Optional number between 0 and 1 specifying percentage between start and end angles. Default is .5
|
1383 | * @returns Middle angle of arc.
|
1384 | */
|
1385 | function ofArcMiddle(arc: IPathArc, ratio?: number): number;
|
1386 | /**
|
1387 | * Total angle of an arc between its start and end angles.
|
1388 | *
|
1389 | * @param arc The arc to measure.
|
1390 | * @returns Angle of arc.
|
1391 | */
|
1392 | function ofArcSpan(arc: IPathArc): number;
|
1393 | /**
|
1394 | * Angle of a line path.
|
1395 | *
|
1396 | * @param line The line path to find the angle of.
|
1397 | * @returns Angle of the line path, in degrees.
|
1398 | */
|
1399 | function ofLineInDegrees(line: IPathLine): number;
|
1400 | /**
|
1401 | * Angle of a line through a point, in degrees.
|
1402 | *
|
1403 | * @param pointToFindAngle The point to find the angle.
|
1404 | * @param origin Point of origin of the angle.
|
1405 | * @returns Angle of the line throught the point, in degrees.
|
1406 | */
|
1407 | function ofPointInDegrees(origin: IPoint, pointToFindAngle: IPoint): number;
|
1408 | /**
|
1409 | * Angle of a line through a point, in radians.
|
1410 | *
|
1411 | * @param pointToFindAngle The point to find the angle.
|
1412 | * @param origin Point of origin of the angle.
|
1413 | * @returns Angle of the line throught the point, in radians.
|
1414 | */
|
1415 | function ofPointInRadians(origin: IPoint, pointToFindAngle: IPoint): number;
|
1416 | /**
|
1417 | * Mirror an angle on either or both x and y axes.
|
1418 | *
|
1419 | * @param angleInDegrees The angle to mirror.
|
1420 | * @param mirrorX Boolean to mirror on the x axis.
|
1421 | * @param mirrorY Boolean to mirror on the y axis.
|
1422 | * @returns Mirrored angle.
|
1423 | */
|
1424 | function mirror(angleInDegrees: number, mirrorX: boolean, mirrorY: boolean): number;
|
1425 | /**
|
1426 | * Get the angle of a joint between 2 chain links.
|
1427 | *
|
1428 | * @param linkA First chain link.
|
1429 | * @param linkB Second chain link.
|
1430 | * @returns Angle between chain links.
|
1431 | */
|
1432 | function ofChainLinkJoint(linkA: IChainLink, linkB: IChainLink): number;
|
1433 | }
|
1434 | declare namespace MakerJs.point {
|
1435 | /**
|
1436 | * Add two points together and return the result as a new point object.
|
1437 | *
|
1438 | * @param a First point.
|
1439 | * @param b Second point.
|
1440 | * @param subtract Optional boolean to subtract instead of add.
|
1441 | * @returns A new point object.
|
1442 | */
|
1443 | function add(a: IPoint, b: IPoint, subtract?: boolean): IPoint;
|
1444 | /**
|
1445 | * Get the average of two points.
|
1446 | *
|
1447 | * @param a First point.
|
1448 | * @param b Second point.
|
1449 | * @returns New point object which is the average of a and b.
|
1450 | */
|
1451 | function average(a: IPoint, b: IPoint): IPoint;
|
1452 | /**
|
1453 | * Clone a point into a new point.
|
1454 | *
|
1455 | * @param pointToClone The point to clone.
|
1456 | * @returns A new point with same values as the original.
|
1457 | */
|
1458 | function clone(pointToClone: IPoint): IPoint;
|
1459 | /**
|
1460 | * From an array of points, find the closest point to a given reference point.
|
1461 | *
|
1462 | * @param referencePoint The reference point.
|
1463 | * @param pointOptions Array of points to choose from.
|
1464 | * @returns The first closest point from the pointOptions.
|
1465 | */
|
1466 | function closest(referencePoint: IPoint, pointOptions: IPoint[]): IPoint;
|
1467 | /**
|
1468 | * Get a point from its polar coordinates.
|
1469 | *
|
1470 | * @param angleInRadians The angle of the polar coordinate, in radians.
|
1471 | * @param radius The radius of the polar coordinate.
|
1472 | * @returns A new point object.
|
1473 | */
|
1474 | function fromPolar(angleInRadians: number, radius: number): IPoint;
|
1475 | /**
|
1476 | * Get a point on a circle or arc path, at a given angle.
|
1477 | * @param angleInDegrees The angle at which you want to find the point, in degrees.
|
1478 | * @param circle A circle or arc.
|
1479 | * @returns A new point object.
|
1480 | */
|
1481 | function fromAngleOnCircle(angleInDegrees: number, circle: IPathCircle): IPoint;
|
1482 | /**
|
1483 | * Get the two end points of an arc path.
|
1484 | *
|
1485 | * @param arc The arc path object.
|
1486 | * @returns Array with 2 elements: [0] is the point object corresponding to the start angle, [1] is the point object corresponding to the end angle.
|
1487 | */
|
1488 | function fromArc(arc: IPathArc): IPoint[];
|
1489 | /**
|
1490 | * Get the two end points of a path.
|
1491 | *
|
1492 | * @param pathContext The path object.
|
1493 | * @returns Array with 2 elements: [0] is the point object corresponding to the origin, [1] is the point object corresponding to the end.
|
1494 | */
|
1495 | function fromPathEnds(pathContext: IPath, pathOffset?: IPoint): IPoint[];
|
1496 | /**
|
1497 | * Calculates the intersection of slopes of two lines.
|
1498 | *
|
1499 | * @param lineA First line to use for slope.
|
1500 | * @param lineB Second line to use for slope.
|
1501 | * @param options Optional IPathIntersectionOptions.
|
1502 | * @returns point of intersection of the two slopes, or null if the slopes did not intersect.
|
1503 | */
|
1504 | function fromSlopeIntersection(lineA: IPathLine, lineB: IPathLine, options?: IPathIntersectionBaseOptions): IPoint;
|
1505 | /**
|
1506 | * Get the middle point of a path.
|
1507 | *
|
1508 | * @param pathContext The path object.
|
1509 | * @param ratio Optional ratio (between 0 and 1) of point along the path. Default is .5 for middle.
|
1510 | * @returns Point on the path, in the middle of the path.
|
1511 | */
|
1512 | function middle(pathContext: IPath, ratio?: number): IPoint;
|
1513 | /**
|
1514 | * Create a clone of a point, mirrored on either or both x and y axes.
|
1515 | *
|
1516 | * @param pointToMirror The point to mirror.
|
1517 | * @param mirrorX Boolean to mirror on the x axis.
|
1518 | * @param mirrorY Boolean to mirror on the y axis.
|
1519 | * @returns Mirrored point.
|
1520 | */
|
1521 | function mirror(pointToMirror: IPoint, mirrorX: boolean, mirrorY: boolean): IPoint;
|
1522 | /**
|
1523 | * Round the values of a point.
|
1524 | *
|
1525 | * @param pointContext The point to serialize.
|
1526 | * @param accuracy Optional exemplar number of decimal places.
|
1527 | * @returns A new point with the values rounded.
|
1528 | */
|
1529 | function rounded(pointContext: IPoint, accuracy?: number): IPoint;
|
1530 | /**
|
1531 | * Rotate a point.
|
1532 | *
|
1533 | * @param pointToRotate The point to rotate.
|
1534 | * @param angleInDegrees The amount of rotation, in degrees.
|
1535 | * @param rotationOrigin The center point of rotation.
|
1536 | * @returns A new point.
|
1537 | */
|
1538 | function rotate(pointToRotate: IPoint, angleInDegrees: number, rotationOrigin?: IPoint): IPoint;
|
1539 | /**
|
1540 | * Scale a point's coordinates.
|
1541 | *
|
1542 | * @param pointToScale The point to scale.
|
1543 | * @param scaleValue The amount of scaling.
|
1544 | * @returns A new point.
|
1545 | */
|
1546 | function scale(pointToScale: IPoint, scaleValue: number): IPoint;
|
1547 | /**
|
1548 | * Distort a point's coordinates.
|
1549 | *
|
1550 | * @param pointToDistort The point to distort.
|
1551 | * @param scaleX The amount of x scaling.
|
1552 | * @param scaleY The amount of y scaling.
|
1553 | * @returns A new point.
|
1554 | */
|
1555 | function distort(pointToDistort: IPoint, scaleX: number, scaleY: number): IPoint;
|
1556 | /**
|
1557 | * Subtract a point from another point, and return the result as a new point. Shortcut to Add(a, b, subtract = true).
|
1558 | *
|
1559 | * @param a First point.
|
1560 | * @param b Second point.
|
1561 | * @returns A new point object.
|
1562 | */
|
1563 | function subtract(a: IPoint, b: IPoint): IPoint;
|
1564 | /**
|
1565 | * A point at 0,0 coordinates.
|
1566 | * NOTE: It is important to call this as a method, with the empty parentheses.
|
1567 | *
|
1568 | * @returns A new point.
|
1569 | */
|
1570 | function zero(): IPoint;
|
1571 | }
|
1572 | declare namespace MakerJs.path {
|
1573 | /**
|
1574 | * Add a path to a model. This is basically equivalent to:
|
1575 | * ```
|
1576 | * parentModel.paths[pathId] = childPath;
|
1577 | * ```
|
1578 | * with additional checks to make it safe for cascading.
|
1579 | *
|
1580 | * @param childPath The path to add.
|
1581 | * @param parentModel The model to add to.
|
1582 | * @param pathId The id of the path.
|
1583 | * @param overwrite Optional flag to overwrite any path referenced by pathId. Default is false, which will create an id similar to pathId.
|
1584 | * @returns The original path (for cascading).
|
1585 | */
|
1586 | function addTo(childPath: IPath, parentModel: IModel, pathId: string, overwrite?: boolean): IPath;
|
1587 | /**
|
1588 | * Create a clone of a path. This is faster than cloneObject.
|
1589 | *
|
1590 | * @param pathToClone The path to clone.
|
1591 | * @param offset Optional point to move path a relative distance.
|
1592 | * @returns Cloned path.
|
1593 | */
|
1594 | function clone(pathToClone: IPath, offset?: IPoint): IPath;
|
1595 | /**
|
1596 | * Copy the schema properties of one path to another.
|
1597 | *
|
1598 | * @param srcPath The source path to copy property values from.
|
1599 | * @param destPath The destination path to copy property values to.
|
1600 | * @returns The source path.
|
1601 | */
|
1602 | function copyProps(srcPath: IPath, destPath: IPath): IPath;
|
1603 | /**
|
1604 | * Set the layer of a path. This is equivalent to:
|
1605 | * ```
|
1606 | * pathContext.layer = layer;
|
1607 | * ```
|
1608 | *
|
1609 | * @param pathContext The path to set the layer.
|
1610 | * @param layer The layer name.
|
1611 | * @returns The original path (for cascading).
|
1612 | */
|
1613 | function layer(pathContext: IPath, layer: string): IPath;
|
1614 | /**
|
1615 | * Create a clone of a path, mirrored on either or both x and y axes.
|
1616 | *
|
1617 | * @param pathToMirror The path to mirror.
|
1618 | * @param mirrorX Boolean to mirror on the x axis.
|
1619 | * @param mirrorY Boolean to mirror on the y axis.
|
1620 | * @returns Mirrored path.
|
1621 | */
|
1622 | function mirror(pathToMirror: IPath, mirrorX: boolean, mirrorY: boolean): IPath;
|
1623 | /**
|
1624 | * Move a path to an absolute point.
|
1625 | *
|
1626 | * @param pathToMove The path to move.
|
1627 | * @param origin The new origin for the path.
|
1628 | * @returns The original path (for cascading).
|
1629 | */
|
1630 | function move(pathToMove: IPath, origin: IPoint): IPath;
|
1631 | /**
|
1632 | * Move a path's origin by a relative amount.
|
1633 | *
|
1634 | * @param pathToMove The path to move.
|
1635 | * @param delta The x & y adjustments as a point object.
|
1636 | * @param subtract Optional boolean to subtract instead of add.
|
1637 | * @returns The original path (for cascading).
|
1638 | */
|
1639 | function moveRelative(pathToMove: IPath, delta: IPoint, subtract?: boolean): IPath;
|
1640 | /**
|
1641 | * Move some paths relatively during a task execution, then unmove them.
|
1642 | *
|
1643 | * @param pathsToMove The paths to move.
|
1644 | * @param deltas The x & y adjustments as a point object array.
|
1645 | * @param task The function to call while the paths are temporarily moved.
|
1646 | */
|
1647 | function moveTemporary(pathsToMove: IPath[], deltas: IPoint[], task: Function): void;
|
1648 | /**
|
1649 | * Rotate a path.
|
1650 | *
|
1651 | * @param pathToRotate The path to rotate.
|
1652 | * @param angleInDegrees The amount of rotation, in degrees.
|
1653 | * @param rotationOrigin The center point of rotation.
|
1654 | * @returns The original path (for cascading).
|
1655 | */
|
1656 | function rotate(pathToRotate: IPath, angleInDegrees: number, rotationOrigin?: IPoint): IPath;
|
1657 | /**
|
1658 | * Scale a path.
|
1659 | *
|
1660 | * @param pathToScale The path to scale.
|
1661 | * @param scaleValue The amount of scaling.
|
1662 | * @returns The original path (for cascading).
|
1663 | */
|
1664 | function scale(pathToScale: IPath, scaleValue: number): IPath;
|
1665 | /**
|
1666 | * Distort a path - scale x and y individually.
|
1667 | *
|
1668 | * @param pathToDistort The path to distort.
|
1669 | * @param scaleX The amount of x scaling.
|
1670 | * @param scaleY The amount of y scaling.
|
1671 | * @returns A new IModel (for circles and arcs) or IPath (for lines and bezier seeds).
|
1672 | */
|
1673 | function distort(pathToDistort: IPath, scaleX: number, scaleY: number): IModel | IPath;
|
1674 | /**
|
1675 | * Connect 2 lines at their slope intersection point.
|
1676 | *
|
1677 | * @param lineA First line to converge.
|
1678 | * @param lineB Second line to converge.
|
1679 | * @param useOriginA Optional flag to converge the origin point of lineA instead of the end point.
|
1680 | * @param useOriginB Optional flag to converge the origin point of lineB instead of the end point.
|
1681 | * @returns point of convergence.
|
1682 | */
|
1683 | function converge(lineA: IPathLine, lineB: IPathLine, useOriginA?: boolean, useOriginB?: boolean): IPoint;
|
1684 | /**
|
1685 | * Alter a path by lengthening or shortening it.
|
1686 | *
|
1687 | * @param pathToAlter Path to alter.
|
1688 | * @param distance Numeric amount of length to add or remove from the path. Use a positive number to lengthen, negative to shorten. When shortening: this function will not alter the path and will return null if the resulting path length is less than or equal to zero.
|
1689 | * @param useOrigin Optional flag to alter from the origin instead of the end of the path.
|
1690 | * @returns The original path (for cascading), or null if the path could not be altered.
|
1691 | */
|
1692 | function alterLength(pathToAlter: IPath, distance: number, useOrigin?: boolean): IPath;
|
1693 | /**
|
1694 | * Get points along a path.
|
1695 | *
|
1696 | * @param pathContext Path to get points from.
|
1697 | * @param numberOfPoints Number of points to divide the path.
|
1698 | * @returns Array of points which are on the path spread at a uniform interval.
|
1699 | */
|
1700 | function toPoints(pathContext: IPath, numberOfPoints: number): IPoint[];
|
1701 | /**
|
1702 | * Get key points (a minimal a number of points) along a path.
|
1703 | *
|
1704 | * @param pathContext Path to get points from.
|
1705 | * @param maxArcFacet Optional maximum length between points on an arc or circle.
|
1706 | * @returns Array of points which are on the path.
|
1707 | */
|
1708 | function toKeyPoints(pathContext: IPath, maxArcFacet?: number): IPoint[];
|
1709 | /**
|
1710 | * Center a path at [0, 0].
|
1711 | *
|
1712 | * @param pathToCenter The path to center.
|
1713 | * @returns The original path (for cascading).
|
1714 | */
|
1715 | function center(pathToCenter: IPath): IPath;
|
1716 | /**
|
1717 | * Move a path so its bounding box begins at [0, 0].
|
1718 | *
|
1719 | * @param pathToZero The path to zero.
|
1720 | * @returns The original path (for cascading).
|
1721 | */
|
1722 | function zero(pathToZero: IPath): IPath;
|
1723 | }
|
1724 | declare namespace MakerJs.path {
|
1725 | /**
|
1726 | * Breaks a path in two. The supplied path will end at the supplied pointOfBreak,
|
1727 | * a new path is returned which begins at the pointOfBreak and ends at the supplied path's initial end point.
|
1728 | * For Circle, the original path will be converted in place to an Arc, and null is returned.
|
1729 | *
|
1730 | * @param pathToBreak The path to break.
|
1731 | * @param pointOfBreak The point at which to break the path.
|
1732 | * @returns A new path of the same type, when path type is line or arc. Returns null for circle.
|
1733 | */
|
1734 | function breakAtPoint(pathToBreak: IPath, pointOfBreak: IPoint): IPath;
|
1735 | }
|
1736 | declare namespace MakerJs.paths {
|
1737 | /**
|
1738 | * Class for arc path.
|
1739 | */
|
1740 | class Arc implements IPathArc {
|
1741 | origin: IPoint;
|
1742 | radius: number;
|
1743 | startAngle: number;
|
1744 | endAngle: number;
|
1745 | type: string;
|
1746 | /**
|
1747 | * Class for arc path, created from origin point, radius, start angle, and end angle.
|
1748 | *
|
1749 | * @param origin The center point of the arc.
|
1750 | * @param radius The radius of the arc.
|
1751 | * @param startAngle The start angle of the arc.
|
1752 | * @param endAngle The end angle of the arc.
|
1753 | */
|
1754 | constructor(origin: IPoint, radius: number, startAngle: number, endAngle: number);
|
1755 | /**
|
1756 | * Class for arc path, created from 2 points, radius, large Arc flag, and clockwise flag.
|
1757 | *
|
1758 | * @param pointA First end point of the arc.
|
1759 | * @param pointB Second end point of the arc.
|
1760 | * @param radius The radius of the arc.
|
1761 | * @param largeArc Boolean flag to indicate clockwise direction.
|
1762 | * @param clockwise Boolean flag to indicate clockwise direction.
|
1763 | */
|
1764 | constructor(pointA: IPoint, pointB: IPoint, radius: number, largeArc: boolean, clockwise: boolean);
|
1765 | /**
|
1766 | * Class for arc path, created from 2 points and optional boolean flag indicating clockwise.
|
1767 | *
|
1768 | * @param pointA First end point of the arc.
|
1769 | * @param pointB Second end point of the arc.
|
1770 | * @param clockwise Boolean flag to indicate clockwise direction.
|
1771 | */
|
1772 | constructor(pointA: IPoint, pointB: IPoint, clockwise?: boolean);
|
1773 | /**
|
1774 | * Class for arc path, created from 3 points.
|
1775 | *
|
1776 | * @param pointA First end point of the arc.
|
1777 | * @param pointB Middle point on the arc.
|
1778 | * @param pointC Second end point of the arc.
|
1779 | */
|
1780 | constructor(pointA: IPoint, pointB: IPoint, pointC: IPoint);
|
1781 | }
|
1782 | /**
|
1783 | * Class for circle path.
|
1784 | */
|
1785 | class Circle implements IPathCircle {
|
1786 | type: string;
|
1787 | origin: IPoint;
|
1788 | radius: number;
|
1789 | /**
|
1790 | * Class for circle path, created from radius. Origin will be [0, 0].
|
1791 | *
|
1792 | * Example:
|
1793 | * ```
|
1794 | * var c = new makerjs.paths.Circle(7);
|
1795 | * ```
|
1796 | *
|
1797 | * @param radius The radius of the circle.
|
1798 | */
|
1799 | constructor(radius: number);
|
1800 | /**
|
1801 | * Class for circle path, created from origin point and radius.
|
1802 | *
|
1803 | * Example:
|
1804 | * ```
|
1805 | * var c = new makerjs.paths.Circle([10, 10], 7);
|
1806 | * ```
|
1807 | *
|
1808 | * @param origin The center point of the circle.
|
1809 | * @param radius The radius of the circle.
|
1810 | */
|
1811 | constructor(origin: IPoint, radius: number);
|
1812 | /**
|
1813 | * Class for circle path, created from 2 points.
|
1814 | *
|
1815 | * Example:
|
1816 | * ```
|
1817 | * var c = new makerjs.paths.Circle([5, 15], [25, 15]);
|
1818 | * ```
|
1819 | *
|
1820 | * @param pointA First point on the circle.
|
1821 | * @param pointB Second point on the circle.
|
1822 | */
|
1823 | constructor(pointA: IPoint, pointB: IPoint);
|
1824 | /**
|
1825 | * Class for circle path, created from 3 points.
|
1826 | *
|
1827 | * Example:
|
1828 | * ```
|
1829 | * var c = new makerjs.paths.Circle([0, 0], [0, 10], [20, 0]);
|
1830 | * ```
|
1831 | *
|
1832 | * @param pointA First point on the circle.
|
1833 | * @param pointB Second point on the circle.
|
1834 | * @param pointC Third point on the circle.
|
1835 | */
|
1836 | constructor(pointA: IPoint, pointB: IPoint, pointC: IPoint);
|
1837 | }
|
1838 | /**
|
1839 | * Class for line path.
|
1840 | */
|
1841 | class Line implements IPathLine {
|
1842 | type: string;
|
1843 | origin: IPoint;
|
1844 | end: IPoint;
|
1845 | /**
|
1846 | * Class for line path, constructed from array of 2 points.
|
1847 | *
|
1848 | * @param points Array of 2 points.
|
1849 | */
|
1850 | constructor(points: IPoint[]);
|
1851 | /**
|
1852 | * Class for line path, constructed from 2 points.
|
1853 | *
|
1854 | * @param origin The origin point of the line.
|
1855 | * @param end The end point of the line.
|
1856 | */
|
1857 | constructor(origin: IPoint, end: IPoint);
|
1858 | }
|
1859 | /**
|
1860 | * Class for chord, which is simply a line path that connects the endpoints of an arc.
|
1861 | *
|
1862 | * @param arc Arc to use as the basic for the chord.
|
1863 | */
|
1864 | class Chord implements IPathLine {
|
1865 | type: string;
|
1866 | origin: IPoint;
|
1867 | end: IPoint;
|
1868 | constructor(arc: IPathArc);
|
1869 | }
|
1870 | /**
|
1871 | * Class for a parallel line path.
|
1872 | *
|
1873 | * @param toLine A line to be parallel to.
|
1874 | * @param distance Distance between parallel and original line.
|
1875 | * @param nearPoint Any point to determine which side of the line to place the parallel.
|
1876 | */
|
1877 | class Parallel implements IPathLine {
|
1878 | type: string;
|
1879 | origin: IPoint;
|
1880 | end: IPoint;
|
1881 | constructor(toLine: IPathLine, distance: number, nearPoint: IPoint);
|
1882 | }
|
1883 | }
|
1884 | declare namespace MakerJs.model {
|
1885 | /**
|
1886 | * Add a Caption object to a model.
|
1887 | * @param modelContext The model to add to.
|
1888 | * @param text Text to add.
|
1889 | * @param leftAnchorPoint Optional Point on left side middle of text.
|
1890 | * @param rightAnchorPoint Optional Point on right side middle of text.
|
1891 | * @returns The original model (for cascading).
|
1892 | */
|
1893 | function addCaption(modelContext: IModel, text: string, leftAnchorPoint?: IPoint, rightAnchorPoint?: IPoint): IModel;
|
1894 | /**
|
1895 | * Add a path as a child. This is basically equivalent to:
|
1896 | * ```
|
1897 | * parentModel.paths[childPathId] = childPath;
|
1898 | * ```
|
1899 | * with additional checks to make it safe for cascading.
|
1900 | *
|
1901 | * @param modelContext The model to add to.
|
1902 | * @param pathContext The path to add.
|
1903 | * @param pathId The id of the path.
|
1904 | * @param overWrite Optional flag to overwrite any path referenced by pathId. Default is false, which will create an id similar to pathId.
|
1905 | * @returns The original model (for cascading).
|
1906 | */
|
1907 | function addPath(modelContext: IModel, pathContext: IPath, pathId: string, overWrite?: boolean): IModel;
|
1908 | /**
|
1909 | * Add a model as a child. This is basically equivalent to:
|
1910 | * ```
|
1911 | * parentModel.models[childModelId] = childModel;
|
1912 | * ```
|
1913 | * with additional checks to make it safe for cascading.
|
1914 | *
|
1915 | * @param parentModel The model to add to.
|
1916 | * @param childModel The model to add.
|
1917 | * @param childModelId The id of the child model.
|
1918 | * @param overWrite Optional flag to overwrite any model referenced by childModelId. Default is false, which will create an id similar to childModelId.
|
1919 | * @returns The original model (for cascading).
|
1920 | */
|
1921 | function addModel(parentModel: IModel, childModel: IModel, childModelId: string, overWrite?: boolean): IModel;
|
1922 | /**
|
1923 | * Add a model as a child of another model. This is basically equivalent to:
|
1924 | * ```
|
1925 | * parentModel.models[childModelId] = childModel;
|
1926 | * ```
|
1927 | * with additional checks to make it safe for cascading.
|
1928 | *
|
1929 | * @param childModel The model to add.
|
1930 | * @param parentModel The model to add to.
|
1931 | * @param childModelId The id of the child model.
|
1932 | * @param overWrite Optional flag to overwrite any model referenced by childModelId. Default is false, which will create an id similar to childModelId.
|
1933 | * @returns The original model (for cascading).
|
1934 | */
|
1935 | function addTo(childModel: IModel, parentModel: IModel, childModelId: string, overWrite?: boolean): IModel;
|
1936 | /**
|
1937 | * Clone a model. Alias of makerjs.cloneObject(modelToClone)
|
1938 | *
|
1939 | * @param modelToClone The model to clone.
|
1940 | * @returns A clone of the model you passed.
|
1941 | */
|
1942 | function clone(modelToClone: IModel): IModel;
|
1943 | /**
|
1944 | * Count the number of child models within a given model.
|
1945 | *
|
1946 | * @param modelContext The model containing other models.
|
1947 | * @returns Number of child models.
|
1948 | */
|
1949 | function countChildModels(modelContext: IModel): number;
|
1950 | /**
|
1951 | * Gets all Caption objects, in absolute position, in this model and its children.
|
1952 | * @param modelContext The model to search for Caption objects.
|
1953 | * @returns Array of Caption objects.
|
1954 | */
|
1955 | function getAllCaptionsOffset(modelContext: IModel): ICaption[];
|
1956 | /**
|
1957 | * Get an unused id in the models map with the same prefix.
|
1958 | *
|
1959 | * @param modelContext The model containing the models map.
|
1960 | * @param modelId The id to use directly (if unused), or as a prefix.
|
1961 | */
|
1962 | function getSimilarModelId(modelContext: IModel, modelId: string): string;
|
1963 | /**
|
1964 | * Get an unused id in the paths map with the same prefix.
|
1965 | *
|
1966 | * @param modelContext The model containing the paths map.
|
1967 | * @param pathId The id to use directly (if unused), or as a prefix.
|
1968 | */
|
1969 | function getSimilarPathId(modelContext: IModel, pathId: string): string;
|
1970 | /**
|
1971 | * Set the layer of a model. This is equivalent to:
|
1972 | * ```
|
1973 | * modelContext.layer = layer;
|
1974 | * ```
|
1975 | *
|
1976 | * @param modelContext The model to set the layer.
|
1977 | * @param layer The layer name.
|
1978 | * @returns The original model (for cascading).
|
1979 | */
|
1980 | function layer(modelContext: IModel, layer: string): IModel;
|
1981 | /**
|
1982 | * Moves all of a model's children (models and paths, recursively) in reference to a single common origin. Useful when points between children need to connect to each other.
|
1983 | *
|
1984 | * @param modelToOriginate The model to originate.
|
1985 | * @param origin Optional offset reference point.
|
1986 | * @returns The original model (for cascading).
|
1987 | */
|
1988 | function originate(modelToOriginate: IModel, origin?: IPoint): IModel;
|
1989 | /**
|
1990 | * Center a model at [0, 0].
|
1991 | *
|
1992 | * @param modelToCenter The model to center.
|
1993 | * @param centerX Boolean to center on the x axis. Default is true.
|
1994 | * @param centerY Boolean to center on the y axis. Default is true.
|
1995 | * @returns The original model (for cascading).
|
1996 | */
|
1997 | function center(modelToCenter: IModel, centerX?: boolean, centerY?: boolean): IModel;
|
1998 | /**
|
1999 | * Create a clone of a model, mirrored on either or both x and y axes.
|
2000 | *
|
2001 | * @param modelToMirror The model to mirror.
|
2002 | * @param mirrorX Boolean to mirror on the x axis.
|
2003 | * @param mirrorY Boolean to mirror on the y axis.
|
2004 | * @returns Mirrored model.
|
2005 | */
|
2006 | function mirror(modelToMirror: IModel, mirrorX: boolean, mirrorY: boolean): IModel;
|
2007 | /**
|
2008 | * Move a model to an absolute point. Note that this is also accomplished by directly setting the origin property. This function exists for cascading.
|
2009 | *
|
2010 | * @param modelToMove The model to move.
|
2011 | * @param origin The new position of the model.
|
2012 | * @returns The original model (for cascading).
|
2013 | */
|
2014 | function move(modelToMove: IModel, origin: IPoint): IModel;
|
2015 | /**
|
2016 | * Move a model's origin by a relative amount.
|
2017 | *
|
2018 | * @param modelToMove The model to move.
|
2019 | * @param delta The x & y adjustments as a point object.
|
2020 | * @returns The original model (for cascading).
|
2021 | */
|
2022 | function moveRelative(modelToMove: IModel, delta: IPoint): IModel;
|
2023 | /**
|
2024 | * Prefix the ids of paths in a model.
|
2025 | *
|
2026 | * @param modelToPrefix The model to prefix.
|
2027 | * @param prefix The prefix to prepend on paths ids.
|
2028 | * @returns The original model (for cascading).
|
2029 | */
|
2030 | function prefixPathIds(modelToPrefix: IModel, prefix: string): IModel;
|
2031 | /**
|
2032 | * Rotate a model.
|
2033 | *
|
2034 | * @param modelToRotate The model to rotate.
|
2035 | * @param angleInDegrees The amount of rotation, in degrees.
|
2036 | * @param rotationOrigin The center point of rotation.
|
2037 | * @returns The original model (for cascading).
|
2038 | */
|
2039 | function rotate(modelToRotate: IModel, angleInDegrees: number, rotationOrigin?: IPoint): IModel;
|
2040 | /**
|
2041 | * Scale a model.
|
2042 | *
|
2043 | * @param modelToScale The model to scale.
|
2044 | * @param scaleValue The amount of scaling.
|
2045 | * @param scaleOrigin Optional boolean to scale the origin point. Typically false for the root model.
|
2046 | * @returns The original model (for cascading).
|
2047 | */
|
2048 | function scale(modelToScale: IModel, scaleValue: number, scaleOrigin?: boolean): IModel;
|
2049 | /**
|
2050 | * Create a distorted copy of a model - scale x and y individually.
|
2051 | *
|
2052 | * @param modelToDistort The model to distort.
|
2053 | * @param scaleX The amount of x scaling.
|
2054 | * @param scaleY The amount of y scaling.
|
2055 | * @param scaleOrigin Optional boolean to scale the origin point. Typically false for the root model.
|
2056 | * @param bezierAccuracy Optional accuracy of Bezier curves.
|
2057 | * @returns New model (for cascading).
|
2058 | */
|
2059 | function distort(modelToDistort: IModel, scaleX: number, scaleY: number, scaleOrigin?: boolean, bezierAccuracy?: number): IModel;
|
2060 | /**
|
2061 | * Convert a model to match a different unit system.
|
2062 | *
|
2063 | * @param modeltoConvert The model to convert.
|
2064 | * @param destUnitType The unit system.
|
2065 | * @returns The scaled model (for cascading).
|
2066 | */
|
2067 | function convertUnits(modeltoConvert: IModel, destUnitType: string): IModel;
|
2068 | /**
|
2069 | * DEPRECATED - use model.walk instead.
|
2070 | * Recursively walk through all paths for a given model.
|
2071 | *
|
2072 | * @param modelContext The model to walk.
|
2073 | * @param callback Callback for each path.
|
2074 | */
|
2075 | function walkPaths(modelContext: IModel, callback: IModelPathCallback): void;
|
2076 | /**
|
2077 | * Recursively walk through all child models and paths for a given model.
|
2078 | *
|
2079 | * @param modelContext The model to walk.
|
2080 | * @param options Object containing callbacks.
|
2081 | * @returns The original model (for cascading).
|
2082 | */
|
2083 | function walk(modelContext: IModel, options: IWalkOptions): IModel;
|
2084 | /**
|
2085 | * Move a model so its bounding box begins at [0, 0].
|
2086 | *
|
2087 | * @param modelToZero The model to zero.
|
2088 | * @param zeroX Boolean to zero on the x axis. Default is true.
|
2089 | * @param zeroY Boolean to zero on the y axis. Default is true.
|
2090 | * @returns The original model (for cascading).
|
2091 | */
|
2092 | function zero(modelToZero: IModel, zeroX?: boolean, zeroY?: boolean): IModel;
|
2093 | }
|
2094 | declare namespace MakerJs.model {
|
2095 | /**
|
2096 | * DEPRECATED - use measure.isPointInsideModel instead.
|
2097 | * Check to see if a path is inside of a model.
|
2098 | *
|
2099 | * @param pathContext The path to check.
|
2100 | * @param modelContext The model to check against.
|
2101 | * @param farPoint Optional point of reference which is outside the bounds of the modelContext.
|
2102 | * @returns Boolean true if the path is inside of the modelContext.
|
2103 | */
|
2104 | function isPathInsideModel(pathContext: IPath, modelContext: IModel, pathOffset?: IPoint, farPoint?: IPoint, measureAtlas?: measure.Atlas): boolean;
|
2105 | /**
|
2106 | * DEPRECATED
|
2107 | * Break a model's paths everywhere they intersect with another path.
|
2108 | *
|
2109 | * @param modelToBreak The model containing paths to be broken.
|
2110 | * @param modelToIntersect Optional model containing paths to look for intersection, or else the modelToBreak will be used.
|
2111 | * @returns The original model (for cascading).
|
2112 | */
|
2113 | function breakPathsAtIntersections(modelToBreak: IModel, modelToIntersect?: IModel): IModel;
|
2114 | /**
|
2115 | * Combine 2 models. Each model will be modified accordingly.
|
2116 | *
|
2117 | * @param modelA First model to combine.
|
2118 | * @param modelB Second model to combine.
|
2119 | * @param includeAInsideB Flag to include paths from modelA which are inside of modelB.
|
2120 | * @param includeAOutsideB Flag to include paths from modelA which are outside of modelB.
|
2121 | * @param includeBInsideA Flag to include paths from modelB which are inside of modelA.
|
2122 | * @param includeBOutsideA Flag to include paths from modelB which are outside of modelA.
|
2123 | * @param options Optional ICombineOptions object.
|
2124 | * @returns A new model containing both of the input models as "a" and "b".
|
2125 | */
|
2126 | function combine(modelA: IModel, modelB: IModel, includeAInsideB?: boolean, includeAOutsideB?: boolean, includeBInsideA?: boolean, includeBOutsideA?: boolean, options?: ICombineOptions): IModel;
|
2127 | /**
|
2128 | * Combine 2 models, resulting in a intersection. Each model will be modified accordingly.
|
2129 | *
|
2130 | * @param modelA First model to combine.
|
2131 | * @param modelB Second model to combine.
|
2132 | * @returns A new model containing both of the input models as "a" and "b".
|
2133 | */
|
2134 | function combineIntersection(modelA: IModel, modelB: IModel): IModel;
|
2135 | /**
|
2136 | * Combine 2 models, resulting in a subtraction of B from A. Each model will be modified accordingly.
|
2137 | *
|
2138 | * @param modelA First model to combine.
|
2139 | * @param modelB Second model to combine.
|
2140 | * @returns A new model containing both of the input models as "a" and "b".
|
2141 | */
|
2142 | function combineSubtraction(modelA: IModel, modelB: IModel): IModel;
|
2143 | /**
|
2144 | * Combine 2 models, resulting in a union. Each model will be modified accordingly.
|
2145 | *
|
2146 | * @param modelA First model to combine.
|
2147 | * @param modelB Second model to combine.
|
2148 | * @returns A new model containing both of the input models as "a" and "b".
|
2149 | */
|
2150 | function combineUnion(modelA: IModel, modelB: IModel): IModel;
|
2151 | }
|
2152 | declare namespace MakerJs {
|
2153 | /**
|
2154 | * Compare keys to see if they are equal.
|
2155 | */
|
2156 | interface ICollectionKeyComparer<K> {
|
2157 | (a: K, b: K): boolean;
|
2158 | }
|
2159 | /**
|
2160 | * A collection for items that share a common key.
|
2161 | */
|
2162 | interface ICollection<K, T> {
|
2163 | key: K;
|
2164 | items: T[];
|
2165 | }
|
2166 | /**
|
2167 | * Collects items that share a common key.
|
2168 | */
|
2169 | class Collector<K, T> {
|
2170 | private comparer?;
|
2171 | collections: ICollection<K, T>[];
|
2172 | constructor(comparer?: ICollectionKeyComparer<K>);
|
2173 | addItemToCollection(key: K, item: T): void;
|
2174 | findCollection(key: K, action?: (index: number) => void): T[];
|
2175 | removeCollection(key: K): boolean;
|
2176 | removeItemFromCollection(key: K, item: T): boolean;
|
2177 | getCollectionsOfMultiple(cb: (key: K, items: T[]) => void): void;
|
2178 | }
|
2179 | /**
|
2180 | * The element type stored in the index of a PointGraph.
|
2181 | */
|
2182 | interface IPointGraphIndexElement {
|
2183 | /**
|
2184 | * The point.
|
2185 | */
|
2186 | point: IPoint;
|
2187 | /**
|
2188 | * The id of this point.
|
2189 | */
|
2190 | pointId: number;
|
2191 | /**
|
2192 | * Array of other pointId's merged with this one.
|
2193 | */
|
2194 | merged?: number[];
|
2195 | /**
|
2196 | * Array of valueId's for this point.
|
2197 | */
|
2198 | valueIds: number[];
|
2199 | /**
|
2200 | * This point's ordinal position in the kd-tree.
|
2201 | */
|
2202 | kdId?: number;
|
2203 | }
|
2204 | /**
|
2205 | * A graph of items which may be located on the same points.
|
2206 | */
|
2207 | class PointGraph<T> {
|
2208 | /**
|
2209 | * Number of points inserted
|
2210 | */
|
2211 | insertedCount: number;
|
2212 | /**
|
2213 | * Map of unique points by x, then y, to a point id. This will remain intact even after merging.
|
2214 | */
|
2215 | graph: {
|
2216 | [x: number]: {
|
2217 | [y: number]: number;
|
2218 | };
|
2219 | };
|
2220 | /**
|
2221 | * Index of points by id.
|
2222 | */
|
2223 | index: {
|
2224 | [pointId: number]: IPointGraphIndexElement;
|
2225 | };
|
2226 | /**
|
2227 | * Map of point ids which once existed but have been merged into another id due to close proximity.
|
2228 | */
|
2229 | merged: {
|
2230 | [pointId: number]: number;
|
2231 | };
|
2232 | /**
|
2233 | * List of values inserted at points.
|
2234 | */
|
2235 | values: T[];
|
2236 | /**
|
2237 | * KD tree object.
|
2238 | */
|
2239 | private kdbush;
|
2240 | constructor();
|
2241 | /**
|
2242 | * Reset the stored points, graphs, lists, to initial state.
|
2243 | */
|
2244 | reset(): void;
|
2245 | /**
|
2246 | * Insert a value.
|
2247 | * @param value Value associated with this point.
|
2248 | * @returns valueId of the inserted value.
|
2249 | */
|
2250 | insertValue(value: T): number;
|
2251 | /**
|
2252 | * Insert a value at a point.
|
2253 | * @param p Point.
|
2254 | * @param value Value associated with this point.
|
2255 | */
|
2256 | insertValueIdAtPoint(valueId: number, p: IPoint): {
|
2257 | existed: boolean;
|
2258 | pointId: number;
|
2259 | };
|
2260 | /**
|
2261 | * Merge points within a given distance from each other. Call this after inserting values.
|
2262 | * @param withinDistance Distance to consider points equal.
|
2263 | */
|
2264 | mergePoints(withinDistance: number): void;
|
2265 | /**
|
2266 | * Finds all points which have only one value associated. Then, merge to the nearest other point within this set.
|
2267 | * Call this after inserting values.
|
2268 | * @param withinDistance Distance to consider points equal.
|
2269 | */
|
2270 | mergeNearestSinglePoints(withinDistance: number): void;
|
2271 | private mergeIndexElements;
|
2272 | /**
|
2273 | * Iterate over points in the index.
|
2274 | * @param cb Callback for each point in the index.
|
2275 | */
|
2276 | forEachPoint(cb: (p: IPoint, values: T[], pointId?: number, el?: IPointGraphIndexElement) => void): void;
|
2277 | /**
|
2278 | * Gets the id of a point, after merging.
|
2279 | * @param p Point to look up id.
|
2280 | */
|
2281 | getIdOfPoint(p: IPoint): number;
|
2282 | /**
|
2283 | * Get the index element of a point, after merging.
|
2284 | * @param p Point to look up index element.
|
2285 | */
|
2286 | getElementAtPoint(p: IPoint): IPointGraphIndexElement;
|
2287 | }
|
2288 | }
|
2289 | declare namespace MakerJs.model {
|
2290 | /**
|
2291 | * Simplify a model's paths by reducing redundancy: combine multiple overlapping paths into a single path. The model must be originated.
|
2292 | *
|
2293 | * @param modelContext The originated model to search for similar paths.
|
2294 | * @param options Optional options object.
|
2295 | * @returns The simplified model (for cascading).
|
2296 | */
|
2297 | function simplify(modelToSimplify: IModel, options?: ISimplifyOptions): IModel;
|
2298 | }
|
2299 | declare namespace MakerJs.path {
|
2300 | /**
|
2301 | * Expand path by creating a model which surrounds it.
|
2302 | *
|
2303 | * @param pathToExpand Path to expand.
|
2304 | * @param expansion Distance to expand.
|
2305 | * @param isolateCaps Optional flag to put the end caps into a separate model named "caps".
|
2306 | * @returns Model which surrounds the path.
|
2307 | */
|
2308 | function expand(pathToExpand: IPath, expansion: number, isolateCaps?: boolean): IModel;
|
2309 | /**
|
2310 | * Represent an arc using straight lines.
|
2311 | *
|
2312 | * @param arc Arc to straighten.
|
2313 | * @param bevel Optional flag to bevel the angle to prevent it from being too sharp.
|
2314 | * @param prefix Optional string prefix to apply to path ids.
|
2315 | * @param close Optional flag to make a closed geometry by connecting the endpoints.
|
2316 | * @returns Model of straight lines with same endpoints as the arc.
|
2317 | */
|
2318 | function straighten(arc: IPathArc, bevel?: boolean, prefix?: string, close?: boolean): IModel;
|
2319 | }
|
2320 | declare namespace MakerJs.model {
|
2321 | /**
|
2322 | * Expand all paths in a model, then combine the resulting expansions.
|
2323 | *
|
2324 | * @param modelToExpand Model to expand.
|
2325 | * @param distance Distance to expand.
|
2326 | * @param joints Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints.
|
2327 | * @param combineOptions Optional object containing combine options.
|
2328 | * @returns Model which surrounds the paths of the original model.
|
2329 | */
|
2330 | function expandPaths(modelToExpand: IModel, distance: number, joints?: number, combineOptions?: ICombineOptions): IModel;
|
2331 | /**
|
2332 | * Outline a model by a specified distance. Useful for accommodating for kerf.
|
2333 | *
|
2334 | * @param modelToOutline Model to outline.
|
2335 | * @param distance Distance to outline.
|
2336 | * @param joints Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints.
|
2337 | * @param inside Optional boolean to draw lines inside the model instead of outside.
|
2338 | * @param options Options to send to combine() function.
|
2339 | * @returns Model which surrounds the paths outside of the original model.
|
2340 | */
|
2341 | function outline(modelToOutline: IModel, distance: number, joints?: number, inside?: boolean, options?: ICombineOptions): IModel;
|
2342 | }
|
2343 | declare namespace MakerJs.units {
|
2344 | /**
|
2345 | * Get a conversion ratio between a source unit and a destination unit.
|
2346 | *
|
2347 | * @param srcUnitType unitType converting from.
|
2348 | * @param destUnitType unitType converting to.
|
2349 | * @returns Numeric ratio of the conversion.
|
2350 | */
|
2351 | function conversionScale(srcUnitType: string, destUnitType: string): number;
|
2352 | /**
|
2353 | * Check to see if unit type is a valid Maker.js unit.
|
2354 | *
|
2355 | * @param tryUnit unit type to check.
|
2356 | * @returns Boolean true if unit type is valid.
|
2357 | */
|
2358 | function isValidUnit(tryUnit: string): boolean;
|
2359 | }
|
2360 | declare namespace MakerJs.measure {
|
2361 | /**
|
2362 | * Find out if two angles are equal.
|
2363 | *
|
2364 | * @param angleA First angle.
|
2365 | * @param angleB Second angle.
|
2366 | * @returns true if angles are the same, false if they are not
|
2367 | */
|
2368 | function isAngleEqual(angleA: number, angleB: number, accuracy?: number): boolean;
|
2369 | /**
|
2370 | * Find out if two paths are equal.
|
2371 | *
|
2372 | * @param pathA First path.
|
2373 | * @param pathB Second path.
|
2374 | * @returns true if paths are the same, false if they are not
|
2375 | */
|
2376 | function isPathEqual(pathA: IPath, pathB: IPath, withinPointDistance?: number, pathAOffset?: IPoint, pathBOffset?: IPoint): boolean;
|
2377 | /**
|
2378 | * Find out if two points are equal.
|
2379 | *
|
2380 | * @param a First point.
|
2381 | * @param b Second point.
|
2382 | * @param withinDistance Optional distance to consider points equal.
|
2383 | * @returns true if points are the same, false if they are not
|
2384 | */
|
2385 | function isPointEqual(a: IPoint, b: IPoint, withinDistance?: number): boolean;
|
2386 | /**
|
2387 | * Find out if a point is distinct among an array of points.
|
2388 | *
|
2389 | * @param pointToCheck point to check.
|
2390 | * @param pointArray array of points.
|
2391 | * @param withinDistance Optional distance to consider points equal.
|
2392 | * @returns false if point is equal to any point in the array.
|
2393 | */
|
2394 | function isPointDistinct(pointToCheck: IPoint, pointArray: IPoint[], withinDistance?: number): boolean;
|
2395 | /**
|
2396 | * Find out if point is on a slope.
|
2397 | *
|
2398 | * @param p Point to check.
|
2399 | * @param b Slope.
|
2400 | * @param withinDistance Optional distance of tolerance.
|
2401 | * @returns true if point is on the slope
|
2402 | */
|
2403 | function isPointOnSlope(p: IPoint, slope: ISlope, withinDistance?: number): boolean;
|
2404 | /**
|
2405 | * Find out if point is on a circle.
|
2406 | *
|
2407 | * @param p Point to check.
|
2408 | * @param circle Circle.
|
2409 | * @param withinDistance Optional distance of tolerance.
|
2410 | * @returns true if point is on the circle
|
2411 | */
|
2412 | function isPointOnCircle(p: IPoint, circle: IPathCircle, withinDistance?: number): boolean;
|
2413 | /**
|
2414 | * Find out if a point lies on a path.
|
2415 | * @param pointToCheck point to check.
|
2416 | * @param onPath path to check against.
|
2417 | * @param withinDistance Optional distance to consider point on the path.
|
2418 | * @param pathOffset Optional offset of path from [0, 0].
|
2419 | * @param options Optional IIsPointOnPathOptions to cache computation.
|
2420 | */
|
2421 | function isPointOnPath(pointToCheck: IPoint, onPath: IPath, withinDistance?: number, pathOffset?: IPoint, options?: IIsPointOnPathOptions): boolean;
|
2422 | /**
|
2423 | * Check for slope equality.
|
2424 | *
|
2425 | * @param slopeA The ISlope to test.
|
2426 | * @param slopeB The ISlope to check for equality.
|
2427 | * @returns Boolean true if slopes are equal.
|
2428 | */
|
2429 | function isSlopeEqual(slopeA: ISlope, slopeB: ISlope): boolean;
|
2430 | /**
|
2431 | * Check for parallel slopes.
|
2432 | *
|
2433 | * @param slopeA The ISlope to test.
|
2434 | * @param slopeB The ISlope to check for parallel.
|
2435 | * @returns Boolean true if slopes are parallel.
|
2436 | */
|
2437 | function isSlopeParallel(slopeA: ISlope, slopeB: ISlope): boolean;
|
2438 | }
|
2439 | declare namespace MakerJs.measure {
|
2440 | /**
|
2441 | * Increase a measurement by an additional measurement.
|
2442 | *
|
2443 | * @param baseMeasure The measurement to increase.
|
2444 | * @param addMeasure The additional measurement.
|
2445 | * @param augmentBaseMeasure Optional flag to call measure.augment on the measurement.
|
2446 | * @returns The increased original measurement (for cascading).
|
2447 | */
|
2448 | function increase(baseMeasure: IMeasure, addMeasure: IMeasure, augmentBaseMeasure?: boolean): IMeasure;
|
2449 | /**
|
2450 | * Check for arc being concave or convex towards a given point.
|
2451 | *
|
2452 | * @param arc The arc to test.
|
2453 | * @param towardsPoint The point to test.
|
2454 | * @returns Boolean true if arc is concave towards point.
|
2455 | */
|
2456 | function isArcConcaveTowardsPoint(arc: IPathArc, towardsPoint: IPoint): boolean;
|
2457 | /**
|
2458 | * DEPRECATED - use isArcSpanOverlapping() instead.
|
2459 | */
|
2460 | function isArcOverlapping(arcA: IPathArc, arcB: IPathArc, excludeTangents: boolean): boolean;
|
2461 | /**
|
2462 | * Check for arc overlapping another arc.
|
2463 | *
|
2464 | * @param arcA The arc to test.
|
2465 | * @param arcB The arc to check for overlap.
|
2466 | * @param excludeTangents Boolean to exclude exact endpoints and only look for deep overlaps.
|
2467 | * @returns Boolean true if arcA is overlapped with arcB.
|
2468 | */
|
2469 | function isArcSpanOverlapping(arcA: IPathArc, arcB: IPathArc, excludeTangents: boolean): boolean;
|
2470 | /**
|
2471 | * Check if a given number is between two given limits.
|
2472 | *
|
2473 | * @param valueInQuestion The number to test.
|
2474 | * @param limitA First limit.
|
2475 | * @param limitB Second limit.
|
2476 | * @param exclusive Flag to exclude equaling the limits.
|
2477 | * @returns Boolean true if value is between (or equal to) the limits.
|
2478 | */
|
2479 | function isBetween(valueInQuestion: number, limitA: number, limitB: number, exclusive: boolean): boolean;
|
2480 | /**
|
2481 | * Check if a given angle is between an arc's start and end angles.
|
2482 | *
|
2483 | * @param angleInQuestion The angle to test.
|
2484 | * @param arc Arc to test against.
|
2485 | * @param exclusive Flag to exclude equaling the start or end angles.
|
2486 | * @returns Boolean true if angle is between (or equal to) the arc's start and end angles.
|
2487 | */
|
2488 | function isBetweenArcAngles(angleInQuestion: number, arc: IPathArc, exclusive: boolean): boolean;
|
2489 | /**
|
2490 | * Check if a given point is between a line's end points.
|
2491 | *
|
2492 | * @param pointInQuestion The point to test.
|
2493 | * @param line Line to test against.
|
2494 | * @param exclusive Flag to exclude equaling the origin or end points.
|
2495 | * @returns Boolean true if point is between (or equal to) the line's origin and end points.
|
2496 | */
|
2497 | function isBetweenPoints(pointInQuestion: IPoint, line: IPathLine, exclusive: boolean): boolean;
|
2498 | /**
|
2499 | * Check if a given bezier seed has all points on the same slope.
|
2500 | *
|
2501 | * @param seed The bezier seed to test.
|
2502 | * @param exclusive Optional boolean to test only within the boundary of the endpoints.
|
2503 | * @returns Boolean true if bezier seed has control points on the line slope and between the line endpoints.
|
2504 | */
|
2505 | function isBezierSeedLinear(seed: IPathBezierSeed, exclusive?: boolean): boolean;
|
2506 | /**
|
2507 | * Check for flow of paths in a chain being clockwise or not.
|
2508 | *
|
2509 | * @param chainContext The chain to test.
|
2510 | * @param out_result Optional output object, if provided, will be populated with convex hull results.
|
2511 | * @returns Boolean true if paths in the chain flow clockwise.
|
2512 | */
|
2513 | function isChainClockwise(chainContext: IChain, out_result?: {
|
2514 | hullPoints?: IPoint[];
|
2515 | keyPoints?: IPoint[];
|
2516 | }): boolean;
|
2517 | /**
|
2518 | * Check for array of points being clockwise or not.
|
2519 | *
|
2520 | * @param points The array of points to test.
|
2521 | * @param out_result Optional output object, if provided, will be populated with convex hull results.
|
2522 | * @returns Boolean true if points flow clockwise.
|
2523 | */
|
2524 | function isPointArrayClockwise(points: IPoint[], out_result?: {
|
2525 | hullPoints?: IPoint[];
|
2526 | keyPoints?: IPoint[];
|
2527 | }): boolean;
|
2528 | /**
|
2529 | * Check for line overlapping another line.
|
2530 | *
|
2531 | * @param lineA The line to test.
|
2532 | * @param lineB The line to check for overlap.
|
2533 | * @param excludeTangents Boolean to exclude exact endpoints and only look for deep overlaps.
|
2534 | * @returns Boolean true if lineA is overlapped with lineB.
|
2535 | */
|
2536 | function isLineOverlapping(lineA: IPathLine, lineB: IPathLine, excludeTangents: boolean): boolean;
|
2537 | /**
|
2538 | * Check for measurement overlapping another measurement.
|
2539 | *
|
2540 | * @param measureA The measurement to test.
|
2541 | * @param measureB The measurement to check for overlap.
|
2542 | * @returns Boolean true if measureA is overlapped with measureB.
|
2543 | */
|
2544 | function isMeasurementOverlapping(measureA: IMeasure, measureB: IMeasure): boolean;
|
2545 | /**
|
2546 | * Gets the slope of a line.
|
2547 | */
|
2548 | function lineSlope(line: IPathLine): ISlope;
|
2549 | /**
|
2550 | * Calculates the distance between two points.
|
2551 | *
|
2552 | * @param a First point.
|
2553 | * @param b Second point.
|
2554 | * @returns Distance between points.
|
2555 | */
|
2556 | function pointDistance(a: IPoint, b: IPoint): number;
|
2557 | /**
|
2558 | * Calculates the smallest rectangle which contains a path.
|
2559 | *
|
2560 | * @param pathToMeasure The path to measure.
|
2561 | * @returns object with low and high points.
|
2562 | */
|
2563 | function pathExtents(pathToMeasure: IPath, addOffset?: IPoint): IMeasure;
|
2564 | /**
|
2565 | * Measures the length of a path.
|
2566 | *
|
2567 | * @param pathToMeasure The path to measure.
|
2568 | * @returns Length of the path.
|
2569 | */
|
2570 | function pathLength(pathToMeasure: IPath): number;
|
2571 | /**
|
2572 | * Measures the length of all paths in a model.
|
2573 | *
|
2574 | * @param modelToMeasure The model containing paths to measure.
|
2575 | * @returns Length of all paths in the model.
|
2576 | */
|
2577 | function modelPathLength(modelToMeasure: IModel): number;
|
2578 | /**
|
2579 | * Measures the smallest rectangle which contains a model.
|
2580 | *
|
2581 | * @param modelToMeasure The model to measure.
|
2582 | * @param atlas Optional atlas to save measurements.
|
2583 | * @returns object with low and high points.
|
2584 | */
|
2585 | function modelExtents(modelToMeasure: IModel, atlas?: Atlas): IMeasureWithCenter;
|
2586 | /**
|
2587 | * Augment a measurement - add more properties such as center point, height and width.
|
2588 | *
|
2589 | * @param measureToAugment The measurement to augment.
|
2590 | * @returns Measurement object with augmented properties.
|
2591 | */
|
2592 | function augment(measureToAugment: IMeasure): IMeasureWithCenter;
|
2593 | /**
|
2594 | * A list of maps of measurements.
|
2595 | *
|
2596 | * @param modelToMeasure The model to measure.
|
2597 | * @param atlas Optional atlas to save measurements.
|
2598 | * @returns object with low and high points.
|
2599 | */
|
2600 | class Atlas {
|
2601 | modelContext: IModel;
|
2602 | /**
|
2603 | * Flag that models have been measured.
|
2604 | */
|
2605 | modelsMeasured: boolean;
|
2606 | /**
|
2607 | * Map of model measurements, mapped by routeKey.
|
2608 | */
|
2609 | modelMap: IMeasureMap;
|
2610 | /**
|
2611 | * Map of path measurements, mapped by routeKey.
|
2612 | */
|
2613 | pathMap: IMeasureMap;
|
2614 | /**
|
2615 | * Constructor.
|
2616 | * @param modelContext The model to measure.
|
2617 | */
|
2618 | constructor(modelContext: IModel);
|
2619 | measureModels(): void;
|
2620 | }
|
2621 | /**
|
2622 | * Measures the minimum bounding hexagon surrounding a model. The hexagon is oriented such that the right and left sides are vertical, and the top and bottom are pointed.
|
2623 | *
|
2624 | * @param modelToMeasure The model to measure.
|
2625 | * @returns IBoundingHex object which is a hexagon model, with an additional radius property.
|
2626 | */
|
2627 | function boundingHexagon(modelToMeasure: IModel): IBoundingHex;
|
2628 | /**
|
2629 | * Check to see if a point is inside of a model.
|
2630 | *
|
2631 | * @param pointToCheck The point to check.
|
2632 | * @param modelContext The model to check against.
|
2633 | * @param options Optional IMeasurePointInsideOptions object.
|
2634 | * @returns Boolean true if the path is inside of the modelContext.
|
2635 | */
|
2636 | function isPointInsideModel(pointToCheck: IPoint, modelContext: IModel, options?: IMeasurePointInsideOptions): boolean;
|
2637 | }
|
2638 | declare namespace MakerJs.exporter {
|
2639 | /**
|
2640 | * @private
|
2641 | */
|
2642 | interface IExportOptions {
|
2643 | /**
|
2644 | * Optional exemplar of number of decimal places.
|
2645 | */
|
2646 | accuracy?: number;
|
2647 | /**
|
2648 | * Optional unit system to embed in exported file, if the export format allows alternate unit systems.
|
2649 | */
|
2650 | units?: string;
|
2651 | }
|
2652 | /**
|
2653 | * Options for JSON export.
|
2654 | */
|
2655 | interface IJsonExportOptions extends IExportOptions {
|
2656 | /**
|
2657 | * Optional number of characters to indent after a newline.
|
2658 | */
|
2659 | indentation?: number;
|
2660 | }
|
2661 | /**
|
2662 | * Renders an item in JSON.
|
2663 | *
|
2664 | * @param itemToExport Item to render: may be a path, an array of paths, or a model object.
|
2665 | * @param options Rendering options object.
|
2666 | * @param options.accuracy Optional exemplar of number of decimal places.
|
2667 | * @param options.indentation Optional number of characters to indent after a newline.
|
2668 | * @returns String of DXF content.
|
2669 | */
|
2670 | function toJson(itemToExport: any, options?: MakerJs.exporter.IJsonExportOptions): string;
|
2671 | /**
|
2672 | * Try to get the unit system from a model
|
2673 | * @private
|
2674 | */
|
2675 | function tryGetModelUnits(itemToExport: any): string;
|
2676 | /**
|
2677 | * Named colors, safe for CSS and DXF
|
2678 | * 17 colors from https://www.w3.org/TR/CSS21/syndata.html#value-def-color mapped to DXF equivalent AutoDesk Color Index
|
2679 | */
|
2680 | var colors: {
|
2681 | black: number;
|
2682 | red: number;
|
2683 | yellow: number;
|
2684 | lime: number;
|
2685 | aqua: number;
|
2686 | blue: number;
|
2687 | fuchsia: number;
|
2688 | white: number;
|
2689 | gray: number;
|
2690 | maroon: number;
|
2691 | orange: number;
|
2692 | olive: number;
|
2693 | green: number;
|
2694 | teal: number;
|
2695 | navy: number;
|
2696 | purple: number;
|
2697 | silver: number;
|
2698 | };
|
2699 | interface IStatusCallback {
|
2700 | (status: {
|
2701 | progress?: number;
|
2702 | }): void;
|
2703 | }
|
2704 | }
|
2705 | declare namespace MakerJs.importer {
|
2706 | /**
|
2707 | * Create a numeric array from a string of numbers. The numbers may be delimited by anything non-numeric.
|
2708 | *
|
2709 | * Example:
|
2710 | * ```
|
2711 | * var n = makerjs.importer.parseNumericList('5, 10, 15.20 25-30-35 4e1 .5');
|
2712 | * ```
|
2713 | *
|
2714 | * @param s The string of numbers.
|
2715 | * @returns Array of numbers.
|
2716 | */
|
2717 | function parseNumericList(s: string): number[];
|
2718 | }
|
2719 | declare namespace MakerJs.exporter {
|
2720 | function toDXF(modelToExport: IModel, options?: IDXFRenderOptions): string;
|
2721 | function toDXF(pathsToExport: IPath[], options?: IDXFRenderOptions): string;
|
2722 | function toDXF(pathToExport: IPath, options?: IDXFRenderOptions): string;
|
2723 | /**
|
2724 | * DXF layer options.
|
2725 | */
|
2726 | interface IDXFLayerOptions {
|
2727 | /**
|
2728 | * DXF layer color.
|
2729 | */
|
2730 | color: number;
|
2731 | }
|
2732 | /**
|
2733 | * DXF rendering options.
|
2734 | */
|
2735 | interface IDXFRenderOptions extends IExportOptions, IPointMatchOptions {
|
2736 | /**
|
2737 | * Text size for MTEXT entities.
|
2738 | */
|
2739 | fontSize?: number;
|
2740 | /**
|
2741 | * DXF options per layer.
|
2742 | */
|
2743 | layerOptions?: {
|
2744 | [layerId: string]: IDXFLayerOptions;
|
2745 | };
|
2746 | /**
|
2747 | * Flag to use POLYLINE
|
2748 | */
|
2749 | usePOLYLINE?: boolean;
|
2750 | }
|
2751 | }
|
2752 | declare namespace MakerJs.solvers {
|
2753 | /**
|
2754 | * Solves for the altitude of an equilateral triangle when you know its side length.
|
2755 | *
|
2756 | * @param sideLength Length of a side of the equilateral triangle (all 3 sides are equal).
|
2757 | * @returns Altitude of the equilateral triangle.
|
2758 | */
|
2759 | function equilateralAltitude(sideLength: number): number;
|
2760 | /**
|
2761 | * Solves for the side length of an equilateral triangle when you know its altitude.
|
2762 | *
|
2763 | * @param altitude Altitude of the equilateral triangle.
|
2764 | * @returns Length of the side of the equilateral triangle (all 3 sides are equal).
|
2765 | */
|
2766 | function equilateralSide(altitude: number): number;
|
2767 | /**
|
2768 | * Solves for the angle of a triangle when you know lengths of 3 sides.
|
2769 | *
|
2770 | * @param lengthA Length of side of triangle, opposite of the angle you are trying to find.
|
2771 | * @param lengthB Length of any other side of the triangle.
|
2772 | * @param lengthC Length of the remaining side of the triangle.
|
2773 | * @returns Angle opposite of the side represented by the first parameter.
|
2774 | */
|
2775 | function solveTriangleSSS(lengthA: number, lengthB: number, lengthC: number): number;
|
2776 | /**
|
2777 | * Solves for the length of a side of a triangle when you know length of one side and 2 angles.
|
2778 | *
|
2779 | * @param oppositeAngleInDegrees Angle which is opposite of the side you are trying to find.
|
2780 | * @param lengthOfSideBetweenAngles Length of one side of the triangle which is between the provided angles.
|
2781 | * @param otherAngleInDegrees An other angle of the triangle.
|
2782 | * @returns Length of the side of the triangle which is opposite of the first angle parameter.
|
2783 | */
|
2784 | function solveTriangleASA(oppositeAngleInDegrees: number, lengthOfSideBetweenAngles: number, otherAngleInDegrees: number): number;
|
2785 | /**
|
2786 | * Solves for the angles of the tangent lines between 2 circles.
|
2787 | *
|
2788 | * @param a First circle.
|
2789 | * @param b Second circle.
|
2790 | * @param inner Boolean to use inner tangents instead of outer tangents.
|
2791 | * @returns Array of angles in degrees where 2 lines between the circles will be tangent to both circles.
|
2792 | */
|
2793 | function circleTangentAngles(a: IPathCircle, b: IPathCircle, inner?: boolean): number[];
|
2794 | }
|
2795 | declare namespace MakerJs.path {
|
2796 | /**
|
2797 | * Find the point(s) where 2 paths intersect.
|
2798 | *
|
2799 | * @param path1 First path to find intersection.
|
2800 | * @param path2 Second path to find intersection.
|
2801 | * @param options Optional IPathIntersectionOptions.
|
2802 | * @returns IPathIntersection object, with points(s) of intersection (and angles, when a path is an arc or circle); or null if the paths did not intersect.
|
2803 | */
|
2804 | function intersection(path1: IPath, path2: IPath, options?: IPathIntersectionOptions): IPathIntersection;
|
2805 | }
|
2806 | declare namespace MakerJs.path {
|
2807 | /**
|
2808 | * Adds a round corner to the outside angle between 2 lines. The lines must meet at one point.
|
2809 | *
|
2810 | * @param lineA First line to fillet, which will be modified to fit the fillet.
|
2811 | * @param lineB Second line to fillet, which will be modified to fit the fillet.
|
2812 | * @returns Arc path object of the new fillet.
|
2813 | */
|
2814 | function dogbone(lineA: IPathLine, lineB: IPathLine, filletRadius: number, options?: IPointMatchOptions): IPathArc;
|
2815 | /**
|
2816 | * Adds a round corner to the inside angle between 2 paths. The paths must meet at one point.
|
2817 | *
|
2818 | * @param pathA First path to fillet, which will be modified to fit the fillet.
|
2819 | * @param pathB Second path to fillet, which will be modified to fit the fillet.
|
2820 | * @param filletRadius Radius of the fillet.
|
2821 | * @param options Optional IPointMatchOptions object to specify pointMatchingDistance.
|
2822 | * @returns Arc path object of the new fillet.
|
2823 | */
|
2824 | function fillet(pathA: IPath, pathB: IPath, filletRadius: number, options?: IPointMatchOptions): IPathArc;
|
2825 | }
|
2826 | declare namespace MakerJs.chain {
|
2827 | /**
|
2828 | * Adds a dogbone fillet between each link in a chain. Each path will be cropped to fit a fillet, and all fillets will be returned as paths in a returned model object.
|
2829 | *
|
2830 | * @param chainToFillet The chain to add fillets to.
|
2831 | * @param filletRadius Radius of the fillet.
|
2832 | * @returns Model object containing paths which fillet the joints in the chain.
|
2833 | */
|
2834 | function dogbone(chainToFillet: IChain, filletRadius: number): IModel;
|
2835 | /**
|
2836 | * Adds a dogbone fillet between each link in a chain. Each path will be cropped to fit a fillet, and all fillets will be returned as paths in a returned model object.
|
2837 | *
|
2838 | * @param chainToFillet The chain to add fillets to.
|
2839 | * @param filletRadii Object specifying directional radii.
|
2840 | * @param filletRadii.left Radius of left turning fillets.
|
2841 | * @param filletRadii.right Radius of right turning fillets.
|
2842 | * @returns Model object containing paths which fillet the joints in the chain.
|
2843 | */
|
2844 | function dogbone(chainToFillet: IChain, filletRadii: {
|
2845 | left?: number;
|
2846 | right?: number;
|
2847 | }): IModel;
|
2848 | /**
|
2849 | * Adds a fillet between each link in a chain. Each path will be cropped to fit a fillet, and all fillets will be returned as paths in a returned model object.
|
2850 | *
|
2851 | * @param chainToFillet The chain to add fillets to.
|
2852 | * @param filletRadius Radius of the fillet.
|
2853 | * @returns Model object containing paths which fillet the joints in the chain.
|
2854 | */
|
2855 | function fillet(chainToFillet: IChain, filletRadius: number): IModel;
|
2856 | /**
|
2857 | * Adds a fillet between each link in a chain. Each path will be cropped to fit a fillet, and all fillets will be returned as paths in a returned model object.
|
2858 | *
|
2859 | * @param chainToFillet The chain to add fillets to.
|
2860 | * @param filletRadii Object specifying directional radii.
|
2861 | * @param filletRadii.left Radius of left turning fillets.
|
2862 | * @param filletRadii.right Radius of right turning fillets.
|
2863 | * @returns Model object containing paths which fillet the joints in the chain.
|
2864 | */
|
2865 | function fillet(chainToFillet: IChain, filletRadii: {
|
2866 | left?: number;
|
2867 | right?: number;
|
2868 | }): IModel;
|
2869 | }
|
2870 | declare namespace MakerJs.kit {
|
2871 | /**
|
2872 | * Helper function to use the JavaScript "apply" function in conjunction with the "new" keyword.
|
2873 | *
|
2874 | * @param ctor The constructor for the class which is an IKit.
|
2875 | * @param args The array of parameters passed to the constructor.
|
2876 | * @returns A new instance of the class, which implements the IModel interface.
|
2877 | */
|
2878 | function construct(ctor: IKit, args: any): IModel;
|
2879 | /**
|
2880 | * Extract just the initial sample values from a kit.
|
2881 | *
|
2882 | * @param ctor The constructor for the class which is an IKit.
|
2883 | * @returns Array of the inital sample values provided in the metaParameters array.
|
2884 | */
|
2885 | function getParameterValues(ctor: IKit): any[];
|
2886 | }
|
2887 | declare namespace MakerJs.model {
|
2888 | /**
|
2889 | * Find a single chain within a model, across all layers. Shorthand of findChains; useful when you know there is only one chain to find in your model.
|
2890 | *
|
2891 | * @param modelContext The model to search for a chain.
|
2892 | * @returns A chain object or null if chains were not found.
|
2893 | */
|
2894 | function findSingleChain(modelContext: IModel): IChain;
|
2895 | /**
|
2896 | * Find paths that have common endpoints and form chains.
|
2897 | *
|
2898 | * @param modelContext The model to search for chains.
|
2899 | * @param options Optional options object.
|
2900 | * @returns An array of chains, or a map (keyed by layer id) of arrays of chains - if options.byLayers is true.
|
2901 | */
|
2902 | function findChains(modelContext: IModel, options?: IFindChainsOptions): IChain[] | IChainsMap;
|
2903 | /**
|
2904 | * Find paths that have common endpoints and form chains.
|
2905 | *
|
2906 | * @param modelContext The model to search for chains.
|
2907 | * @param callback Callback function when chains are found.
|
2908 | * @param options Optional options object.
|
2909 | * @returns An array of chains, or a map (keyed by layer id) of arrays of chains - if options.byLayers is true.
|
2910 | */
|
2911 | function findChains(modelContext: IModel, callback: IChainCallback, options?: IFindChainsOptions): IChain[] | IChainsMap;
|
2912 | }
|
2913 | declare namespace MakerJs.chain {
|
2914 | /**
|
2915 | * Shift the links of an endless chain.
|
2916 | *
|
2917 | * @param chainContext Chain to cycle through. Must be endless.
|
2918 | * @param amount Optional number of links to shift. May be negative to cycle backwards.
|
2919 | * @returns The chainContext for cascading.
|
2920 | */
|
2921 | function cycle(chainContext: IChain, amount?: number): IChain;
|
2922 | /**
|
2923 | * Reverse the links of a chain.
|
2924 | *
|
2925 | * @param chainContext Chain to reverse.
|
2926 | * @returns The chainContext for cascading.
|
2927 | */
|
2928 | function reverse(chainContext: IChain): IChain;
|
2929 | /**
|
2930 | * Set the beginning of an endless chain to a known routeKey of a path.
|
2931 | *
|
2932 | * @param chainContext Chain to cycle through. Must be endless.
|
2933 | * @param routeKey RouteKey of the desired path to start the chain with.
|
2934 | * @returns The chainContext for cascading.
|
2935 | */
|
2936 | function startAt(chainContext: IChain, routeKey: string): IChain;
|
2937 | /**
|
2938 | * Convert a chain to a new model, independent of any model from where the chain was found.
|
2939 | *
|
2940 | * @param chainContext Chain to convert to a model.
|
2941 | * @param detachFromOldModel Flag to remove the chain's paths from their current parent model. If false, each path will be cloned. If true, the original path will be re-parented into the resulting new model. Default is false.
|
2942 | * @returns A new model containing paths from the chain.
|
2943 | */
|
2944 | function toNewModel(chainContext: IChain, detachFromOldModel?: boolean): IModel;
|
2945 | /**
|
2946 | * Get points along a chain of paths.
|
2947 | *
|
2948 | * @param chainContext Chain of paths to get points from.
|
2949 | * @param distance Numeric distance along the chain between points, or numeric array of distances along the chain between each point.
|
2950 | * @param maxPoints Maximum number of points to retrieve.
|
2951 | * @returns Array of points which are on the chain spread at a uniform interval.
|
2952 | */
|
2953 | function toPoints(chainContext: IChain, distanceOrDistances: number | number[], maxPoints?: number): IPoint[];
|
2954 | /**
|
2955 | * Get key points (a minimal a number of points) along a chain of paths.
|
2956 | *
|
2957 | * @param chainContext Chain of paths to get points from.
|
2958 | * @param maxArcFacet The maximum length between points on an arc or circle.
|
2959 | * @returns Array of points which are on the chain.
|
2960 | */
|
2961 | function toKeyPoints(chainContext: IChain, maxArcFacet?: number): IPoint[];
|
2962 | }
|
2963 | declare namespace MakerJs.model {
|
2964 | /**
|
2965 | * Remove paths from a model which have endpoints that do not connect to other paths.
|
2966 | *
|
2967 | * @param modelContext The model to search for dead ends.
|
2968 | * @param pointMatchingDistance Optional max distance to consider two points as the same.
|
2969 | * @param keep Optional callback function (which should return a boolean) to decide if a dead end path should be kept instead.
|
2970 | * @param trackDeleted Optional callback function which will log discarded paths and the reason they were discarded.
|
2971 | * @returns The input model (for cascading).
|
2972 | */
|
2973 | function removeDeadEnds(modelContext: IModel, pointMatchingDistance?: number, keep?: IWalkPathBooleanCallback, trackDeleted?: (wp: IWalkPath, reason: string) => void): IModel;
|
2974 | }
|
2975 | declare namespace MakerJs.exporter {
|
2976 | /**
|
2977 | * Attributes for an XML tag.
|
2978 | * @private
|
2979 | */
|
2980 | interface IXmlTagAttrs {
|
2981 | [name: string]: any;
|
2982 | }
|
2983 | /**
|
2984 | * Class for an XML tag.
|
2985 | * @private
|
2986 | */
|
2987 | class XmlTag {
|
2988 | name: string;
|
2989 | attrs?: IXmlTagAttrs;
|
2990 | /**
|
2991 | * Text between the opening and closing tags.
|
2992 | */
|
2993 | innerText: string;
|
2994 | /**
|
2995 | * Boolean to indicate that the innerText has been escaped.
|
2996 | */
|
2997 | innerTextEscaped: boolean;
|
2998 | /**
|
2999 | * Flag to explicitly close XML tags.
|
3000 | */
|
3001 | closingTags?: boolean;
|
3002 | /**
|
3003 | * Escapes certain characters within a string so that it can appear in a tag or its attribute.
|
3004 | *
|
3005 | * @returns Escaped string.
|
3006 | */
|
3007 | static escapeString(value: string): string;
|
3008 | /**
|
3009 | * @param name Name of the XML tag.
|
3010 | * @param attrs Optional attributes for the tag.
|
3011 | */
|
3012 | constructor(name: string, attrs?: IXmlTagAttrs);
|
3013 | /**
|
3014 | * Get the opening tag.
|
3015 | *
|
3016 | * @param selfClose Flag to determine if opening tag should be self closing.
|
3017 | */
|
3018 | getOpeningTag(selfClose: boolean): string;
|
3019 | /**
|
3020 | * Get the inner text.
|
3021 | */
|
3022 | getInnerText(): string;
|
3023 | /**
|
3024 | * Get the closing tag.
|
3025 | */
|
3026 | getClosingTag(): string;
|
3027 | /**
|
3028 | * Output the entire tag as a string.
|
3029 | */
|
3030 | toString(): string;
|
3031 | }
|
3032 | }
|
3033 | declare namespace MakerJs.exporter {
|
3034 | /**
|
3035 | * Converts a model to a @jscad/csg CAG object - 2D to 2D. See https://en.wikibooks.org/wiki/OpenJSCAD_User_Guide#2D_Paths
|
3036 | *
|
3037 | * Example:
|
3038 | * ```
|
3039 | * //First, use npm install @jscad/csg from the command line in your jscad project
|
3040 | * //Create a CAG instance from a model.
|
3041 | * var { CAG } = require('@jscad/csg');
|
3042 | * var model = new makerjs.models.Ellipse(70, 40);
|
3043 | * var cag = makerjs.exporter.toJscadCAG(CAG, model, {maxArcFacet: 1});
|
3044 | * ```
|
3045 | *
|
3046 | * @param jscadCAG @jscad/csg CAG engine, see https://www.npmjs.com/package/@jscad/csg
|
3047 | * @param modelToExport Model object to export.
|
3048 | * @param options Optional options object.
|
3049 | * @param options.byLayers Optional flag to separate chains by layers.
|
3050 | * @param options.pointMatchingDistance Optional max distance to consider two points as the same.
|
3051 | * @param options.maxArcFacet The maximum length between points on an arc or circle.
|
3052 | * @param options.statusCallback Optional callback function to get the percentage complete.
|
3053 | * @returns jscad CAG object in 2D, or a map (keyed by layer id) of jscad CAG objects - if options.byLayers is true.
|
3054 | */
|
3055 | function toJscadCAG(jscadCAG: typeof jscad.CAG, modelToExport: IModel, jsCadCagOptions?: IJscadCagOptions): jscad.CAG | {
|
3056 | [layerId: string]: jscad.CAG;
|
3057 | };
|
3058 | /**
|
3059 | * Converts a model to a @jscad/csg CSG object - 2D to 3D.
|
3060 | *
|
3061 | * Example:
|
3062 | * ```
|
3063 | * //First, use npm install @jscad/csg from the command line in your jscad project
|
3064 | * //Create a CSG instance from a model.
|
3065 | * var { CAG } = require('@jscad/csg');
|
3066 | * var model = new makerjs.models.Ellipse(70, 40);
|
3067 | * var csg = makerjs.exporter.toJscadCSG(CAG, model, {maxArcFacet: 1, extrude: 10});
|
3068 | * ```
|
3069 | *
|
3070 | * @param jscadCAG @jscad/csg CAG engine, see https://www.npmjs.com/package/@jscad/csg
|
3071 | * @param modelToExport Model object to export.
|
3072 | * @param options Optional options object.
|
3073 | * @param options.byLayers Optional flag to separate chains by layers.
|
3074 | * @param options.pointMatchingDistance Optional max distance to consider two points as the same.
|
3075 | * @param options.maxArcFacet The maximum length between points on an arc or circle.
|
3076 | * @param options.statusCallback Optional callback function to get the percentage complete.
|
3077 | * @param options.extrude Optional default extrusion distance.
|
3078 | * @param options.layerOptions Optional object map of options per layer, keyed by layer name. Each value for a key is an object with 'extrude' and 'z' properties.
|
3079 | * @returns jscad CAG object in 2D, or a map (keyed by layer id) of jscad CAG objects - if options.byLayers is true.
|
3080 | */
|
3081 | function toJscadCSG(jscadCAG: typeof jscad.CAG, modelToExport: IModel, options?: IJscadCsgOptions): jscad.CSG;
|
3082 | /**
|
3083 | * Creates a string of JavaScript code for execution with a Jscad environment.
|
3084 | *
|
3085 | * @param modelToExport Model object to export.
|
3086 | * @param options Export options object.
|
3087 | * @param options.byLayers Optional flag to separate chains by layers.
|
3088 | * @param options.pointMatchingDistance Optional max distance to consider two points as the same.
|
3089 | * @param options.maxArcFacet The maximum length between points on an arc or circle.
|
3090 | * @param options.statusCallback Optional callback function to get the percentage complete.
|
3091 | * @param options.extrude Optional default extrusion distance.
|
3092 | * @param options.layerOptions Optional object map of options per layer, keyed by layer name. Each value for a key is an object with 'extrude' and 'z' properties.
|
3093 | * @returns String of JavaScript containing a main() function for Jscad.
|
3094 | */
|
3095 | function toJscadScript(modelToExport: IModel, options?: IJscadScriptOptions): string;
|
3096 | /**
|
3097 | * Exports a model in STL format - 2D to 3D.
|
3098 | *
|
3099 | * @param jscadCAG @jscad/csg CAG engine, see https://www.npmjs.com/package/@jscad/csg
|
3100 | * @param stlSerializer @jscad/stl-serializer, see https://www.npmjs.com/package/@jscad/stl-serializer
|
3101 | * @param modelToExport Model object to export.
|
3102 | * @param options Optional options object.
|
3103 | * @param options.byLayers Optional flag to separate chains by layers.
|
3104 | * @param options.pointMatchingDistance Optional max distance to consider two points as the same.
|
3105 | * @param options.maxArcFacet The maximum length between points on an arc or circle.
|
3106 | * @param options.statusCallback Optional callback function to get the percentage complete.
|
3107 | * @param options.extrude Optional default extrusion distance.
|
3108 | * @param options.layerOptions Optional object map of options per layer, keyed by layer name. Each value for a key is an object with 'extrude' and 'z' properties.
|
3109 | * @returns String in STL ASCII format.
|
3110 | */
|
3111 | function toJscadSTL(CAG: typeof jscad.CAG, stlSerializer: jscad.StlSerializer, modelToExport: IModel, options?: IJscadCsgOptions): string | ArrayBuffer[];
|
3112 | /**
|
3113 | * OpenJsCad export options.
|
3114 | */
|
3115 | interface IOpenJsCadOptions extends IFindLoopsOptions, IExportOptions {
|
3116 | /**
|
3117 | * Optional depth of 3D extrusion.
|
3118 | */
|
3119 | extrusion?: number;
|
3120 | /**
|
3121 | * Optional size of curve facets.
|
3122 | */
|
3123 | facetSize?: number;
|
3124 | /**
|
3125 | * Optional override of function name, default is "main".
|
3126 | */
|
3127 | functionName?: string;
|
3128 | /**
|
3129 | * Optional options applied to specific first-child models by model id.
|
3130 | */
|
3131 | modelMap?: IOpenJsCadOptionsMap;
|
3132 | }
|
3133 | /**
|
3134 | * Map of OpenJsCad export options.
|
3135 | */
|
3136 | interface IOpenJsCadOptionsMap {
|
3137 | [modelId: string]: IOpenJsCadOptions;
|
3138 | }
|
3139 | /**
|
3140 | * Jscad CAG export options.
|
3141 | */
|
3142 | interface IJscadCagOptions extends IExportOptions, IPointMatchOptions {
|
3143 | /**
|
3144 | * Flag to separate chains by layers.
|
3145 | */
|
3146 | byLayers?: boolean;
|
3147 | /**
|
3148 | * The maximum length between points on an arc or circle.
|
3149 | */
|
3150 | maxArcFacet?: number;
|
3151 | /**
|
3152 | * Optional callback to get status during the export.
|
3153 | */
|
3154 | statusCallback?: IStatusCallback;
|
3155 | }
|
3156 | /**
|
3157 | * Jscad CAG extrusion options.
|
3158 | */
|
3159 | interface IJscadExtrudeOptions {
|
3160 | /**
|
3161 | * Optional depth of 3D extrusion.
|
3162 | */
|
3163 | extrude?: number;
|
3164 | /**
|
3165 | * Optional depth of 3D extrusion.
|
3166 | */
|
3167 | z?: number;
|
3168 | }
|
3169 | /**
|
3170 | * Jscad CSG export options.
|
3171 | */
|
3172 | interface IJscadCsgOptions extends IJscadCagOptions, IJscadExtrudeOptions {
|
3173 | /**
|
3174 | * SVG options per layer.
|
3175 | */
|
3176 | layerOptions?: {
|
3177 | [layerId: string]: IJscadExtrudeOptions;
|
3178 | };
|
3179 | }
|
3180 | /**
|
3181 | * Jscad Script export options.
|
3182 | */
|
3183 | interface IJscadScriptOptions extends IJscadCsgOptions {
|
3184 | /**
|
3185 | * Optional override of function name, default is "main".
|
3186 | */
|
3187 | functionName?: string;
|
3188 | /**
|
3189 | * Optional number of spaces to indent.
|
3190 | */
|
3191 | indent?: number;
|
3192 | }
|
3193 | }
|
3194 | declare namespace MakerJs.exporter {
|
3195 | /**
|
3196 | * Injects drawing into a PDFKit document.
|
3197 | *
|
3198 | * @param doc PDFKit.PDFDocument object. See https://pdfkit.org/
|
3199 | * @param modelToExport Model object to export.
|
3200 | * @param options Export options object.
|
3201 | * @returns String of PDF file contents.
|
3202 | */
|
3203 | function toPDF(doc: PDFKit.PDFDocument, modelToExport: IModel, options?: IPDFRenderOptions): void;
|
3204 | /**
|
3205 | * PDF rendering options.
|
3206 | */
|
3207 | interface IPDFRenderOptions extends IExportOptions {
|
3208 | /**
|
3209 | * Font name, see list at https://github.com/foliojs/pdfkit/blob/master/docs/text.coffee.md#fonts
|
3210 | */
|
3211 | fontName?: string;
|
3212 | /**
|
3213 | * Font size.
|
3214 | */
|
3215 | fontSize?: number;
|
3216 | /**
|
3217 | * Rendered reference origin.
|
3218 | */
|
3219 | origin?: IPoint;
|
3220 | /**
|
3221 | * SVG color of the rendered paths.
|
3222 | */
|
3223 | stroke?: string;
|
3224 | }
|
3225 | }
|
3226 | declare namespace MakerJs.exporter {
|
3227 | /**
|
3228 | * Map of SVG Path Data by layer name.
|
3229 | */
|
3230 | interface IPathDataByLayerMap {
|
3231 | [layer: string]: string;
|
3232 | }
|
3233 | /**
|
3234 | * Convert a chain to SVG path data.
|
3235 | *
|
3236 | * @param chain Chain to convert.
|
3237 | * @param offset IPoint relative offset point.
|
3238 | * @param accuracy Optional accuracy of SVG path data.
|
3239 | * @returns String of SVG path data.
|
3240 | */
|
3241 | function chainToSVGPathData(chain: IChain, offset: IPoint, accuracy?: number): string;
|
3242 | /**
|
3243 | * Export a path to SVG path data.
|
3244 | *
|
3245 | * @param pathToExport IPath to export.
|
3246 | * @param pathOffset IPoint relative offset of the path object.
|
3247 | * @param exportOffset IPoint relative offset point of the export.
|
3248 | * @param accuracy Optional accuracy of SVG path data.
|
3249 | * @param clockwiseCircle Optional flag to use clockwise winding for circles.
|
3250 | * @returns String of SVG path data.
|
3251 | */
|
3252 | function pathToSVGPathData(pathToExport: IPath, pathOffset: IPoint, exportOffset: IPoint, accuracy?: number, clockwiseCircle?: boolean): string;
|
3253 | /**
|
3254 | * Convert a model to SVG path data.
|
3255 | *
|
3256 | * @param modelToExport Model to export.
|
3257 | * @param options Optional ISVGPathDataRenderOptions object.
|
3258 | * @param options.accuracy Optional accuracy of SVG decimals.
|
3259 | * @param options.byLayers Optional boolean flag (default false) to return a map of path data by layer.
|
3260 | * @param options.fillRule Optional SVG fill rule: 'evenodd' (default) or 'nonzero'.
|
3261 | * @param options.origin Optional origin. Default x = 0, y = topmost y point in the model. Use [0, 0] to use the same origin as Maker.js, which will translate to negative Y values in SVG.
|
3262 | * @returns String of SVG path data (if options.byLayers is false) or an object map of path data by layer .
|
3263 | */
|
3264 | function toSVGPathData(modelToExport: IModel, options?: ISVGPathDataRenderOptions): IPathDataByLayerMap | string;
|
3265 | /**
|
3266 | * Convert a model to SVG path data.
|
3267 | *
|
3268 | * @param modelToExport Model to export.
|
3269 | * @param byLayers Optional boolean flag to return a map of path data by layer.
|
3270 | * @param origin Optional origin. Default x = 0, y = topmost y point in the model. Use [0, 0] to use the same origin as Maker.js, which will translate to negative Y values in SVG.
|
3271 | * @param accuracy Optional accuracy of SVG decimals.
|
3272 | * @returns String of SVG path data (if byLayers is false) or an object map of path data by layer .
|
3273 | */
|
3274 | function toSVGPathData(modelToExport: IModel, byLayers?: boolean, origin?: IPoint, accuracy?: number): IPathDataByLayerMap | string;
|
3275 | function toSVG(modelToExport: IModel, options?: ISVGRenderOptions): string;
|
3276 | function toSVG(pathsToExport: IPath[], options?: ISVGRenderOptions): string;
|
3277 | function toSVG(pathToExport: IPath, options?: ISVGRenderOptions): string;
|
3278 | /**
|
3279 | * Map of MakerJs unit system to SVG unit system
|
3280 | */
|
3281 | interface svgUnitConversion {
|
3282 | [unitType: string]: {
|
3283 | svgUnitType: string;
|
3284 | scaleConversion: number;
|
3285 | };
|
3286 | }
|
3287 | /**
|
3288 | * Map of MakerJs unit system to SVG unit system
|
3289 | */
|
3290 | var svgUnit: svgUnitConversion;
|
3291 | /**
|
3292 | * SVG rendering options.
|
3293 | */
|
3294 | interface ISVGElementRenderOptions {
|
3295 | /**
|
3296 | * SVG fill color.
|
3297 | */
|
3298 | fill?: string;
|
3299 | /**
|
3300 | * SVG color of the rendered paths.
|
3301 | */
|
3302 | stroke?: string;
|
3303 | /**
|
3304 | * SVG stroke width of paths. This may have a unit type suffix, if not, the value will be in the same unit system as the units property.
|
3305 | */
|
3306 | strokeWidth?: string;
|
3307 | /**
|
3308 | * CSS style to apply to elements.
|
3309 | */
|
3310 | cssStyle?: string;
|
3311 | }
|
3312 | /**
|
3313 | * Annotate paths with directional flow marks.
|
3314 | */
|
3315 | interface IFlowAnnotation {
|
3316 | /**
|
3317 | * Size of flow marks (arrows and circle).
|
3318 | */
|
3319 | size: number;
|
3320 | }
|
3321 | /**
|
3322 | * SVG rendering options.
|
3323 | */
|
3324 | interface ISVGRenderOptions extends IExportOptions, ISVGElementRenderOptions {
|
3325 | /**
|
3326 | * Optional attributes to add to the root svg tag.
|
3327 | */
|
3328 | svgAttrs?: IXmlTagAttrs;
|
3329 | /**
|
3330 | * SVG font size and font size units.
|
3331 | */
|
3332 | fontSize?: string;
|
3333 | /**
|
3334 | * Scale of the SVG rendering.
|
3335 | */
|
3336 | scale?: number;
|
3337 | /**
|
3338 | * Indicate that the id's of paths should be rendered as SVG text elements.
|
3339 | */
|
3340 | annotate?: boolean;
|
3341 | /**
|
3342 | * Options to show direction of path flow.
|
3343 | */
|
3344 | flow?: IFlowAnnotation;
|
3345 | /**
|
3346 | * Rendered reference origin.
|
3347 | */
|
3348 | origin?: IPoint;
|
3349 | /**
|
3350 | * Use SVG < path > elements instead of < line >, < circle > etc.
|
3351 | */
|
3352 | useSvgPathOnly?: boolean;
|
3353 | /**
|
3354 | * Flag to use SVG viewbox.
|
3355 | */
|
3356 | viewBox?: boolean;
|
3357 | /**
|
3358 | * SVG fill rule.
|
3359 | */
|
3360 | fillRule?: 'nonzero' | 'evenodd';
|
3361 | /**
|
3362 | * SVG stroke linecap.
|
3363 | */
|
3364 | strokeLineCap?: string;
|
3365 | /**
|
3366 | * SVG options per layer.
|
3367 | */
|
3368 | layerOptions?: {
|
3369 | [layerId: string]: ISVGElementRenderOptions;
|
3370 | };
|
3371 | /**
|
3372 | * Flag to remove the "vector-effect: non-scaling-stroke" attribute.
|
3373 | */
|
3374 | scalingStroke?: boolean;
|
3375 | /**
|
3376 | * Flag to explicitly close XML tags.
|
3377 | */
|
3378 | closingTags?: boolean;
|
3379 | }
|
3380 | /**
|
3381 | * SVG Path Data rendering options.
|
3382 | */
|
3383 | interface ISVGPathDataRenderOptions extends IExportOptions {
|
3384 | /**
|
3385 | * Optional boolean flag to return a map of path data by layer.
|
3386 | */
|
3387 | byLayers?: boolean;
|
3388 | /**
|
3389 | * SVG fill-rule.
|
3390 | */
|
3391 | fillRule?: 'nonzero' | 'evenodd';
|
3392 | /**
|
3393 | * Optional origin. Default x = 0, y = topmost y point in the model. Use [0, 0] to use the same origin as Maker.js, which will translate to negative Y values in SVG.
|
3394 | */
|
3395 | origin?: IPoint;
|
3396 | }
|
3397 | }
|
3398 | declare namespace MakerJs.importer {
|
3399 | /**
|
3400 | * SVG importing options.
|
3401 | */
|
3402 | interface ISVGImportOptions {
|
3403 | /**
|
3404 | * Optional accuracy of Bezier curves and elliptic paths.
|
3405 | */
|
3406 | bezierAccuracy?: number;
|
3407 | }
|
3408 | /**
|
3409 | * Create a model from SVG path data.
|
3410 | *
|
3411 | * @param pathData SVG path data.
|
3412 | * @param options ISVGImportOptions object.
|
3413 | * @param options.bezierAccuracy Optional accuracy of Bezier curves.
|
3414 | * @returns An IModel object.
|
3415 | */
|
3416 | function fromSVGPathData(pathData: string, options?: ISVGImportOptions): IModel;
|
3417 | }
|
3418 | declare namespace MakerJs.layout {
|
3419 | /**
|
3420 | * Layout the children of a model along a path.
|
3421 | * The x-position of each child will be projected onto the path so that the proportion between children is maintained.
|
3422 | * Each child will be rotated such that it will be perpendicular to the path at the child's x-center.
|
3423 | *
|
3424 | * @param parentModel The model containing children to lay out.
|
3425 | * @param onPath The path on which to lay out.
|
3426 | * @param baseline Numeric percentage value of vertical displacement from the path. Default is zero.
|
3427 | * @param reversed Flag to travel along the path in reverse. Default is false.
|
3428 | * @param contain Flag to contain the children layout within the length of the path. Default is false.
|
3429 | * @param rotate Flag to rotate the child to perpendicular. Default is true.
|
3430 | * @returns The parentModel, for cascading.
|
3431 | */
|
3432 | function childrenOnPath(parentModel: IModel, onPath: IPath, baseline?: number, reversed?: boolean, contain?: boolean, rotate?: boolean): IModel;
|
3433 | /**
|
3434 | * Layout the children of a model along a chain.
|
3435 | * The x-position of each child will be projected onto the chain so that the proportion between children is maintained.
|
3436 | * The projected positions of the children will become an array of points that approximate the chain.
|
3437 | * Each child will be rotated such that it will be mitered according to the vertex angles formed by this series of points.
|
3438 | *
|
3439 | * @param parentModel The model containing children to lay out.
|
3440 | * @param onChain The chain on which to lay out.
|
3441 | * @param baseline Numeric percentage value of vertical displacement from the chain. Default is zero.
|
3442 | * @param reversed Flag to travel along the chain in reverse. Default is false.
|
3443 | * @param contain Flag to contain the children layout within the length of the chain. Default is false.
|
3444 | * @param rotate Flag to rotate the child to mitered angle. Default is true.
|
3445 | * @returns The parentModel, for cascading.
|
3446 | */
|
3447 | function childrenOnChain(parentModel: IModel, onChain: IChain, baseline?: number, reversed?: boolean, contain?: boolean, rotated?: boolean): IModel;
|
3448 | /**
|
3449 | * Layout clones in a radial format.
|
3450 | *
|
3451 | * Example:
|
3452 | * ```
|
3453 | * //daisy petals
|
3454 | * var makerjs = require('makerjs');
|
3455 | *
|
3456 | * var belt = new makerjs.models.Belt(5, 50, 20);
|
3457 | *
|
3458 | * makerjs.model.move(belt, [25, 0]);
|
3459 | *
|
3460 | * var petals = makerjs.layout.cloneToRadial(belt, 8, 45);
|
3461 | *
|
3462 | * document.write(makerjs.exporter.toSVG(petals));
|
3463 | * ```
|
3464 | *
|
3465 | * @param itemToClone: Either a model or a path object.
|
3466 | * @param count Number of clones in the radial result.
|
3467 | * @param angleInDegrees angle of rotation between clones..
|
3468 | * @returns A new model with clones in a radial format.
|
3469 | */
|
3470 | function cloneToRadial(itemToClone: IModel | IPath, count: number, angleInDegrees: number, rotationOrigin?: IPoint): IModel;
|
3471 | /**
|
3472 | * Layout clones in a column format.
|
3473 | *
|
3474 | * Example:
|
3475 | * ```
|
3476 | * //Grooves for a finger joint
|
3477 | * var m = require('makerjs');
|
3478 | *
|
3479 | * var dogbone = new m.models.Dogbone(50, 20, 2, -1, false);
|
3480 | *
|
3481 | * var grooves = m.layout.cloneToColumn(dogbone, 5, 20);
|
3482 | *
|
3483 | * document.write(m.exporter.toSVG(grooves));
|
3484 | * ```
|
3485 | *
|
3486 | * @param itemToClone: Either a model or a path object.
|
3487 | * @param count Number of clones in the column.
|
3488 | * @param margin Optional distance between each clone.
|
3489 | * @returns A new model with clones in a column.
|
3490 | */
|
3491 | function cloneToColumn(itemToClone: IModel | IPath, count: number, margin?: number): IModel;
|
3492 | /**
|
3493 | * Layout clones in a row format.
|
3494 | *
|
3495 | * Example:
|
3496 | * ```
|
3497 | * //Tongue and grooves for a box joint
|
3498 | * var m = require('makerjs');
|
3499 | * var tongueWidth = 60;
|
3500 | * var grooveWidth = 50;
|
3501 | * var grooveDepth = 30;
|
3502 | * var groove = new m.models.Dogbone(grooveWidth, grooveDepth, 5, 0, true);
|
3503 | *
|
3504 | * groove.paths['leftTongue'] = new m.paths.Line([-tongueWidth / 2, 0], [0, 0]);
|
3505 | * groove.paths['rightTongue'] = new m.paths.Line([grooveWidth, 0], [grooveWidth + tongueWidth / 2, 0]);
|
3506 | *
|
3507 | * var tongueAndGrooves = m.layout.cloneToRow(groove, 3);
|
3508 | *
|
3509 | * document.write(m.exporter.toSVG(tongueAndGrooves));
|
3510 | * ```
|
3511 | *
|
3512 | * @param itemToClone: Either a model or a path object.
|
3513 | * @param count Number of clones in the row.
|
3514 | * @param margin Optional distance between each clone.
|
3515 | * @returns A new model with clones in a row.
|
3516 | */
|
3517 | function cloneToRow(itemToClone: IModel | IPath, count: number, margin?: number): IModel;
|
3518 | /**
|
3519 | * Layout clones in a grid format.
|
3520 | *
|
3521 | * Example:
|
3522 | * ```
|
3523 | * //Grid of squares
|
3524 | * var m = require('makerjs');
|
3525 | * var square = new m.models.Square(43);
|
3526 | * var grid = m.layout.cloneToGrid(square, 5, 5, 7);
|
3527 | * document.write(m.exporter.toSVG(grid));
|
3528 | * ```
|
3529 | *
|
3530 | * @param itemToClone: Either a model or a path object.
|
3531 | * @param xCount Number of columns in the grid.
|
3532 | * @param yCount Number of rows in the grid.
|
3533 | * @param margin Optional numeric distance between each clone. Can also be a 2 dimensional array of numbers, to specify distances in x and y dimensions.
|
3534 | * @returns A new model with clones in a grid layout.
|
3535 | */
|
3536 | function cloneToGrid(itemToClone: IModel | IPath, xCount: number, yCount: number, margin?: number | IPoint): IModel;
|
3537 | /**
|
3538 | * Layout clones in a brick format. Alternating rows will have an additional item in each row.
|
3539 | *
|
3540 | * Examples:
|
3541 | * ```
|
3542 | * //Brick wall
|
3543 | * var m = require('makerjs');
|
3544 | * var brick = new m.models.RoundRectangle(50, 30, 4);
|
3545 | * var wall = m.layout.cloneToBrick(brick, 8, 6, 3);
|
3546 | * document.write(m.exporter.toSVG(wall));
|
3547 | * ```
|
3548 | *
|
3549 | * ```
|
3550 | * //Fish scales
|
3551 | * var m = require('makerjs');
|
3552 | * var arc = new m.paths.Arc([0, 0], 50, 20, 160);
|
3553 | * var scales = m.layout.cloneToBrick(arc, 8, 20);
|
3554 | * document.write(m.exporter.toSVG(scales));
|
3555 | * ```
|
3556 | *
|
3557 | * @param itemToClone: Either a model or a path object.
|
3558 | * @param xCount Number of columns in the brick grid.
|
3559 | * @param yCount Number of rows in the brick grid.
|
3560 | * @param margin Optional numeric distance between each clone. Can also be a 2 dimensional array of numbers, to specify distances in x and y dimensions.
|
3561 | * @returns A new model with clones in a brick layout.
|
3562 | */
|
3563 | function cloneToBrick(itemToClone: IModel | IPath, xCount: number, yCount: number, margin?: number | IPoint): IModel;
|
3564 | /**
|
3565 | * Layout clones in a honeycomb format. Alternating rows will have an additional item in each row.
|
3566 | *
|
3567 | * Examples:
|
3568 | * ```
|
3569 | * //Honeycomb
|
3570 | * var m = require('makerjs');
|
3571 | * var hex = new m.models.Polygon(6, 50, 30);
|
3572 | * var pattern = m.layout.cloneToHoneycomb(hex, 8, 9, 10);
|
3573 | * document.write(m.exporter.toSVG(pattern));
|
3574 | * ```
|
3575 | *
|
3576 | * @param itemToClone: Either a model or a path object.
|
3577 | * @param xCount Number of columns in the honeycomb grid.
|
3578 | * @param yCount Number of rows in the honeycomb grid.
|
3579 | * @param margin Optional distance between each clone.
|
3580 | * @returns A new model with clones in a honeycomb layout.
|
3581 | */
|
3582 | function cloneToHoneycomb(itemToClone: IModel | IPath, xCount: number, yCount: number, margin?: number): IModel;
|
3583 | }
|
3584 | declare namespace MakerJs.models {
|
3585 | class BezierCurve implements IModel {
|
3586 | models: IModelMap;
|
3587 | paths: IPathMap;
|
3588 | origin: IPoint;
|
3589 | type: string;
|
3590 | seed: IPathBezierSeed;
|
3591 | accuracy: number;
|
3592 | constructor(points: IPoint[], accuracy?: number);
|
3593 | constructor(seed: IPathBezierSeed, accuracy?: number);
|
3594 | constructor(origin: IPoint, control: IPoint, end: IPoint, accuracy?: number);
|
3595 | constructor(origin: IPoint, controls: IPoint[], end: IPoint, accuracy?: number);
|
3596 | constructor(origin: IPoint, control1: IPoint, control2: IPoint, end: IPoint, accuracy?: number);
|
3597 | static typeName: string;
|
3598 | static getBezierSeeds(curve: BezierCurve, options?: IFindChainsOptions): IPath[] | {
|
3599 | [layer: string]: IPath[];
|
3600 | };
|
3601 | static computeLength(seed: IPathBezierSeed): number;
|
3602 | static computePoint(seed: IPathBezierSeed, t: number): IPoint;
|
3603 | }
|
3604 | }
|
3605 | declare var Bezier: typeof BezierJs.Bezier;
|
3606 | declare namespace MakerJs.models {
|
3607 | class Ellipse implements IModel {
|
3608 | models: IModelMap;
|
3609 | origin: IPoint;
|
3610 | /**
|
3611 | * Class for Ellipse created with 2 radii.
|
3612 | *
|
3613 | * @param radiusX The x radius of the ellipse.
|
3614 | * @param radiusY The y radius of the ellipse.
|
3615 | * @param accuracy Optional accuracy of the underlying BezierCurve.
|
3616 | */
|
3617 | constructor(radiusX: number, radiusY: number, accuracy?: number);
|
3618 | /**
|
3619 | * Class for Ellipse created at a specific origin and 2 radii.
|
3620 | *
|
3621 | * @param origin The center of the ellipse.
|
3622 | * @param radiusX The x radius of the ellipse.
|
3623 | * @param radiusY The y radius of the ellipse.
|
3624 | * @param accuracy Optional accuracy of the underlying BezierCurve.
|
3625 | */
|
3626 | constructor(origin: IPoint, radiusX: number, radiusY: number, accuracy?: number);
|
3627 | /**
|
3628 | * Class for Ellipse created at a specific x, y and 2 radii.
|
3629 | *
|
3630 | * @param cx The x coordinate of the center of the ellipse.
|
3631 | * @param cy The y coordinate of the center of the ellipse.
|
3632 | * @param rX The x radius of the ellipse.
|
3633 | * @param rY The y radius of the ellipse.
|
3634 | * @param accuracy Optional accuracy of the underlying BezierCurve.
|
3635 | */
|
3636 | constructor(cx: number, cy: number, rx: number, ry: number, accuracy?: number);
|
3637 | }
|
3638 | class EllipticArc implements IModel {
|
3639 | models: IModelMap;
|
3640 | /**
|
3641 | * Class for Elliptic Arc created by distorting a circular arc.
|
3642 | *
|
3643 | * @param arc The circular arc to use as the basis of the elliptic arc.
|
3644 | * @param radiusX The x radius of the ellipse.
|
3645 | * @param radiusY The y radius of the ellipse.
|
3646 | * @param accuracy Optional accuracy of the underlying BezierCurve.
|
3647 | */
|
3648 | constructor(startAngle: number, endAngle: number, radiusX: number, radiusY: number, accuracy?: number);
|
3649 | /**
|
3650 | * Class for Elliptic Arc created by distorting a circular arc.
|
3651 | *
|
3652 | * @param arc The circular arc to use as the basis of the elliptic arc.
|
3653 | * @param distortX The x scale of the ellipse.
|
3654 | * @param distortY The y scale of the ellipse.
|
3655 | * @param accuracy Optional accuracy of the underlying BezierCurve.
|
3656 | */
|
3657 | constructor(arc: IPathArc, distortX: number, distortY: number, accuracy?: number);
|
3658 | }
|
3659 | }
|
3660 | declare namespace MakerJs.models {
|
3661 | class ConnectTheDots implements IModel {
|
3662 | paths: IPathMap;
|
3663 | /**
|
3664 | * Create a model by connecting points designated in a string. The model will be 'closed' - i.e. the last point will connect to the first point.
|
3665 | *
|
3666 | * Example:
|
3667 | * ```
|
3668 | * var c = new makerjs.models.ConnectTheDots('-10 0 10 0 0 20'); // 3 coordinates to form a triangle
|
3669 | * ```
|
3670 | *
|
3671 | * @param numericList String containing a list of numbers which can be delimited by spaces, commas, or anything non-numeric (Note: [exponential notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) is allowed).
|
3672 | */
|
3673 | constructor(numericList: string);
|
3674 | /**
|
3675 | * Create a model by connecting points designated in a string. The model may be closed, or left open.
|
3676 | *
|
3677 | * Example:
|
3678 | * ```
|
3679 | * var c = new makerjs.models.ConnectTheDots(false, '-10 0 10 0 0 20'); // 3 coordinates to form a polyline
|
3680 | * ```
|
3681 | *
|
3682 | * @param isClosed Flag to specify if last point should connect to the first point.
|
3683 | * @param numericList String containing a list of numbers which can be delimited by spaces, commas, or anything non-numeric (Note: [exponential notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) is allowed).
|
3684 | */
|
3685 | constructor(isClosed: boolean, numericList: string);
|
3686 | /**
|
3687 | * Create a model by connecting points designated in a numeric array. The model will be 'closed' - i.e. the last point will connect to the first point.
|
3688 | *
|
3689 | * Example:
|
3690 | * ```
|
3691 | * var c = new makerjs.models.ConnectTheDots([-10, 0, 10, 0, 0, 20]); // 3 coordinates to form a triangle
|
3692 | * ```
|
3693 | *
|
3694 | * @param coords Array of coordinates.
|
3695 | */
|
3696 | constructor(coords: number[]);
|
3697 | /**
|
3698 | * Create a model by connecting points designated in a numeric array. The model may be closed, or left open.
|
3699 | *
|
3700 | * Example:
|
3701 | * ```
|
3702 | * var c = new makerjs.models.ConnectTheDots(false, [-10, 0, 10, 0, 0, 20]); // 3 coordinates to form a polyline
|
3703 | * ```
|
3704 | *
|
3705 | * @param isClosed Flag to specify if last point should connect to the first point.
|
3706 | * @param coords Array of coordinates.
|
3707 | */
|
3708 | constructor(isClosed: boolean, coords: number[]);
|
3709 | /**
|
3710 | * Create a model by connecting points designated in an array of points. The model may be closed, or left open.
|
3711 | *
|
3712 | * Example:
|
3713 | * ```
|
3714 | * var c = new makerjs.models.ConnectTheDots(false, [[-10, 0], [10, 0], [0, 20]]); // 3 coordinates left open
|
3715 | * ```
|
3716 | *
|
3717 | * @param isClosed Flag to specify if last point should connect to the first point.
|
3718 | * @param points Array of IPoints.
|
3719 | */
|
3720 | constructor(isClosed: boolean, points: IPoint[]);
|
3721 | }
|
3722 | }
|
3723 | declare namespace MakerJs.models {
|
3724 | class Polygon implements IModel {
|
3725 | paths: IPathMap;
|
3726 | constructor(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number, circumscribed?: boolean);
|
3727 | static circumscribedRadius(radius: number, angleInRadians: number): number;
|
3728 | static getPoints(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number, circumscribed?: boolean): IPoint[];
|
3729 | }
|
3730 | }
|
3731 | declare namespace MakerJs.models {
|
3732 | class Holes implements IModel {
|
3733 | paths: IPathMap;
|
3734 | /**
|
3735 | * Create an array of circles of the same radius from an array of center points.
|
3736 | *
|
3737 | * Example:
|
3738 | * ```
|
3739 | * //Create some holes from an array of points
|
3740 | * var makerjs = require('makerjs');
|
3741 | * var model = new makerjs.models.Holes(10, [[0, 0],[50, 0],[25, 40]]);
|
3742 | * var svg = makerjs.exporter.toSVG(model);
|
3743 | * document.write(svg);
|
3744 | * ```
|
3745 | *
|
3746 | * @param holeRadius Hole radius.
|
3747 | * @param points Array of points for origin of each hole.
|
3748 | * @param ids Optional array of corresponding path ids for the holes.
|
3749 | */
|
3750 | constructor(holeRadius: number, points: IPoint[], ids?: string[]);
|
3751 | }
|
3752 | }
|
3753 | declare namespace MakerJs.models {
|
3754 | class BoltCircle implements IModel {
|
3755 | paths: IPathMap;
|
3756 | constructor(boltRadius: number, holeRadius: number, boltCount: number, firstBoltAngleInDegrees?: number);
|
3757 | }
|
3758 | }
|
3759 | declare namespace MakerJs.models {
|
3760 | class BoltRectangle implements IModel {
|
3761 | paths: IPathMap;
|
3762 | constructor(width: number, height: number, holeRadius: number);
|
3763 | }
|
3764 | }
|
3765 | declare namespace MakerJs.models {
|
3766 | class Dogbone implements IModel {
|
3767 | paths: IPathMap;
|
3768 | /**
|
3769 | * Create a dogbone from width, height, corner radius, style, and bottomless flag.
|
3770 | *
|
3771 | * Example:
|
3772 | * ```
|
3773 | * var d = new makerjs.models.Dogbone(50, 100, 5);
|
3774 | * ```
|
3775 | *
|
3776 | * @param width Width of the rectangle.
|
3777 | * @param height Height of the rectangle.
|
3778 | * @param radius Corner radius.
|
3779 | * @param style Optional corner style: 0 (default) for dogbone, 1 for vertical, -1 for horizontal.
|
3780 | * @param bottomless Optional flag to omit the bottom line and bottom corners (default false).
|
3781 | */
|
3782 | constructor(width: number, height: number, radius: number, style?: number, bottomless?: boolean);
|
3783 | }
|
3784 | }
|
3785 | declare namespace MakerJs.models {
|
3786 | class Dome implements IModel {
|
3787 | paths: IPathMap;
|
3788 | constructor(width: number, height: number, radius?: number, bottomless?: boolean);
|
3789 | }
|
3790 | }
|
3791 | declare namespace MakerJs.models {
|
3792 | class RoundRectangle implements IModel {
|
3793 | origin: IPoint;
|
3794 | paths: IPathMap;
|
3795 | /**
|
3796 | * Create a round rectangle from width, height, and corner radius.
|
3797 | *
|
3798 | * Example:
|
3799 | * ```
|
3800 | * var r = new makerjs.models.RoundRectangle(100, 50, 5);
|
3801 | * ```
|
3802 | *
|
3803 | * @param width Width of the rectangle.
|
3804 | * @param height Height of the rectangle.
|
3805 | * @param radius Corner radius.
|
3806 | */
|
3807 | constructor(width: number, height: number, radius: number);
|
3808 | /**
|
3809 | * Create a round rectangle which will surround a model.
|
3810 | *
|
3811 | * Example:
|
3812 | * ```
|
3813 | * var b = new makerjs.models.BoltRectangle(30, 20, 1); //draw a bolt rectangle so we have something to surround
|
3814 | * var r = new makerjs.models.RoundRectangle(b, 2.5); //surround it
|
3815 | * ```
|
3816 | *
|
3817 | * @param modelToSurround IModel object.
|
3818 | * @param margin Distance from the model. This will also become the corner radius.
|
3819 | */
|
3820 | constructor(modelToSurround: IModel, margin: number);
|
3821 | }
|
3822 | }
|
3823 | declare namespace MakerJs.models {
|
3824 | class Oval implements IModel {
|
3825 | paths: IPathMap;
|
3826 | constructor(width: number, height: number);
|
3827 | }
|
3828 | }
|
3829 | declare namespace MakerJs.models {
|
3830 | class OvalArc implements IModel {
|
3831 | paths: IPathMap;
|
3832 | models: IModelMap;
|
3833 | constructor(startAngle: number, endAngle: number, sweepRadius: number, slotRadius: number, selfIntersect?: boolean, isolateCaps?: boolean);
|
3834 | }
|
3835 | }
|
3836 | declare namespace MakerJs.models {
|
3837 | class Rectangle implements IModel {
|
3838 | paths: IPathMap;
|
3839 | origin: IPoint;
|
3840 | /**
|
3841 | * Create a rectangle from width and height.
|
3842 | *
|
3843 | * Example:
|
3844 | * ```
|
3845 | * //Create a rectangle from width and height
|
3846 | * var makerjs = require('makerjs');
|
3847 | * var model = new makerjs.models.Rectangle(50, 100);
|
3848 | * var svg = makerjs.exporter.toSVG(model);
|
3849 | * document.write(svg);
|
3850 | * ```
|
3851 | *
|
3852 | * @param width Width of the rectangle.
|
3853 | * @param height Height of the rectangle.
|
3854 | */
|
3855 | constructor(width: number, height: number);
|
3856 | /**
|
3857 | * Create a rectangle which will surround a model.
|
3858 | *
|
3859 | * Example:
|
3860 | * ```
|
3861 | * //Create a rectangle which will surround a model
|
3862 | * var makerjs = require('makerjs');
|
3863 | * var e = new makerjs.models.Ellipse(17, 10); // draw an ellipse so we have something to surround.
|
3864 | * var r = new makerjs.models.Rectangle(e, 3); // draws a rectangle surrounding the ellipse by 3 units.
|
3865 | * var svg = makerjs.exporter.toSVG({ models: { e: e, r: r }});
|
3866 | * document.write(svg);
|
3867 | * ```
|
3868 | *
|
3869 | * @param modelToSurround IModel object.
|
3870 | * @param margin Optional distance from the model.
|
3871 | */
|
3872 | constructor(modelToSurround: IModel, margin?: number);
|
3873 | /**
|
3874 | * Create a rectangle from a measurement.
|
3875 | *
|
3876 | * Example:
|
3877 | * ```
|
3878 | * //Create a rectangle from a measurement.
|
3879 | * var makerjs = require('makerjs');
|
3880 | * var e = new makerjs.models.Ellipse(17, 10); // draw an ellipse so we have something to measure.
|
3881 | * var m = makerjs.measure.modelExtents(e); // measure the ellipse.
|
3882 | * var r = new makerjs.models.Rectangle(m); // draws a rectangle surrounding the ellipse.
|
3883 | * var svg = makerjs.exporter.toSVG({ models: { e: e, r: r }});
|
3884 | * document.write(svg);
|
3885 | * ```
|
3886 | *
|
3887 | * @param measurement IMeasure object. See http://maker.js.org/docs/api/modules/makerjs.measure.html#pathextents and http://maker.js.org/docs/api/modules/makerjs.measure.html#modelextents to get measurements of paths and models.
|
3888 | */
|
3889 | constructor(measurement: IMeasure);
|
3890 | }
|
3891 | }
|
3892 | declare namespace MakerJs.models {
|
3893 | class Ring implements IModel {
|
3894 | paths: IPathMap;
|
3895 | constructor(outerRadius: number, innerRadius?: number);
|
3896 | }
|
3897 | }
|
3898 | declare namespace MakerJs.models {
|
3899 | class Belt implements IModel {
|
3900 | paths: IPathMap;
|
3901 | constructor(leftRadius: number, distance: number, rightRadius: number);
|
3902 | }
|
3903 | }
|
3904 | declare namespace MakerJs.models {
|
3905 | class SCurve implements IModel {
|
3906 | paths: IPathMap;
|
3907 | constructor(width: number, height: number);
|
3908 | }
|
3909 | }
|
3910 | declare namespace MakerJs.models {
|
3911 | class Slot implements IModel {
|
3912 | paths: IPathMap;
|
3913 | origin: IPoint;
|
3914 | models: IModelMap;
|
3915 | constructor(origin: IPoint, endPoint: IPoint, radius: number, isolateCaps?: boolean);
|
3916 | }
|
3917 | }
|
3918 | declare namespace MakerJs.models {
|
3919 | class Square implements IModel {
|
3920 | paths: IPathMap;
|
3921 | constructor(side: number);
|
3922 | }
|
3923 | }
|
3924 | declare namespace MakerJs.models {
|
3925 | class Star implements IModel {
|
3926 | paths: IPathMap;
|
3927 | constructor(numberOfPoints: number, outerRadius: number, innerRadius?: number, skipPoints?: number);
|
3928 | static InnerRadiusRatio(numberOfPoints: number, skipPoints: number): number;
|
3929 | }
|
3930 | }
|
3931 | declare namespace MakerJs.models {
|
3932 | class Text implements IModel {
|
3933 | models: IModelMap;
|
3934 | /**
|
3935 | * Renders text in a given font to a model.
|
3936 | * @param font OpenType.Font object.
|
3937 | * @param text String of text to render.
|
3938 | * @param fontSize Font size.
|
3939 | * @param combine Flag (default false) to perform a combineUnion upon each character with characters to the left and right.
|
3940 | * @param centerCharacterOrigin Flag (default false) to move the x origin of each character to the center. Useful for rotating text characters.
|
3941 | * @param bezierAccuracy Optional accuracy of Bezier curves.
|
3942 | * @param opentypeOptions Optional opentype.RenderOptions object.
|
3943 | * @returns Model of the text.
|
3944 | */
|
3945 | constructor(font: opentype.Font, text: string, fontSize: number, combine?: boolean, centerCharacterOrigin?: boolean, bezierAccuracy?: number, opentypeOptions?: opentype.RenderOptions);
|
3946 | /**
|
3947 | * Convert an opentype glyph to a model.
|
3948 | * @param glyph Opentype.Glyph object.
|
3949 | * @param fontSize Font size.
|
3950 | * @param bezierAccuracy Optional accuracy of Bezier curves.
|
3951 | * @returns Model of the glyph.
|
3952 | */
|
3953 | static glyphToModel(glyph: opentype.Glyph, fontSize: number, bezierAccuracy?: number): IModel;
|
3954 | }
|
3955 | }
|