@projectstorm/geometry
Advanced tools
Comparing version 6.4.1 to 6.4.2
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["@projectstorm/react-diagrams-geometry"]=e():t["@projectstorm/react-diagrams-geometry"]=e()}(self,(function(){return(()=>{"use strict";var t={712:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BezierCurve=e.BezierCurvepPoints=void 0;const o=i(364),n=i(902);var r;!function(t){t[t.SOURCE=0]="SOURCE",t[t.SOURCE_CONTROL=1]="SOURCE_CONTROL",t[t.TARGET_CONTROL=2]="TARGET_CONTROL",t[t.TARGET=3]="TARGET"}(r=e.BezierCurvepPoints||(e.BezierCurvepPoints={}));class s extends n.Polygon{constructor(){super([new o.Point(0,0),new o.Point(0,0),new o.Point(0,0),new o.Point(0,0)])}getSVGCurve(){return`M${this.getSource().toSVG()} C${this.getSourceControl().toSVG()}, ${this.getTargetControl().toSVG()}, ${this.getTarget().toSVG()}`}setPoints(t){if(4!==t.length)throw new Error("BezierCurve must have extactly 4 points");super.setPoints(t)}getSource(){return this.points[r.SOURCE]}getSourceControl(){return this.points[r.SOURCE_CONTROL]}getTargetControl(){return this.points[r.TARGET_CONTROL]}getTarget(){return this.points[r.TARGET]}setSource(t){this.points[r.SOURCE]=t}setSourceControl(t){this.points[r.SOURCE_CONTROL]=t}setTargetControl(t){this.points[r.TARGET_CONTROL]=t}setTarget(t){this.points[r.TARGET]=t}}e.BezierCurve=s},306:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Matrix=void 0;e.Matrix=class{constructor(t){this.matrix=t}mmul(t){return this.matrix=this.matrix.map(((e,i)=>t.asArray()[0].map(((o,n)=>e.reduce(((e,o,r)=>e+this.matrix[i][r]*t.asArray()[r][n]),0))))),this}asArray(){return this.matrix}get(t,e){return this.asArray()[t][e]}}},364:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Point=void 0;const o=i(306);class n{constructor(t,e){this.x=t,this.y=e}translate(t,e){this.x+=t,this.y+=e}clone(){return new n(this.x,this.y)}toSVG(){return this.x+" "+this.y}asMatrix(){return new o.Matrix([[this.x],[this.y],[1]])}transform(t){let e=t.mmul(this.asMatrix());this.x=e.get(0,0),this.y=e.get(1,0)}static middlePoint(t,e){return new n((e.x+t.x)/2,(e.y+t.y)/2)}static multiply(...t){let e=t[0];for(let i=1;i<t.length;i++)e=e.mmul(t[i]);return e}static scaleMatrix(t,e){return new o.Matrix([[t,0,0],[0,e,0],[0,0,1]])}static translateMatrix(t,e){return new o.Matrix([[1,0,t],[0,1,e],[0,0,1]])}static rotateMatrix(t){return new o.Matrix([[Math.cos(t),-1*Math.sin(t),0],[Math.sin(t),Math.cos(t),0],[0,0,1]])}static createScaleMatrix(t,e,i){return this.multiply(n.translateMatrix(i.x,i.y),n.scaleMatrix(t,e),n.translateMatrix(-i.x,-i.y))}static createRotateMatrix(t,e){return this.multiply(n.translateMatrix(e.x,e.y),n.rotateMatrix(t),n.translateMatrix(-e.x,-e.y))}}e.Point=n},902:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Polygon=void 0;const o=i(364),n=i(804);class r{constructor(t=[]){this.points=t}serialize(){return n.map(this.points,(t=>[t.x,t.y]))}deserialize(t){this.points=n.map(t,(t=>new o.Point(t[0],t[1])))}scale(t,e,i){let r=o.Point.createScaleMatrix(t,e,i);n.forEach(this.points,(t=>{t.transform(r)}))}transform(t){n.forEach(this.points,(e=>{e.transform(t)}))}setPoints(t){this.points=t}getPoints(){return this.points}rotate(t){this.transform(o.Point.createRotateMatrix(t/(180/Math.PI),this.getOrigin()))}translate(t,e){n.forEach(this.points,(i=>{i.translate(t,e)}))}doClone(t){this.points=n.map(t.points,(t=>t.clone()))}clone(){let t=Object.create(this);return t.doClone(this),t}getOrigin(){if(0===this.points.length)return null;let t=this.getBoundingBox();return o.Point.middlePoint(t.getTopLeft(),t.getBottomRight())}static boundingBoxFromPolygons(t){return r.boundingBoxFromPoints(n.flatMap(t,(t=>t.getPoints())))}static boundingBoxFromPoints(t){if(0===t.length)return new s.Rectangle(0,0,0,0);let e=t[0].x,i=t[0].x,n=t[0].y,r=t[0].y;for(let o=1;o<t.length;o++)t[o].x<e&&(e=t[o].x),t[o].x>i&&(i=t[o].x),t[o].y<n&&(n=t[o].y),t[o].y>r&&(r=t[o].y);return new s.Rectangle(new o.Point(e,n),new o.Point(i,n),new o.Point(i,r),new o.Point(e,r))}getBoundingBox(){let t=this.points[0].x,e=this.points[0].x,i=this.points[0].y,n=this.points[0].y;for(let o=1;o<this.points.length;o++)this.points[o].x<t&&(t=this.points[o].x),this.points[o].x>e&&(e=this.points[o].x),this.points[o].y<i&&(i=this.points[o].y),this.points[o].y>n&&(n=this.points[o].y);return new s.Rectangle(new o.Point(t,i),new o.Point(e,i),new o.Point(e,n),new o.Point(t,n))}}e.Polygon=r;const s=i(719)},719:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Rectangle=void 0;const o=i(364),n=i(902);class r extends n.Polygon{constructor(t=0,e=0,i=0,n=0){t instanceof o.Point&&e instanceof o.Point&&i instanceof o.Point&&n instanceof o.Point?super([t,e,i,n]):t instanceof o.Point?super([t,new o.Point(t.x+e,t.y),new o.Point(t.x+e,t.y+i),new o.Point(t.x,t.y+i)]):super(r.pointsFromBounds(t,e,i,n))}static pointsFromBounds(t,e,i,n){return[new o.Point(t,e),new o.Point(t+i,e),new o.Point(t+i,e+n),new o.Point(t,e+n)]}updateDimensions(t,e,i,o){this.points=r.pointsFromBounds(t,e,i,o)}setPoints(t){if(4!==t.length)throw"Rectangles must always have 4 points";super.setPoints(t)}containsPoint(t){const e=this.getTopLeft(),i=this.getBottomRight();return t.x>=e.x&&t.x<=i.x&&t.y>=e.y&&t.y<=i.y}getWidth(){return Math.sqrt(Math.pow(this.getTopLeft().x-this.getTopRight().x,2)+Math.pow(this.getTopLeft().y-this.getTopRight().y,2))}getHeight(){return Math.sqrt(Math.pow(this.getBottomLeft().x-this.getTopLeft().x,2)+Math.pow(this.getBottomLeft().y-this.getTopLeft().y,2))}getTopMiddle(){return o.Point.middlePoint(this.getTopLeft(),this.getTopRight())}getBottomMiddle(){return o.Point.middlePoint(this.getBottomLeft(),this.getBottomRight())}getLeftMiddle(){return o.Point.middlePoint(this.getBottomLeft(),this.getTopLeft())}getRightMiddle(){return o.Point.middlePoint(this.getBottomRight(),this.getTopRight())}getTopLeft(){return this.points[0]}getTopRight(){return this.points[1]}getBottomRight(){return this.points[2]}getBottomLeft(){return this.points[3]}}e.Rectangle=r},920:function(t,e,i){var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i),Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(364),e),n(i(306),e),n(i(902),e),n(i(719),e),n(i(712),e)},804:t=>{t.exports=require("lodash")}},e={};return function i(o){var n=e[o];if(void 0!==n)return n.exports;var r=e[o]={exports:{}};return t[o].call(r.exports,r,r.exports,i),r.exports}(920)})()})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["@projectstorm/react-diagrams-geometry"]=e():t["@projectstorm/react-diagrams-geometry"]=e()}(self,(function(){return(()=>{"use strict";var t={419:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BezierCurve=e.BezierCurvepPoints=void 0;const o=i(397),n=i(312);var r;!function(t){t[t.SOURCE=0]="SOURCE",t[t.SOURCE_CONTROL=1]="SOURCE_CONTROL",t[t.TARGET_CONTROL=2]="TARGET_CONTROL",t[t.TARGET=3]="TARGET"}(r=e.BezierCurvepPoints||(e.BezierCurvepPoints={}));class s extends n.Polygon{constructor(){super([new o.Point(0,0),new o.Point(0,0),new o.Point(0,0),new o.Point(0,0)])}getSVGCurve(){return`M${this.getSource().toSVG()} C${this.getSourceControl().toSVG()}, ${this.getTargetControl().toSVG()}, ${this.getTarget().toSVG()}`}setPoints(t){if(4!==t.length)throw new Error("BezierCurve must have extactly 4 points");super.setPoints(t)}getSource(){return this.points[r.SOURCE]}getSourceControl(){return this.points[r.SOURCE_CONTROL]}getTargetControl(){return this.points[r.TARGET_CONTROL]}getTarget(){return this.points[r.TARGET]}setSource(t){this.points[r.SOURCE]=t}setSourceControl(t){this.points[r.SOURCE_CONTROL]=t}setTargetControl(t){this.points[r.TARGET_CONTROL]=t}setTarget(t){this.points[r.TARGET]=t}}e.BezierCurve=s},848:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Matrix=void 0;e.Matrix=class{constructor(t){this.matrix=t}mmul(t){return this.matrix=this.matrix.map(((e,i)=>t.asArray()[0].map(((o,n)=>e.reduce(((e,o,r)=>e+this.matrix[i][r]*t.asArray()[r][n]),0))))),this}asArray(){return this.matrix}get(t,e){return this.asArray()[t][e]}}},397:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Point=void 0;const o=i(848);class n{constructor(t,e){this.x=t,this.y=e}translate(t,e){this.x+=t,this.y+=e}clone(){return new n(this.x,this.y)}toSVG(){return this.x+" "+this.y}asMatrix(){return new o.Matrix([[this.x],[this.y],[1]])}transform(t){let e=t.mmul(this.asMatrix());this.x=e.get(0,0),this.y=e.get(1,0)}static middlePoint(t,e){return new n((e.x+t.x)/2,(e.y+t.y)/2)}static multiply(...t){let e=t[0];for(let i=1;i<t.length;i++)e=e.mmul(t[i]);return e}static scaleMatrix(t,e){return new o.Matrix([[t,0,0],[0,e,0],[0,0,1]])}static translateMatrix(t,e){return new o.Matrix([[1,0,t],[0,1,e],[0,0,1]])}static rotateMatrix(t){return new o.Matrix([[Math.cos(t),-1*Math.sin(t),0],[Math.sin(t),Math.cos(t),0],[0,0,1]])}static createScaleMatrix(t,e,i){return this.multiply(n.translateMatrix(i.x,i.y),n.scaleMatrix(t,e),n.translateMatrix(-i.x,-i.y))}static createRotateMatrix(t,e){return this.multiply(n.translateMatrix(e.x,e.y),n.rotateMatrix(t),n.translateMatrix(-e.x,-e.y))}}e.Point=n},312:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Polygon=void 0;const o=i(397),n=i(804);class r{constructor(t=[]){this.points=t}serialize(){return n.map(this.points,(t=>[t.x,t.y]))}deserialize(t){this.points=n.map(t,(t=>new o.Point(t[0],t[1])))}scale(t,e,i){let r=o.Point.createScaleMatrix(t,e,i);n.forEach(this.points,(t=>{t.transform(r)}))}transform(t){n.forEach(this.points,(e=>{e.transform(t)}))}setPoints(t){this.points=t}getPoints(){return this.points}rotate(t){this.transform(o.Point.createRotateMatrix(t/(180/Math.PI),this.getOrigin()))}translate(t,e){n.forEach(this.points,(i=>{i.translate(t,e)}))}doClone(t){this.points=n.map(t.points,(t=>t.clone()))}clone(){let t=Object.create(this);return t.doClone(this),t}getOrigin(){if(0===this.points.length)return null;let t=this.getBoundingBox();return o.Point.middlePoint(t.getTopLeft(),t.getBottomRight())}static boundingBoxFromPolygons(t){return r.boundingBoxFromPoints(n.flatMap(t,(t=>t.getPoints())))}static boundingBoxFromPoints(t){if(0===t.length)return new s.Rectangle(0,0,0,0);let e=t[0].x,i=t[0].x,n=t[0].y,r=t[0].y;for(let o=1;o<t.length;o++)t[o].x<e&&(e=t[o].x),t[o].x>i&&(i=t[o].x),t[o].y<n&&(n=t[o].y),t[o].y>r&&(r=t[o].y);return new s.Rectangle(new o.Point(e,n),new o.Point(i,n),new o.Point(i,r),new o.Point(e,r))}getBoundingBox(){let t=this.points[0].x,e=this.points[0].x,i=this.points[0].y,n=this.points[0].y;for(let o=1;o<this.points.length;o++)this.points[o].x<t&&(t=this.points[o].x),this.points[o].x>e&&(e=this.points[o].x),this.points[o].y<i&&(i=this.points[o].y),this.points[o].y>n&&(n=this.points[o].y);return new s.Rectangle(new o.Point(t,i),new o.Point(e,i),new o.Point(e,n),new o.Point(t,n))}}e.Polygon=r;const s=i(114)},114:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Rectangle=void 0;const o=i(397),n=i(312);class r extends n.Polygon{constructor(t=0,e=0,i=0,n=0){t instanceof o.Point&&e instanceof o.Point&&i instanceof o.Point&&n instanceof o.Point?super([t,e,i,n]):t instanceof o.Point?super([t,new o.Point(t.x+e,t.y),new o.Point(t.x+e,t.y+i),new o.Point(t.x,t.y+i)]):super(r.pointsFromBounds(t,e,i,n))}static pointsFromBounds(t,e,i,n){return[new o.Point(t,e),new o.Point(t+i,e),new o.Point(t+i,e+n),new o.Point(t,e+n)]}updateDimensions(t,e,i,o){this.points=r.pointsFromBounds(t,e,i,o)}setPoints(t){if(4!==t.length)throw"Rectangles must always have 4 points";super.setPoints(t)}containsPoint(t){const e=this.getTopLeft(),i=this.getBottomRight();return t.x>=e.x&&t.x<=i.x&&t.y>=e.y&&t.y<=i.y}getWidth(){return Math.sqrt(Math.pow(this.getTopLeft().x-this.getTopRight().x,2)+Math.pow(this.getTopLeft().y-this.getTopRight().y,2))}getHeight(){return Math.sqrt(Math.pow(this.getBottomLeft().x-this.getTopLeft().x,2)+Math.pow(this.getBottomLeft().y-this.getTopLeft().y,2))}getTopMiddle(){return o.Point.middlePoint(this.getTopLeft(),this.getTopRight())}getBottomMiddle(){return o.Point.middlePoint(this.getBottomLeft(),this.getBottomRight())}getLeftMiddle(){return o.Point.middlePoint(this.getBottomLeft(),this.getTopLeft())}getRightMiddle(){return o.Point.middlePoint(this.getBottomRight(),this.getTopRight())}getTopLeft(){return this.points[0]}getTopRight(){return this.points[1]}getBottomRight(){return this.points[2]}getBottomLeft(){return this.points[3]}}e.Rectangle=r},418:function(t,e,i){var o=this&&this.__createBinding||(Object.create?function(t,e,i,o){void 0===o&&(o=i),Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,o){void 0===o&&(o=i),t[o]=e[i]}),n=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||o(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(i(397),e),n(i(848),e),n(i(312),e),n(i(114),e),n(i(419),e)},804:t=>{t.exports=require("lodash")}},e={};return function i(o){var n=e[o];if(void 0!==n)return n.exports;var r=e[o]={exports:{}};return t[o].call(r.exports,r,r.exports,i),r.exports}(418)})()})); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@projectstorm/geometry", | ||
"version": "6.4.1", | ||
"version": "6.4.2", | ||
"author": "dylanvorster", | ||
@@ -31,3 +31,3 @@ "license": "MIT", | ||
"typings": "./dist/@types/index", | ||
"gitHead": "c6556d7475592473b9a5e0c924ef8b328a8cf94a" | ||
"gitHead": "4649597a97ff66f249bfcce052346692b6306115" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package