@flatten-js/core
Advanced tools
Comparing version 1.2.22 to 1.2.23
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ # Example: flatten-js in a browser |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ # Example: flatten-js in React environment |
@@ -0,0 +0,0 @@ import React, {Component} from 'react'; |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ # Example: flatten-js in a browser as es6 module |
@@ -0,0 +0,0 @@ // Just hit "node index.js" in the terminal while you are in the directory of this project |
{ | ||
"name": "nodejs", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"lockfileVersion": 1, | ||
@@ -5,0 +5,0 @@ "requires": true, |
@@ -150,2 +150,3 @@ // Type definitions for flatten-js library | ||
rotate(angle: number, center: Point): Arc; | ||
scale(scaleX: number, scaleY: number) : Arc; | ||
transform(matrix?: Matrix): Arc; | ||
@@ -152,0 +153,0 @@ sortPoints(pts: Array<Point>): Array<Point>; |
@@ -0,0 +0,0 @@ /** |
{ | ||
"name": "@flatten-js/core", | ||
"version": "1.2.22", | ||
"version": "1.2.23", | ||
"description": "Javascript library for 2d geometry", | ||
@@ -73,4 +73,4 @@ "main": "dist/main.cjs.js", | ||
"dependencies": { | ||
"@flatten-js/interval-tree": "^1.0.13" | ||
"@flatten-js/interval-tree": "^1.0.14" | ||
} | ||
} |
@@ -0,0 +0,0 @@ /** |
import * as Utils from "../../src/utils/utils"; | ||
export default Utils; |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ import resolve from 'rollup-plugin-node-resolve'; |
@@ -6,2 +6,4 @@ [![npm version](https://badge.fury.io/js/%40flatten-js%2Fcore.svg)](https://badge.fury.io/js/%40flatten-js%2Fcore) | ||
[![Rate on Openbase](https://badges.openbase.com/js/rating/@flatten-js/core.svg)](https://openbase.com/js/@flatten-js/core?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge) | ||
# Javascript library for 2d geometry | ||
@@ -8,0 +10,0 @@ |
@@ -0,0 +0,0 @@ import resolve from 'rollup-plugin-node-resolve'; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /* |
@@ -407,4 +407,18 @@ /** | ||
/** | ||
* Return new arc scaled by scaleX, scaleY. | ||
* @param {number} scaleX - scale value by X | ||
* @param {number} scaleY - scale value by Y | ||
* @returns {Arc} | ||
*/ | ||
scale(scaleX = 1, scaleY = 1) { | ||
let m = new Flatten.Matrix(); | ||
m = m.scale(scaleX, scaleY); | ||
return this.transform(m); | ||
} | ||
/** | ||
* Return new arc transformed using affine transformation matrix <br/> | ||
* Note, that non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result | ||
* Note 1. Non-equal scaling by x and y (abs(matrix[0]) != abs(matrix[3])) produce illegal result because | ||
* it should create elliptic arc but this package does not support ellipses | ||
* Note 2. Mirror transformation (matrix[0] * matrix[3] < 0) change direction of the arc to the opposite | ||
* TODO: support non-equal scaling arc to ellipse or throw exception ? | ||
@@ -418,3 +432,7 @@ * @param {Matrix} matrix - affine transformation matrix | ||
let newCenter = this.pc.transform(matrix); | ||
let arc = Flatten.Arc.arcSE(newCenter, newStart, newEnd, this.counterClockwise); | ||
let newDirection = this.counterClockwise; | ||
if (matrix.a * matrix.d < 0) { | ||
newDirection = !newDirection; | ||
} | ||
let arc = Flatten.Arc.arcSE(newCenter, newStart, newEnd, newDirection); | ||
return arc; | ||
@@ -421,0 +439,0 @@ } |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -50,2 +50,8 @@ /** | ||
// second point omitted issue #84 | ||
if (args.length === 1 && args[0] instanceof Flatten.Point) { | ||
this.ps = args[0].clone(); | ||
return; | ||
} | ||
if (args.length === 2 && args[0] instanceof Flatten.Point && args[1] instanceof Flatten.Point) { | ||
@@ -52,0 +58,0 @@ this.ps = args[0].clone(); |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import LinkedList from './linked_list'; |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ import Flatten from "../flatten"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import * as Constants from './utils/constants'; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -7,3 +7,3 @@ 'use strict'; | ||
import {Point, Vector, Circle, Line, Segment, Arc, Box, Polygon, Edge, Face, Ray} from '../../index'; | ||
import {point, vector, circle, line, segment, arc, ray} from '../../index'; | ||
import {point, vector, circle, line, segment, arc, matrix, ray} from '../../index'; | ||
@@ -323,2 +323,14 @@ describe('#Flatten.Arc', function() { | ||
}) | ||
it('Can mirror arc by Y axis using transformation matrix', () => { | ||
let a1 = arc(point(0, 10), 20, -Math.PI / 4, Math.PI / 4, true); | ||
let m = matrix().scale(-1, 1); | ||
let a2 = a1.transform(m); | ||
expect(a2.start.x).to.be.closeTo(-a1.start.x, Flatten.DP_TOL); | ||
expect(a2.start.y).to.be.closeTo(a1.start.y, Flatten.DP_TOL); | ||
expect(a2.end.x).to.be.closeTo(-a1.end.x, Flatten.DP_TOL); | ||
expect(a2.end.y).to.be.closeTo(a1.end.y, Flatten.DP_TOL); | ||
expect(a2.center.x).to.be.closeTo(-a1.center.x, Flatten.DP_TOL); | ||
expect(a2.center.y).to.be.closeTo(a1.center.y, Flatten.DP_TOL); | ||
expect(a2.counterClockwise).to.be.equal(!a1.counterClockwise); | ||
}); | ||
it('Method svg() without parameters creates svg string with default attributes', function() { | ||
@@ -325,0 +337,0 @@ let arc = new Arc(point(), 5, Math.PI/4, 3*Math.PI/4, Flatten.CCW); |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -24,2 +24,8 @@ /** | ||
}); | ||
it('May construct segment when second point is omitted', function () { | ||
let ps = new Point(10,10); | ||
let segment = new Segment(ps); | ||
expect(segment.start).to.deep.equal({x:10, y:10}); | ||
expect(segment.end).to.deep.equal({x:0, y:0}); | ||
}); | ||
it('May constructor by array [4] ', function () { | ||
@@ -26,0 +32,0 @@ let ps = new Point(1,1); |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
5498124
35082
339