Skip to content

Commit

Permalink
Commit build
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbol99 committed Jul 25, 2023
1 parent bc7af8e commit a91f800
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 75 deletions.
64 changes: 39 additions & 25 deletions dist/main.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,22 +246,15 @@ class LinkedList {
this.last = last || this.first;
}

/**
* Throw an error if circular loop detected in the linked list
* @param {LinkedListElement} first element to start iteration
* @throws {Flatten.Errors.INFINITE_LOOP}
*/
static testInfiniteLoop(first) {
let edge = first;
let controlEdge = first;
do {
if (edge != first && edge === controlEdge) {
throw Flatten.Errors.INFINITE_LOOP; // new Error("Infinite loop")
[Symbol.iterator]() {
let value = undefined;
return {
next: () => {
value = value ? value.next : this.first;
return {value: value, done: value === undefined};
}
edge = edge.next;
controlEdge = controlEdge.next.next;
} while (edge != first)
}
};
};

/**
* Return number of elements in the list
Expand Down Expand Up @@ -386,15 +379,22 @@ class LinkedList {
return this.first === undefined;
}

[Symbol.iterator]() {
let value = undefined;
return {
next: () => {
value = value ? value.next : this.first;
return {value: value, done: value === undefined};
/**
* Throw an error if circular loop detected in the linked list
* @param {LinkedListElement} first element to start iteration
* @throws {Flatten.Errors.INFINITE_LOOP}
*/
static testInfiniteLoop(first) {
let edge = first;
let controlEdge = first;
do {
if (edge != first && edge === controlEdge) {
throw Flatten.Errors.INFINITE_LOOP; // new Error("Infinite loop")
}
};
};
edge = edge.next;
controlEdge = controlEdge.next.next;
} while (edge != first)
}
}

/*
Expand Down Expand Up @@ -6251,7 +6251,7 @@ class Box extends Shape {
* @returns {Box}
*/
transform(m = new Flatten.Matrix()) {
const transformed_points = this.toPoints().map(pt => m.transform([pt.x, pt.y]));
const transformed_points = this.toPoints().map(pt => pt.transform(m));
return transformed_points.reduce(
(new_box, pt) => new_box.merge(pt), new Box())
}
Expand Down Expand Up @@ -7430,7 +7430,7 @@ class Polygon {

/**
* Add new face to polygon. Returns added face
* @param {Points[]|Segments[]|Arcs[]|Circle|Box} args - new face may be create with one of the following ways: <br/>
* @param {Point[]|Segment[]|Arc[]|Circle|Box} args - new face may be create with one of the following ways: <br/>
* 1) array of points that describe closed path (edges are segments) <br/>
* 2) array of shapes (segments and arcs) which describe closed path <br/>
* 3) circle - will be added as counterclockwise arc <br/>
Expand Down Expand Up @@ -7912,6 +7912,20 @@ class Polygon {
return newPolygon;
}

/**
* Return new polygon with coordinates multiplied by scaling factor
* @param {number} sx - x-axis scaling factor
* @param {number} sy - y-axis scaling factor
* @returns {Polygon}
*/
scale(sx, sy) {
let newPolygon = new Polygon();
for (let face of this.faces) {
newPolygon.addFace(face.shapes.map(shape => shape.scale(sx, sy)));
}
return newPolygon;
}

/**
* Return new polygon transformed using affine transformation matrix
* @param {Matrix} matrix - affine transformation matrix
Expand Down
64 changes: 39 additions & 25 deletions dist/main.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,15 @@ class LinkedList {
this.last = last || this.first;
}

/**
* Throw an error if circular loop detected in the linked list
* @param {LinkedListElement} first element to start iteration
* @throws {Flatten.Errors.INFINITE_LOOP}
*/
static testInfiniteLoop(first) {
let edge = first;
let controlEdge = first;
do {
if (edge != first && edge === controlEdge) {
throw Flatten.Errors.INFINITE_LOOP; // new Error("Infinite loop")
[Symbol.iterator]() {
let value = undefined;
return {
next: () => {
value = value ? value.next : this.first;
return {value: value, done: value === undefined};
}
edge = edge.next;
controlEdge = controlEdge.next.next;
} while (edge != first)
}
};
};

/**
* Return number of elements in the list
Expand Down Expand Up @@ -382,15 +375,22 @@ class LinkedList {
return this.first === undefined;
}

[Symbol.iterator]() {
let value = undefined;
return {
next: () => {
value = value ? value.next : this.first;
return {value: value, done: value === undefined};
/**
* Throw an error if circular loop detected in the linked list
* @param {LinkedListElement} first element to start iteration
* @throws {Flatten.Errors.INFINITE_LOOP}
*/
static testInfiniteLoop(first) {
let edge = first;
let controlEdge = first;
do {
if (edge != first && edge === controlEdge) {
throw Flatten.Errors.INFINITE_LOOP; // new Error("Infinite loop")
}
};
};
edge = edge.next;
controlEdge = controlEdge.next.next;
} while (edge != first)
}
}

