mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-31 11:40:47 +08:00
Merge pull request #6018 from danmarshall/master
Updated to Maker.js 0.4.2
This commit is contained in:
@@ -25,6 +25,7 @@ function test() {
|
||||
}
|
||||
|
||||
function testAngle() {
|
||||
makerjs.angle.areEqual(12, 13);
|
||||
makerjs.angle.mirror(45, true, false);
|
||||
makerjs.angle.noRevolutions(90);
|
||||
makerjs.angle.ofArcEnd(paths.arc);
|
||||
@@ -63,12 +64,15 @@ function test() {
|
||||
}
|
||||
|
||||
function testModel(){
|
||||
makerjs.model.combine(model, model, true, false, true, false);
|
||||
makerjs.model.convertUnits(model, makerjs.unitType.Centimeter);
|
||||
makerjs.model.getSimilarPathId(model, 'foo');
|
||||
makerjs.model.mirror(model, false, true);
|
||||
makerjs.model.move(makerjs.model.originate(model, [9,9]), [0,0]);
|
||||
makerjs.model.moveRelative(model, [1,1]);
|
||||
makerjs.model.originate(model);
|
||||
makerjs.model.rotate(makerjs.model.scale(model, 6), 45, [0,0]);
|
||||
makerjs.model.walkPaths(model, (modelContext: MakerJs.IModel, pathId: string, pathContext: MakerJs.IPath) => {});
|
||||
}
|
||||
|
||||
function testModels(): MakerJs.IModel[] {
|
||||
@@ -83,11 +87,13 @@ function test() {
|
||||
new makerjs.models.Ring(7, 7),
|
||||
new makerjs.models.RoundRectangle(2, 2, 0),
|
||||
new makerjs.models.SCurve(5, .9),
|
||||
new makerjs.models.Square(8)
|
||||
new makerjs.models.Square(8),
|
||||
new makerjs.models.Star(5, 10, 5)
|
||||
];
|
||||
}
|
||||
|
||||
function testPath() {
|
||||
makerjs.path.areEqual(paths.line, paths.circle);
|
||||
makerjs.path.breakAtPoint(paths.arc, [0,0]).type;
|
||||
makerjs.path.dogbone(paths.line, paths.line, 7);
|
||||
makerjs.path.fillet(paths.arc, paths.line, 4);
|
||||
@@ -121,6 +127,7 @@ function test() {
|
||||
makerjs.point.closest([0,0], [p1, p2]);
|
||||
makerjs.point.fromAngleOnCircle(22, paths.circle);
|
||||
makerjs.point.fromArc(paths.arc);
|
||||
makerjs.point.fromPathEnds(paths.line);
|
||||
makerjs.point.fromPolar(Math.PI, 7);
|
||||
makerjs.point.middle(paths.line);
|
||||
makerjs.point.mirror(p1, true, false);
|
||||
|
||||
Vendored
+85
-15
@@ -37,6 +37,12 @@ declare module MakerJs {
|
||||
* @param accuracy Optional exemplar of number of decimal places.
|
||||
*/
|
||||
function round(n: number, accuracy?: number): number;
|
||||
/**
|
||||
* Clone an object.
|
||||
*
|
||||
* @param objectToClone The object to clone.
|
||||
* @returns A new clone of the original object.
|
||||
*/
|
||||
function cloneObject<T>(objectToClone: T): T;
|
||||
/**
|
||||
* Copy the properties from one object to another object.
|
||||
@@ -294,6 +300,14 @@ declare module MakerJs {
|
||||
function isModel(item: any): boolean;
|
||||
}
|
||||
declare module MakerJs.angle {
|
||||
/**
|
||||
* Find out if two angles are equal.
|
||||
*
|
||||
* @param a First angle.
|
||||
* @param b Second angle.
|
||||
* @returns true if angles are the same, false if they are not
|
||||
*/
|
||||
function areEqual(angle1: number, angle2: number): boolean;
|
||||
/**
|
||||
* Ensures an angle is not greater than 360
|
||||
*
|
||||
@@ -388,7 +402,7 @@ declare module MakerJs.point {
|
||||
* @param b Second point.
|
||||
* @returns true if points are the same, false if they are not
|
||||
*/
|
||||
function areEqualRounded(a: IPoint, b: IPoint): boolean;
|
||||
function areEqualRounded(a: IPoint, b: IPoint, accuracy?: number): boolean;
|
||||
/**
|
||||
* Clone a point into a new point.
|
||||
*
|
||||
@@ -426,14 +440,21 @@ declare module MakerJs.point {
|
||||
* @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.
|
||||
*/
|
||||
function fromArc(arc: IPathArc): IPoint[];
|
||||
/**
|
||||
* Get the two end points of a path.
|
||||
*
|
||||
* @param pathContext The path object.
|
||||
* @returns Array with 2 elements: [0] is the point object corresponding to the origin, [1] is the point object corresponding to the end.
|
||||
*/
|
||||
function fromPathEnds(pathContext: IPath): IPoint[];
|
||||
/**
|
||||
* Get the middle point of a path. Currently only supports Arc and Line paths.
|
||||
*
|
||||
* @param path The path object.
|
||||
* @param pathContext The path object.
|
||||
* @param ratio Optional ratio (between 0 and 1) of point along the path. Default is .5 for middle.
|
||||
* @returns Point on the path, in the middle of the path.
|
||||
*/
|
||||
function middle(path: IPath, ratio?: number): IPoint;
|
||||
function middle(pathContext: IPath, ratio?: number): IPoint;
|
||||
/**
|
||||
* Create a clone of a point, mirrored on either or both x and y axes.
|
||||
*
|
||||
@@ -477,6 +498,14 @@ declare module MakerJs.point {
|
||||
function zero(): IPoint;
|
||||
}
|
||||
declare module MakerJs.path {
|
||||
/**
|
||||
* Find out if two paths are equal.
|
||||
*
|
||||
* @param a First path.
|
||||
* @param b Second path.
|
||||
* @returns true if paths are the same, false if they are not
|
||||
*/
|
||||
function areEqual(path1: IPath, path2: IPath): boolean;
|
||||
/**
|
||||
* Create a clone of a path, mirrored on either or both x and y axes.
|
||||
*
|
||||
@@ -600,6 +629,13 @@ declare module MakerJs.paths {
|
||||
}
|
||||
}
|
||||
declare module MakerJs.model {
|
||||
/**
|
||||
* Get an unused id in the paths map with the same prefix.
|
||||
*
|
||||
* @param modelContext The model containing the paths map.
|
||||
* @param pathId The pathId to use directly (if unused), or as a prefix.
|
||||
*/
|
||||
function getSimilarPathId(modelContext: IModel, pathId: string): string;
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -658,6 +694,33 @@ declare module MakerJs.model {
|
||||
* @returns The scaled model (for chaining).
|
||||
*/
|
||||
function convertUnits(modeltoConvert: IModel, destUnitType: string): IModel;
|
||||
/**
|
||||
* Callback signature for walkPaths.
|
||||
*/
|
||||
interface IModelPathCallback {
|
||||
(modelContext: IModel, pathId: string, pathContext: IPath): void;
|
||||
}
|
||||
/**
|
||||
* Recursively walk through all paths for a given model.
|
||||
*
|
||||
* @param modelContext The model to walk.
|
||||
* @param callback Callback for each path.
|
||||
*/
|
||||
function walkPaths(modelContext: IModel, callback: IModelPathCallback): void;
|
||||
}
|
||||
declare module MakerJs.model {
|
||||
/**
|
||||
* Combine 2 models. The models should be originated.
|
||||
*
|
||||
* @param modelA First model to combine.
|
||||
* @param modelB Second model to combine.
|
||||
* @param includeAInsideB Flag to include paths from modelA which are inside of modelB.
|
||||
* @param includeAOutsideB Flag to include paths from modelA which are outside of modelB.
|
||||
* @param includeBInsideA Flag to include paths from modelB which are inside of modelA.
|
||||
* @param includeBOutsideA Flag to include paths from modelB which are outside of modelA.
|
||||
* @param farPoint Optional point of reference which is outside the bounds of both models.
|
||||
*/
|
||||
function combine(modelA: IModel, modelB: IModel, includeAInsideB: boolean, includeAOutsideB: boolean, includeBInsideA: boolean, includeBOutsideA: boolean, farPoint?: IPoint): void;
|
||||
}
|
||||
declare module MakerJs.units {
|
||||
/**
|
||||
@@ -1023,6 +1086,18 @@ declare module MakerJs.exporter {
|
||||
viewBox: boolean;
|
||||
}
|
||||
}
|
||||
declare module MakerJs.models {
|
||||
class ConnectTheDots implements IModel {
|
||||
paths: IPathMap;
|
||||
constructor(isClosed: boolean, points: IPoint[]);
|
||||
}
|
||||
}
|
||||
declare module MakerJs.models {
|
||||
class Polygon extends ConnectTheDots {
|
||||
constructor(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number);
|
||||
static getPoints(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number): IPoint[];
|
||||
}
|
||||
}
|
||||
declare module MakerJs.models {
|
||||
class BoltCircle implements IModel {
|
||||
paths: IPathMap;
|
||||
@@ -1035,12 +1110,6 @@ declare module MakerJs.models {
|
||||
constructor(width: number, height: number, holeRadius: number);
|
||||
}
|
||||
}
|
||||
declare module MakerJs.models {
|
||||
class ConnectTheDots implements IModel {
|
||||
paths: IPathMap;
|
||||
constructor(isClosed: boolean, points: IPoint[]);
|
||||
}
|
||||
}
|
||||
declare module MakerJs.models {
|
||||
class RoundRectangle implements IModel {
|
||||
paths: IPathMap;
|
||||
@@ -1058,12 +1127,6 @@ declare module MakerJs.models {
|
||||
constructor(startAngle: number, endAngle: number, sweepRadius: number, slotRadius: number);
|
||||
}
|
||||
}
|
||||
declare module MakerJs.models {
|
||||
class Polygon extends ConnectTheDots {
|
||||
constructor(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number);
|
||||
static getPoints(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number): IPoint[];
|
||||
}
|
||||
}
|
||||
declare module MakerJs.models {
|
||||
class Rectangle extends ConnectTheDots {
|
||||
constructor(width: number, height: number);
|
||||
@@ -1086,3 +1149,10 @@ declare module MakerJs.models {
|
||||
constructor(side: number);
|
||||
}
|
||||
}
|
||||
declare module MakerJs.models {
|
||||
class Star implements IModel {
|
||||
paths: IPathMap;
|
||||
constructor(numberOfPoints: number, outerRadius: number, innerRadius?: number, skipPoints?: number);
|
||||
static InnerRadiusRatio(numberOfPoints: number, skipPoints: number): number;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user