/*
Expand Down Expand Up @@ -6247,7 +6247,7 @@ class Box extends Shape {
* @returns {Box}
*/
transform(m = new Flatten.Matrix()) {
const transformed_points = this.toPoints().map(pt => m.transform([pt.x, pt.y]));
const transformed_points = this.toPoints().map(pt => pt.transform(m));
return transformed_points.reduce(
(new_box, pt) => new_box.merge(pt), new Box())
}
Expand Down Expand Up @@ -7426,7 +7426,7 @@ class Polygon {

/**
* Add new face to polygon. Returns added face
* @param {Points[]|Segments[]|Arcs[]|Circle|Box} args - new face may be create with one of the following ways: <br/>
* @param {Point[]|Segment[]|Arc[]|Circle|Box} args - new face may be create with one of the following ways: <br/>
* 1) array of points that describe closed path (edges are segments) <br/>
* 2) array of shapes (segments and arcs) which describe closed path <br/>
* 3) circle - will be added as counterclockwise arc <br/>
Expand Down Expand Up @@ -7908,6 +7908,20 @@ class Polygon {
return newPolygon;
}

/**
* Return new polygon with coordinates multiplied by scaling factor
* @param {number} sx - x-axis scaling factor
* @param {number} sy - y-axis scaling factor
* @returns {Polygon}
*/
scale(sx, sy) {
let newPolygon = new Polygon();
for (let face of this.faces) {
newPolygon.addFace(face.shapes.map(shape => shape.scale(sx, sy)));
}
return newPolygon;
}

/**
* Return new polygon transformed using affine transformation matrix
* @param {Matrix} matrix - affine transformation matrix
Expand Down
64 changes: 39 additions & 25 deletions dist/main.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,15 @@
this.last = last || this.first;
}

/**
* Throw an error if circular loop detected in the linked list
* @param {LinkedListElement} first element to start iteration
* @throws {Flatten.Errors.INFINITE_LOOP}
*/
static testInfiniteLoop(first) {
let edge = first;
let controlEdge = first;
do {
if (edge != first && edge === controlEdge) {
throw Flatten.Errors.INFINITE_LOOP; // new Error("Infinite loop")
[Symbol.iterator]() {
let value = undefined;
return {
next: () => {
value = value ? value.next : this.first;
return {value: value, done: value === undefined};
}
edge = edge.next;
controlEdge = controlEdge.next.next;
} while (edge != first)
}
};
};

/**
* Return number of elements in the list
Expand Down Expand Up @@ -388,15 +381,22 @@
return this.first === undefined;
}

[Symbol.iterator]() {
let value = undefined;
return {
next: () => {
value = value ? value.next : this.first;
return {value: value, done: value === undefined};
/**
* Throw an error if circular loop detected in the linked list
* @param {LinkedListElement} first element to start iteration
* @throws {Flatten.Errors.INFINITE_LOOP}
*/
static testInfiniteLoop(first) {
let edge = first;
let controlEdge = first;
do {
if (edge != first && edge === controlEdge) {
throw Flatten.Errors.INFINITE_LOOP; // new Error("Infinite loop")
}
};
};
edge = edge.next;
controlEdge = controlEdge.next.next;
} while (edge != first)
}
}

/*
Expand Down Expand Up @@ -6253,7 +6253,7 @@
* @returns {Box}
*/
transform(m = new Flatten.Matrix()) {
const transformed_points = this.toPoints().map(pt => m.transform([pt.x, pt.y]));
const transformed_points = this.toPoints().map(pt => pt.transform(m));
return transformed_points.reduce(
(new_box, pt) => new_box.merge(pt), new Box())
}
Expand Down Expand Up @@ -7432,7 +7432,7 @@

/**
* Add new face to polygon. Returns added face
* @param {Points[]|Segments[]|Arcs[]|Circle|Box} args - new face may be create with one of the following ways: <br/>
* @param {Point[]|Segment[]|Arc[]|Circle|Box} args - new face may be create with one of the following ways: <br/>
* 1) array of points that describe closed path (edges are segments) <br/>
* 2) array of shapes (segments and arcs) which describe closed path <br/>
* 3) circle - will be added as counterclockwise arc <br/>
Expand Down Expand Up @@ -7914,6 +7914,20 @@
return newPolygon;
}

/**
* Return new polygon with coordinates multiplied by scaling factor
* @param {number} sx - x-axis scaling factor
* @param {number} sy - y-axis scaling factor
* @returns {Polygon}
*/
scale(sx, sy) {
let newPolygon = new Polygon();
for (let face of this.faces) {
newPolygon.addFace(face.shapes.map(shape => shape.scale(sx, sy)));
}
return newPolygon;
}

/**
* Return new polygon transformed using affine transformation matrix
* @param {Matrix} matrix - affine transformation matrix
Expand Down

0 comments on commit a91f800

Please sign in to comment.