{"version":3,"sources":["webpack:///../src/js/BezierPath.js","webpack:///../src/js/Bounds.js","webpack:///../src/js/Circle.js","webpack:///../src/js/CircleSector.js","webpack:///../src/js/CubicBezierCurve.js","webpack:///../src/js/Grid.js","webpack:///../src/js/KeyHandler.js","webpack:///../src/js/Line.js","webpack:///../src/js/MouseHandler.js","webpack:///../src/js/PBImage.js","webpack:///../src/js/PlotBoilerplate.js","webpack:///../src/js/Polygon.js","webpack:///../src/js/Triangle.js","webpack:///../src/js/UIDGenerator.js","webpack:///../src/js/VEllipse.js","webpack:///../src/js/Vector.js","webpack:///../src/js/VertTuple.js","webpack:///../src/js/Vertex.js","webpack:///../src/js/VertexAttr.js","webpack:///../src/js/VertexListeners.js","webpack:///../src/js/draw.js","webpack:///../src/js/drawgl.js","webpack:///../src/js/geomutils.js","webpack:///../src/js/utils/helpers/drawutilssvg.js","webpack:///webpack/bootstrap","webpack:///../src/js/entry.js"],"names":["Object","defineProperty","exports","value","BezierPath","Bounds_1","CubicBezierCurve_1","UIDGenerator_1","Vertex_1","pathPoints","this","className","START_POINT","START_CONTROL_POINT","END_CONTROL_POINT","END_POINT","uid","UIDGenerator","next","totalArcLength","adjustCircular","bezierCurves","prototype","addCurve","curve","push","length","startPoint","endPoint","adjustSuccessorControlPoint","getLength","locateCurveByStartPoint","point","i","equals","locateCurveByEndPoint","locateCurveByStartControlPoint","startControlPoint","locateCurveByEndControlPoint","endControlPoint","updateArcLengths","getCurveCount","getCurveAt","curveIndex","translate","amount","getStartPoint","add","getStartControlPoint","getEndControlPoint","getEndPoint","scale","anchor","scaling","rotate","angle","center","getClosestT","p","minIndex","minDist","dist","curveT","uMin","u","getPointAt","distance","Math","max","min","getPoint","console","log","uTemp","clone","relativeU","t","getTangentAt","getTangent","warn","getPerpendicularAt","getPerpendicular","uResult","_locateUIndex","bCurve","uPart","path","uBefore","getSubPathAt","startT","endT","startU","endU","uStartResult","uEndResult","firstT","lastT","firstCurve","getSubCurveAt","fromArray","curves","reverse","moveCurvePoint","pointID","moveAmount","adjustPredecessorControlPoint","obtainHandleLength","mainCurve","neighbourCurve","adjustNeighbourControlPoint","mainPoint","mainControlPoint","neighbourPoint","neighbourControlPoint","obtainHandleLengths","mainHandleBounds","Vertex","x","y","neighbourHandleBounds","mainHandleLength","sqrt","pow","neighbourHandleLength","set","getBounds","b","Number","POSITIVE_INFINITY","NEGATIVE_INFINITY","Bounds","toSVGString","options","buffer","c","toSVGPathData","join","toJSON","prettyFormat","fromJSON","jsonString","obj","JSON","parse","Array","isArray","arr","bPath","lastCurve","CubicBezierCurve","isInstance","fromObject","toReducedListRepresentation","digits","toFixed","fromReducedListRepresentation","listJSON","pointArray","bezierPath","Polygon_1","width","height","toPolygon","Polygon","computeFromVertices","vertices","vert","xMin","xMax","yMin","yMax","Circle","Line_1","Vector_1","radius","containsCircle","circle","lineDistance","line","getClosestPoint","vertAt","circleUtils","tangentAt","pointA","Vector","perp","circleIntersection","abs","p0","p1","d","a","h","p2","x3","y3","x4","y4","Line","cos","sin","CircleSector","startAngle","endAngle","data","circleSectorUtils","describeSVGArc","polarToCartesian","centerX","centerY","moveToStart","end","start","PI","firstHalf","secondHalf","concat","largeArcFlag","pathData","curveIntervals","segmentCache","segmentLengths","arcLength","moveControlPoint","tmp","pointB","curveStep","tmpLength","newLength","result","tPrev","tNext","iteration","locateIntervalByDistance","tStart","tEnd","stepCount","tDiff","v","getPointByID","id","Error","t2","nt2","tX","tY","startVec","endVec","inv","convertU2T","tangentVector","toString","Grid","size","utils","baseLog","base","num","mapRasterScale","adjustFactor","gf","floor","KeyHandler","downListeners","pressListeners","upListeners","keyStates","element","globalThis","trackAllKeys","trackAll","installListeners","fireEvent","event","listeners","hasListener","lis","keyCode","listener","fireDownEvent","e","handler","firePressEvent","fireUpEvent","key2code","key","KEY_CODES","_self","addEventListener","_keyDownListener","_keyPressListener","_keyUpListener","releaseListeners","removeEventListener","down","press","up","isDown","extendStatics","__extends","setPrototypeOf","__proto__","hasOwnProperty","call","__","constructor","create","VertTuple_1","_super","_this","intersection","denominator","numerator1","numerator2","isNaN","VertTuple","MouseHandler","XWheelEvent","XMouseEvent","apply","arguments","MouseEvent","WheelEvent","name","mouseDownPos","undefined","mouseDragPos","mousePos","mouseButton","installed","handlers","mousemove","mkParams","drag","relPos","mouseup","button","mousedown","click","wheel","offsetX","offsetY","eventName","rel","xEvent","params","isTouchEvent","pos","leftButton","middleButton","rightButton","draggedFrom","wasDragged","dragAmount","listenFor","unlistenFor","callback","throwAlreadyInstalled","move","destroy","PBImage","image","upperLeft","lowerRight","draw_1","drawgl_1","drawutilssvg_1","BezierPath_1","Circle_1","CircleSector_1","Grid_1","KeyHandler_1","MouseHandler_1","PBImage_1","Triangle_1","VEllipse_1","VertexAttr_1","PlotBoilerplate","config","VertexAttr","model","bezierAutoAdjust","renderTime","selectable","isSelected","draggable","visible","canvas","f","fetch","fullSize","val","fitToParent","bool","scaleX","scaleY","rasterGrid","rasterScaleX","rasterScaleY","rasterAdjustFactor","drawOrigin","autoAdjustOffset","offsetAdjustXPercent","offsetAdjustYPercent","backgroundColor","redrawOnResize","defaultCanvasWidth","DEFAULT_CANVAS_WIDTH","defaultCanvasHeight","DEFAULT_CANVAS_HEIGHT","canvasWidthFactor","canvasHeightFactor","cssScaleX","cssScaleY","cssUniformScale","saveFile","hooks","setToRetina","_setToRetina","autoDetectRetina","enableSVGExport","preClear","func","preDraw","postDraw","enableMouse","enableTouch","enableKeys","enableMouseWheel","enableGL","drawConfig","drawVertices","drawBezierHandleLines","drawBezierHandlePoints","drawHandleLines","drawHandlePoints","drawGrid","bezier","color","lineWidth","handleLine","polygon","triangle","ellipse","circleSector","vertex","selectedVertex","vector","grid","canvasSize","canvasElement","document","querySelector","tagName","toLowerCase","eventCatcher","drawutilsgl","ctx","getContext","draw","fill","copyInstance","drawutils","drawutilssvg","parentElement","createElement","style","position","left","top","cursor","appendChild","body","selectPolygon","draggedElements","drawables","_saveFile","resizeCanvas","installInputListeners","updateCSSscale","redraw","focus","_a","pb","svgNode","createElementNS","tosvgDraw","offset","tosvgFill","beginDrawCycle","clear","drawAll","svgCode","XMLSerializer","serializeToString","blob","Blob","type","_saveAs","error","pixelRatio","devicePixelRatio","fitToView","bounds","canvasCenter","canvasRatio","ratio","addXY","setOffset","newUniformZoom","setZoom","setConsole","con","setCSSscale","drawable","VEllipse","axis","addDragListener","Triangle","attr","enableBezierPathAutoAdjust","remove","removeWithVertices","removeVertex","splice","removeAll","keepVertices","Boolean","getVertexNear","pixelPosition","pixelTolerance","locatePointNear","transformMousePosition","typeName","vindex","gScale","gSize","cs","round","setCurrentId","raster","crosshair","_handleColor","drawDrawables","setCurrentClassName","drawDrawable","cubicBezier","diamondHandle","circleHandle","polyline","circleArc","arrow","sub","drawSelectPolygon","squareHandle","Date","getTime","clearSelection","viewport","getFProp","elem","propName","parseFloat","getComputedStyle","getPropertyValue","getAvailableContainerSpace","container","parentNode","display","padding","border","pl","pr","pt","bl","br","bt","bb","w","clientWidth","clientHeight","_setSize","HTMLCanvasElement","SVGElement","setAttribute","setSize","innerWidth","documentElement","innerHeight","space","selectVerticesInPolygon","containsVert","tolerance","Draggable","VERTEX","setVIndex","handleClick","DEFAULT_CLICK_TOLERANCE","fireClickEvent","keyHandler","paths","pindex","cindex","pid","revertMousePosition","getDraggedElementCount","mouseDownHandler","which","fireDragStartEvent","mouseDragHandler","oldDragAmount","fireDragEvent","mouseUpHandler","fireDragEndEvent","mouseWheelHandler","zoomStep","we","deltaY","preventDefault","newOffset","zoomFactorX","zoomFactorY","interactionPos","oldPos","newPos","newOffsetX","newOffsetY","relPos_1","getBoundingClientRect","AF","touchMovePos","touchDownPos","draggedElement","multiTouchStartScale","clearTouch_1","touchStart","touches","clientX","clientY","DEFAULT_TOUCH_TOLERANCE","draggingVertex","fakeEvent","touchMove","stopPropagation","trans","diff","difference","deltaX","touchEnd","touchCancel","multipointStart","multipointEnd","pinch","fingerA","item","fingerB","zoom","createGUI","class_1","isVertex","safeMergeByKeys","extension","k","typ","transform","fallback","isOpen","addVertex","getVertexAt","index","inside","j","xi","yi","xj","yj","area","signedArea","isClockwise","factor","toQuadraticBezierData","qbezier","cc0","cc1","edgeCenter","limit","toQuadraticBezierSVGString","qdata","toCubicBezierData","threshold","cbezier","aCenter","bCenter","a2","b0","toCubicBezierSVGString","toCubicBezierPath","pathdata","total","l","sum","n","geomutils_1","calcCircumcircle","getArea","getCentroid","scaleToCentroid","centroid","getCircumcircle","isAdjacent","tri","getThirdVertex","vert1","vert2","dx","dy","A","B","C","D","E","F","G","EPSILON","cx","cy","radius_squared","inCircumcircle","min3","max3","determinant","containsPoint","pointIsInTriangle","getIncircularTriangle","lineA","lineB","lineC","bisector1","geomutils","nsectAngle","bisector2","getIncircle","getIncenter","p0x","p0y","p1x","p1y","p2x","p2y","px","py","s","current","vertA","vertB","inverse","buildArrowHead","zA","zB","headlen","atan2","factory","setLength","normalize","moveTo","newA","v0","v1","colinear","l2","vtutils","dist2","hasPoint","insideBoundsOnly","pointDistance","VertexListeners_1","tuple","NaN","VertexListeners","setX","setY","invX","invY","amountX","amountY","addX","addY","eqX","eqY","origin","len","ZERO","multiplyScalar","scalar","randomVertex","viewPort","random","dragStart","dragEnd","addClickListener","_addListener","removeClickListener","_removeListener","removeDragListener","addDragStartListener","removeDragStartListener","addDragEndListener","removeDragEndListener","_fireEvent","ve","newListener","oldListener","context","fillShapes","save","beginPath","lineTo","strokeStyle","stroke","restore","_fillOrDraw","complete","naturalWidth","drawImage","naturalHeight","rect","closePath","fillStyle","bezierCurveTo","quadraticBezier","controlPoint","quadraticCurveTo","cubicBezierPath","handle","square","dot","arc","asSegment","radiusX","radiusY","sizeX","sizeY","ceil","setLineDash","text","fillText","strokeText","label","rotation","clearRect","fillRect","gl","_zindex","glutils","GLU","_vertShader","compileShader","vertCode","VERTEX_SHADER","_fragShader","fragCode","FRAGMENT_SHADER","_program","makeProgram","vertex_buffer","createBuffer","_x2rel","_y2rel","copy","curId","Float32Array","bindBuffer","ARRAY_BUFFER","bufferData","STATIC_DRAW","coord","getAttribLocation","vertexAttribPointer","FLOAT","enableVertexAttribArray","uRotationVector","getUniformLocation","uniform2fv","drawArrays","LINES","TRIANGLE_FAN","clearColor","enable","DEPTH_TEST","COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","verts","vbuffer","shaderCode","shaderType","shader","createShader","shaderSource","getShaderParameter","COMPILE_STATUS","getShaderInfoLog","deleteShader","vertShader","fragShader","program","createProgram","attachShader","linkProgram","useProgram","detachShader","pA","pB","pC","lineAB","lineAC","insideAngle","clockwise","scaleFactor","isSecondary","gNode","cache","Map","addStyleDefs","createSVGNode","nodeStyle","keys","rules","drawSettings","innerHTML","findElement","nodeName","node","get","toUpperCase","delete","makeNode","_bindFillDraw","curClassName","_x","_y","setImageSize","ratioX","ratioY","src","arcData","childNodes","child","getAttribute","removeAllChildNodes","firstChild","removeChild","lastChild","createSvg","HEAD_XML","__webpack_module_cache__","__webpack_require__","moduleId","module","__webpack_modules__"],"mappings":"wCA2BAA,OAAOC,eAAeC,EAAS,aAAc,CAAEC,OAAO,IACtDD,EAAQE,gBAAa,EACrB,IAAIC,EAAW,EAAQ,KACnBC,EAAqB,EAAQ,KAC7BC,EAAiB,EAAQ,KACzBC,EAAW,EAAQ,KAcnBJ,EAA4B,WAa5B,SAASA,EAAWK,GAIhBC,KAAKC,UAAY,aAEjBD,KAAKE,YAAc,EAEnBF,KAAKG,oBAAsB,EAE3BH,KAAKI,kBAAoB,EAEzBJ,KAAKK,UAAY,EACjBL,KAAKM,IAAMT,EAAeU,aAAaC,OAClCT,IACDA,EAAa,IACjBC,KAAKS,eAAiB,EAGtBT,KAAKU,gBAAiB,EACtBV,KAAKW,aAAe,GAklCxB,OAtkCAjB,EAAWkB,UAAUC,SAAW,SAAUC,GACtC,GAAa,MAATA,QAAiC,IAATA,EACxB,KAAM,wCACVd,KAAKW,aAAaI,KAAKD,GACnBd,KAAKW,aAAaK,OAAS,GAC3BF,EAAMG,WAAajB,KAAKW,aAAa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AAyBE,GAC3B,OAAOF,EAAyBE,GAAU17B,QAG3C,IAAI27B,EAASH,EAAyBE,GAAY,CAGjD17B,QAAS,IAOV,OAHA47B,EAAoBF,GAAU7oB,KAAK8oB,EAAO37B,QAAS27B,EAAQA,EAAO37B,QAASy7B,GAGpEE,EAAO37B,QCjBf0Q,WAAW3P,aAAe,iBAC1B2P,WAAW+G,WAAa,kBACxB/G,WAAW8f,gBAAkB,uBAC7B9f,WAAWxJ,OAAS,cAEpBwJ,WAAW1I,OAAS,cACpB0I,WAAWhB,KAAO,WAClBgB,WAAWtE,KAAO,YAClBsE,WAAWpF,OAAS,cACpBoF,WAAWvH,iBAAmB,wBAC9BuH,WAAWxQ,WAAa,kBACxBwQ,WAAWzG,QAAU,eACrByG,WAAW0P,SAAW,gBACtB1P,WAAWuP,SAAW,gBACtBvP,WAAWjG,OAAS,cACpBiG,WAAWnE,aAAe,oBAC1BmE,WAAW4F,QAAU,eACrB5F,WAAWgD,aAAe,oBAC1BhD,WAAWN,WAAa,kBACxBM,WAAWkM,UAAY,iBAGvBlM,WAAWmM,aAAe,oBAC1BnM,WAAWsd,UAAY,iBACvBtd,WAAW6G,gBAAkB,U","file":"plotboilerplate.min.js","sourcesContent":["\"use strict\";\n/**\n * @author Ikaros Kappler\n * @date 2013-08-19\n * @modified 2018-08-16 Added closure. Removed the 'IKRS' wrapper.\n * @modified 2018-11-20 Added circular auto-adjustment.\n * @modified 2018-11-25 Added the point constants to the BezierPath class itself.\n * @modified 2018-11-28 Added the locateCurveByStartPoint() function.\n * @modified 2018-12-04 Added the toSVGString() function.\n * @modified 2019-03-23 Added JSDoc tags.\n * @modified 2019-03-23 Changed the fuctions getPoint and getPointAt to match semantics in the Line class.\n * @modified 2019-11-18 Fixed the clone function: adjustCircular attribute was not cloned.\n * @modified 2019-12-02 Removed some excessive comments.\n * @modified 2019-12-04 Fixed the missing obtainHandleLengths behavior in the adjustNeightbourControlPoint function.\n * @modified 2020-02-06 Added function locateCurveByEndPoint( Vertex ).\n * @modified 2020-02-11 Added 'return this' to the scale(Vertex,number) and to the translate(Vertex) function.\n * @modified 2020-03-24 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-06-03 Made the private helper function _locateUIndex to a private function.\n * @modified 2020-06-03 Added the getBounds() function.\n * @modified 2020-07-14 Changed the moveCurvePoint(...,Vertex) to moveCurvePoint(...,XYCoords).\n * @modified 2020-07-24 Added the getClosestT(Vertex) function.\n * @modified 2020-12-29 Constructor is now private (no explicit use intended).\n * @version 2.3.0\n *\n * @file BezierPath\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.BezierPath = void 0;\nvar Bounds_1 = require(\"./Bounds\");\nvar CubicBezierCurve_1 = require(\"./CubicBezierCurve\");\nvar UIDGenerator_1 = require(\"./UIDGenerator\");\nvar Vertex_1 = require(\"./Vertex\");\n/**\n * @classdesc A BezierPath class.\n *\n * This was refactored from an older project.\n *\n * @requires Bounds\n * @requires Vertex\n * @requires CubicBezierCurve\n * @requires XYCoords\n * @requires SVGSerializable\n * @requires UID\n * @requires UIDGenerator\n **/\nvar BezierPath = /** @class */ (function () {\n    /**\n     * The constructor.<br>\n     * <br>\n     * This constructor expects a sequence of path points and will approximate\n     * the location of control points by picking some between the points.<br>\n     * You should consider just constructing empty paths and then add more curves later using\n     * the addCurve() function.\n     *\n     * @constructor\n     * @name BezierPath\n     * @param {Vertex[]} pathPoints - An array of path vertices (no control points).\n     **/\n    function BezierPath(pathPoints) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"BezierPath\";\n        /** @constant {number} */\n        this.START_POINT = 0;\n        /** @constant {number} */\n        this.START_CONTROL_POINT = 1;\n        /** @constant {number} */\n        this.END_CONTROL_POINT = 2;\n        /** @constant {number} */\n        this.END_POINT = 3;\n        this.uid = UIDGenerator_1.UIDGenerator.next();\n        if (!pathPoints)\n            pathPoints = [];\n        this.totalArcLength = 0.0;\n        // Set this flag to true if you want the first point and\n        // last point of the path to be auto adjusted, too.\n        this.adjustCircular = false;\n        this.bezierCurves = [];\n    }\n    ;\n    /**\n     * Add a cubic bezier curve to the end of this path.\n     *\n     * @method addCurve\n     * @param {CubicBezierCurve} curve - The curve to be added to the end of the path.\n     * @instance\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    BezierPath.prototype.addCurve = function (curve) {\n        if (curve == null || typeof curve == 'undefined')\n            throw \"Cannot add null curve to bézier path.\";\n        this.bezierCurves.push(curve);\n        if (this.bezierCurves.length > 1) {\n            curve.startPoint = this.bezierCurves[this.bezierCurves.length - 2].endPoint;\n            this.adjustSuccessorControlPoint(this.bezierCurves.length - 2, // curveIndex,\n            true, // obtainHandleLength,  \n            true // updateArcLengths  \n            );\n        }\n        else {\n            this.totalArcLength += curve.getLength();\n        }\n    };\n    ;\n    /**\n     * Locate the curve with the given start point (function returns the index).\n     *\n     * @method locateCurveByStartPoint\n     * @param {Vertex} point - The (curve start-) point to look for.\n     * @instance\n     * @memberof BezierPath\n     * @return {number} The curve index or -1 if curve (start-) point not found\n     **/\n    BezierPath.prototype.locateCurveByStartPoint = function (point) {\n        // for( var i in this.bezierCurves ) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (this.bezierCurves[i].startPoint.equals(point))\n                return i;\n        }\n        return -1;\n    };\n    ;\n    /**\n     * Locate the curve with the given end point (function returns the index).\n     *\n     * @method locateCurveByEndPoint\n     * @param {Vertex} point - The (curve end-) point to look for.\n     * @instance\n     * @memberof BezierPath\n     * @return {number} The curve index or -1 if curve (end-) point not found\n     **/\n    BezierPath.prototype.locateCurveByEndPoint = function (point) {\n        // for( var i in this.bezierCurves ) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (this.bezierCurves[i].endPoint.equals(point))\n                return i;\n        }\n        return -1;\n    };\n    ;\n    /**\n     * Locate the curve with the given start point (function returns the index).\n     *\n     * @method locateCurveByStartControlPoint\n     * @param {Vertex} point - The (curve endt-) point to look for.\n     * @instance\n     * @memberof BezierPath\n     * @return {number} The curve index or -1 if curve (end-) point not found\n     **/\n    BezierPath.prototype.locateCurveByStartControlPoint = function (point) {\n        // for( var i in this.bezierCurves ) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (this.bezierCurves[i].startControlPoint.equals(point))\n                return i;\n        }\n        return -1;\n    };\n    ;\n    // +---------------------------------------------------------------------------------\n    // | Locate the curve with the given end control point.\n    // |\n    // | @param point:Vertex The point to look for.\n    // | @return Number The index or -1 if not found.\n    // +-------------------------------\n    BezierPath.prototype.locateCurveByEndControlPoint = function (point) {\n        // for( var i in this.bezierCurves ) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (this.bezierCurves[i].endControlPoint.equals(point))\n                return i;\n        }\n        return -1;\n    };\n    ;\n    /**\n     * Get the total length of this path.<br>\n     * <br>\n     * Note that the returned value comes from the curve buffer. Unregistered changes\n     * to the curve points will result in invalid path length values.\n     *\n     * @method getLength\n     * @instance\n     * @memberof BezierPath\n     * @return {number} The (buffered) length of the path.\n     **/\n    BezierPath.prototype.getLength = function () {\n        return this.totalArcLength;\n    };\n    ;\n    /**\n     * This function is internally called whenever the curve or path configuration\n     * changed. It updates the attribute that stores the path length information.<br>\n     * <br>\n     * If you perform any unregistered changes to the curve points you should call\n     * this function afterwards to update the curve buffer. Not updating may\n     * result in unexpected behavior.\n     *\n     * @method updateArcLengths\n     * @instance\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    BezierPath.prototype.updateArcLengths = function () {\n        this.totalArcLength = 0.0;\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            this.bezierCurves[i].updateArcLengths();\n            this.totalArcLength += this.bezierCurves[i].getLength();\n        }\n    };\n    ;\n    /**\n     * Get the number of curves in this path.\n     *\n     * @method getCurveCount\n     * @instance\n     * @memberof BezierPath\n     * @return {number} The number of curves in this path.\n     **/\n    BezierPath.prototype.getCurveCount = function () {\n        return this.bezierCurves.length;\n    };\n    ;\n    /**\n     * Get the cubic bezier curve at the given index.\n     *\n     * @method getCurveAt\n     * @param {number} index - The curve index from 0 to getCurveCount()-1.\n     * @instance\n     * @memberof BezierPath\n     * @return {CubicBezierCurve} The curve at the specified index.\n     **/\n    BezierPath.prototype.getCurveAt = function (curveIndex) {\n        return this.bezierCurves[curveIndex];\n    };\n    ;\n    /**\n     * Remove the end point of this path (which removes the last curve from this path).<br>\n     * <br>\n     * Please note that this function does never remove the first curve, thus the path\n     * cannot be empty after this call.\n     *\n     * @method removeEndPoint\n     * @instance\n     * @memberof BezierPath\n     * @return {boolean} Indicating if the last curve was removed.\n     **/\n    /*\n    BezierPath.prototype.removeEndPoint = function() {\n    if( this.bezierCurves.length <= 1 )\n        return false;\n    \n    var newArray = [ this.bezierCurves.length-1 ];\n    for( var i = 0; i < this.bezierCurves.length-1; i++ ) {\n        newArray[i] = this.bezierCurves[i];\n    }\n    \n    // Update arc length\n    this.totalArcLength -= this.bezierCurves[ this.bezierCurves.length-1 ].getLength();\n    this.bezierCurves = newArray;\n    return true;\n    }\n    */\n    /**\n     * Remove the start point of this path (which removes the first curve from this path).<br>\n     * <br>\n     * Please note that this function does never remove the last curve, thus the path\n     * cannot be empty after this call.<br>\n     *\n     * @method removeStartPoint\n     * @instance\n     * @memberof BezierPath\n     * @return {boolean} Indicating if the first curve was removed.\n     **/\n    /*\n    BezierPath.prototype.removeStartPoint = function() {\n\n    if( this.bezierCurves.length <= 1 )\n        return false;\n\n    var newArray = [ this.bezierCurves.length-1 ];\n    for( var i = 1; i < this.bezierCurves.length; i++ ) {\n\n        newArray[i-1] = this.bezierCurves[i];\n\n    }\n    \n    // Update arc length\n    this.totalArcLength -= this.bezierCurves[ 0 ].getLength();\n    this.bezierCurves = newArray;\n    \n    return true;\n    }\n    */\n    /**\n     * Removes a path point inside the path.\n     *\n     * This function joins the bezier curve at the given index with\n     * its predecessor, which means that the start point at the given\n     * curve index will be removed.\n     *\n     * @method joinAt\n     * @param {number} curveIndex - The index of the curve to be joined with its predecessor.\n     * @instance\n     * @memberof BezierPath\n     * @return {boolean} True if the passed index indicated an inner vertex and the two curves were joined.\n     **/\n    /*\n    BezierPath.prototype.joinAt = function( curveIndex ) {\n\n    if( curveIndex < 0 || curveIndex >= this.bezierCurves.length )\n        return false;\n    \n    var leftCurve  = this.bezierCurves[ curveIndex-1 ];\n    var rightCurve = this.bezierCurves[ curveIndex ];\n\n    // Make the length of the new handle double that long\n    var leftControlPoint = leftCurve.getStartControlPoint().clone();\n    leftControlPoint.sub( leftCurve.getStartPoint() );\n    leftControlPoint.multiplyScalar( 2.0 );\n    leftControlPoint.add( leftCurve.getStartPoint() );\n    \n    var rightControlPoint = rightCurve.getEndControlPoint().clone();\n    rightControlPoint.sub( rightCurve.getEndPoint() );\n    rightControlPoint.multiplyScalar( 2.0 );\n    rightControlPoint.add( rightCurve.getEndPoint() );\n\n    var newCurve = new IKRS.CubicBezierCurve( leftCurve.getStartPoint(),\n                          rightCurve.getEndPoint(),\n                          leftControlPoint,\n                          rightControlPoint\n                        );\n    // Place into array\n    var newArray = [ this.bezierCurves.length - 1 ];\n\n    for( var i = 0; i < curveIndex-1; i++ )\n        newArray[ i ] = this.bezierCurves[i];\n    \n    newArray[ curveIndex-1 ] = newCurve;\n    \n    // Shift trailing curves left\n    for( var i = curveIndex; i+1 < this.bezierCurves.length; i++ )\n        newArray[ i ] = this.bezierCurves[ i+1 ];\n        \n    this.bezierCurves = newArray;\n    this.updateArcLengths();\n\n    return true;\n    }\n    */\n    /**\n     * Add a new inner curve point to the path.<br>\n     * <br>\n     * This function splits the bezier curve at the given index and given\n     * curve segment index.\n     *\n     * @method splitAt\n     * @param {number} curveIndex - The index of the curve to split.\n     * @param {nunber} segmentIndex - The index of the curve segment where the split should be performed.\n     * @instance\n     * @memberof BezierPath\n     * @return {boolean} True if the passed indices were valid and the path was split.\n     **/\n    /*\n    BezierPath.prototype.splitAt = function( curveIndex,\n                         segmentIndex\n                       ) {\n    // Must be a valid curve index\n    if( curveIndex < 0 || curveIndex >= this.bezierCurves.length )\n        return false;\n\n    var oldCurve = this.bezierCurves[ curveIndex ];\n\n    // Segment must be an INNER point!\n    // (the outer points are already bezier end/start points!)\n    if( segmentIndex < 1 || segmentIndex-1 >= oldCurve.segmentCache.length )\n        return false;\n\n    // Make room for a new curve\n    for( var c = this.bezierCurves.length; c > curveIndex; c-- ) {\n        // Move one position to the right\n        this.bezierCurves[ c ] = this.bezierCurves[ c-1 ];\n    }\n\n    // Accumulate segment lengths\n    var u = 0;\n    for( var i = 0; i < segmentIndex; i++ )\n        u += oldCurve.segmentLengths[i];\n    //var tangent = oldCurve.getTangentAt( u );\n    var tangent = oldCurve.getTangent( u );\n    tangent = tangent.multiplyScalar( 0.25 );\n\n    var leftEndControlPoint = oldCurve.segmentCache[ segmentIndex ].clone();\n    leftEndControlPoint.sub( tangent );\n    \n    var rightStartControlPoint = oldCurve.segmentCache[ segmentIndex ].clone();\n    rightStartControlPoint.add( tangent );\n    \n    // Make the old existing handles a quarter that long\n    var leftStartControlPoint = oldCurve.getStartControlPoint().clone();\n    // move to (0,0)\n    leftStartControlPoint.sub( oldCurve.getStartPoint() );\n    leftStartControlPoint.multiplyScalar( 0.25 );\n    leftStartControlPoint.add( oldCurve.getStartPoint() );\n\n    var rightEndControlPoint = oldCurve.getEndControlPoint().clone();\n    // move to (0,0)\n    rightEndControlPoint.sub( oldCurve.getEndPoint() );\n    rightEndControlPoint.multiplyScalar( 0.25 );\n    rightEndControlPoint.add( oldCurve.getEndPoint() );\n\n    var newLeft  = new CubicBezierCurve( oldCurve.getStartPoint(),                      // old start point\n                         oldCurve.segmentCache[ segmentIndex ],         // new end point\n                         leftStartControlPoint,                         // old start control point\n                         leftEndControlPoint                            // new end control point\n                       );\n    var newRight = new CubicBezierCurve( oldCurve.segmentCache[ segmentIndex ],         // new start point\n                         oldCurve.getEndPoint(),                        // old end point\n                         rightStartControlPoint,                        // new start control point\n                         rightEndControlPoint                           // old end control point\n                       );\n    \n    // Insert split curve(s) at free index\n    this.bezierCurves[ curveIndex ]     = newLeft;\n    this.bezierCurves[ curveIndex + 1 ] = newRight;\n    \n    // Update total arc length, even if there is only a very little change!\n    this.totalArcLength -= oldCurve.getLength();\n    this.totalArcLength += newLeft.getLength();\n    this.totalArcLength += newRight.getLength();\n\n    return true;\n    };\n    */\n    /*\n    insertVertexAt( t:number ) : void {\n    console.log('Inserting vertex at', t );\n    // Find the curve index\n    var u : number = 0;\n    var curveIndex : number = -1;\n    var localT : number = 0.0;\n    for( var i = 0; curveIndex == -1 && i < this.bezierCurves.length; i++ ) {\n        \n    }\n    }; */\n    /**\n     * Move the whole bezier path by the given (x,y)-amount.\n     *\n     * @method translate\n     * @param {Vertex} amount - The amount to be added (amount.x and amount.y)\n     *                          to each vertex of the curve.\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath} this for chaining\n     **/\n    BezierPath.prototype.translate = function (amount) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            var curve = this.bezierCurves[i];\n            curve.getStartPoint().add(amount);\n            curve.getStartControlPoint().add(amount);\n            curve.getEndControlPoint().add(amount);\n        }\n        // Don't forget to translate the last curve's last point\n        var curve = this.bezierCurves[this.bezierCurves.length - 1];\n        curve.getEndPoint().add(amount);\n        this.updateArcLengths();\n        return this;\n    };\n    ;\n    /**\n     * Scale the whole bezier path by the given (x,y)-factors.\n     *\n     * @method scale\n     * @param {Vertex} anchor - The scale origin to scale from.\n     * @param {number} amount - The scalar to be multiplied with.\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath} this for chaining.\n     **/\n    BezierPath.prototype.scale = function (anchor, scaling) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            var curve = this.bezierCurves[i];\n            curve.getStartPoint().scale(scaling, anchor);\n            curve.getStartControlPoint().scale(scaling, anchor);\n            curve.getEndControlPoint().scale(scaling, anchor);\n            // Do NOT scale the end point here!\n            // Don't forget that the curves are connected and on curve's end point\n            // the the successor's start point (same instance)!\n        }\n        // Finally move the last end point (was not scaled yet)\n        if (this.bezierCurves.length > 0 && !this.adjustCircular) {\n            this.bezierCurves[this.bezierCurves.length - 1].getEndPoint().scale(scaling, anchor);\n        }\n        this.updateArcLengths();\n        return this;\n    };\n    ;\n    /**\n     * Rotate the whole bezier path around a point..\n     *\n     * @method rotate\n     * @param {Vertex} angle  - The angle to rotate this path by.\n     * @param {Vertex} center - The rotation center.\n     * @instance\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    BezierPath.prototype.rotate = function (angle, center) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            var curve = this.bezierCurves[i];\n            curve.getStartPoint().rotate(angle, center);\n            curve.getStartControlPoint().rotate(angle, center);\n            curve.getEndControlPoint().rotate(angle, center);\n            // Do NOT rotate the end point here!\n            // Don't forget that the curves are connected and on curve's end point\n            // the the successor's start point (same instance)!\n        }\n        // Finally move the last end point (was not scaled yet)\n        if (this.bezierCurves.length > 0 && !this.adjustCircular) {\n            this.bezierCurves[this.bezierCurves.length - 1].getEndPoint().rotate(angle, center);\n        }\n    };\n    ;\n    /**\n     * Get the 't' position on this curve with the minimal distance to point p.\n     *\n     * @param {Vertex} p - The point to find the closest curve point for.\n     * @return {number} A value t with 0.0 <= t <= 1.0.\n     **/\n    BezierPath.prototype.getClosestT = function (p) {\n        // Find the spline to extract the value from\n        // var i : number = 0;\n        var uTemp = 0.0;\n        var minIndex = -1;\n        var minDist = 0.0;\n        var dist = 0.0;\n        var curveT = 0.0;\n        var uMin = 0.0;\n        var u = 0.0;\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            curveT = this.bezierCurves[i].getClosestT(p);\n            dist = this.bezierCurves[i].getPointAt(curveT).distance(p);\n            if (minIndex == -1 || dist < minDist) {\n                minIndex = i;\n                minDist = dist;\n                uMin = u + curveT * this.bezierCurves[i].getLength();\n            }\n            u += this.bezierCurves[i].getLength();\n        }\n        return Math.max(0.0, Math.min(1.0, uMin / this.totalArcLength));\n    };\n    ;\n    /**\n     * Get the point on the bézier path at the given relative path location.\n     *\n     * @method getPoint\n     * @param {number} u - The relative path position: <pre>0 <= u <= this.getLength()</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The point at the relative path position.\n     **/\n    BezierPath.prototype.getPoint = function (u) {\n        if (u < 0 || u > this.totalArcLength) {\n            console.log(\"[BezierPath.getPoint(u)] u is out of bounds: \" + u + \".\");\n            return null;\n        }\n        // Find the spline to extract the value from\n        var i = 0;\n        var uTemp = 0.0;\n        while (i < this.bezierCurves.length &&\n            (uTemp + this.bezierCurves[i].getLength()) < u) {\n            uTemp += this.bezierCurves[i].getLength();\n            i++;\n        }\n        // if u == arcLength\n        //   -> i is max\n        if (i >= this.bezierCurves.length)\n            return this.bezierCurves[this.bezierCurves.length - 1].getEndPoint().clone();\n        var bCurve = this.bezierCurves[i];\n        var relativeU = u - uTemp;\n        return bCurve.getPoint(relativeU);\n    };\n    ;\n    /**\n     * Get the point on the bézier path at the given path fraction.\n     *\n     * @method getPointAt\n     * @param {number} t - The absolute path position: <pre>0.0 <= t <= 1.0</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The point at the absolute path position.\n     **/\n    BezierPath.prototype.getPointAt = function (t) {\n        return this.getPoint(t * this.totalArcLength);\n    };\n    ;\n    /**\n     * Get the tangent of the bézier path at the given path fraction.<br>\n     * <br>\n     * Note that the returned vector is not normalized.\n     *\n     * @method getTangentAt\n     * @param {number} t - The absolute path position: <pre>0.0 <= t <= 1.0</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The tangent vector at the absolute path position.\n     **/\n    BezierPath.prototype.getTangentAt = function (t) {\n        return this.getTangent(t * this.totalArcLength);\n    };\n    ;\n    /**\n     *  Get the tangent of the bézier path at the given path location.<br>\n     * <br>\n     * Note that the returned vector is not normalized.\n     *\n     * @method getTangent\n     * @param {number} u - The relative path position: <pre>0 <= u <= getLength()</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The tangent vector at the relative path position.\n     **/\n    BezierPath.prototype.getTangent = function (u) {\n        if (u < 0 || u > this.totalArcLength) {\n            console.warn(\"[BezierPath.getTangent(u)] u is out of bounds: \" + u + \".\");\n            return null;\n        }\n        // Find the spline to extract the value from\n        var i = 0;\n        var uTemp = 0.0;\n        while (i < this.bezierCurves.length &&\n            (uTemp + this.bezierCurves[i].getLength()) < u) {\n            uTemp += this.bezierCurves[i].getLength();\n            i++;\n        }\n        var bCurve = this.bezierCurves[i];\n        var relativeU = u - uTemp;\n        return bCurve.getTangent(relativeU);\n    };\n    ;\n    /**\n     * Get the perpendicular of the bézier path at the given absolute path location (fraction).<br>\n     * <br>\n     * Note that the returned vector is not normalized.\n     *\n     * @method getPerpendicularAt\n     * @param {number} t - The absolute path position: <pre>0.0 <= t <= 1.0</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The perpendicluar vector at the absolute path position.\n     **/\n    BezierPath.prototype.getPerpendicularAt = function (t) {\n        return this.getPerpendicular(t * this.totalArcLength);\n    };\n    ;\n    /**\n     * Get the perpendicular of the bézier path at the given relative path location.<br>\n     * <br>\n     * Note that the returned vector is not normalized.\n     *\n     * @method getPerpendicular\n     * @param {number} u - The relative path position: <pre>0 <= u <= getLength()</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The perpendicluar vector at the relative path position.\n     **/\n    BezierPath.prototype.getPerpendicular = function (u) {\n        if (u < 0 || u > this.totalArcLength) {\n            console.log(\"[BezierPath.getPerpendicular(u)] u is out of bounds: \" + u + \".\");\n            return null;\n        }\n        // Find the spline to extract the value from\n        var i = 0;\n        var uTemp = 0.0;\n        var uResult = BezierPath._locateUIndex(this, u);\n        var bCurve = this.bezierCurves[uResult.i];\n        var relativeU = u - uResult.uPart;\n        return bCurve.getPerpendicular(relativeU);\n    };\n    ;\n    /**\n     * This is a helper function to locate the curve index for a given\n     * absolute path position u.\n     *\n     * I decided to put this into privat scope as it is really specific. Maybe\n     * put this into a utils wrapper.\n     *\n     * Returns:\n     * - {number} i - the index of the containing curve.\n     * - {number} uPart - the absolute curve length sum (length from the beginning to u, should equal u itself).\n     * - {number} uBefore - the absolute curve length for all segments _before_ the matched curve (usually uBefore <= uPart).\n     **/\n    BezierPath._locateUIndex = function (path, u) {\n        var i = 0;\n        var uTemp = 0.0;\n        var uBefore = 0.0;\n        while (i < path.bezierCurves.length &&\n            (uTemp + path.bezierCurves[i].getLength()) < u) {\n            uTemp += path.bezierCurves[i].getLength();\n            if (i + 1 < path.bezierCurves.length)\n                uBefore += path.bezierCurves[i].getLength();\n            i++;\n        }\n        return { i: i, uPart: uTemp, uBefore: uBefore };\n    };\n    ;\n    /**\n     * Get a specific sub path from this path. The start and end position are specified by\n     * ratio number in [0..1].\n     *\n     * 0.0 is at the beginning of the path.\n     * 1.0 is at the end of the path.\n     *\n     * Values below 0 or beyond 1 are cropped down to the [0..1] interval.\n     *\n     * startT > endT is allowed, the returned sub path will have inverse direction then.\n     *\n     * @method getSubPathAt\n     * @param {number} startT - The start position of the sub path.\n     * @param {number} endT - The end position of the sub path.\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath} The desired sub path in the bounds [startT..endT].\n     **/\n    BezierPath.prototype.getSubPathAt = function (startT, endT) {\n        startT = Math.max(0, startT);\n        endT = Math.min(1.0, endT);\n        var startU = startT * this.totalArcLength;\n        var endU = endT * this.totalArcLength;\n        var uStartResult = BezierPath._locateUIndex(this, startU); // { i:int, uPart:float, uBefore:float }\n        var uEndResult = BezierPath._locateUIndex(this, endU); // { i:int, uPart:float, uBefore:float }\n        var firstT = (startU - uStartResult.uBefore) / this.bezierCurves[uStartResult.i].getLength();\n        if (uStartResult.i == uEndResult.i) {\n            // Subpath begins and ends in the same path segment (just get a simple sub curve from that path element).\n            var lastT = (endU - uEndResult.uBefore) / this.bezierCurves[uEndResult.i].getLength();\n            var firstCurve = this.bezierCurves[uStartResult.i].getSubCurveAt(firstT, lastT);\n            return BezierPath.fromArray([firstCurve]);\n        }\n        else {\n            var curves = [];\n            if (uStartResult.i > uEndResult.i) {\n                // Back to front direction\n                var firstCurve = this.bezierCurves[uStartResult.i].getSubCurveAt(firstT, 0.0);\n                curves.push(firstCurve);\n                for (var i = uStartResult.i - 1; i > uEndResult.i; i--) {\n                    curves.push(this.bezierCurves[i].clone().reverse());\n                }\n                var lastT = (endU - uEndResult.uBefore) / this.bezierCurves[uEndResult.i].getLength();\n                curves.push(this.bezierCurves[uEndResult.i].getSubCurveAt(1.0, lastT));\n            }\n            else {\n                // Front to back direction\n                var firstCurve = this.bezierCurves[uStartResult.i].getSubCurveAt(firstT, 1.0);\n                curves.push(firstCurve);\n                for (var i = uStartResult.i + 1; i < uEndResult.i && i < this.bezierCurves.length; i++) {\n                    curves.push(this.bezierCurves[i].clone());\n                }\n                var lastT = (endU - uEndResult.uBefore) / this.bezierCurves[uEndResult.i].getLength();\n                curves.push(this.bezierCurves[uEndResult.i].getSubCurveAt(0, lastT));\n            }\n            return BezierPath.fromArray(curves);\n        }\n    };\n    ;\n    /**\n     * This function moves the addressed curve point (or control point) with\n     * keeping up the path's curve integrity.<br>\n     * <br>\n     * Thus is done by moving neighbour- and control- points as needed.\n     *\n     * @method moveCurvePoint\n     * @param {number} curveIndex - The curve index to move a point from.\n     * @param {number} pointID - One of the curve's four point IDs (START_POINT,\n     *                           START_CONTROL_POINT, END_CONTRO_POINT or END_POINT).\n     * @param {XYCoords} moveAmount - The amount to move the addressed vertex by.\n     * @instance\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    BezierPath.prototype.moveCurvePoint = function (curveIndex, pointID, moveAmount) {\n        var bCurve = this.getCurveAt(curveIndex);\n        bCurve.moveCurvePoint(pointID, moveAmount, true, // move control point, too\n        true // updateArcLengths\n        );\n        // If inner point and NOT control point\n        //  --> move neightbour\n        if (pointID == this.START_POINT && (curveIndex > 0 || this.adjustCircular)) {\n            // Set predecessor's control point!\n            var predecessor = this.getCurveAt(curveIndex - 1 < 0 ? this.bezierCurves.length + (curveIndex - 1) : curveIndex - 1);\n            predecessor.moveCurvePoint(this.END_CONTROL_POINT, moveAmount, true, // move control point, too\n            false // updateArcLengths\n            );\n        }\n        else if (pointID == this.END_POINT && (curveIndex + 1 < this.bezierCurves.length || this.adjustCircular)) {\n            // Set successcor\n            var successor = this.getCurveAt((curveIndex + 1) % this.bezierCurves.length);\n            successor.moveCurvePoint(this.START_CONTROL_POINT, moveAmount, true, // move control point, too\n            false // updateArcLengths\n            );\n        }\n        else if (pointID == this.START_CONTROL_POINT && curveIndex > 0) {\n            this.adjustPredecessorControlPoint(curveIndex, true, // obtain handle length?\n            false // update arc lengths\n            );\n        }\n        else if (pointID == this.END_CONTROL_POINT && curveIndex + 1 < this.getCurveCount()) {\n            this.adjustSuccessorControlPoint(curveIndex, true, // obtain handle length?\n            false // update arc lengths\n            );\n        }\n        // Don't forget to update the arc lengths!\n        // Note: this can be optimized as only two curves have changed their lengths!\n        this.updateArcLengths();\n    };\n    ;\n    /**\n     * This helper function adjusts the given point's predecessor's control point.\n     *\n     * @method adjustPredecessorControlPoint\n     * @param {number} curveIndex - The curve index to move a point from.\n     * @param {boolean} obtainHandleLength - Moves the point with keeping the original handle length.\n     * @param {boolean} updateArcLength - The amount to move the addressed vertex by.\n     * @instance\n     * @private\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    BezierPath.prototype.adjustPredecessorControlPoint = function (curveIndex, obtainHandleLength, updateArcLengths) {\n        if (!this.adjustCircular && curveIndex <= 0)\n            return; // false;\n        var mainCurve = this.getCurveAt(curveIndex);\n        var neighbourCurve = this.getCurveAt(curveIndex - 1 < 0 ? this.getCurveCount() + (curveIndex - 1) : curveIndex - 1);\n        BezierPath.adjustNeighbourControlPoint(mainCurve, neighbourCurve, mainCurve.getStartPoint(), // the reference point\n        mainCurve.getStartControlPoint(), // the dragged control point\n        neighbourCurve.getEndPoint(), // the neighbour's point\n        neighbourCurve.getEndControlPoint(), // the neighbour's control point to adjust\n        obtainHandleLength, updateArcLengths);\n    };\n    ;\n    /**\n     * This helper function adjusts the given point's successor's control point.\n     *\n     * @method adjustSuccessorControlPoint\n     * @param {number} curveIndex - The curve index to move a point from.\n     * @param {boolean} obtainHandleLength - Moves the point with keeping the original handle length.\n     * @param {boolean} updateArcLength - The amount to move the addressed vertex by.\n     * @instance\n     * @private\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    BezierPath.prototype.adjustSuccessorControlPoint = function (curveIndex, obtainHandleLength, updateArcLengths) {\n        if (!this.adjustCircular && curveIndex + 1 > this.getCurveCount())\n            return; //  false; \n        var mainCurve = this.getCurveAt(curveIndex);\n        var neighbourCurve = this.getCurveAt((curveIndex + 1) % this.getCurveCount());\n        /* return */ BezierPath.adjustNeighbourControlPoint(mainCurve, neighbourCurve, mainCurve.getEndPoint(), // the reference point\n        mainCurve.getEndControlPoint(), // the dragged control point\n        neighbourCurve.getStartPoint(), // the neighbour's point\n        neighbourCurve.getStartControlPoint(), // the neighbour's control point to adjust\n        obtainHandleLength, updateArcLengths);\n    };\n    ;\n    /**\n     * This helper function adjusts the given point's successor's control point.\n     *\n     * @method adjustNeighbourControlPoint\n     * @param {CubicBezierCurve} mainCurve\n     * @param {CubicBezierCurve} neighbourCurve\n     * @param {Vertex} mainPoint\n     * @param {Vertex} mainControlPoint\n     * @param {Vertex} neighbourPoint\n     * @param {Vertex} neighbourControlPoint\n     * @param {boolean} obtainHandleLengths\n     * @param {boolean} updateArcLengths\n     * @instance\n     * @private\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    // !!! TODO: SHOULDNT THIS BE A STATIC FUNCTION ???\n    BezierPath.adjustNeighbourControlPoint = function (mainCurve, neighbourCurve, mainPoint, mainControlPoint, neighbourPoint, neighbourControlPoint, obtainHandleLengths, updateArcLengths) {\n        // Calculate start handle length\n        var mainHandleBounds = new Vertex_1.Vertex(mainControlPoint.x - mainPoint.x, mainControlPoint.y - mainPoint.y);\n        var neighbourHandleBounds = new Vertex_1.Vertex(neighbourControlPoint.x - neighbourPoint.x, neighbourControlPoint.y - neighbourPoint.y);\n        var mainHandleLength = Math.sqrt(Math.pow(mainHandleBounds.x, 2) + Math.pow(mainHandleBounds.y, 2));\n        var neighbourHandleLength = Math.sqrt(Math.pow(neighbourHandleBounds.x, 2) + Math.pow(neighbourHandleBounds.y, 2));\n        if (mainHandleLength <= 0.1)\n            return; // no secure length available for division? What about zoom? Use EPSILON?\t\n        // Just invert the main handle (keep length or not?\n        if (obtainHandleLengths) {\n            neighbourControlPoint.set(neighbourPoint.x - mainHandleBounds.x * (neighbourHandleLength / mainHandleLength), neighbourPoint.y - mainHandleBounds.y * (neighbourHandleLength / mainHandleLength));\n        }\n        else {\n            neighbourControlPoint.set(neighbourPoint.x - mainHandleBounds.x, neighbourPoint.y - mainHandleBounds.y);\n        }\n        neighbourCurve.updateArcLengths();\n    };\n    ;\n    /**\n     * Get the bounds of this Bézier path.\n     *\n     * Note the the curves' underlyung segment buffers are used to determine the bounds. The more\n     * elements the segment buffers have, the more precise the returned bounds will be.\n     *\n     * @return {Bounds} The bounds of this Bézier path.\n     **/\n    BezierPath.prototype.getBounds = function () {\n        var min = new Vertex_1.Vertex(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);\n        var max = new Vertex_1.Vertex(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);\n        var b;\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            b = this.bezierCurves[i].getBounds();\n            min.x = Math.min(min.x, b.min.x);\n            min.y = Math.min(min.y, b.min.y);\n            max.x = Math.max(max.x, b.max.x);\n            max.y = Math.max(max.y, b.max.y);\n        }\n        return new Bounds_1.Bounds(min, max);\n    };\n    ;\n    /**\n     * Clone this BezierPath (deep clone).\n     *\n     * @method clone\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath}\n     **/\n    BezierPath.prototype.clone = function () {\n        var path = new BezierPath(null);\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            path.bezierCurves.push(this.bezierCurves[i].clone());\n            // Connect splines\n            if (i > 0)\n                path.bezierCurves[i - 1].endPoint = path.bezierCurves[i].startPoint;\n        }\n        path.updateArcLengths();\n        path.adjustCircular = this.adjustCircular;\n        return path;\n    };\n    ;\n    /**\n     * Compare this and the passed Bézier path.\n     *\n     * @method equals\n     * @param {BezierPath} path - The pass to compare with.\n     * @instance\n     * @memberof BezierPath\n     * @return {boolean}\n     **/\n    BezierPath.prototype.equals = function (path) {\n        if (!path)\n            return false;\n        // Check if path contains the credentials\n        if (!path.bezierCurves)\n            return false;\n        if (typeof path.bezierCurves.length == \"undefined\")\n            return false;\n        if (path.bezierCurves.length != this.bezierCurves.length)\n            return false;\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (!this.bezierCurves[i].equals(path.bezierCurves[i]))\n                return false;\n        }\n        return true;\n    };\n    ;\n    /**\n     * Create a <pre>&lt;path&gt;</pre> SVG representation of this bézier curve.\n     *\n     * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.\n     * @method toSVGString\n     * @param {object=} [options={}] - Like options.className\n     * @param {string=} [options.className] - The classname to use for the SVG item.\n     * @instance\n     * @memberof BezierPath\n     * @return {string} The SVG string.\n     **/\n    BezierPath.prototype.toSVGString = function (options) {\n        options = options || {};\n        var buffer = [];\n        buffer.push('<path');\n        if (options.className)\n            buffer.push(' class=\"' + options.className + '\"');\n        buffer.push(' d=\"');\n        for (var c = 0; c < this.bezierCurves.length; c++) {\n            if (c > 0)\n                buffer.push(' ');\n            buffer.push(this.bezierCurves[c].toSVGPathData());\n        }\n        buffer.push('\" />');\n        return buffer.join('');\n    };\n    ;\n    /**\n     * Create a JSON string representation of this bézier curve.\n     *\n     * @method toJSON\n     * @param {boolean} prettyFormat - If true then the function will add line breaks.\n     * @instance\n     * @memberof BezierPath\n     * @return {string} The JSON string.\n     **/\n    BezierPath.prototype.toJSON = function (prettyFormat) {\n        var buffer = [];\n        buffer.push(\"[\"); // array begin\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (i > 0)\n                buffer.push(\",\");\n            if (prettyFormat)\n                buffer.push(\"\\n\\t\");\n            else\n                buffer.push(\" \");\n            buffer.push(this.bezierCurves[i].toJSON(prettyFormat));\n        }\n        if (this.bezierCurves.length != 0)\n            buffer.push(\" \");\n        buffer.push(\"]\"); // array end\n        return buffer.join(\"\"); // Convert to string, with empty separator.\n    };\n    ;\n    /**\n     * Parse a BezierPath from the given JSON string.\n     *\n     * @method fromJSON\n     * @param {string} jsonString - The string with the JSON data.\n     * @throw An error if the string is not JSON or does not contain a bezier path object.\n     * @static\n     * @memberof BezierPath\n     * @return {BezierPath} The parsed bezier path instance.\n     **/\n    BezierPath.fromJSON = function (jsonString) {\n        var obj = JSON.parse(jsonString);\n        return BezierPath.fromArray(obj);\n    };\n    ;\n    /**\n     * Create a BezierPath instance from the given array.\n     *\n     * @method fromArray\n     * @param {Vertex[][]} arr - A two-dimensional array containing the bezier path vertices.\n     * @throw An error if the array does not contain proper bezier path data.\n     * @static\n     * @memberof BezierPath\n     * @return {BezierPath} The bezier path instance retrieved from the array data.\n     **/\n    BezierPath.fromArray = function (obj) {\n        if (!Array.isArray(obj))\n            throw \"[BezierPath.fromArray] Passed object must be an array.\";\n        var arr = obj; // FORCE?\n        if (arr.length < 1)\n            throw \"[BezierPath.fromArray] Passed array must contain at least one bezier curve (has \" + arr.length + \").\";\n        // Create an empty bezier path\n        var bPath = new BezierPath(null);\n        var lastCurve = null;\n        for (var i = 0; i < arr.length; i++) {\n            // Convert object (or array?) to bezier curve\n            var bCurve = null;\n            if (CubicBezierCurve_1.CubicBezierCurve.isInstance(arr[i])) {\n                bCurve = arr[i].clone();\n            }\n            else if (0 in arr[i] && 1 in arr[i] && 2 in arr[i] && 3 in arr[i]) {\n                if (!arr[i][0] || !arr[i][1] || !arr[i][2] || !arr[i][3])\n                    throw \"Cannot convert path data to BezierPath instance. At least one element is undefined (index=\" + i + \"): \" + arr[i];\n                bCurve = CubicBezierCurve_1.CubicBezierCurve.fromArray(arr[i]);\n            }\n            else {\n                bCurve = CubicBezierCurve_1.CubicBezierCurve.fromObject(arr[i]);\n            }\n            // Set curve start point?\n            // (avoid duplicate point instances!)\n            if (lastCurve)\n                bCurve.startPoint = lastCurve.endPoint;\n            // Add to path's internal list\n            bPath.bezierCurves.push(bCurve);\n            // bPath.totalArcLength += bCurve.getLength(); \t    \n            lastCurve = bCurve;\n        }\n        bPath.updateArcLengths();\n        // Bezier segments added. Done\n        return bPath;\n    };\n    ;\n    /**\n     * This function converts the bezier path into a string containing\n     * integer values only.\n     * The points' float values are rounded to 1 digit after the comma.\n     *\n     * The returned string represents a JSON array (with leading '[' and\n     * trailing ']', the separator is ',').\n     *\n     * @method toReducedListRepresentation\n     * @param {number} digits - The number of digits to be used after the comma '.'.\n     * @instance\n     * @memberof BezierPath\n     * @return {string} The reduced list representation of this path.\n     **/\n    BezierPath.prototype.toReducedListRepresentation = function (digits) {\n        if (typeof digits == \"undefined\")\n            digits = 1;\n        var buffer = [];\n        buffer.push(\"[\"); // array begin\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            var curve = this.bezierCurves[i];\n            buffer.push(curve.getStartPoint().x.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getStartPoint().y.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getStartControlPoint().x.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getStartControlPoint().y.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getEndControlPoint().x.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getEndControlPoint().y.toFixed(digits));\n            buffer.push(\",\");\n        }\n        if (this.bezierCurves.length != 0) {\n            var curve = this.bezierCurves[this.bezierCurves.length - 1];\n            buffer.push(curve.getEndPoint().x.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getEndPoint().y.toFixed(digits));\n        }\n        buffer.push(\"]\"); // array end\n        return buffer.join(\"\"); // Convert to string, with empty separator.\n    };\n    ;\n    /**\n     * Parse a BezierPath instance from the reduced list representation.<br>\n     * <br>\n     * The passed string must represent a JSON array containing numbers only.\n     *\n     * @method fromReducedListRepresentation\n     * @param {string} listJSON - The number of digits to be used after the floating point.\n     * @throw An error if the string is malformed.\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath} The bezier path instance retrieved from the string.\n     **/\n    BezierPath.fromReducedListRepresentation = function (listJSON) {\n        // Parse the array\n        var pointArray = JSON.parse(listJSON);\n        if (!pointArray.length) {\n            console.log(\"Cannot parse bezier path from non-array object nor from empty point list.\");\n            throw \"Cannot parse bezier path from non-array object nor from empty point list.\";\n        }\n        if (pointArray.length < 8) {\n            console.log(\"Cannot build bezier path. The passed array must contain at least 8 elements (numbers).\");\n            throw \"Cannot build bezier path. The passed array must contain at least 8 elements (numbers).\";\n        }\n        // Convert to object\n        var bezierPath = new BezierPath(null); // No points yet\n        var startPoint = null;\n        var startControlPoint = null;\n        var endControlPoint = null;\n        var endPoint = null;\n        var i = 0;\n        do {\n            if (i == 0)\n                startPoint = new Vertex_1.Vertex(pointArray[i], pointArray[i + 1]);\n            startControlPoint = new Vertex_1.Vertex(pointArray[i + 2], pointArray[i + 3]);\n            endControlPoint = new Vertex_1.Vertex(pointArray[i + 4], pointArray[i + 5]);\n            endPoint = new Vertex_1.Vertex(pointArray[i + 6], pointArray[i + 7]);\n            var bCurve = new CubicBezierCurve_1.CubicBezierCurve(startPoint, endPoint, startControlPoint, endControlPoint);\n            bezierPath.bezierCurves.push(bCurve);\n            startPoint = endPoint;\n            i += 6;\n        } while (i + 2 < pointArray.length);\n        bezierPath.updateArcLengths();\n        return bezierPath;\n    };\n    ;\n    // +---------------------------------------------------------------------------------\n    // | These constants equal the values from CubicBezierCurve.\n    // +-------------------------------\n    /** @constant {number} */\n    BezierPath.START_POINT = 0;\n    /** @constant {number} */\n    BezierPath.START_CONTROL_POINT = 1;\n    /** @constant {number} */\n    BezierPath.END_CONTROL_POINT = 2;\n    /** @constant {number} */\n    BezierPath.END_POINT = 3;\n    return BezierPath;\n}());\nexports.BezierPath = BezierPath;\n//# sourceMappingURL=BezierPath.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2020-05-11\n * @modified 2020-10-30 Added the static computeFromVertices function.\n * @modified 2020-11-19 Set min, max, width and height to private.\n * @modified 2021-02-02 Added the `toPolygon` method.\n * @version  1.2.0\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Bounds = void 0;\nvar Polygon_1 = require(\"./Polygon\");\nvar Vertex_1 = require(\"./Vertex\");\n/**\n * @classdesc A bounds class with min and max values. Implementing IBounds.\n *\n * @requires XYCoords\n * @requires Vertex\n * @requires IBounds\n **/\nvar Bounds = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name Bounds\n     * @param {XYCoords} min - The min values (x,y) as a XYCoords tuple.\n     * @param {XYCoords} max - The max values (x,y) as a XYCoords tuple.\n     **/\n    function Bounds(min, max) {\n        this.min = min;\n        this.max = max;\n        this.width = max.x - min.x;\n        this.height = max.y - min.y;\n    }\n    ;\n    /**\n     * Convert this rectangular bounding box to a polygon with four vertices.\n     *\n     * @method toPolygon\n     * @instance\n     * @memberof Bounds\n     * @return {Polygon} This bound rectangle as a polygon.\n     */\n    Bounds.prototype.toPolygon = function () {\n        return new Polygon_1.Polygon([\n            new Vertex_1.Vertex(this.min),\n            new Vertex_1.Vertex(this.max.x, this.min.y),\n            new Vertex_1.Vertex(this.max),\n            new Vertex_1.Vertex(this.min.x, this.max.y)\n        ], false);\n    };\n    ;\n    /**\n     * Compute the minimal bounding box for a given set of vertices.\n     *\n     * An empty vertex array will return an empty bounding box located at (0,0).\n     *\n     * @static\n     * @method computeFromVertices\n     * @memberof Bounds\n     * @param {Array<Vertex>} vertices - The set of vertices you want to get the bounding box for.\n     * @return The minimal Bounds for the given vertices.\n     **/\n    Bounds.computeFromVertices = function (vertices) {\n        if (vertices.length == 0)\n            return new Bounds(new Vertex_1.Vertex(0, 0), new Vertex_1.Vertex(0, 0));\n        var xMin = vertices[0].x;\n        var xMax = vertices[0].x;\n        var yMin = vertices[0].y;\n        var yMax = vertices[0].y;\n        var vert;\n        for (var i in vertices) {\n            vert = vertices[i];\n            xMin = Math.min(xMin, vert.x);\n            xMax = Math.max(xMax, vert.x);\n            yMin = Math.min(yMin, vert.y);\n            yMax = Math.max(yMax, vert.y);\n        }\n        return new Bounds(new Vertex_1.Vertex(xMin, yMin), new Vertex_1.Vertex(xMax, yMax));\n    };\n    ;\n    return Bounds;\n}()); // END class bounds\nexports.Bounds = Bounds;\n//# sourceMappingURL=Bounds.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2020-05-04\n * @modified 2020-05-09 Ported to typescript.\n * @modified 2020-05-25 Added the vertAt and tangentAt functions.\n * @mofidied 2020-09-07 Added the circleIntersection(Circle) function.\n * @modified 2020-09-07 Changed the vertAt function by switching sin and cos! The old version did not return the correct vertex (by angle) accoring to the assumed circle math.\n * @modified 2020-10-16 Added the containsCircle(...) function.\n * @modified 2021-01-20 Added UID.\n * @version  1.2.0\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Circle = void 0;\nvar Line_1 = require(\"./Line\");\nvar UIDGenerator_1 = require(\"./UIDGenerator\");\nvar Vector_1 = require(\"./Vector\");\nvar Vertex_1 = require(\"./Vertex\");\n/**\n * @classdesc A simple circle: center point and radius.\n *\n * @requires Line\n * @requires Vector\n * @requires VertTuple\n * @requires Vertex\n * @requires SVGSerializale\n * @requires UID\n * @requires UIDGenerator\n **/\nvar Circle = /** @class */ (function () {\n    /**\n     * Create a new circle with given center point and radius.\n     *\n     * @constructor\n     * @name Circle\n     * @param {Vertex} center - The center point of the circle.\n     * @param {number} radius - The radius of the circle.\n     */\n    function Circle(center, radius) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"Circle\";\n        this.uid = UIDGenerator_1.UIDGenerator.next();\n        this.center = center;\n        this.radius = radius;\n    }\n    ;\n    /**\n     * Check if the given circle is fully contained inside this circle.\n     *\n     * @method containsCircle\n     * @param {Circle} circle - The circle to check if it is contained in this circle.\n     * @instance\n     * @memberof Circle\n     * @return {boolean} `true` if any only if the given circle is completely inside this circle.\n     */\n    Circle.prototype.containsCircle = function (circle) {\n        return this.center.distance(circle.center) + circle.radius < this.radius;\n    };\n    ;\n    /**\n     * Calculate the distance from this circle to the given line.\n     *\n     * * If the line does not intersect this ciecle then the returned\n     *   value will be the minimal distance.\n     * * If the line goes through this circle then the returned value\n     *   will be max inner distance and it will be negative.\n     *\n     * @method lineDistance\n     * @param {Line} line - The line to measure the distance to.\n     * @return {number} The minimal distance from the outline of this circle to the given line.\n     * @instance\n     * @memberof Circle\n     */\n    Circle.prototype.lineDistance = function (line) {\n        var closestPointOnLine = line.getClosestPoint(this.center);\n        return closestPointOnLine.distance(this.center) - this.radius;\n    };\n    ;\n    /**\n     * Get the vertex on the this circle for the given angle.\n     *\n     * @method vertAt\n     * @param {number} angle - The angle (in radians) to use.\n     * @return {Vertex} The vertex (point) at the given angle.\n     * @instance\n     * @memberof Circle\n     **/\n    Circle.prototype.vertAt = function (angle) {\n        // Find the point on the circle respective the angle. Then move relative to center.\n        return Circle.circleUtils.vertAt(angle, this.radius).add(this.center);\n    };\n    ;\n    /**\n     * Get a tangent line of this circle for a given angle.\n     *\n     * Point a of the returned line is located on the circle, the length equals the radius.\n     *\n     * @method tangentAt\n     * @instance\n     * @param {number} angle - The angle (in radians) to use.\n     * @return {Line} The tangent line.\n     * @memberof Circle\n     **/\n    Circle.prototype.tangentAt = function (angle) {\n        var pointA = Circle.circleUtils.vertAt(angle, this.radius);\n        // Construct the perpendicular of the line in point a. Then move relative to center.\n        return new Vector_1.Vector(pointA, new Vertex_1.Vertex(0, 0)).add(this.center).perp();\n    };\n    ;\n    /**\n     * Calculate the intersection points (if exists) with the given circle.\n     *\n     * @method circleIntersection\n     * @instance\n     * @memberof Circle\n     * @param {Circle} circle\n     * @return {Line|null} The intersection points (as a line) or null if the two circles do not intersect.\n     **/\n    Circle.prototype.circleIntersection = function (circle) {\n        // Circles do not intersect at all?\n        if (this.center.distance(circle.center) > this.radius + circle.radius) {\n            return null;\n        }\n        // One circle is fully inside the other?\n        if (this.center.distance(circle.center) < Math.abs(this.radius - circle.radius)) {\n            return null;\n        }\n        // Based on the C++ implementation by Robert King\n        //    https://stackoverflow.com/questions/3349125/circle-circle-intersection-points\n        // and the 'Circles and spheres' article by Paul Bourke.\n        //    http://paulbourke.net/geometry/circlesphere/\n        //\n        // This is the original C++ implementation:\n        //\n        // pair<Point, Point> intersections(Circle c) {\n        //    Point P0(x, y);\n        //    Point P1(c.x, c.y);\n        //    float d, a, h;\n        //    d = P0.distance(P1);\n        //    a = (r*r - c.r*c.r + d*d)/(2*d);\n        //    h = sqrt(r*r - a*a);\n        //    Point P2 = P1.sub(P0).scale(a/d).add(P0);\n        //    float x3, y3, x4, y4;\n        //    x3 = P2.x + h*(P1.y - P0.y)/d;\n        //    y3 = P2.y - h*(P1.x - P0.x)/d;\n        //    x4 = P2.x - h*(P1.y - P0.y)/d;\n        //    y4 = P2.y + h*(P1.x - P0.x)/d;\n        //    return pair<Point, Point>(Point(x3, y3), Point(x4, y4));\n        // } \n        var p0 = this.center;\n        var p1 = circle.center;\n        var d = p0.distance(p1);\n        var a = (this.radius * this.radius - circle.radius * circle.radius + d * d) / (2 * d);\n        var h = Math.sqrt(this.radius * this.radius - a * a);\n        var p2 = p1.clone().scale(a / d, p0);\n        var x3 = p2.x + h * (p1.y - p0.y) / d;\n        var y3 = p2.y - h * (p1.x - p0.x) / d;\n        var x4 = p2.x - h * (p1.y - p0.y) / d;\n        var y4 = p2.y + h * (p1.x - p0.x) / d;\n        return new Line_1.Line(new Vertex_1.Vertex(x3, y3), new Vertex_1.Vertex(x4, y4));\n    };\n    ;\n    /**\n      * Create an SVG representation of this circle.\n      *\n      * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.\n      * @method toSVGString\n      * @param {object=} options - An optional set of options, like 'className'.\n      * @return {string} A string representing the SVG code for this vertex.\n      * @instance\n      * @memberof Circle\n      */\n    Circle.prototype.toSVGString = function (options) {\n        options = options || {};\n        var buffer = [];\n        buffer.push('<circle');\n        if (options.className)\n            buffer.push(' class=\"' + options.className + '\"');\n        buffer.push(' cx=\"' + this.center.x + '\"');\n        buffer.push(' cy=\"' + this.center.y + '\"');\n        buffer.push(' r=\"' + this.radius + '\"');\n        buffer.push(' />');\n        return buffer.join('');\n    };\n    ;\n    Circle.circleUtils = {\n        vertAt: function (angle, radius) {\n            /* return new Vertex( Math.sin(angle) * radius,\n                       Math.cos(angle) * radius ); */\n            return new Vertex_1.Vertex(Math.cos(angle) * radius, Math.sin(angle) * radius);\n        }\n    };\n    return Circle;\n}()); // END class\nexports.Circle = Circle;\n//# sourceMappingURL=Circle.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2020-12-17\n * @modified 2021-01-20 Added UID.\n * @version  1.1.0\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.CircleSector = void 0;\nvar UIDGenerator_1 = require(\"./UIDGenerator\");\n/**\n * @classdesc A simple circle sector: circle, start- and end-angle.\n *\n * @requires Line\n * @requires SVGSerializale\n * @requires UID\n * @requires UIDGenerator\n * @requires XYCoords\n **/\nvar CircleSector = /** @class */ (function () {\n    /**\n     * Create a new circle sector with given circle, start- and end-angle.\n     *\n     * @constructor\n     * @name CircleSector\n     * @param {Circle} circle - The circle.\n     * @param {number} startAngle - The start angle of the sector.\n     * @param {number} endAngle - The end angle of the sector.\n     */\n    function CircleSector(circle, startAngle, endAngle) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"CircleSector\";\n        this.uid = UIDGenerator_1.UIDGenerator.next();\n        this.circle = circle;\n        this.startAngle = startAngle;\n        this.endAngle = endAngle;\n    }\n    ;\n    /**\n      * Create an SVG representation of this circle.\n      *\n      * @method toSVGString\n      * @param {object=} options - An optional set of options, like 'className'.\n      * @return {string} A string representing the SVG code for this vertex.\n      * @instance\n      * @memberof Circle\n      */\n    CircleSector.prototype.toSVGString = function (options) {\n        options = options || {};\n        var buffer = [];\n        buffer.push('<path ');\n        if (options.className)\n            buffer.push(' class=\"' + options.className + '\"');\n        var data = CircleSector.circleSectorUtils.describeSVGArc(this.circle.center.x, this.circle.center.y, this.circle.radius, this.startAngle, this.endAngle);\n        buffer.push(' d=\"' + data.join(\" \") + '\" />');\n        return buffer.join('');\n    };\n    ;\n    CircleSector.circleSectorUtils = {\n        /**\n         * Helper function to convert polar circle coordinates to cartesian coordinates.\n         *\n         * TODO: generalize for ellipses (two radii).\n         *\n         * @param {number} angle - The angle in radians.\n        */\n        polarToCartesian: function (centerX, centerY, radius, angle) {\n            return {\n                x: centerX + (radius * Math.cos(angle)),\n                y: centerY + (radius * Math.sin(angle))\n            };\n        },\n        /**\n         * Helper function to convert a circle section as SVG arc params (for the `d` attribute).\n         * Found at: https://stackoverflow.com/questions/5736398/how-to-calculate-the-svg-path-for-an-arc-of-a-circle\n         *\n         * TODO: generalize for ellipses (two radii).\n         *\n         * @param {boolean} options.moveToStart - If false (default=true) the initial 'Move' command will not be used.\n         * @return [ 'A', radiusx, radiusy, rotation=0, largeArcFlag=1|0, sweepFlag=0, endx, endy ]\n         */\n        describeSVGArc: function (x, y, radius, startAngle, endAngle, options) {\n            if (typeof options === 'undefined')\n                options = { moveToStart: true };\n            var end = CircleSector.circleSectorUtils.polarToCartesian(x, y, radius, endAngle);\n            var start = CircleSector.circleSectorUtils.polarToCartesian(x, y, radius, startAngle);\n            // Split full circles into two halves.\n            // Some browsers have problems to render full circles (described by start==end).\n            if (Math.PI * 2 - Math.abs(startAngle - endAngle) < 0.001) {\n                var firstHalf = CircleSector.circleSectorUtils.describeSVGArc(x, y, radius, startAngle, startAngle + (endAngle - startAngle) / 2, options);\n                var firstEndPoint = { x: firstHalf[firstHalf.length - 2],\n                    y: firstHalf[firstHalf.length - 1]\n                };\n                var secondHalf = CircleSector.circleSectorUtils.describeSVGArc(x, y, radius, startAngle + (endAngle - startAngle) / 2, endAngle, options);\n                return firstHalf.concat(secondHalf);\n            }\n            // Boolean stored as integers (0|1).\n            var largeArcFlag = endAngle - startAngle <= Math.PI ? 0 : 1;\n            var sweepFlag = 1;\n            var pathData = [];\n            if (options.moveToStart) {\n                pathData.push('M', start.x, start.y);\n            }\n            pathData.push(\"A\", radius, radius, 0, largeArcFlag, sweepFlag, end.x, end.y);\n            return pathData;\n        }\n    };\n    return CircleSector;\n}()); // END class\nexports.CircleSector = CircleSector;\n//# sourceMappingURL=CircleSector.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2013-08-15\n * @modified 2018-08-16 Added a closure. Removed the wrapper class 'IKRS'. Replaced class THREE.Vector2 by Vertex class.\n * @modified 2018-11-19 Added the fromArray(Array) function.\n * @modified 2018-11-28 Added the locateCurveByPoint(Vertex) function.\n * @modified 2018-12-04 Added the toSVGPathData() function.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2019-03-23 Changed the signatures of getPoint, getPointAt and getTangent (!version 2.0).\n * @modified 2019-12-02 Fixed the updateArcLength function. It used the wrong pointAt function (was renamed before).\n * @modified 2020-02-06 Added the getSubCurveAt(number,number) function.\n * @modified 2020-02-06 Fixed a serious bug in the arc lenght calculation (length was never reset, urgh).\n * @modified 2020-02-07 Added the isInstance(any) function.\n * @modified 2020-02-10 Added the reverse() function.\n * @modified 2020-02-10 Fixed the translate(...) function (returning 'this' was missing).\n * @modified 2020-03-24 Ported this class from vanilla JS to Typescript.\n * @modified 2020-06-03 Added the getBounds() function.\n * @modified 2020-07-14 Changed the moveCurvePoint(...,Vertex) to moveCurvePoint(...,XYCoords), which is more generic.\n * @modified 2020-07-24 Added the getClosestT function and the helper function locateIntervalByDistance(...).\n * @modified 2021-01-20 Added UID.\n * @version 2.5.0\n *\n * @file CubicBezierCurve\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.CubicBezierCurve = void 0;\nvar Bounds_1 = require(\"./Bounds\");\nvar UIDGenerator_1 = require(\"./UIDGenerator\");\nvar Vertex_1 = require(\"./Vertex\");\nvar Vector_1 = require(\"./Vector\");\n/**\n * @classdesc A refactored cubic bezier curve class.\n *\n * @requires Bounds\n * @requires Vertex\n * @requires Vector\n * @requires XYCoords\n * @requires SVGSerializable\n * @requires UID\n * @requires UIDGenerator\n */\nvar CubicBezierCurve = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name CubicBezierCurve\n     * @param {Vertex} startPoint - The Bézier curve's start point.\n     * @param {Vertex} endPoint   - The Bézier curve's end point.\n     * @param {Vertex} startControlPoint - The Bézier curve's start control point.\n     * @param {Vertex} endControlPoint   - The Bézier curve's end control point.\n     **/\n    function CubicBezierCurve(startPoint, endPoint, startControlPoint, endControlPoint) {\n        /** @constant {number} */\n        this.START_POINT = CubicBezierCurve.START_POINT;\n        /** @constant {number} */\n        this.START_CONTROL_POINT = CubicBezierCurve.START_CONTROL_POINT;\n        /** @constant {number} */\n        this.END_CONTROL_POINT = CubicBezierCurve.END_CONTROL_POINT;\n        /** @constant {number} */\n        this.END_POINT = CubicBezierCurve.END_POINT;\n        this.uid = UIDGenerator_1.UIDGenerator.next();\n        this.startPoint = startPoint;\n        this.startControlPoint = startControlPoint;\n        this.endPoint = endPoint;\n        this.endControlPoint = endControlPoint;\n        this.curveIntervals = 30;\n        // An array of vertices\n        this.segmentCache = [];\n        // An array of floats\n        this.segmentLengths = [];\n        // float\n        this.arcLength = null;\n        this.updateArcLengths();\n    }\n    ;\n    /**\n     * Move the given curve point (the start point, end point or one of the two\n     * control points).\n     *\n     * @method moveCurvePoint\n     * @param {number} pointID - The numeric identicator of the point to move. Use one of the four eBezierPoint constants.\n     * @param {XYCoords} moveAmount - The amount to move the specified point by.\n     * @param {boolean} moveControlPoint - Move the control points along with their path point (if specified point is a path point).\n     * @param {boolean} updateArcLengths - Specifiy if the internal arc segment buffer should be updated.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {void}\n     **/\n    CubicBezierCurve.prototype.moveCurvePoint = function (pointID, moveAmount, moveControlPoint, updateArcLengths) {\n        if (pointID == this.START_POINT) {\n            this.getStartPoint().add(moveAmount);\n            if (moveControlPoint)\n                this.getStartControlPoint().add(moveAmount);\n        }\n        else if (pointID == this.START_CONTROL_POINT) {\n            this.getStartControlPoint().add(moveAmount);\n        }\n        else if (pointID == this.END_CONTROL_POINT) {\n            this.getEndControlPoint().add(moveAmount);\n        }\n        else if (pointID == this.END_POINT) {\n            this.getEndPoint().add(moveAmount);\n            if (moveControlPoint)\n                this.getEndControlPoint().add(moveAmount);\n        }\n        else {\n            console.log(\"[CubicBezierCurve.moveCurvePoint] pointID '\" + pointID + \"' invalid.\");\n        }\n        if (updateArcLengths)\n            this.updateArcLengths();\n    };\n    ;\n    /**\n     * Translate the whole curve by the given {x,y} amount: moves all four points.\n     *\n     * @method translate\n     * @param {Vertex} amount - The amount to translate this curve by.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {CubicBezierCurve} this (for chaining).\n     **/\n    CubicBezierCurve.prototype.translate = function (amount) {\n        this.startPoint.add(amount);\n        this.startControlPoint.add(amount);\n        this.endControlPoint.add(amount);\n        this.endPoint.add(amount);\n        return this;\n    };\n    ;\n    /**\n     * Reverse this curve, means swapping start- and end-point and swapping\n     * start-control- and end-control-point.\n     *\n     * @method reverse\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {CubicBezierCurve} this (for chaining).\n     **/\n    CubicBezierCurve.prototype.reverse = function () {\n        var tmp = this.startPoint;\n        this.startPoint = this.endPoint;\n        this.endPoint = tmp;\n        tmp = this.startControlPoint;\n        this.startControlPoint = this.endControlPoint;\n        this.endControlPoint = tmp;\n        return this;\n    };\n    ;\n    /**\n     * Get the total curve length.<br>\n     * <br>\n     * As not all Bézier curved have a closed formula to calculate their lengths, this\n     * implementation uses a segment buffer (with a length of 30 segments). So the\n     * returned length is taken from the arc segment buffer.<br>\n     * <br>\n     * Note that if the curve points were changed and the segment buffer was not\n     * updated this function might return wrong (old) values.\n     *\n     * @method getLength\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {number} >= 0\n     **/\n    CubicBezierCurve.prototype.getLength = function () {\n        return this.arcLength;\n    };\n    ;\n    /**\n     * Uptate the internal arc segment buffer and their lengths.<br>\n     * <br>\n     * All class functions update the buffer automatically; if any\n     * curve point is changed by other reasons you should call this\n     * function to keep actual values in the buffer.\n     *\n     * @method updateArcLengths\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {void}\n     **/\n    CubicBezierCurve.prototype.updateArcLengths = function () {\n        var pointA = this.startPoint.clone(), pointB = new Vertex_1.Vertex(0, 0), curveStep = 1.0 / this.curveIntervals;\n        var u = curveStep;\n        // Clear segment cache\n        this.segmentCache = [];\n        // Push start point into buffer\n        this.segmentCache.push(this.startPoint);\n        this.segmentLengths = [];\n        var newLength = 0.0;\n        var t = 0.0;\n        var tmpLength;\n        while (t <= 1.0) {\n            pointB = this.getPointAt(t);\n            // Store point into cache\n            this.segmentCache.push(pointB);\n            // Calculate segment length\n            tmpLength = pointA.distance(pointB);\n            this.segmentLengths.push(tmpLength);\n            newLength += tmpLength;\n            pointA = pointB;\n            t += curveStep;\n        }\n        this.arcLength = newLength;\n    };\n    ;\n    /**\n     * Get a 't' (relative position on curve) with the closest distance to point 'p'.\n     *\n     * The returned number is 0.0 <= t <= 1.0. Use the getPointAt(t) function to retrieve the actual curve point.\n     *\n     * This function uses a recursive approach by cutting the curve into several linear segments.\n     *\n     * @param {Vertex} p - The point to find the closest position ('t' on the curve).\n     * @return {number}\n     **/\n    CubicBezierCurve.prototype.getClosestT = function (p) {\n        // We would like to have an error that's not larger than 1.0.\n        var desiredEpsilon = 1.0;\n        var t = 0.0;\n        var result = { t: 0, tPrev: 0.0, tNext: 1.0 };\n        var iteration = 0;\n        do {\n            result = this.locateIntervalByDistance(p, result.tPrev, result.tNext, this.curveIntervals);\n            iteration++;\n            // Be sure: stop after 4 iterations\n        } while (iteration < 4 && this.getPointAt(result.tPrev).distance(this.getPointAt(result.tNext)) > desiredEpsilon);\n        return result.t;\n    };\n    ;\n    /**\n     * This helper function locates the 't' on a fixed step interval with the minimal distance\n     * between the curve (at 't') and the given point.\n     *\n     * Furthermore you must specify a sub curve (start 't' and end 't') you want to search on.\n     * Using tStart=0.0 and tEnd=1.0 will search on the full curve.\n     *\n     * @param {Vertex} p - The point to find the closest curve point for.\n     * @param {number} tStart - The start position (start 't' of the sub curve). Should be >= 0.0.\n     * @param {number} tEnd - The end position (end 't' of the sub curve). Should be <= 1.0.\n     * @param {number} stepCount - The number of steps to check within the interval.\n     *\n     * @return {object} - An object with t, tPrev and tNext (numbers).\n     **/\n    CubicBezierCurve.prototype.locateIntervalByDistance = function (p, tStart, tEnd, stepCount) {\n        var minIndex = -1;\n        var minDist = 0;\n        var t = 0.0;\n        var tDiff = tEnd - tStart;\n        for (var i = 0; i <= stepCount; i++) {\n            t = tStart + tDiff * (i / stepCount);\n            var vert = this.getPointAt(t);\n            var dist = vert.distance(p);\n            if (minIndex == -1 || dist < minDist) {\n                minIndex = i;\n                minDist = dist;\n            }\n        }\n        return { t: tStart + tDiff * (minIndex / stepCount),\n            tPrev: tStart + tDiff * (Math.max(0, minIndex - 1) / stepCount),\n            tNext: tStart + tDiff * (Math.min(stepCount, minIndex + 1) / stepCount)\n        };\n    };\n    ;\n    /**\n     * Get the bounds of this bezier curve.\n     *\n     * The bounds are approximated by the underlying segment buffer; the more segment there are,\n     * the more accurate will be the returned bounds.\n     *\n     * @return {Bounds} The bounds of this curve.\n     **/\n    CubicBezierCurve.prototype.getBounds = function () {\n        var min = new Vertex_1.Vertex(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);\n        var max = new Vertex_1.Vertex(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);\n        var v;\n        for (var i = 0; i < this.segmentCache.length; i++) {\n            v = this.segmentCache[i];\n            min.x = Math.min(min.x, v.x);\n            min.y = Math.min(min.y, v.y);\n            max.x = Math.max(max.x, v.x);\n            max.y = Math.max(max.y, v.y);\n        }\n        return new Bounds_1.Bounds(min, max);\n    };\n    ;\n    /**\n     * Get the start point of the curve.<br>\n     * <br>\n     * This function just returns this.startPoint.\n     *\n     * @method getStartPoint\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex} this.startPoint\n     **/\n    CubicBezierCurve.prototype.getStartPoint = function () {\n        return this.startPoint;\n    };\n    ;\n    /**\n     * Get the end point of the curve.<br>\n     * <br>\n     * This function just returns this.endPoint.\n     *\n     * @method getEndPoint\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex} this.endPoint\n     **/\n    CubicBezierCurve.prototype.getEndPoint = function () {\n        return this.endPoint;\n    };\n    ;\n    /**\n     * Get the start control point of the curve.<br>\n     * <br>\n     * This function just returns this.startControlPoint.\n     *\n     * @method getStartControlPoint\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex} this.startControlPoint\n     **/\n    CubicBezierCurve.prototype.getStartControlPoint = function () {\n        return this.startControlPoint;\n    };\n    ;\n    /**\n     * Get the end control point of the curve.<br>\n     * <br>\n     * This function just returns this.endControlPoint.\n     *\n     * @method getEndControlPoint\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex} this.endControlPoint\n     **/\n    CubicBezierCurve.prototype.getEndControlPoint = function () {\n        return this.endControlPoint;\n    };\n    ;\n    /**\n     * Get one of the four curve points specified by the passt point ID.\n     *\n     * @method getEndControlPoint\n     * @param {number} id - One of START_POINT, START_CONTROL_POINT, END_CONTROL_POINT or END_POINT.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    CubicBezierCurve.prototype.getPointByID = function (id) {\n        if (id == this.START_POINT)\n            return this.startPoint;\n        if (id == this.END_POINT)\n            return this.endPoint;\n        if (id == this.START_CONTROL_POINT)\n            return this.startControlPoint;\n        if (id == this.END_CONTROL_POINT)\n            return this.endControlPoint;\n        throw new Error(\"Invalid point ID '\" + id + \"'.\");\n    };\n    ;\n    /**\n     * Get the curve point at a given position t, where t is in [0,1].<br>\n     * <br>\n     * @see Line.pointAt\n     *\n     * @method getPointAt\n     * @param {number} t - The position on the curve in [0,1] (0 means at\n     *                     start point, 1 means at end point, other values address points in bertween).\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    CubicBezierCurve.prototype.getPointAt = function (t) {\n        // Perform some powerful math magic\n        var x = this.startPoint.x * Math.pow(1.0 - t, 3) + this.startControlPoint.x * 3 * t * Math.pow(1.0 - t, 2)\n            + this.endControlPoint.x * 3 * Math.pow(t, 2) * (1.0 - t) + this.endPoint.x * Math.pow(t, 3);\n        var y = this.startPoint.y * Math.pow(1.0 - t, 3) + this.startControlPoint.y * 3 * t * Math.pow(1.0 - t, 2)\n            + this.endControlPoint.y * 3 * Math.pow(t, 2) * (1.0 - t) + this.endPoint.y * Math.pow(t, 3);\n        return new Vertex_1.Vertex(x, y);\n    };\n    ;\n    /**\n     * Get the curve point at a given position u, where u is in [0,arcLength].<br>\n     * <br>\n     * @see CubicBezierCurve.getPointAt\n     *\n     * @method getPoint\n     * @param {number} u - The position on the curve in [0,arcLength] (0 means at\n     *                     start point, arcLength means at end point, other values address points in bertween).\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    CubicBezierCurve.prototype.getPoint = function (u) {\n        return this.getPointAt(u / this.arcLength);\n    };\n    ;\n    /**\n     * Get the curve tangent vector at a given absolute curve position t in [0,1].<br>\n     * <br>\n     * Note that the returned tangent vector (end point) is not normalized and relative to (0,0).\n     *\n     * @method getTangent\n     * @param {number} t - The position on the curve in [0,1].\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    CubicBezierCurve.prototype.getTangentAt = function (t) {\n        var a = this.getStartPoint();\n        var b = this.getStartControlPoint();\n        var c = this.getEndControlPoint();\n        var d = this.getEndPoint();\n        // This is the shortened one\n        var t2 = t * t;\n        var t3 = t * t2;\n        // (1 - t)^2 = (1-t)*(1-t) = 1 - t - t + t^2 = 1 - 2*t + t^2\n        var nt2 = 1 - 2 * t + t2;\n        var tX = -3 * a.x * nt2 +\n            b.x * (3 * nt2 - 6 * (t - t2)) +\n            c.x * (6 * (t - t2) - 3 * t2) +\n            3 * d.x * t2;\n        var tY = -3 * a.y * nt2 +\n            b.y * (3 * nt2 - 6 * (t - t2)) +\n            c.y * (6 * (t - t2) - 3 * t2) +\n            3 * d.y * t2;\n        // Note: my implementation does NOT normalize tangent vectors!\n        return new Vertex_1.Vertex(tX, tY);\n    };\n    ;\n    /**\n     * Get a sub curve at the given start end end offsets (values between 0.0 and 1.0).\n     *\n     * tStart >= tEnd is allowed, you will get a reversed sub curve then.\n     *\n     * @method getSubCurveAt\n     * @param {number} tStart – The start offset of the desired sub curve (must be in [0..1]).\n     * @param {number} tEnd – The end offset if the desired cub curve (must be in [0..1]).\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {CubicBezierCurve} The sub curve as a new curve.\n     **/\n    CubicBezierCurve.prototype.getSubCurveAt = function (tStart, tEnd) {\n        var startVec = new Vector_1.Vector(this.getPointAt(tStart), this.getTangentAt(tStart));\n        var endVec = new Vector_1.Vector(this.getPointAt(tEnd), this.getTangentAt(tEnd).inv());\n        // Tangents are relative. Make absolute.\n        startVec.b.add(startVec.a);\n        endVec.b.add(endVec.a);\n        // This 'splits' the curve at the given point at t.\n        startVec.scale(0.33333333 * (tEnd - tStart));\n        endVec.scale(0.33333333 * (tEnd - tStart));\n        // Draw the bezier curve\n        // pb.draw.cubicBezier( startVec.a, endVec.a, startVec.b, endVec.b, '#8800ff', 2 );\n        return new CubicBezierCurve(startVec.a, endVec.a, startVec.b, endVec.b);\n    };\n    ;\n    /**\n     * Convert a relative curve position u to the absolute curve position t.\n     *\n     * @method convertU2t\n     * @param {number} u - The relative position on the curve in [0,arcLength].\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {number}\n     **/\n    CubicBezierCurve.prototype.convertU2T = function (u) {\n        return Math.max(0.0, Math.min(1.0, (u / this.arcLength)));\n    };\n    ;\n    /**\n     * Get the curve tangent vector at a given relative position u in [0,arcLength].<br>\n     * <br>\n     * Note that the returned tangent vector (end point) is not normalized.\n     *\n     * @method getTangent\n     * @param {number} u - The position on the curve in [0,arcLength].\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    CubicBezierCurve.prototype.getTangent = function (u) {\n        return this.getTangentAt(this.convertU2T(u));\n    };\n    ;\n    /**\n     * Get the curve perpendicular at a given relative position u in [0,arcLength] as a vector.<br>\n     * <br>\n     * Note that the returned vector (end point) is not normalized.\n     *\n     * @method getPerpendicular\n     * @param {number} u - The relative position on the curve in [0,arcLength].\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    CubicBezierCurve.prototype.getPerpendicular = function (u) {\n        return this.getPerpendicularAt(this.convertU2T(u));\n    };\n    ;\n    /**\n     * Get the curve perpendicular at a given absolute position t in [0,1] as a vector.<br>\n     * <br>\n     * Note that the returned vector (end point) is not normalized.\n     *\n     * @method getPerpendicularAt\n     * @param {number} u - The absolute position on the curve in [0,1].\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    CubicBezierCurve.prototype.getPerpendicularAt = function (t) {\n        var tangentVector = this.getTangentAt(t);\n        return new Vertex_1.Vertex(tangentVector.y, -tangentVector.x);\n    };\n    ;\n    /**\n     * Clone this Bézier curve (deep clone).\n     *\n     * @method clone\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {CubicBezierCurve}\n     **/\n    CubicBezierCurve.prototype.clone = function () {\n        return new CubicBezierCurve(this.getStartPoint().clone(), this.getEndPoint().clone(), this.getStartControlPoint().clone(), this.getEndControlPoint().clone());\n    };\n    ;\n    /**\n     * Check if this and the specified curve are equal.<br>\n     * <br>\n     * All four points need to be equal for this, the Vertex.equals function is used.<br>\n     * <br>\n     * Please note that this function is not type safe (comparison with any object will fail).\n     *\n     * @method clone\n     * @param {CubicBezierCurve} curve - The curve to compare with.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {boolean}\n     **/\n    CubicBezierCurve.prototype.equals = function (curve) {\n        // Note: in the earlier vanilla-JS version this was callable with plain objects.\n        //       Let's see if this restricted version works out.\n        if (!curve)\n            return false;\n        if (!curve.startPoint ||\n            !curve.endPoint ||\n            !curve.startControlPoint ||\n            !curve.endControlPoint)\n            return false;\n        return this.startPoint.equals(curve.startPoint)\n            && this.endPoint.equals(curve.endPoint)\n            && this.startControlPoint.equals(curve.startControlPoint)\n            && this.endControlPoint.equals(curve.endControlPoint);\n    };\n    ;\n    /**\n     * Quick check for class instance.\n     * Is there a better way?\n     *\n     * @method isInstance\n     * @param {any} obj - Check if the passed object/value is an instance of CubicBezierCurve.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {boolean}\n     **/\n    CubicBezierCurve.isInstance = function (obj) {\n        // Note: check this again\n        /* OLD VANILLA JS IMPLEMENTATION */\n        /* if( typeof obj != \"object\" )\n            return false;\n        function hasXY(v) {\n            return typeof v != \"undefined\" && typeof v.x == \"number\" && typeof v.y == \"number\";\n        }\n        return typeof obj.startPoint == \"object\" && hasXY(obj.startPoint)\n            && typeof obj.endPoint == \"object\" && hasXY(obj.endPoint)\n            && typeof obj.startControlPoint == \"object\" && hasXY(obj.startControlPoint)\n            && typeof obj.endControlPoint == \"object\" && hasXY(obj.endControlPoint);\n        */\n        return obj instanceof CubicBezierCurve;\n    };\n    ;\n    /**\n     * Create an SVG path data representation of this bézier curve.\n     *\n     * Path data string format is:<br>\n     *  <pre>'M x0 y1 C dx0 dy1 dx1 dy1 x1 x2'</pre><br>\n     * or in other words<br>\n     *   <pre>'M startoint.x startPoint.y C startControlPoint.x startControlPoint.y endControlPoint.x endControlPoint.y endPoint.x endPoint.y'</pre>\n     *\n     * @method toSVGPathData\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {string}  The SVG path data string.\n     **/\n    CubicBezierCurve.prototype.toSVGPathData = function () {\n        var buffer = [];\n        buffer.push('M ');\n        buffer.push(this.startPoint.x.toString());\n        buffer.push(' ');\n        buffer.push(this.startPoint.y.toString());\n        buffer.push(' C ');\n        buffer.push(this.startControlPoint.x.toString());\n        buffer.push(' ');\n        buffer.push(this.startControlPoint.y.toString());\n        buffer.push(' ');\n        buffer.push(this.endControlPoint.x.toString());\n        buffer.push(' ');\n        buffer.push(this.endControlPoint.y.toString());\n        buffer.push(' ');\n        buffer.push(this.endPoint.x.toString());\n        buffer.push(' ');\n        buffer.push(this.endPoint.y.toString());\n        return buffer.join('');\n    };\n    ;\n    /**\n     * Convert this curve to a JSON string.\n     *\n     * @method toJSON\n     * @param {boolean=} [prettyFormat=false] - If set to true the function will add line breaks.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {string} The JSON data.\n     **/\n    CubicBezierCurve.prototype.toJSON = function (prettyFormat) {\n        var jsonString = \"{ \" + // begin object\n            (prettyFormat ? \"\\n\\t\" : \"\") +\n            \"\\\"startPoint\\\" : [\" + this.getStartPoint().x + \",\" + this.getStartPoint().y + \"], \" +\n            (prettyFormat ? \"\\n\\t\" : \"\") +\n            \"\\\"endPoint\\\" : [\" + this.getEndPoint().x + \",\" + this.getEndPoint().y + \"], \" +\n            (prettyFormat ? \"\\n\\t\" : \"\") +\n            \"\\\"startControlPoint\\\": [\" + this.getStartControlPoint().x + \",\" + this.getStartControlPoint().y + \"], \" +\n            (prettyFormat ? \"\\n\\t\" : \"\") +\n            \"\\\"endControlPoint\\\" : [\" + this.getEndControlPoint().x + \",\" + this.getEndControlPoint().y + \"]\" +\n            (prettyFormat ? \"\\n\\t\" : \"\") +\n            \" }\"; // end object\n        return jsonString;\n    };\n    ;\n    /**\n     * Parse a Bézier curve from the given JSON string.\n     *\n     * @method fromJSON\n     * @param {string} jsonString - The JSON data to parse.\n     * @memberof CubicBezierCurve\n     * @static\n     * @throws An exception if the JSON string is malformed.\n     * @return {CubicBezierCurve}\n     **/\n    CubicBezierCurve.fromJSON = function (jsonString) {\n        var obj = JSON.parse(jsonString);\n        return CubicBezierCurve.fromObject(obj);\n    };\n    ;\n    /**\n     * Try to convert the passed object to a CubicBezierCurve.\n     *\n     * @method fromObject\n     * @param {object} obj - The object to convert.\n     * @memberof CubicBezierCurve\n     * @static\n     * @throws An exception if the passed object is malformed.\n     * @return {CubicBezierCurve}\n     **/\n    CubicBezierCurve.fromObject = function (obj) {\n        if (typeof obj !== \"object\")\n            throw \"Can only build from object.\";\n        if (!obj.startPoint)\n            throw \"Object member \\\"startPoint\\\" missing.\";\n        if (!obj.endPoint)\n            throw \"Object member \\\"endPoint\\\" missing.\";\n        if (!obj.startControlPoint)\n            throw \"Object member \\\"startControlPoint\\\" missing.\";\n        if (!obj.endControlPoint)\n            throw \"Object member \\\"endControlPoint\\\" missing.\";\n        return new CubicBezierCurve(new Vertex_1.Vertex(obj.startPoint[0], obj.startPoint[1]), new Vertex_1.Vertex(obj.endPoint[0], obj.endPoint[1]), new Vertex_1.Vertex(obj.startControlPoint[0], obj.startControlPoint[1]), new Vertex_1.Vertex(obj.endControlPoint[0], obj.endControlPoint[1]));\n    };\n    ;\n    /**\n     * Convert a 4-element array of vertices to a cubic bézier curve.\n     *\n     * @method fromArray\n     * @param {Vertex[]} arr -  [ startVertex, endVertex, startControlVertex, endControlVertex ]\n     * @memberof CubicBezierCurve\n     * @throws An exception if the passed array is malformed.\n     * @return {CubicBezierCurve}\n     **/\n    CubicBezierCurve.fromArray = function (arr) {\n        if (!Array.isArray(arr))\n            throw \"Can only build from object.\";\n        if (arr.length != 4)\n            throw \"Can only build from array with four elements.\";\n        return new CubicBezierCurve(arr[0], arr[1], arr[2], arr[3]);\n    };\n    ;\n    /** @constant {number} */\n    CubicBezierCurve.START_POINT = 0;\n    /** @constant {number} */\n    CubicBezierCurve.START_CONTROL_POINT = 1;\n    /** @constant {number} */\n    CubicBezierCurve.END_CONTROL_POINT = 2;\n    /** @constant {number} */\n    CubicBezierCurve.END_POINT = 3;\n    return CubicBezierCurve;\n}());\nexports.CubicBezierCurve = CubicBezierCurve;\n//# sourceMappingURL=CubicBezierCurve.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2018-11-28\n * @modified 2018-12-09 Added the utils: baseLog(Number,Number) and mapRasterScale(Number,Number).\n * @version  1.0.1\n *\n * @file Grid\n * @fileoverview Note that the PlotBoilerplate already has a Grid instance member. The Grid is not meant\n *               to be added to the canvas as a drawable as it encapsulates more an abstract concept of the canvas\n *               rather than a drawable object.\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Grid = void 0;\n/**\n * @classdesc A grid class with vertical and horizontal lines (or a raster).\n *\n * Note that the PlotBoilerplate already has a Grid instance member. The Grid is not meant\n * to be added to the canvas as a drawable as it encapsulates more an abstract concept of the canvas\n * rather than a drawable object.\n *\n * @requires Vertex\n */\nvar Grid = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name Grid\n     * @param {Vertex} center - The offset of the grid (default is [0,0]).\n     * @param {Vertex} size   - The x- and y-size of the grid.\n     **/\n    function Grid(center, size) {\n        this.center = center;\n        this.size = size;\n    }\n    ;\n    /**\n     * @memberof Grid\n     **/\n    Grid.utils = {\n        /**\n         * Calculate the logarithm of the given number (num) to a given base.<br>\n         * <br>\n         * This function returns the number l with<br>\n         *  <pre>num == Math.pow(base,l)</pre>\n         *\n         * @member baseLog\n         * @function\n         * @memberof Grid\n         * @inner\n         * @param {number} base - The base to calculate the logarithm to.\n         * @param {number} num  - The number to calculate the logarithm for.\n         * @return {number} <pre>log(base)/log(num)</pre>\n         **/\n        baseLog: function (base, num) { return Math.log(base) / Math.log(num); },\n        /**\n         * Calculate the raster scale for a given logarithmic mapping.<br>\n         * <br>\n         * Example (with adjustFactor=2):<br>\n         * <pre>\n         * If scale is 4.33, then the mapping is 1/2 (because 2^2 <= 4.33 <= 2^3)<br>\n         * If scale is 0.33, then the mapping is 2 because (2^(1/2) >= 0.33 >= 2^(1/4)\n         * </pre>\n         *\n         * @member mapRasterScale\n         * @function\n         * @memberof Grid\n         * @inner\n         * @param {number} adjustFactor The base for the logarithmic raster scaling when zoomed.\n         * @param {number} scale        The currently used scale factor.\n         * @return {number}\n         **/\n        mapRasterScale: function (adjustFactor, scale) {\n            var gf = 1.0;\n            if (scale >= 1) {\n                gf = Math.abs(Math.floor(1 / Grid.utils.baseLog(adjustFactor, scale)));\n                gf = 1 / Math.pow(adjustFactor, gf);\n            }\n            else {\n                gf = Math.abs(Math.floor(Grid.utils.baseLog(1 / adjustFactor, 1 / (scale + 1))));\n                //gf = Math.pow( adjustFactor, gf );\n            }\n            return gf;\n        }\n    };\n    return Grid;\n}());\nexports.Grid = Grid;\n//# sourceMappingURL=Grid.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2018-11-11 (Alaaf)\n * @modified 2020-03-28 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-07-28 Changed the `delete` key code from 8 to 46.\n * @modified 2020-10-04 Changed `window` to `globalThis`.\n * @modified 2020-10-04 Added extended JSDoc.\n * @version  1.0.4\n *\n * @file KeyHandler\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.KeyHandler = void 0;\n/**\n * @classdesc A generic key handler.\n *\n * Example\n * =======\n * @example\n *      // Javascript\n *\tnew KeyHandler( { trackAll : true } )\n *\t    .down('enter',function() { console.log('ENTER was hit.'); } )\n *\t    .press('enter',function() { console.log('ENTER was pressed.'); } )\n *\t    .up('enter',function() { console.log('ENTER was released.'); } )\n *\n *          .down('e',function() { console.log('e was hit. shift is pressed?',keyHandler.isDown('shift')); } )\n *\n *\t    .up('windows',function() { console.log('windows was released.'); } )\n *\t;\n */\nvar KeyHandler = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @instance\n     * @memberof KeyHandler\n     * @param {HTMLElement} options.element (optional) The HTML element to listen on; if null then 'window' will be used.\n     * @param {boolean} options.trackAll (optional) Set to true if you want to keep track of _all_ keys (keyStatus).\n    **/\n    function KeyHandler(options) {\n        this.downListeners = [];\n        this.pressListeners = [];\n        this.upListeners = [];\n        this.keyStates = {};\n        options = options || {};\n        this.element = options.element ? options.element : globalThis;\n        this.downListeners = [];\n        this.pressListeners = [];\n        this.upListeners = [];\n        this.keyStates = [];\n        // This could be made configurable in a later version. It allows to\n        // keep track of the key status no matter if there are any listeners\n        // on the key or not.\n        this.trackAllKeys = options.trackAll || false;\n        // Install the listeners\n        this.installListeners();\n    }\n    ;\n    /**\n     * A helper function to fire key events from this KeyHandler.\n     *\n     * @param {KeyboardEvent} event - The key event to fire.\n     * @param {Array<XKeyListener>} listener - The listeners to fire to.\n     */\n    KeyHandler.prototype.fireEvent = function (event, listeners) {\n        var hasListener = false;\n        for (var i in listeners) {\n            var lis = listeners[i];\n            if (lis.keyCode != event.keyCode)\n                continue;\n            lis.listener(event);\n            hasListener = true;\n        }\n        return hasListener;\n    };\n    ;\n    /**\n     * Internal function to fire a new keydown event to all listeners.\n     * You should not call this function on your own unless you know what you do.\n     *\n     * @name fireDownEvent\n     * @memberof KeyHandler\n     * @instance\n     * @private\n     * @param {KeyboardEvent} e\n     * @param {KeyHandler} handler\n     * @return {void}\n     */\n    KeyHandler.prototype.fireDownEvent = function (e, handler) {\n        if (handler.fireEvent(e, handler.downListeners) || handler.trackAllKeys) {\n            // Down event has listeners. Update key state.\n            handler.keyStates[e.keyCode] = 'down';\n        }\n    };\n    ;\n    /**\n     * Internal function to fire a new keypress event to all listeners.\n     * You should not call this function on your own unless you know what you do.\n     *\n     * @name firePressEvent\n     * @memberof KeyHandler\n     * @instance\n     * @private\n     * @param {KeyboardEvent} e\n     * @param {KeyHandler} handler\n     * @return void\n     */\n    KeyHandler.prototype.firePressEvent = function (e, handler) {\n        handler.fireEvent(e, handler.pressListeners);\n    };\n    ;\n    /**\n     * Internal function to fire a new keyup event to all listeners.\n     * You should not call this function on your own unless you know what you do.\n     *\n     * @name fireUpEvent\n     * @memberof KeyHandler\n     * @instance\n     * @private\n     * @param {KeyboardEvent} e\n     * @param {KeyHandler} handler\n     * @return {void}\n     */\n    KeyHandler.prototype.fireUpEvent = function (e, handler) {\n        if (handler.fireEvent(e, handler.upListeners) || handler.trackAllKeys) {\n            // Up event has listeners. Clear key state.\n            delete handler.keyStates[e.keyCode];\n        }\n    };\n    ;\n    /**\n     * Resolve the key/name code.\n     */\n    KeyHandler.key2code = function (key) {\n        if (typeof key == 'number')\n            return key;\n        if (typeof key != 'string')\n            throw \"Unknown key name or key type (should be a string or integer): \" + key;\n        if (KeyHandler.KEY_CODES[key])\n            return KeyHandler.KEY_CODES[key];\n        throw \"Unknown key (cannot resolve key code): \" + key;\n    };\n    ;\n    /**\n     * Install the required listeners into the initially passed element.\n     *\n     * By default the listeners are installed into the root element specified on\n     * construction (or 'window').\n     */\n    KeyHandler.prototype.installListeners = function () {\n        var _self = this;\n        this.element.addEventListener('keydown', this._keyDownListener = function (e) { _self.fireDownEvent(e, _self); });\n        this.element.addEventListener('keypress', this._keyPressListener = function (e) { _self.firePressEvent(e, _self); });\n        this.element.addEventListener('keyup', this._keyUpListener = function (e) { _self.fireUpEvent(e, _self); });\n    };\n    ;\n    /**\n     *  Remove all installed event listeners from the underlying element.\n     */\n    KeyHandler.prototype.releaseListeners = function () {\n        this.element.removeEventListener('keydown', this._keyDownListener);\n        this.element.removeEventListener('keypress', this._keyPressListener);\n        this.element.removeEventListener('keyup', this._keyUpListener);\n    };\n    ;\n    /**\n     * Listen for key down. This function allows chaining.\n     *\n     * Example: new KeyHandler().down('enter',function() {console.log('Enter hit.')});\n     *\n     * @name down\n     * @memberof KeyHandler\n     * @instance\n     * @param {string|number} key -  Any key identifier, key code or one from the KEY_CODES list.\n     * @param {(e:KeyboardEvent)=>void} e -  The callback to be triggered.\n     * @return {KeyHandler} this\n     */\n    KeyHandler.prototype.down = function (key, listener) {\n        this.downListeners.push({ key: key, keyCode: KeyHandler.key2code(key), listener: listener });\n        return this;\n    };\n    ;\n    /**\n     * Listen for key press.\n     *\n     * Example: new KeyHandler().press('enter',function() {console.log('Enter pressed.')});\n     *\n     * @name press\n     * @memberof KeyHandler\n     * @instance\n     * @param {string|number} key - Any key identifier, key code or one from the KEY_CODES list.\n     * @param {(e:KeyboardEvent)=>void} listener - The callback to be triggered.\n     * @return {KeyHandler} this\n     */\n    KeyHandler.prototype.press = function (key, listener) {\n        this.pressListeners.push({ key: key, keyCode: KeyHandler.key2code(key), listener: listener });\n        return this;\n    };\n    ;\n    /**\n     * Listen for key up.\n     *\n     * Example: new KeyHandler().up('enter',function() {console.log('Enter released.')});\n     *\n     * @name up\n     * @memberof KeyHandler\n     * @instance\n     * @param {string} key - Any key identifier, key code or one from the KEY_CODES list.\n     * @param {(e:KeyboardEvent)=>void)} e - The callback to be triggered.\n     * @return {KeyHandler} this\n     */\n    KeyHandler.prototype.up = function (key, listener) {\n        this.upListeners.push({ key: key, keyCode: KeyHandler.key2code(key), listener: listener });\n        return this;\n    };\n    ;\n    /**\n     * Check if a specific key is currently held pressed.\n     *\n     * @param {string|number} key - Any key identifier, key code or one from the KEY_CODES list.\n     */\n    KeyHandler.prototype.isDown = function (key) {\n        if (typeof key == 'number')\n            return this.keyStates[key] ? true : false;\n        else\n            return this.keyStates[KeyHandler.key2code(key)] ? true : false;\n    };\n    /**\n     * Source:\n     * https://keycode.info/\n     */\n    KeyHandler.KEY_CODES = {\n        'break': 3,\n        'backspace': 8,\n        // 'delete'\t : 8, // alternate: 46\n        'tab': 9,\n        'clear': 12,\n        'enter': 13,\n        'shift': 16,\n        'ctrl': 17,\n        'alt': 18,\n        'pause': 19,\n        // 'break'\t         : 19,\n        'capslock': 20,\n        'hangul': 21,\n        'hanja': 25,\n        'escape': 27,\n        'conversion': 28,\n        'non-conversion': 29,\n        'spacebar': 32,\n        'pageup': 33,\n        'pagedown': 34,\n        'end': 35,\n        'home': 36,\n        'leftarrow': 37,\n        'uparrow': 38,\n        'rightarrow': 39,\n        'downarrow': 40,\n        'select': 41,\n        'print': 42,\n        'execute': 43,\n        'printscreen': 44,\n        'insert': 45,\n        'delete': 46,\n        'help': 47,\n        '0': 48,\n        '1': 49,\n        '2': 50,\n        '3': 51,\n        '4': 52,\n        '5': 53,\n        '6': 54,\n        '7': 55,\n        '8': 56,\n        '9': 57,\n        ':': 58,\n        'semicolon (firefox)': 59,\n        'equals': 59,\n        '<': 60,\n        'equals (firefox)': 61,\n        'ß': 63,\n        '@ (firefox)': 64,\n        'a': 65,\n        'b': 66,\n        'c': 67,\n        'd': 68,\n        'e': 69,\n        'f': 70,\n        'g': 71,\n        'h': 72,\n        'i': 73,\n        'j': 74,\n        'k': 75,\n        'l': 76,\n        'm': 77,\n        'n': 78,\n        'o': 79,\n        'p': 80,\n        'q': 81,\n        'r': 82,\n        's': 83,\n        't': 84,\n        'u': 85,\n        'v': 86,\n        'w': 87,\n        'x': 88,\n        'y': 89,\n        'z': 90,\n        'windows': 91,\n        'leftcommand': 91,\n        'chromebooksearch': 91,\n        'rightwindowkey': 92,\n        'windowsmenu': 93,\n        'rightcommant': 93,\n        'sleep': 95,\n        'numpad0': 96,\n        'numpad1': 97,\n        'numpad2': 98,\n        'numpad3': 99,\n        'numpad4': 100,\n        'numpad5': 101,\n        'numpad6': 102,\n        'numpad7': 103,\n        'numpad8': 104,\n        'numpad9': 105,\n        'multiply': 106,\n        'add': 107,\n        'numpadperiod': 108,\n        'subtract': 109,\n        'decimalpoint': 110,\n        'divide': 111,\n        'f1': 112,\n        'f2': 113,\n        'f3': 114,\n        'f4': 115,\n        'f5': 116,\n        'f6': 117,\n        'f7': 118,\n        'f8': 119,\n        'f9': 120,\n        'f10': 121,\n        'f11': 122,\n        'f12': 123,\n        'f13': 124,\n        'f14': 125,\n        'f15': 126,\n        'f16': 127,\n        'f17': 128,\n        'f18': 129,\n        'f19': 130,\n        'f20': 131,\n        'f21': 132,\n        'f22': 133,\n        'f23': 134,\n        'f24': 135,\n        'numlock': 144,\n        'scrolllock': 145,\n        '^': 160,\n        '!': 161,\n        // '؛' \t : 162 // (arabic semicolon)\n        '#': 163,\n        '$': 164,\n        'ù': 165,\n        'pagebackward': 166,\n        'pageforward': 167,\n        'refresh': 168,\n        'closingparen': 169,\n        '*': 170,\n        '~+*': 171,\n        // 'home'\t         : 172,\n        'minus': 173,\n        // 'mute'           : 173,\n        // 'unmute'\t : 173,\n        'decreasevolumelevel': 174,\n        'increasevolumelevel': 175,\n        'next': 176,\n        'previous': 177,\n        'stop': 178,\n        'play/pause': 179,\n        'email': 180,\n        'mute': 181,\n        'unmute': 181,\n        //'decreasevolumelevel'\t182 // firefox\n        //'increasevolumelevel'\t183 // firefox\n        'semicolon': 186,\n        'ñ': 186,\n        'equal': 187,\n        'comma': 188,\n        'dash': 189,\n        'period': 190,\n        'forwardslash': 191,\n        'ç': 191,\n        'grave accent': 192,\n        //'ñ' 192,\n        'æ': 192,\n        'ö': 192,\n        '?': 193,\n        '/': 193,\n        '°': 193,\n        // 'numpadperiod'\t : 194, // chrome\n        'openbracket': 219,\n        'backslash': 220,\n        'closebracket': 221,\n        'å': 221,\n        'singlequote': 222,\n        'ø': 222,\n        'ä': 222,\n        '`': 223,\n        // 'left or right ⌘ key (firefox)'\t224\n        'altgr': 225,\n        // '< /git >, left back slash'\t226\n        'GNOME Compose Key': 230,\n        'XF86Forward': 233,\n        'XF86Back': 234,\n        'alphanumeric': 240,\n        'hiragana': 242,\n        'katakana': 242,\n        'half-width': 243,\n        'full-width': 243,\n        'kanji': 244,\n        'unlocktrackpad': 251,\n        'toggletouchpad': 255\n    };\n    return KeyHandler;\n}());\nexports.KeyHandler = KeyHandler;\n//# sourceMappingURL=KeyHandler.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2016-03-12\n * @modified 2018-12-05 Refactored the code from the morley-triangle script.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2019-04-28 Fixed a bug in the Line.sub( Vertex ) function (was not working).\n * @modified 2019-09-02 Added the Line.add( Vertex ) function.\n * @modified 2019-09-02 Added the Line.denominator( Line ) function.\n * @modified 2019-09-02 Added the Line.colinear( Line ) function.\n * @modified 2019-09-02 Fixed an error in the Line.intersection( Line ) function (class Point was renamed to Vertex).\n * @modified 2019-12-15 Added the Line.moveTo(Vertex) function.\n * @modified 2020-03-16 The Line.angle(Line) parameter is now optional. The baseline (x-axis) will be used if not defined.\n * @modified 2020-03-23 Ported to Typescript from JS.\n * @modified 2020-12-04 The `intersection` function returns undefined if both lines are parallel.\n * @version  2.1.3\n *\n * @file Line\n * @public\n **/\nvar __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Line = void 0;\nvar VertTuple_1 = require(\"./VertTuple\");\nvar Vertex_1 = require(\"./Vertex\");\n/**\n * @classdesc A line consists of two vertices a and b.<br>\n * <br>\n * This is some refactored code from my 'Morley Triangle' test<br>\n *   https://github.com/IkarosKappler/morleys-trisector-theorem\n *\n * @requires Vertex\n */\nvar Line = /** @class */ (function (_super) {\n    __extends(Line, _super);\n    /**\n     * Creates an instance of Line.\n     *\n     * @constructor\n     * @name Line\n     * @param {Vertex} a The line's first point.\n     * @param {Vertex} b The line's second point.\n     **/\n    function Line(a, b) {\n        var _this = _super.call(this, a, b, function (a, b) { return new Line(a, b); }) || this;\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        _this.className = \"Line\";\n        return _this;\n    }\n    /**\n     * Get the intersection if this line and the specified line.\n     *\n     * @method intersection\n     * @param {Line} line The second line.\n     * @return {Vertex|undefined} The intersection (may lie outside the end-points) or `undefined` if both lines are parallel.\n     * @instance\n     * @memberof Line\n     **/\n    // !!! DO NOT MOVE TO VertTuple\n    Line.prototype.intersection = function (line) {\n        var denominator = this.denominator(line);\n        if (denominator == 0)\n            return null;\n        var a = this.a.y - line.a.y;\n        var b = this.a.x - line.a.x;\n        var numerator1 = ((line.b.x - line.a.x) * a) - ((line.b.y - line.a.y) * b);\n        var numerator2 = ((this.b.x - this.a.x) * a) - ((this.b.y - this.a.y) * b);\n        a = numerator1 / denominator; // NaN if parallel lines\n        b = numerator2 / denominator;\n        // Catch NaN?\n        var x = this.a.x + (a * (this.b.x - this.a.x));\n        var y = this.a.y + (a * (this.b.y - this.a.y));\n        if (isNaN(a) || isNaN(x) || isNaN(y)) {\n            return undefined;\n        }\n        // if we cast these lines infinitely in both directions, they intersect here:\n        return new Vertex_1.Vertex(x, y);\n    };\n    ;\n    /**\n     * Create an SVG representation of this line.\n     *\n     * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.\n     * @method toSVGString\n     * @param {options} p - A set of options, like the 'classname' to use\n     *                      for the line object.\n     * @return {string} The SVG string representing this line.\n     * @instance\n     * @memberof Line\n     **/\n    Line.prototype.toSVGString = function (options) {\n        options = options || {};\n        var buffer = [];\n        buffer.push('<line');\n        if (options.className)\n            buffer.push(' class=\"' + options.className + '\"');\n        buffer.push(' x1=\"' + this.a.x + '\"');\n        buffer.push(' y1=\"' + this.a.y + '\"');\n        buffer.push(' x2=\"' + this.b.x + '\"');\n        buffer.push(' y2=\"' + this.b.y + '\"');\n        buffer.push(' />');\n        return buffer.join('');\n    };\n    ;\n    return Line;\n}(VertTuple_1.VertTuple));\nexports.Line = Line;\n//# sourceMappingURL=Line.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2018-03-19\n * @modified 2018-04-28 Added the param 'wasDragged'.\n * @modified 2018-08-16 Added the param 'dragAmount'.\n * @modified 2018-08-27 Added the param 'element'.\n * @modified 2018-11-11 Changed the scope from a simple global var to a member of window/_context.\n * @modified 2018-11-19 Renamed the 'mousedown' function to 'down' and the 'mouseup' function to 'up'.\n * @modified 2018-11-28 Added the 'wheel' listener.\n * @modified 2018-12-09 Cleaned up some code.\n * @modified 2019-02-10 Cleaned up some more code.\n * @modified 2020-03-25 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-04-08 Fixed the click event (internally fired a 'mouseup' event) (1.0.10)\n * @modified 2020-04-08 Added the optional 'name' property. (1.0.11)\n * @modified 2020-04-08 The new version always installs internal listenrs to track drag events even\n *                      if there is no external drag listener installed (1.1.0).\n * @modified 2020-10-04 Added extended JSDoc comments.\n * @modified 2020-11-25 Added the `isTouchEvent` param.\n * @modified 2021-01-10 The mouse handler is now also working with SVGElements.\n * @version  1.2.0\n *\n * @file MouseHandler\n * @public\n **/\nvar __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.MouseHandler = exports.XWheelEvent = exports.XMouseEvent = void 0;\nvar XMouseEvent = /** @class */ (function (_super) {\n    __extends(XMouseEvent, _super);\n    function XMouseEvent() {\n        return _super !== null && _super.apply(this, arguments) || this;\n    }\n    return XMouseEvent;\n}(MouseEvent));\nexports.XMouseEvent = XMouseEvent;\nvar XWheelEvent = /** @class */ (function (_super) {\n    __extends(XWheelEvent, _super);\n    function XWheelEvent() {\n        return _super !== null && _super.apply(this, arguments) || this;\n    }\n    return XWheelEvent;\n}(WheelEvent));\nexports.XWheelEvent = XWheelEvent;\n/**\n * @classdesc A simple mouse handler for demos.\n * Use to avoid load massive libraries like jQuery.\n *\n * @requires XYCoords\n */\nvar MouseHandler = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * Pass the DOM element you want to receive mouse events from.\n     *\n     * Usage\n     * =====\n     * @example\n     *   // Javascript\n     *   new MouseHandler( document.getElementById('mycanvas') )\n     *\t    .drag( function(e) {\n     *\t\tconsole.log( 'Mouse dragged: ' + JSON.stringify(e) );\n     *\t\tif( e.params.leftMouse ) ;\n     *\t\telse if( e.params.rightMouse ) ;\n     *\t    } )\n     *\t    .move( function(e) {\n     *\t\tconsole.log( 'Mouse moved: ' + JSON.stringify(e.params) );\n     *\t    } )\n     *          .up( function(e) {\n     *              console.log( 'Mouse up. Was dragged?', e.params.wasDragged );\n     *          } )\n     *          .down( function(e) {\n     *              console.log( 'Mouse down.' );\n     *          } )\n     *          .click( function(e) {\n     *              console.log( 'Click.' );\n     *          } )\n     *          .wheel( function(e) {\n     *              console.log( 'Wheel. delta='+e.deltaY );\n     *          } )\n     *\n     * @example\n     *   // Typescript\n     *   new MouseHandler( document.getElementById('mycanvas') )\n     *\t    .drag( (e:XMouseEvent) => {\n     *\t\tconsole.log( 'Mouse dragged: ' + JSON.stringify(e) );\n     *\t\tif( e.params.leftMouse ) ;\n     *\t\telse if( e.params.rightMouse ) ;\n     *\t    } )\n     *\t    .move( (e:XMouseEvent) => {\n     *\t\tconsole.log( 'Mouse moved: ' + JSON.stringify(e.params) );\n     *\t    } )\n     *          .up( (e:XMouseEvent) => {\n     *              console.log( 'Mouse up. Was dragged?', e.params.wasDragged );\n     *          } )\n     *          .down( (e:XMouseEvent) => {\n     *              console.log( 'Mouse down.' );\n     *          } )\n     *          .click( (e:XMouseEvent) => {\n     *              console.log( 'Click.' );\n     *          } )\n     *          .wheel( (e:XWheelEvent) => {\n     *              console.log( 'Wheel. delta='+e.deltaY );\n     *          } )\n     *\n     * @constructor\n     * @instance\n     * @memberof MouseHandler\n     * @param {HTMLElement} element\n     **/\n    function MouseHandler(element, name) {\n        this.mouseDownPos = undefined;\n        this.mouseDragPos = undefined;\n        this.mousePos = undefined;\n        this.mouseButton = -1;\n        this.listeners = {};\n        this.installed = {};\n        this.handlers = {};\n        // +----------------------------------------------------------------------\n        // | Some private vars to store the current mouse/position/button state.\n        // +-------------------------------------------------\n        this.name = name;\n        this.element = element;\n        this.mouseDownPos = null;\n        this.mouseDragPos = null;\n        this.mousePos = null;\n        this.mouseButton = -1;\n        this.listeners = {};\n        this.installed = {};\n        this.handlers = {};\n        // +----------------------------------------------------------------------\n        // | Define the internal event handlers.\n        // |\n        // | They will dispatch the modified event (relative mouse position,\n        // | drag offset, ...) to the callbacks.\n        // +-------------------------------------------------\n        var _self = this;\n        this.handlers['mousemove'] = function (e) {\n            if (_self.listeners.mousemove)\n                _self.listeners.mousemove(_self.mkParams(e, 'mousemove'));\n            if (_self.mouseDragPos && _self.listeners.drag)\n                _self.listeners.drag(_self.mkParams(e, 'drag'));\n            if (_self.mouseDownPos)\n                _self.mouseDragPos = _self.relPos(e);\n        };\n        this.handlers['mouseup'] = function (e) {\n            if (_self.listeners.mouseup)\n                _self.listeners.mouseup(_self.mkParams(e, 'mouseup'));\n            _self.mouseDragPos = undefined;\n            _self.mouseDownPos = undefined;\n            _self.mouseButton = -1;\n        };\n        this.handlers['mousedown'] = function (e) {\n            _self.mouseDragPos = _self.relPos(e);\n            _self.mouseDownPos = _self.relPos(e);\n            _self.mouseButton = e.button;\n            if (_self.listeners.mousedown)\n                _self.listeners.mousedown(_self.mkParams(e, 'mousedown'));\n        };\n        this.handlers['click'] = function (e) {\n            if (_self.listeners.click)\n                _self.listeners.click(_self.mkParams(e, 'click'));\n        };\n        this.handlers['wheel'] = function (e) {\n            if (_self.listeners.wheel)\n                _self.listeners.wheel(_self.mkParams(e, 'wheel'));\n        };\n        this.element.addEventListener('mousemove', this.handlers['mousemove']);\n        this.element.addEventListener('mouseup', this.handlers['mouseup']);\n        this.element.addEventListener('mousedown', this.handlers['mousedown']);\n        this.element.addEventListener('click', this.handlers['click']);\n        this.element.addEventListener('wheel', this.handlers['wheel']);\n    }\n    /**\n     * Get relative position from the given MouseEvent.\n     *\n     * @name relPos\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @param {MouseEvent} e - The mouse event to get the relative position for.\n     * @return {XYCoords} The relative mouse coordinates.\n     */\n    MouseHandler.prototype.relPos = function (e) {\n        return { x: e.offsetX,\n            y: e.offsetY\n        };\n    };\n    ;\n    /**\n     * Build the extended event params.\n     *\n     * @name mkParams\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @param {MouseEvent} e - The mouse event to get the relative position for.\n     * @param {string} eventName - The name of the firing event.\n     * @return {XMouseEvent}\n     */\n    MouseHandler.prototype.mkParams = function (e, eventName) {\n        var rel = this.relPos(e);\n        var xEvent = e;\n        xEvent.params = {\n            element: this.element,\n            name: eventName,\n            isTouchEvent: false,\n            pos: rel,\n            button: this.mouseButton,\n            leftButton: this.mouseButton == 0,\n            middleButton: this.mouseButton == 1,\n            rightButton: this.mouseButton == 2,\n            mouseDownPos: this.mouseDownPos,\n            draggedFrom: this.mouseDragPos,\n            wasDragged: (this.mouseDownPos != null && (this.mouseDownPos.x != rel.x || this.mouseDownPos.y != rel.y)),\n            dragAmount: (this.mouseDownPos != null ? { x: rel.x - this.mouseDragPos.x, y: rel.y - this.mouseDragPos.y } : { x: 0, y: 0 })\n        };\n        return xEvent;\n    };\n    /**\n     * Install a new listener.\n     * Please note that this mouse handler can only handle one listener per event type.\n     *\n     * @name listenFor\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @param {string} eventName - The name of the firing event to listen for.\n     * @return {void}\n     */\n    MouseHandler.prototype.listenFor = function (eventName) {\n        if (this.installed[eventName])\n            return;\n        // In the new version 1.1.0 has all internal listeners installed by default.\n        this.installed[eventName] = true;\n    };\n    /**\n     * Un-install a new listener.\n     *\n     * @name listenFor\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @param {string} eventName - The name of the firing event to unlisten for.\n     * @return {void}\n     */\n    MouseHandler.prototype.unlistenFor = function (eventName) {\n        if (!this.installed[eventName])\n            return;\n        // In the new version 1.1.0 has all internal listeners installed by default.\n        delete this.installed[eventName];\n    };\n    /**\n     * Installer function to listen for a specific event: mouse-drag.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name drag\n     * @memberof MouseHandler\n     * @instance\n     * @param {XMouseCallback} callback - The drag-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    MouseHandler.prototype.drag = function (callback) {\n        if (this.listeners.drag)\n            this.throwAlreadyInstalled('drag');\n        this.listeners.drag = callback;\n        this.listenFor('mousedown');\n        this.listenFor('mousemove');\n        this.listenFor('mouseup');\n        return this;\n    };\n    ;\n    /**\n     * Installer function to listen for a specific event: mouse-move.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name move\n     * @memberof MouseHandler\n     * @instance\n     * @param {XMouseCallback} callback - The move-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    MouseHandler.prototype.move = function (callback) {\n        if (this.listeners.mousemove)\n            this.throwAlreadyInstalled('mousemove');\n        this.listenFor('mousemove');\n        this.listeners.mousemove = callback;\n        return this;\n    };\n    ;\n    /**\n     * Installer function to listen for a specific event: mouse-up.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name up\n     * @memberof MouseHandler\n     * @instance\n     * @param {XMouseCallback} callback - The up-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    MouseHandler.prototype.up = function (callback) {\n        if (this.listeners.mouseup)\n            this.throwAlreadyInstalled('mouseup');\n        this.listenFor('mouseup');\n        this.listeners.mouseup = callback;\n        return this;\n    };\n    ;\n    /**\n     * Installer function to listen for a specific event: mouse-down.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name down\n     * @memberof MouseHandler\n     * @instance\n     * @param {XMouseCallback} callback - The down-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    MouseHandler.prototype.down = function (callback) {\n        if (this.listeners.mousedown)\n            this.throwAlreadyInstalled('mousedown');\n        this.listenFor('mousedown');\n        this.listeners.mousedown = callback;\n        return this;\n    };\n    ;\n    /**\n     * Installer function to listen for a specific event: mouse-click.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name click\n     * @memberof MouseHandler\n     * @instance\n     * @param {XMouseCallback} callback - The click-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    MouseHandler.prototype.click = function (callback) {\n        if (this.listeners.click)\n            this.throwAlreadyInstalled('click');\n        this.listenFor('click');\n        this.listeners.click = callback;\n        return this;\n    };\n    ;\n    /**\n     * Installer function to listen for a specific event: mouse-wheel.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name wheel\n     * @memberof MouseHandler\n     * @instance\n     * @param {XWheelCallback} callback - The wheel-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    MouseHandler.prototype.wheel = function (callback) {\n        if (this.listeners.wheel)\n            this.throwAlreadyInstalled('wheel');\n        this.listenFor('wheel');\n        this.listeners.wheel = callback;\n        return this;\n    };\n    ;\n    /**\n     * An internal function to throw events.\n     *\n     * @name throwAlreadyInstalled\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @param {string} name - The name of the event.\n     * @return {void}\n     */\n    MouseHandler.prototype.throwAlreadyInstalled = function (name) {\n        throw \"This MouseHandler already has a '\" + name + \"' callback. To keep the code simple there is only room for one.\";\n    };\n    ;\n    /**\n     * Call this when your work is done.\n     *\n     * The function will un-install all event listeners.\n     *\n     * @name destroy\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @return {void}\n     */\n    MouseHandler.prototype.destroy = function () {\n        this.unlistenFor('mousedown');\n        this.unlistenFor('mousemove');\n        this.unlistenFor('moseup');\n        this.unlistenFor('click');\n        this.unlistenFor('wheel');\n        this.element.removeEventListener('mousemove', this.handlers['mousemove']);\n        this.element.removeEventListener('mouseup', this.handlers['mousedown']);\n        this.element.removeEventListener('mousedown', this.handlers['mousedown']);\n        this.element.removeEventListener('click', this.handlers['click']);\n        this.element.removeEventListener('wheel', this.handlers['wheel']);\n    };\n    return MouseHandler;\n}());\nexports.MouseHandler = MouseHandler;\n//# sourceMappingURL=MouseHandler.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2019-01-30\n * @modified 2019-03-23 Added JSDoc tags.\n * @modified 2020-03-25 Ported this class from vanilla-JS to Typescript.\n * @modified 2021-01-20 Added UID.\n * @version 1.1.0\n *\n * @file PBImage\n * @fileoverview As native Image objects have only a position and with\n *               and height thei are not suitable for UI dragging interfaces.\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.PBImage = void 0;\nvar UIDGenerator_1 = require(\"./UIDGenerator\");\n/**\n * @classdesc A wrapper for image objects. Has an upper left and a lower right corner point.\n *\n * @requires Vertex\n * @requires SVGSerializable\n * @requires UID\n * @requires UIDGenerator\n */\nvar PBImage = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name PBImage\n     * @param {Image} image - The actual image.\n     * @param {Vertex} upperLeft - The upper left corner.\n     * @param {Vertex} lowerRight - The lower right corner.\n     **/\n    function PBImage(image, upperLeft, lowerRight) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"PBImage\";\n        this.uid = UIDGenerator_1.UIDGenerator.next();\n        this.image = image;\n        this.upperLeft = upperLeft;\n        this.lowerRight = lowerRight;\n    }\n    ;\n    /**\n     * Convert this vertex to SVG code.\n     *\n     * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.\n     * @method toSVGString\n     * @param {object=} options - An optional set of options, like 'className'.\n     * @return {string} A string representing the SVG code for this vertex.\n     * @instance\n     * @memberof PBImage\n     **/\n    PBImage.prototype.toSVGString = function (options) {\n        console.warn(\"PBImage is not yet SVG serializable. Returning empty SVG string.\");\n        return \"\";\n    };\n    ;\n    return PBImage;\n}());\nexports.PBImage = PBImage;\n//# sourceMappingURL=PBImage.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2018-10-23\n * @modified 2018-11-19 Added multi-select and multi-drag.\n * @modified 2018-12-04 Added basic SVG export.\n * @modified 2018-12-09 Extended the constructor (canvas).\n * @modified 2018-12-18 Added the config.redrawOnResize param.\n * @modified 2018-12-18 Added the config.defaultCanvas{Width,Height} params.\n * @modified 2018-12-19 Added CSS scaling.\n * @modified 2018-12-28 Removed the unused 'drawLabel' param. Added the 'enableMouse' and 'enableKeys' params.\n * @modified 2018-12-29 Added the 'drawOrigin' param.\n * @modified 2018-12-29 Renamed the 'autoCenterOffset' param to 'autoAdjustOffset'. Added the params 'offsetAdjustXPercent' and 'offsetAdjustYPercent'.\n * @modified 2019-01-14 Added params 'drawBezierHandleLines' and 'drawBezierHandlePoints'. Added the 'redraw' praam to the add() function.\n * @modified 2019-01-16 Added params 'drawHandleLines' and 'drawHandlePoints'. Added the new params to the dat.gui interface.\n * @modified 2019-01-30 Added the 'Vector' type (extending the Line class).\n * @modified 2019-01-30 Added the 'PBImage' type (a wrapper for images).\n * @modified 2019-02-02 Added the 'canvasWidthFactor' and 'canvasHeightFactor' params.\n * @modified 2019-02-03 Removed the drawBackgroundImage() function, with had no purpose at all. Just add an image to the drawables-list.\n * @modified 2019-02-06 Vertices (instace of Vertex) can now be added. Added the 'draggable' attribute to the vertex attributes.\n * @modified 2019-02-10 Fixed a draggable-bug in PBImage handling (scaling was not possible).\n * @modified 2019-02-10 Added the 'enableTouch' option (default is true).\n * @modified 2019-02-14 Added the console for debugging (setConsole(object)).\n * @modified 2019-02-19 Added two new constants: DEFAULT_CLICK_TOLERANCE and DEFAULT_TOUCH_TOLERANCE.\n * @modified 2019-02-19 Added the second param to the locatePointNear(Vertex,Number) function.\n * @modified 2019-02-20 Removed the 'loadFile' entry from the GUI as it was experimental and never in use.\n * @modified 2019-02-23 Removed the 'rebuild' function as it had no purpose.\n * @modified 2019-02-23 Added scaling of the click-/touch-tolerance with the CSS scale.\n * @modified 2019-03-23 Added JSDoc tags. Changed the default value of config.drawOrigin to false.\n * @modified 2019-04-03 Fixed the touch-drag position detection for canvas elements that are not located at document position (0,0).\n * @modified 2019-04-03 Tweaked the fit-to-parent function to work with paddings and borders.\n * @modified 2019-04-28 Added the preClear callback param (called before the canvas was cleared on redraw and before any elements are drawn).\n * @modified 2019-09-18 Added basics for WebGL support (strictly experimental).\n * @modified 2019-10-03 Added the .beginDrawCycle call in the redraw function.\n * @modified 2019-11-06 Added fetch.num, fetch.val, fetch.bool, fetch.func functions.\n * @modified 2019-11-13 Fixed an issue with the mouse-sensitive area around vertices (were affected by zoom).\n * @modified 2019-11-13 Added the 'enableMouseWheel' param.\n * @modified 2019-11-18 Added the Triangle class as a regular drawable element.\n * @modified 2019-11-18 The add function now works with arrays, too.\n * @modified 2019-11-18 Added the _handleColor helper function to determine the render color of non-draggable vertices.\n * @modified 2019-11-19 Fixed a bug in the resizeCanvas function; retina resolution was not possible.\n * @modified 2019-12-04 Added relative positioned zooming.\n * @modified 2019-12-04 Added offsetX and offsetY params.\n * @modified 2019-12-04 Added an 'Set to fullsize retina' button to the GUI config.\n * @modified 2019-12-07 Added the drawConfig for lines, polygons, ellipse, triangles, bezier curves and image control lines.\n * @modified 2019-12-08 Fixed a css scale bug in the viewport() function.\n * @modified 2019-12-08 Added the drawconfig UI panel (line colors and line widths).\n * @modified 2020-02-06 Added handling for the end- and end-control-points of non-cirular Bézier paths (was still missing).\n * @modified 2020-02-06 Fixed a drag-amount bug in the move handling of end points of Bezier paths (control points was not properly moved when non circular).\n * @modified 2020-03-28 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-03-29 Fixed the enableSVGExport flag (read enableEport before).\n * @modified 2020-05-09 Included the Cirlcle class.\n * @modified 2020-06-22 Added the rasterScaleX and rasterScaleY config params.\n * @modified 2020-06-03 Fixed the selectedVerticesOnPolyon(Polygon) function: non-selectable vertices were selected too, before.\n * @modified 2020-07-06 Replacing Touchy.js by AlloyFinger.js\n * @modified 2020-07-27 Added the getVertexNear(XYCoords,number) function\n * @modified 2020-07-27 Extended the remove(Drawable) function: vertices are now removed, too.\n * @modified 2020-07-28 Added PlotBoilerplate.revertMousePosition(number,number) –  the inverse function of transformMousePosition(...).\n * @modified 2020-07-31 Added PlotBoilerplate.getDraggedElementCount() to check wether any elements are currently being dragged.\n * @modified 2020-08-19 Added the VertexAttributes.visible attribute to make vertices invisible.\n * @modified 2020-11-17 Added pure click handling (no dragEnd and !wasMoved jiggliny any more) to the PlotBoilerplate.\n * @modified 2020-12-11 Added the `removeAll(boolean)` function.\n * @modified 2020-12-17 Added the `CircleSector` drawable.\n * @modified 2021-01-04 Avoiding multiple redraw call on adding multiple Drawables (array).\n * @modified 2021-01-08 Added param `draw:DraLib<void>` to the methods `drawVertices`, `drawGrid` and `drawSelectPolygon`.\n * @modified 2021-01-08 Added the customizable `drawAll(...)` function.\n * @modified 2021-01-09 Added the `drawDrawable(...)` function.\n * @modified 2021-01-10 Added the `eventCatcher` element (used to track mouse events on SVGs).\n * @modified 2021-01-26 Fixed SVG resizing.\n * @modified 2021-01-26 Replaced the old SVGBuilder by the new `drawutilssvg` library.\n * @version  1.12.2\n *\n * @file PlotBoilerplate\n * @fileoverview The main class.\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.PlotBoilerplate = void 0;\nvar draw_1 = require(\"./draw\");\nvar drawgl_1 = require(\"./drawgl\");\nvar drawutilssvg_1 = require(\"./utils/helpers/drawutilssvg\");\nvar BezierPath_1 = require(\"./BezierPath\");\nvar Bounds_1 = require(\"./Bounds\");\nvar Circle_1 = require(\"./Circle\");\nvar CircleSector_1 = require(\"./CircleSector\");\nvar Grid_1 = require(\"./Grid\");\nvar KeyHandler_1 = require(\"./KeyHandler\");\nvar Line_1 = require(\"./Line\");\nvar MouseHandler_1 = require(\"./MouseHandler\");\nvar PBImage_1 = require(\"./PBImage\");\nvar Polygon_1 = require(\"./Polygon\");\nvar Triangle_1 = require(\"./Triangle\");\nvar VEllipse_1 = require(\"./VEllipse\");\nvar Vector_1 = require(\"./Vector\");\nvar Vertex_1 = require(\"./Vertex\");\nvar VertexAttr_1 = require(\"./VertexAttr\");\n/**\n * @classdesc The main class of the PlotBoilerplate.\n *\n * @requires Vertex\n * @requires Line\n * @requires Vector\n * @requires Polygon\n * @requires PBImage\n * @requires VEllipse\n * @requires Circle\n * @requires MouseHandler\n * @requires KeyHandler\n * @requires VertexAttr\n * @requires CubicBezierCurve\n * @requires BezierPath\n * @requires Drawable\n * @requires DrawConfig\n * @requires IHooks\n * @requires PBParams\n * @requires Triangle\n * @requires drawutils\n * @requires drawutilsgl\n * @requires SVGSerializable\n * @requires XYCoords\n * @requires XYDimension\n */\nvar PlotBoilerplate = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name PlotBoilerplate\n     * @public\n     * @param {object} config={} - The configuration.\n     * @param {HTMLCanvasElement} config.canvas - Your canvas element in the DOM (required).\n     * @param {boolean=} [config.fullSize=true] - If set to true the canvas will gain full window size.\n     * @param {boolean=} [config.fitToParent=true] - If set to true the canvas will gain the size of its parent container (overrides fullSize).\n     * @param {number=}  [config.scaleX=1.0] - The initial x-zoom. Default is 1.0.\n     * @param {number=}  [config.scaleY=1.0] - The initial y-zoom. Default is 1.0.\n     * @param {number=}  [config.offsetX=1.0] - The initial x-offset. Default is 0.0. Note that autoAdjustOffset=true overrides these values.\n     * @param {number=}  [config.offsetY=1.0] - The initial y-offset. Default is 0.0. Note that autoAdjustOffset=true overrides these values.\n     * @param {boolean=} [config.rasterGrid=true] - If set to true the background grid will be drawn rastered.\n     * @param {boolean=} [config.rasterScaleX=1.0] - Define the default horizontal raster scale (default=1.0).\n     * @param {boolean=} [config.rasterScaleY=1.0] - Define the default vertical raster scale (default=1.0).\n     * @param {number=}  [config.rasterAdjustFactor=1.0] - The exponential limit for wrapping down the grid. (2.0 means: halve the grid each 2.0*n zoom step).\n     * @param {boolean=} [config.drawOrigin=false] - Draw a crosshair at (0,0).\n     * @param {boolean=} [config.autoAdjustOffset=true] -  When set to true then the origin of the XY plane will\n     *                         be re-adjusted automatically (see the params\n     *                         offsetAdjust{X,Y}Percent for more).\n     * @param {number=}  [config.offsetAdjustXPercent=50] - The x-fallback position for the origin after\n     *                         resizing the canvas.\n     * @param {number=}  [config.offsetAdjustYPercent=50] - The y-fallback position for the origin after\n     *                         resizing the canvas.\n     * @param {number=}  [config.defaultCanvasWidth=1024] - The canvas size fallback (width) if no automatic resizing\n     *                         is switched on.\n     * @param {number=}  [config.defaultCanvasHeight=768] - The canvas size fallback (height) if no automatic resizing\n     *                         is switched on.\n     * @param {number=}  [config.canvasWidthFactor=1.0] - Scaling factor (width) upon the canvas size.\n     *                         In combination with cssScale{X,Y} this can be used to obtain\n     *                         sub pixel resolutions for retina displays.\n     * @param {number=}  [config.canvasHeightFactor=1.0] - Scaling factor (height) upon the canvas size.\n     *                         In combination with cssScale{X,Y} this can be used to obtain\n     *                         sub pixel resolutions for retina displays.\n     * @param {number=}  [config.cssScaleX=1.0] - Visually resize the canvas (horizontally) using CSS transforms (scale).\n     * @param {number=}  [config.cssScaleY=1.0] - Visually resize the canvas (vertically) using CSS transforms (scale).\n     * @param {boolan=}  [config.cssUniformScale=true] - CSS scale x and y obtaining aspect ratio.\n     * @param {boolean=} [config.autoDetectRetina=true] - When set to true (default) the canvas will try to use the display's pixel ratio.\n     * @param {string=}  [config.backgroundColor=#ffffff] - The backround color.\n     * @param {boolean=} [config.redrawOnResize=true] - Switch auto-redrawing on resize on/off (some applications\n     *                         might want to prevent automatic redrawing to avoid data loss from the draw buffer).\n     * @param {boolean=} [config.drawBezierHandleLines=true] - Indicates if Bézier curve handles should be drawn (used for\n     *                         editors, no required in pure visualizations).\n     * @param {boolean=} [config.drawBezierHandlePoints=true] - Indicates if Bézier curve handle points should be drawn.\n     * @param {function=} [config.preClear=null] - A callback function that will be triggered just before the\n     *                         draw function clears the canvas (before anything else was drawn).\n     * @param {function=} [config.preDraw=null] - A callback function that will be triggered just before the draw\n     *                         function starts.\n     * @param {function=} [config.postDraw=null] - A callback function that will be triggered right after the drawing\n     *                         process finished.\n     * @param {boolean=} [config.enableMouse=true] - Indicates if the application should handle mouse events for you.\n     * @param {boolean=} [config.enableTouch=true] - Indicates if the application should handle touch events for you.\n     * @param {boolean=} [config.enableKeys=true] - Indicates if the application should handle key events for you.\n     * @param {boolean=} [config.enableMouseWheel=true] - Indicates if the application should handle mouse wheel events for you.\n     * @param {boolean=} [config.enableGL=false] - Indicates if the application should use the experimental WebGL features (not recommended).\n     * @param {boolean=} [config.enableSVGExport=true] - Indicates if the SVG export should be enabled (default is true).\n     *                                                   Note that changes from the postDraw hook might not be visible in the export.\n     */\n    function PlotBoilerplate(config) {\n        // This should be in some static block ...\n        VertexAttr_1.VertexAttr.model = { bezierAutoAdjust: false,\n            renderTime: 0,\n            selectable: true,\n            isSelected: false,\n            draggable: true,\n            visible: true\n        };\n        if (typeof config.canvas == 'undefined')\n            throw \"No canvas specified.\";\n        /**\n         * A global config that's attached to the dat.gui control interface.\n         *\n         * @member {Object}\n         * @memberof PlotBoilerplate\n         * @instance\n         */\n        var f = PlotBoilerplate.utils.fetch;\n        this.config = {\n            canvas: config.canvas,\n            fullSize: f.val(config, 'fullSize', true),\n            fitToParent: f.bool(config, 'fitToParent', true),\n            scaleX: f.num(config, 'scaleX', 1.0),\n            scaleY: f.num(config, 'scaleY', 1.0),\n            offsetX: f.num(config, 'offsetX', 0.0),\n            offsetY: f.num(config, 'offsetY', 0.0),\n            rasterGrid: f.bool(config, 'rasterGrid', true),\n            rasterScaleX: f.num(config, 'rasterScaleX', 1.0),\n            rasterScaleY: f.num(config, 'rasterScaleY', 1.0),\n            rasterAdjustFactor: f.num(config, 'rasterAdjustdFactror', 2.0),\n            drawOrigin: f.bool(config, 'drawOrigin', false),\n            autoAdjustOffset: f.val(config, 'autoAdjustOffset', true),\n            offsetAdjustXPercent: f.num(config, 'offsetAdjustXPercent', 50),\n            offsetAdjustYPercent: f.num(config, 'offsetAdjustYPercent', 50),\n            backgroundColor: config.backgroundColor || '#ffffff',\n            redrawOnResize: f.bool(config, 'redrawOnResize', true),\n            defaultCanvasWidth: f.num(config, 'defaultCanvasWidth', PlotBoilerplate.DEFAULT_CANVAS_WIDTH),\n            defaultCanvasHeight: f.num(config, 'defaultCanvasHeight', PlotBoilerplate.DEFAULT_CANVAS_HEIGHT),\n            canvasWidthFactor: f.num(config, 'canvasWidthFactor', 1.0),\n            canvasHeightFactor: f.num(config, 'canvasHeightFactor', 1.0),\n            cssScaleX: f.num(config, 'cssScaleX', 1.0),\n            cssScaleY: f.num(config, 'cssScaleY', 1.0),\n            cssUniformScale: f.bool(config, 'cssUniformScale', true),\n            saveFile: function () { _self.hooks.saveFile(_self); },\n            setToRetina: function () { _self._setToRetina(); },\n            autoDetectRetina: f.bool(config, 'autoDetectRetina', true),\n            enableSVGExport: f.bool(config, 'enableSVGExport', true),\n            // Listeners/observers\n            preClear: f.func(config, 'preClear', null),\n            preDraw: f.func(config, 'preDraw', null),\n            postDraw: f.func(config, 'postDraw', null),\n            // Interaction\n            enableMouse: f.bool(config, 'enableMouse', true),\n            enableTouch: f.bool(config, 'enableTouch', true),\n            enableKeys: f.bool(config, 'enableKeys', true),\n            enableMouseWheel: f.bool(config, 'enableMouseWheel', true),\n            // Experimental (and unfinished)\n            enableGL: f.bool(config, 'enableGL', false)\n        }; // END confog\n        /**\n         * Configuration for drawing things.\n         *\n         * @member {Object}\n         * @memberof PlotBoilerplate\n         * @instance\n         */\n        this.drawConfig = {\n            drawVertices: true,\n            drawBezierHandleLines: f.bool(config, 'drawBezierHandleLines', true),\n            drawBezierHandlePoints: f.bool(config, 'drawBezierHandlePoints', true),\n            drawHandleLines: f.bool(config, 'drawHandleLines', true),\n            drawHandlePoints: f.bool(config, 'drawHandlePoints', true),\n            drawGrid: f.bool(config, 'drawGrid', true),\n            bezier: {\n                color: '#00a822',\n                lineWidth: 2,\n                handleLine: {\n                    color: 'rgba(180,180,180,0.5)',\n                    lineWidth: 1\n                }\n            },\n            polygon: {\n                color: '#0022a8',\n                lineWidth: 1\n            },\n            triangle: {\n                color: '#6600ff',\n                lineWidth: 1\n            },\n            ellipse: {\n                color: '#2222a8',\n                lineWidth: 1\n            },\n            circle: {\n                color: '#22a8a8',\n                lineWidth: 2\n            },\n            circleSector: {\n                color: '#2280a8',\n                lineWidth: 1\n            },\n            vertex: {\n                color: '#a8a8a8',\n                lineWidth: 1\n            },\n            selectedVertex: {\n                color: '#c08000',\n                lineWidth: 2\n            },\n            line: {\n                color: '#a844a8',\n                lineWidth: 1\n            },\n            vector: {\n                color: '#ff44a8',\n                lineWidth: 1\n            },\n            image: {\n                color: '#a8a8a8',\n                lineWidth: 1\n            }\n        }; // END drawConfig\n        // +---------------------------------------------------------------------------------\n        // | Object members.\n        // +-------------------------------\n        this.grid = new Grid_1.Grid(new Vertex_1.Vertex(0, 0), new Vertex_1.Vertex(50, 50));\n        this.canvasSize = { width: PlotBoilerplate.DEFAULT_CANVAS_WIDTH, height: PlotBoilerplate.DEFAULT_CANVAS_HEIGHT };\n        var canvasElement = typeof config.canvas == 'string'\n            ? document.querySelector(config.canvas)\n            : config.canvas;\n        // Which renderer to use: Canvas2D, WebGL (experimental) or SVG?\n        if (canvasElement.tagName.toLowerCase() === 'canvas') {\n            this.canvas = canvasElement;\n            this.eventCatcher = this.canvas;\n            if (this.config.enableGL && typeof drawgl_1.drawutilsgl === \"undefined\") {\n                console.warn(\"Cannot use webgl. Package was compiled without experimental gl support. Please use plotboilerplate-glsupport.min.js instead.\");\n                console.warn(\"Disabling GL and falling back to Canvas2D.\");\n                this.config.enableGL = false;\n            }\n            if (this.config.enableGL) {\n                var ctx = this.canvas.getContext('webgl'); // webgl-experimental?\n                this.draw = new drawgl_1.drawutilsgl(ctx, false);\n                // PROBLEM: same instance of fill and draw when using WebGL.\n                //          Shader program cannot be duplicated on the same context.\n                this.fill = this.draw.copyInstance(true);\n                console.warn('Initialized with experimental mode enableGL=true. Note that this is not yet fully implemented.');\n            }\n            else {\n                var ctx = this.canvas.getContext('2d');\n                this.draw = new draw_1.drawutils(ctx, false);\n                this.fill = new draw_1.drawutils(ctx, true);\n            }\n        }\n        else if (canvasElement.tagName.toLowerCase() === 'svg') {\n            if (typeof drawutilssvg_1.drawutilssvg === \"undefined\")\n                throw \"The svg draw library is not yet integrated part of PlotBoilerplate. Please include ./src/js/utils/helpers/drawutils.svg into your document.\";\n            this.canvas = canvasElement;\n            this.draw = new drawutilssvg_1.drawutilssvg(this.canvas, new Vertex_1.Vertex(), // offset\n            new Vertex_1.Vertex(), // scale\n            this.canvasSize, false, // fillShapes=false\n            this.drawConfig, false // isSecondary=false\n            );\n            this.fill = this.draw.copyInstance(true); // fillShapes=true\n            if (this.canvas.parentElement) {\n                this.eventCatcher = document.createElement('div');\n                this.eventCatcher.style.position = 'absolute';\n                this.eventCatcher.style.left = '0';\n                this.eventCatcher.style.top = '0';\n                this.eventCatcher.style.cursor = 'pointer';\n                this.canvas.parentElement.style.position = 'relative';\n                this.canvas.parentElement.appendChild(this.eventCatcher);\n            }\n            else {\n                this.eventCatcher = document.body;\n            }\n        }\n        else {\n            throw 'Element is neither a canvas nor an svg element.';\n        }\n        this.draw.scale.set(this.config.scaleX, this.config.scaleY);\n        this.fill.scale.set(this.config.scaleX, this.config.scaleY);\n        this.vertices = [];\n        this.selectPolygon = null;\n        this.draggedElements = [];\n        this.drawables = [];\n        this.console = console;\n        this.hooks = {\n            // This is changable from the outside\n            saveFile: PlotBoilerplate._saveFile\n        };\n        var _self = this;\n        globalThis.addEventListener('resize', function () { return _self.resizeCanvas(); });\n        this.resizeCanvas();\n        if (config.autoDetectRetina) {\n            this._setToRetina();\n        }\n        this.installInputListeners();\n        // Apply the configured CSS scale.\n        this.updateCSSscale();\n        // Init\t\n        this.redraw();\n        // Gain focus\n        this.canvas.focus();\n    }\n    ; // END constructor\n    /**\n     * This function opens a save-as file dialog and – once an output file is\n     * selected – stores the current canvas contents as an SVG image.\n     *\n     * It is the default hook for saving files and can be overwritten.\n     *\n     * @method _saveFile\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     * @private\n     **/\n    PlotBoilerplate._saveFile = function (pb) {\n        if (typeof drawutilssvg_1.drawutilssvg === \"undefined\") {\n            console.error(\"Cannot convert image to SVG. The svg renderer 'drawutilssvg' is missing. Did you load it?\");\n            return;\n        }\n        // Create fake SVG node\n        var svgNode = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n        // var svgNode = document.getElementById('preview-svg');\n        // Draw everything to fake node.\n        var tosvgDraw = new drawutilssvg_1.drawutilssvg(svgNode, pb.draw.offset, pb.draw.scale, pb.canvasSize, false, // fillShapes=false\n        pb.drawConfig);\n        var tosvgFill = tosvgDraw.copyInstance(true); // fillShapes=true\n        tosvgDraw.beginDrawCycle(0);\n        tosvgFill.beginDrawCycle(0);\n        tosvgDraw.clear(pb.config.backgroundColor);\n        pb.drawAll(0, tosvgDraw, tosvgFill);\n        // Full support in all browsers \\o/\n        //    https://caniuse.com/xml-serializer\n        var serializer = new XMLSerializer();\n        var svgCode = serializer.serializeToString(svgNode);\n        var blob = new Blob([svgCode], { type: \"image/svg;charset=utf-8\" });\n        // See documentation for FileSaver.js for usage.\n        //    https://github.com/eligrey/FileSaver.js\n        if (typeof globalThis[\"saveAs\"] != \"function\")\n            throw \"Cannot save file; did you load the ./utils/savefile helper function and the eligrey/SaveFile library?\";\n        var _saveAs = globalThis[\"saveAs\"];\n        _saveAs(blob, \"plotboilerplate.svg\");\n    };\n    ;\n    /**\n     * This function sets the canvas resolution to factor 2.0 (or the preferred pixel ratio of your device) for retina displays.\n     * Please not that in non-GL mode this might result in very slow rendering as the canvas buffer size may increase.\n     *\n     * @method _setToRetina\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     * @private\n     **/\n    PlotBoilerplate.prototype._setToRetina = function () {\n        this.config.autoDetectRetina = true;\n        var pixelRatio = globalThis.devicePixelRatio || 1;\n        this.config.cssScaleX = this.config.cssScaleY = 1.0 / pixelRatio; // 0.5;\n        this.config.canvasWidthFactor = this.config.canvasHeightFactor = pixelRatio; // 2.0;\n        this.resizeCanvas();\n        this.updateCSSscale();\n    };\n    ;\n    /**\n     * Set the current zoom and draw offset to fit the given bounds.\n     *\n     * This method currently restores the aspect zoom ratio.\n     *\n     **/\n    PlotBoilerplate.prototype.fitToView = function (bounds) {\n        var canvasCenter = new Vertex_1.Vertex(this.canvasSize.width / 2.0, this.canvasSize.height / 2.0);\n        var canvasRatio = this.canvasSize.width / this.canvasSize.height;\n        var ratio = bounds.width / bounds.height;\n        // Find the new draw offset\n        var center = new Vertex_1.Vertex(bounds.max.x - bounds.width / 2.0, bounds.max.y - bounds.height / 2.0)\n            .inv()\n            .addXY(this.canvasSize.width / 2.0, this.canvasSize.height / 2.0);\n        this.setOffset(center);\n        if (canvasRatio < ratio) {\n            var newUniformZoom = this.canvasSize.width / bounds.width;\n            this.setZoom(newUniformZoom, newUniformZoom, canvasCenter);\n        }\n        else {\n            var newUniformZoom = this.canvasSize.height / bounds.height;\n            this.setZoom(newUniformZoom, newUniformZoom, canvasCenter);\n        }\n        this.redraw();\n    };\n    ;\n    /**\n     * Set the console for this instance.\n     *\n     * @method setConsole\n     * @param {Console} con - The new console object (default is globalThis.console).\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.setConsole = function (con) {\n        this.console = con;\n    };\n    ;\n    /**\n     * Update the CSS scale for the canvas depending onf the cssScale{X,Y} settings.<br>\n     * <br>\n     * This function is usually only used inernally.\n     *\n     * @method updateCSSscale\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     * @private\n     **/\n    PlotBoilerplate.prototype.updateCSSscale = function () {\n        if (this.config.cssUniformScale) {\n            PlotBoilerplate.utils.setCSSscale(this.canvas, this.config.cssScaleX, this.config.cssScaleX);\n        }\n        else {\n            PlotBoilerplate.utils.setCSSscale(this.canvas, this.config.cssScaleX, this.config.cssScaleY);\n        }\n    };\n    ;\n    /**\n     * Add a drawable object.<br>\n     * <br>\n     * This must be either:<br>\n     * <pre>\n     *  * a Vertex\n     *  * a Line\n     *  * a Vector\n     *  * a VEllipse\n     *  * a Circle\n     *  * a Polygon\n     *  * a Triangle\n     *  * a BezierPath\n     *  * a BPImage\n     * </pre>\n     *\n     * @param {Drawable|Drawable[]} drawable - The drawable (of one of the allowed class instance) to add.\n     * @param {boolean} [redraw=true] - If true the function will trigger redraw after the drawable(s) was/were added.\n     * @method add\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.add = function (drawable, redraw) {\n        if (Array.isArray(drawable)) {\n            var arr = drawable;\n            // for( var i in arr )\n            for (var i = 0; i < arr.length; i++) {\n                this.add(arr[i], false);\n            }\n        }\n        else if (drawable instanceof Vertex_1.Vertex) {\n            this.drawables.push(drawable);\n            this.vertices.push(drawable);\n        }\n        else if (drawable instanceof Line_1.Line) {\n            // Add some lines\n            this.drawables.push(drawable);\n            this.vertices.push(drawable.a);\n            this.vertices.push(drawable.b);\n        }\n        else if (drawable instanceof Vector_1.Vector) {\n            this.drawables.push(drawable);\n            this.vertices.push(drawable.a);\n            this.vertices.push(drawable.b);\n        }\n        else if (drawable instanceof VEllipse_1.VEllipse) {\n            this.vertices.push(drawable.center);\n            this.vertices.push(drawable.axis);\n            this.drawables.push(drawable);\n            drawable.center.listeners.addDragListener(function (e) {\n                drawable.axis.add(e.params.dragAmount);\n            });\n        }\n        else if (drawable instanceof Circle_1.Circle) {\n            this.vertices.push(drawable.center);\n            this.drawables.push(drawable);\n        }\n        else if (drawable instanceof CircleSector_1.CircleSector) {\n            this.vertices.push(drawable.circle.center);\n            this.drawables.push(drawable);\n        }\n        else if (drawable instanceof Polygon_1.Polygon) {\n            this.drawables.push(drawable);\n            // for( var i in drawable.vertices )\n            for (var i = 0; i < drawable.vertices.length; i++)\n                this.vertices.push(drawable.vertices[i]);\n        }\n        else if (drawable instanceof Triangle_1.Triangle) {\n            this.drawables.push(drawable);\n            this.vertices.push(drawable.a);\n            this.vertices.push(drawable.b);\n            this.vertices.push(drawable.c);\n        }\n        else if (drawable instanceof BezierPath_1.BezierPath) {\n            this.drawables.push(drawable);\n            var bezierPath = drawable;\n            for (var i = 0; i < bezierPath.bezierCurves.length; i++) {\n                if (!drawable.adjustCircular && i == 0)\n                    this.vertices.push(bezierPath.bezierCurves[i].startPoint);\n                this.vertices.push(bezierPath.bezierCurves[i].endPoint);\n                this.vertices.push(bezierPath.bezierCurves[i].startControlPoint);\n                this.vertices.push(bezierPath.bezierCurves[i].endControlPoint);\n                bezierPath.bezierCurves[i].startControlPoint.attr.selectable = false;\n                bezierPath.bezierCurves[i].endControlPoint.attr.selectable = false;\n            }\n            PlotBoilerplate.utils.enableBezierPathAutoAdjust(drawable);\n        }\n        else if (drawable instanceof PBImage_1.PBImage) {\n            this.vertices.push(drawable.upperLeft);\n            this.vertices.push(drawable.lowerRight);\n            this.drawables.push(drawable);\n            // Todo: think about a IDragEvent interface\n            drawable.upperLeft.listeners.addDragListener(function (e) {\n                drawable.lowerRight.add(e.params.dragAmount);\n            });\n            drawable.lowerRight.attr.selectable = false;\n        }\n        else {\n            throw \"Cannot add drawable of unrecognized type: \" + (typeof drawable) + \".\";\n        }\n        // This is a workaround for backwards compatibility when the 'redraw' param was not yet present.\n        if (redraw || typeof redraw == 'undefined')\n            this.redraw();\n    };\n    ;\n    /**\n     * Remove a drawable object.<br>\n     * <br>\n     * This must be either:<br>\n     * <pre>\n     *  * a Vertex\n     *  * a Line\n     *  * a Vector\n     *  * a VEllipse\n     *  * a Circle\n     *  * a Polygon\n     *  * a BezierPath\n     *  * a BPImage\n     *  * a Triangle\n     * </pre>\n     *\n     * @param {Object} drawable - The drawable (of one of the allowed class instance) to remove.\n     * @param {boolean} [redraw=false]\n     * @method remove\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.remove = function (drawable, redraw, removeWithVertices) {\n        if (drawable instanceof Vertex_1.Vertex)\n            this.removeVertex(drawable, false);\n        for (var i = 0; i < this.drawables.length; i++) {\n            if (this.drawables[i] === drawable) {\n                this.drawables.splice(i, 1);\n                if (removeWithVertices) {\n                    // Check if some listeners need to be removed\n                    if (drawable instanceof Line_1.Line) {\n                        // Add some lines\n                        this.removeVertex(drawable.a, false);\n                        this.removeVertex(drawable.b, false);\n                    }\n                    else if (drawable instanceof Vector_1.Vector) {\n                        this.removeVertex(drawable.a, false);\n                        this.removeVertex(drawable.b, false);\n                    }\n                    else if (drawable instanceof VEllipse_1.VEllipse) {\n                        this.removeVertex(drawable.center, false);\n                        this.removeVertex(drawable.axis, false);\n                    }\n                    else if (drawable instanceof Circle_1.Circle) {\n                        this.removeVertex(drawable.center, false);\n                    }\n                    else if (drawable instanceof CircleSector_1.CircleSector) {\n                        this.removeVertex(drawable.circle.center, false);\n                    }\n                    else if (drawable instanceof Polygon_1.Polygon) {\n                        // for( var i in drawable.vertices )\n                        for (var i = 0; i < drawable.vertices.length; i++)\n                            this.removeVertex(drawable.vertices[i], false);\n                    }\n                    else if (drawable instanceof Triangle_1.Triangle) {\n                        this.removeVertex(drawable.a, false);\n                        this.removeVertex(drawable.b, false);\n                        this.removeVertex(drawable.c, false);\n                    }\n                    else if (drawable instanceof BezierPath_1.BezierPath) {\n                        for (var i = 0; i < drawable.bezierCurves.length; i++) {\n                            this.removeVertex(drawable.bezierCurves[i].startPoint, false);\n                            this.removeVertex(drawable.bezierCurves[i].startControlPoint, false);\n                            this.removeVertex(drawable.bezierCurves[i].endControlPoint, false);\n                            if (i + 1 == drawable.bezierCurves.length) {\n                                this.removeVertex(drawable.bezierCurves[i].endPoint, false);\n                            }\n                        }\n                    }\n                    else if (drawable instanceof PBImage_1.PBImage) {\n                        this.removeVertex(drawable.upperLeft, false);\n                        this.removeVertex(drawable.lowerRight, false);\n                    }\n                } // END removeWithVertices\n                if (redraw)\n                    this.redraw();\n                return;\n            }\n        }\n    };\n    ;\n    /**\n     * Remove a vertex from the vertex list.<br>\n     *\n     * @param {Vertex} vert - The vertex to remove.\n     * @param {boolean} [redraw=false]\n     * @method removeVertex\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.removeVertex = function (vert, redraw) {\n        for (var i = 0; i < this.vertices.length; i++) {\n            if (this.vertices[i] === vert) {\n                this.vertices.splice(i, 1);\n                if (redraw)\n                    this.redraw();\n                return;\n            }\n        }\n    };\n    ;\n    /**\n     * Remove all elements.\n     *\n     * If you want to keep the vertices, pass `true`.\n     *\n     * @method removeAll\n     * @param {boolean=false} keepVertices\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     */\n    PlotBoilerplate.prototype.removeAll = function (keepVertices) {\n        this.drawables = [];\n        if (!Boolean(keepVertices)) {\n            this.vertices = [];\n        }\n        this.redraw();\n    };\n    ;\n    /**\n     * Find the vertex near the given position.\n     *\n     * The position is the absolute vertex position, not the x-y-coordinates on the canvas.\n     *\n     * @param {XYCoords} position - The position of the vertex to search for.\n     * @param {number} pixelTolerance - A radius around the position to include into the search.\n     *                                  Note that the tolerance will be scaled up/down when zoomed.\n     * @return The vertex near the given position or undefined if none was found there.\n     **/\n    PlotBoilerplate.prototype.getVertexNear = function (pixelPosition, pixelTolerance) {\n        var p = this.locatePointNear(this.transformMousePosition(pixelPosition.x, pixelPosition.y), pixelTolerance / Math.min(this.config.cssScaleX, this.config.cssScaleY));\n        if (p && p.typeName == \"vertex\")\n            return this.vertices[p.vindex];\n        return undefined;\n    };\n    ;\n    /**\n     * Draw the grid with the current config settings.<br>\n     *\n     * This function is usually only used internally.\n     *\n     * @method drawGrid\n     * @param {DrawLib} draw - The drawing library to use to draw lines.\n     * @private\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.drawGrid = function (draw) {\n        var gScale = {\n            x: Grid_1.Grid.utils.mapRasterScale(this.config.rasterAdjustFactor, this.draw.scale.x) * this.config.rasterScaleX / this.config.cssScaleX,\n            y: Grid_1.Grid.utils.mapRasterScale(this.config.rasterAdjustFactor, this.draw.scale.y) * this.config.rasterScaleY / this.config.cssScaleY\n        };\n        var gSize = { width: this.grid.size.x * gScale.x, height: this.grid.size.y * gScale.y };\n        var cs = { width: this.canvasSize.width / 2, height: this.canvasSize.height / 2 };\n        var offset = this.draw.offset.clone().inv();\n        offset.x = (Math.round(offset.x + cs.width) / Math.round(gSize.width)) * (gSize.width) / this.draw.scale.x + (((this.draw.offset.x - cs.width) / this.draw.scale.x) % gSize.width);\n        offset.y = (Math.round(offset.y + cs.height) / Math.round(gSize.height)) * (gSize.height) / this.draw.scale.y + (((this.draw.offset.y - cs.height) / this.draw.scale.x) % gSize.height);\n        if (this.drawConfig.drawGrid) {\n            if (this.config.rasterGrid) { // TODO: move config member to drawConfig\n                draw.setCurrentId('raster');\n                draw.raster(offset, (this.canvasSize.width) / this.draw.scale.x, (this.canvasSize.height) / this.draw.scale.y, gSize.width, gSize.height, 'rgba(0,128,255,0.125)');\n            }\n            else {\n                draw.setCurrentId('grid');\n                draw.grid(offset, (this.canvasSize.width) / this.draw.scale.x, (this.canvasSize.height) / this.draw.scale.y, gSize.width, gSize.height, 'rgba(0,128,255,0.095)');\n            }\n        }\n    };\n    ;\n    /**\n     * Draw the origin with the current config settings.<br>\n     *\n     * This function is usually only used internally.\n     *\n     * @method drawOrigin\n     * @param {DrawLib} draw - The drawing library to use to draw lines.\n     * @private\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.drawOrigin = function (draw) {\n        // Add a crosshair to mark the origin\n        draw.setCurrentId('origin');\n        draw.crosshair({ x: 0, y: 0 }, 10, '#000000');\n    };\n    ;\n    /**\n     * This is just a tiny helper function to determine the render color of vertices.\n     **/\n    PlotBoilerplate.prototype._handleColor = function (h, color) {\n        return h.attr.isSelected ? this.drawConfig.selectedVertex.color : (h.attr.draggable ? color : 'rgba(128,128,128,0.5)');\n    };\n    /**\n     * Draw all drawables.\n     *\n     * This function is usually only used internally.\n     *\n     * @method drawDrawables\n     * @param {number} renderTime - The current render time. It will be used to distinct\n     *                              already draw vertices from non-draw-yet vertices.\n     * @param {DrawLib} draw - The drawing library to use to draw lines.\n     * @param {DrawLib} fill - The drawing library to use to fill areas.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.drawDrawables = function (renderTime, draw, fill) {\n        for (var i in this.drawables) {\n            var d = this.drawables[i];\n            this.draw.setCurrentId(d.uid);\n            this.fill.setCurrentId(d.uid);\n            this.draw.setCurrentClassName(d.className);\n            this.draw.setCurrentClassName(d.className);\n            this.drawDrawable(d, renderTime, draw, fill);\n        }\n    };\n    ;\n    /**\n     * Draw the given drawable.\n     *\n     * This function is usually only used internally.\n     *\n     * @method drawDrawable\n     * @param {Drawable} d - The drawable to draw.\n     * @param {number} renderTime - The current render time. It will be used to distinct\n     *                              already draw vertices from non-draw-yet vertices.\n     * @param {DrawLib} draw - The drawing library to use to draw lines.\n     * @param {DrawLib} fill - The drawing library to use to fill areas.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.drawDrawable = function (d, renderTime, draw, fill) {\n        if (d instanceof BezierPath_1.BezierPath) {\n            for (var c in d.bezierCurves) {\n                draw.cubicBezier(d.bezierCurves[c].startPoint, d.bezierCurves[c].endPoint, d.bezierCurves[c].startControlPoint, d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.color, this.drawConfig.bezier.lineWidth);\n                if (this.drawConfig.drawBezierHandlePoints && this.drawConfig.drawHandlePoints) {\n                    if (!d.bezierCurves[c].startPoint.attr.bezierAutoAdjust) {\n                        if (d.bezierCurves[c].startPoint.attr.visible) {\n                            draw.setCurrentId(d.uid + \"_h0\");\n                            draw.setCurrentClassName(d.className + \"-start-handle\");\n                            draw.diamondHandle(d.bezierCurves[c].startPoint, 7, this._handleColor(d.bezierCurves[c].startPoint, this.drawConfig.vertex.color));\n                        }\n                        d.bezierCurves[c].startPoint.attr.renderTime = renderTime;\n                    }\n                    if (!d.bezierCurves[c].endPoint.attr.bezierAutoAdjust) {\n                        if (d.bezierCurves[c].endPoint.attr.visible) {\n                            draw.setCurrentId(d.uid + \"_h1\");\n                            draw.setCurrentClassName(d.className + \"-end-handle\");\n                            draw.diamondHandle(d.bezierCurves[c].endPoint, 7, this._handleColor(d.bezierCurves[c].endPoint, this.drawConfig.vertex.color));\n                        }\n                        d.bezierCurves[c].endPoint.attr.renderTime = renderTime;\n                    }\n                    if (d.bezierCurves[c].startControlPoint.attr.visible) {\n                        draw.setCurrentId(d.uid + \"_h2\");\n                        draw.setCurrentClassName(d.className + \"-start-control-handle\");\n                        draw.circleHandle(d.bezierCurves[c].startControlPoint, 3, this._handleColor(d.bezierCurves[c].startControlPoint, '#008888'));\n                    }\n                    if (d.bezierCurves[c].endControlPoint.attr.visible) {\n                        draw.setCurrentId(d.uid + \"_h3\");\n                        draw.setCurrentClassName(d.className + \"-end-control-handle\");\n                        draw.circleHandle(d.bezierCurves[c].endControlPoint, 3, this._handleColor(d.bezierCurves[c].endControlPoint, '#008888'));\n                    }\n                    d.bezierCurves[c].startControlPoint.attr.renderTime = renderTime;\n                    d.bezierCurves[c].endControlPoint.attr.renderTime = renderTime;\n                }\n                else {\n                    d.bezierCurves[c].startPoint.attr.renderTime = renderTime;\n                    d.bezierCurves[c].endPoint.attr.renderTime = renderTime;\n                    d.bezierCurves[c].startControlPoint.attr.renderTime = renderTime;\n                    d.bezierCurves[c].endControlPoint.attr.renderTime = renderTime;\n                }\n                if (this.drawConfig.drawBezierHandleLines && this.drawConfig.drawHandleLines) {\n                    draw.setCurrentId(d.uid + \"_l0\");\n                    draw.setCurrentClassName(d.className + \"-start-line\");\n                    draw.line(d.bezierCurves[c].startPoint, d.bezierCurves[c].startControlPoint, this.drawConfig.bezier.handleLine.color, this.drawConfig.bezier.handleLine.lineWidth);\n                    draw.setCurrentId(d.uid + \"_l1\");\n                    draw.setCurrentClassName(d.className + \"-end-line\");\n                    draw.line(d.bezierCurves[c].endPoint, d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.handleLine.color, this.drawConfig.bezier.handleLine.lineWidth);\n                }\n            }\n        }\n        else if (d instanceof Polygon_1.Polygon) {\n            draw.polygon(d, this.drawConfig.polygon.color, this.drawConfig.polygon.lineWidth);\n            if (!this.drawConfig.drawHandlePoints) {\n                for (var i in d.vertices) {\n                    d.vertices[i].attr.renderTime = renderTime;\n                }\n            }\n        }\n        else if (d instanceof Triangle_1.Triangle) {\n            draw.polyline([d.a, d.b, d.c], false, this.drawConfig.triangle.color, this.drawConfig.triangle.lineWidth);\n            if (!this.drawConfig.drawHandlePoints)\n                d.a.attr.renderTime = d.b.attr.renderTime = d.c.attr.renderTime = renderTime;\n        }\n        else if (d instanceof VEllipse_1.VEllipse) {\n            if (this.drawConfig.drawHandleLines) {\n                draw.setCurrentId(d.uid + \"_e0\");\n                draw.setCurrentClassName(d.className + \"-v-line\");\n                draw.line(d.center.clone().add(0, d.axis.y - d.center.y), d.axis, '#c8c8c8');\n                draw.setCurrentId(d.uid + \"_e1\");\n                draw.setCurrentClassName(d.className + \"-h-line\");\n                draw.line(d.center.clone().add(d.axis.x - d.center.x, 0), d.axis, '#c8c8c8');\n            }\n            draw.setCurrentId(d.uid);\n            draw.setCurrentClassName(\"\" + d.className);\n            draw.ellipse(d.center, Math.abs(d.axis.x - d.center.x), Math.abs(d.axis.y - d.center.y), this.drawConfig.ellipse.color, this.drawConfig.ellipse.lineWidth);\n            if (!this.drawConfig.drawHandlePoints) {\n                d.center.attr.renderTime = renderTime;\n                d.axis.attr.renderTime = renderTime;\n            }\n        }\n        else if (d instanceof Circle_1.Circle) {\n            draw.circle(d.center, d.radius, this.drawConfig.circle.color, this.drawConfig.circle.lineWidth);\n        }\n        else if (d instanceof CircleSector_1.CircleSector) {\n            draw.circleArc(d.circle.center, d.circle.radius, d.startAngle, d.endAngle, this.drawConfig.circleSector.color, this.drawConfig.circleSector.lineWidth);\n        }\n        else if (d instanceof Vertex_1.Vertex) {\n            if (this.drawConfig.drawVertices &&\n                (!d.attr.selectable || !d.attr.draggable) && d.attr.visible) {\n                // Draw as special point (grey)\t\t\n                draw.circleHandle(d, 7, this.drawConfig.vertex.color);\n                d.attr.renderTime = renderTime;\n            }\n        }\n        else if (d instanceof Line_1.Line) {\n            draw.line(d.a, d.b, this.drawConfig.line.color, this.drawConfig.line.lineWidth);\n            if (!this.drawConfig.drawHandlePoints || !d.a.attr.selectable)\n                d.a.attr.renderTime = renderTime;\n            if (!this.drawConfig.drawHandlePoints || !d.b.attr.selectable)\n                d.b.attr.renderTime = renderTime;\n        }\n        else if (d instanceof Vector_1.Vector) {\n            draw.arrow(d.a, d.b, this.drawConfig.vector.color);\n            if (this.drawConfig.drawHandlePoints && d.b.attr.selectable && d.b.attr.visible) {\n                draw.setCurrentId(d.uid + \"_h0\");\n                draw.setCurrentClassName(d.className + \"-handle\");\n                draw.circleHandle(d.b, 3, '#a8a8a8');\n            }\n            else {\n                d.b.attr.renderTime = renderTime;\n            }\n            if (!this.drawConfig.drawHandlePoints || !d.a.attr.selectable)\n                d.a.attr.renderTime = renderTime;\n            if (!this.drawConfig.drawHandlePoints || !d.b.attr.selectable)\n                d.b.attr.renderTime = renderTime;\n        }\n        else if (d instanceof PBImage_1.PBImage) {\n            if (this.drawConfig.drawHandleLines) {\n                draw.setCurrentId(d.uid + \"_l0\");\n                draw.setCurrentClassName(d.className + \"-line\");\n                draw.line(d.upperLeft, d.lowerRight, this.drawConfig.image.color, this.drawConfig.image.lineWidth);\n            }\n            fill.setCurrentId(d.uid);\n            fill.image(d.image, d.upperLeft, d.lowerRight.clone().sub(d.upperLeft));\n            if (this.drawConfig.drawHandlePoints) {\n                draw.setCurrentId(d.uid + \"_h0\");\n                draw.setCurrentClassName(d.className + \"-lower-right\");\n                draw.circleHandle(d.lowerRight, 3, this.drawConfig.image.color);\n                d.lowerRight.attr.renderTime = renderTime;\n            }\n        }\n        else {\n            console.error('Cannot draw object. Unknown class.');\n        }\n    };\n    ;\n    /**\n     * Draw the select-polygon (if there is one).\n     *\n     * This function is usually only used internally.\n     *\n     * @method drawSelectPolygon\n     * @private\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.drawSelectPolygon = function (draw) {\n        // Draw select polygon?\n        if (this.selectPolygon != null && this.selectPolygon.vertices.length > 0) {\n            draw.setCurrentId(this.selectPolygon.uid);\n            draw.polygon(this.selectPolygon, '#888888');\n            draw.crosshair(this.selectPolygon.vertices[0], 3, '#008888');\n        }\n    };\n    ;\n    /**\n     * Draw all vertices that were not yet drawn with the given render time.<br>\n     * <br>\n     * This function is usually only used internally.\n     *\n     * @method drawVertices\n     * @private\n     * @param {number} renderTime - The current render time. It is used to distinct\n     *                              already draw vertices from non-draw-yet vertices.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.drawVertices = function (renderTime, draw) {\n        // Draw all vertices as small squares if they were not already drawn by other objects\n        for (var i in this.vertices) {\n            if (this.drawConfig.drawVertices\n                && this.vertices[i].attr.renderTime != renderTime\n                && this.vertices[i].attr.visible) {\n                draw.setCurrentId(this.vertices[i].uid);\n                draw.squareHandle(this.vertices[i], 5, this._handleColor(this.vertices[i], 'rgb(0,128,192)'));\n            }\n        }\n    };\n    ;\n    /**\n     * Trigger redrawing of all objects.<br>\n     * <br>\n     * Usually this function is automatically called when objects change.\n     *\n     * @method redraw\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.redraw = function () {\n        var renderTime = new Date().getTime();\n        if (this.config.preClear)\n            this.config.preClear();\n        this.clear();\n        if (this.config.preDraw)\n            this.config.preDraw();\n        this.drawAll(renderTime, this.draw, this.fill);\n        if (this.config.postDraw)\n            this.config.postDraw();\n    };\n    ;\n    /**\n     * Draw all: drawables, grid, select-polygon and vertices.\n     *\n     * @method drawAll\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.drawAll = function (renderTime, draw, fill) {\n        // Tell the drawing library that a new drawing cycle begins (required for the GL lib).\n        draw.beginDrawCycle(renderTime);\n        fill.beginDrawCycle(renderTime);\n        this.drawGrid(draw);\n        if (this.config.drawOrigin)\n            this.drawOrigin(draw);\n        this.drawDrawables(renderTime, draw, fill);\n        this.drawVertices(renderTime, draw);\n        this.drawSelectPolygon(draw);\n    };\n    ; // END redraw\n    /**\n     * This function clears the canvas with the configured background color.<br>\n     * <br>\n     * This function is usually only used internally.\n     *\n     * @method clear\n     * @private\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.clear = function () {\n        // Note that elements might have an alpha channel. Clear the scene first.\n        this.draw.clear(this.config.backgroundColor);\n    };\n    ;\n    /**\n     * Clear the selection.<br>\n     * <br>\n     * This function is usually only used internally.\n     *\n     * @method clearSelection\n     * @private\n     * @param {boolean=} [redraw=false] - Indicates if the redraw function should be triggered.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {PlotBoilerplate} this\n     **/\n    PlotBoilerplate.prototype.clearSelection = function (redraw) {\n        for (var i in this.vertices)\n            this.vertices[i].attr.isSelected = false;\n        if (redraw)\n            this.redraw();\n        return this;\n    };\n    ;\n    /**\n     * Get the current view port.\n     *\n     * @method viewport\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {Bounds} The current viewport.\n     **/\n    PlotBoilerplate.prototype.viewport = function () {\n        return new Bounds_1.Bounds(this.transformMousePosition(0, 0), this.transformMousePosition(this.canvasSize.width * this.config.cssScaleX, this.canvasSize.height * this.config.cssScaleY));\n    };\n    ;\n    /**\n     * Trigger the saveFile.hook.\n     *\n     * @method saveFile\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.saveFile = function () {\n        this.hooks.saveFile(this);\n    };\n    ;\n    /**\n     * Internal helper function used to get 'float' properties from elements.\n     * Used to determine border withs and paddings that were defined using CSS.\n     */\n    PlotBoilerplate.prototype.getFProp = function (elem, propName) {\n        return parseFloat(globalThis.getComputedStyle(elem, null).getPropertyValue(propName));\n    };\n    /**\n     * Get the available inner space of the given container.\n     *\n     * Size minus padding minus border.\n     **/\n    PlotBoilerplate.prototype.getAvailableContainerSpace = function () {\n        var _self = this;\n        var container = _self.canvas.parentNode; // Element | Document | DocumentFragment;\n        // var canvas : HTMLCanvasElement = _self.canvas;\n        _self.canvas.style.display = 'none';\n        /* var\n        padding : number = parseFloat( globalThis.getComputedStyle(container, null).getPropertyValue('padding') ) || 0,\n        border : number = parseFloat( globalThis.getComputedStyle(_self.canvas, null).getPropertyValue('border-width') ) || 0,\n        pl : number = parseFloat( globalThis.getComputedStyle(container, null).getPropertyValue('padding-left') ) || padding,\n        pr : number = parseFloat( globalThis.getComputedStyle(container, null).getPropertyValue('padding-right') ) || padding,\n        pt : number = parseFloat( globalThis.getComputedStyle(container, null).getPropertyValue('padding-top') ) || padding,\n        pb : number = parseFloat( globalThis.getComputedStyle(container, null).getPropertyValue('padding-bottom') ) || padding,\n        bl : number = parseFloat( globalThis.getComputedStyle(_self.canvas, null).getPropertyValue('border-left-width') ) || border,\n        br : number = parseFloat( globalThis.getComputedStyle(_self.canvas, null).getPropertyValue('border-right-width') ) || border,\n        bt : number = parseFloat( globalThis.getComputedStyle(_self.canvas, null).getPropertyValue('border-top-width') ) || border,\n        bb : number = parseFloat( globalThis.getComputedStyle(_self.canvas, null).getPropertyValue('border-bottom-width') ) || border;\n        */\n        var padding = this.getFProp(container, 'padding') || 0, border = this.getFProp(_self.canvas, 'border-width') || 0, pl = this.getFProp(container, 'padding-left') || padding, pr = this.getFProp(container, 'padding-right') || padding, pt = this.getFProp(container, 'padding-top') || padding, pb = this.getFProp(container, 'padding-bottom') || padding, bl = this.getFProp(_self.canvas, 'border-left-width') || border, br = this.getFProp(_self.canvas, 'border-right-width') || border, bt = this.getFProp(_self.canvas, 'border-top-width') || border, bb = this.getFProp(_self.canvas, 'border-bottom-width') || border;\n        var w = container.clientWidth;\n        var h = container.clientHeight;\n        _self.canvas.style.display = 'block';\n        return { width: (w - pl - pr - bl - br), height: (h - pt - pb - bt - bb) };\n    };\n    ;\n    /**\n     * This function resizes the canvas to the required settings (toggles fullscreen).<br>\n     * <br>\n     * This function is usually only used internally but feel free to call it if resizing required.\n     *\n     * @method resizeCanvas\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.resizeCanvas = function () {\n        var _this = this;\n        var _self = this;\n        var _setSize = function (w, h) {\n            w *= _self.config.canvasWidthFactor;\n            h *= _self.config.canvasHeightFactor;\n            _self.canvasSize.width = w;\n            _self.canvasSize.height = h;\n            // TODO: use CanvasWrapper.setSize here?\n            if (_self.canvas instanceof HTMLCanvasElement) {\n                _self.canvas.width = w;\n                _self.canvas.height = h;\n            }\n            else if (_self.canvas instanceof SVGElement) {\n                _this.canvas.setAttribute('viewBox', \"0 0 \" + w + \" \" + h);\n                _this.canvas.setAttribute('width', \"\" + w);\n                _this.canvas.setAttribute('height', \"\" + h);\n                _this.draw.setSize(_self.canvasSize); // No need to set size to this.fill (instance copy)\n                // console.log(\n                _this.eventCatcher.style.width = w + \"px\";\n                _this.eventCatcher.style.height = h + \"px\";\n            }\n            else {\n                console.error('Error: cannot resize canvas element because it seems neither be a HTMLCanvasElement nor an SVGElement.');\n            }\n            if (_self.config.autoAdjustOffset) {\n                _self.draw.offset.x = _self.fill.offset.x = _self.config.offsetX = w * (_self.config.offsetAdjustXPercent / 100);\n                _self.draw.offset.y = _self.fill.offset.y = _self.config.offsetY = h * (_self.config.offsetAdjustYPercent / 100);\n            }\n        };\n        if (_self.config.fullSize && !_self.config.fitToParent) {\n            // Set editor size\n            var width = globalThis.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;\n            var height = globalThis.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;\n            _self.canvas.style.position = 'absolute';\n            _self.canvas.style.width = (_self.config.canvasWidthFactor * width) + 'px';\n            _self.canvas.style.height = (_self.config.canvasWidthFactor * height) + 'px';\n            _self.canvas.style.top = '0px';\n            _self.canvas.style.left = '0px';\n            _setSize(width, height);\n        }\n        else if (_self.config.fitToParent) {\n            // Set editor size\n            _self.canvas.style.position = 'absolute';\n            var space = this.getAvailableContainerSpace();\n            _self.canvas.style.width = (_self.config.canvasWidthFactor * space.width) + 'px';\n            _self.canvas.style.height = (_self.config.canvasHeightFactor * space.height) + 'px';\n            _self.canvas.style.top = null;\n            _self.canvas.style.left = null;\n            _setSize(space.width, space.height);\n        }\n        else {\n            _self.canvas.style.width = null;\n            _self.canvas.style.height = null;\n            _setSize(_self.config.defaultCanvasWidth, _self.config.defaultCanvasHeight);\n        }\n        if (_self.config.redrawOnResize)\n            _self.redraw();\n    };\n    ;\n    /**\n     *  Add all vertices inside the polygon to the current selection.<br>\n     *\n     * @method selectVerticesInPolygon\n     * @param {Polygon} polygon - The polygonal selection area.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.selectVerticesInPolygon = function (polygon) {\n        for (var i in this.vertices) {\n            if (this.vertices[i].attr.selectable && polygon.containsVert(this.vertices[i]))\n                this.vertices[i].attr.isSelected = true;\n        }\n    };\n    ;\n    /**\n     * (Helper) Locates the point (index) at the passed position. Using an internal tolerance of 7 pixels.\n     *\n     * The result is an object { type : 'bpath', pindex, cindex, pid }\n     *\n     * Returns false if no point is near the passed position.\n     *\n     * @method locatePointNear\n     * @param {Vertex} point - The polygonal selection area.\n     * @param {number=} [tolerance=7] - The tolerance to use identtifying vertices.\n     * @private\n     * @return {IDraggable} Or false if none found.\n     **/\n    PlotBoilerplate.prototype.locatePointNear = function (point, tolerance) {\n        var _self = this;\n        if (typeof tolerance == 'undefined')\n            tolerance = 7;\n        // Apply the zoom (the tolerant area should not shrink or grow when zooming)\n        tolerance /= _self.draw.scale.x;\n        // Search in vertices\n        // for( var vindex in _self.vertices ) {\n        for (var vindex = 0; vindex < _self.vertices.length; vindex++) {\n            var vert = _self.vertices[vindex];\n            if ((vert.attr.draggable || vert.attr.selectable) && vert.distance(point) < tolerance) {\n                // { type : 'vertex', vindex : vindex };\n                return new PlotBoilerplate.Draggable(vert, PlotBoilerplate.Draggable.VERTEX).setVIndex(vindex);\n            }\n        }\n        return null;\n    };\n    /**\n     * Handle left-click event.<br>\n     *\n     * @method handleClick\n     * @param {number} x - The click X position on the canvas.\n     * @param {number} y - The click Y position on the canvas.\n     * @private\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.handleClick = function (e) {\n        var _self = this;\n        // const x:number = e.params.pos.x;\n        //const y:number = e.params.pos.y;\n        var p = this.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));\n        if (p) {\n            _self.vertices[p.vindex].listeners.fireClickEvent(e);\n            if (this.keyHandler && this.keyHandler.isDown('shift')) {\n                if (p.typeName == 'bpath') {\n                    var vert = _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid);\n                    if (vert.attr.selectable)\n                        vert.attr.isSelected = !vert.attr.isSelected;\n                }\n                else if (p.typeName == 'vertex') {\n                    var vert = _self.vertices[p.vindex];\n                    if (vert.attr.selectable)\n                        vert.attr.isSelected = !vert.attr.isSelected;\n                }\n                _self.redraw();\n            }\n            else if (this.keyHandler.isDown('y') /* && p.type=='bpath' && (p.pid==BezierPath.START_POINT || p.pid==BezierPath.END_POINT) */) {\n                _self.vertices[p.vindex].attr.bezierAutoAdjust = !_self.vertices[p.vindex].attr.bezierAutoAdjust;\n                _self.redraw();\n            }\n        }\n        else if (_self.selectPolygon != null) {\n            var vert = _self.transformMousePosition(e.params.pos.x, e.params.pos.y);\n            _self.selectPolygon.vertices.push(new Vertex_1.Vertex(vert.x, vert.y));\n            _self.redraw();\n        }\n    };\n    /**\n     * Transforms the given x-y-(mouse-)point to coordinates respecting the view offset\n     * and the zoom settings.\n     *\n     * @method transformMousePosition\n     * @param {number} x - The x position relative to the canvas.\n     * @param {number} y - The y position relative to the canvas.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {XYCoords} A simple object <pre>{ x : Number, y : Number }</pre> with the transformed coordinates.\n     **/\n    PlotBoilerplate.prototype.transformMousePosition = function (x, y) {\n        /* return { x : (x/this.config.cssScaleX-this.config.offsetX)/(this.config.scaleX),\n           y : (y/this.config.cssScaleY-this.config.offsetY)/(this.config.scaleY) }; */\n        // console.log('offset', this.config.offsetX, this.config.offsetY, this.draw.offset );\n        return { x: (x / this.config.cssScaleX - this.config.offsetX) / (this.config.scaleX),\n            y: (y / this.config.cssScaleY - this.config.offsetY) / (this.config.scaleY) };\n    };\n    ;\n    /**\n     * Revert a transformed mouse position back to canvas coordinates.\n     *\n     * This is the inverse function of `transformMousePosition`.\n     *\n     * @method revertMousePosition\n     * @param {number} x - The x component of the position to revert.\n     * @param {number} y - The y component of the position to revert.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {XYCoords} The canvas coordinates for the given position.\n     **/\n    PlotBoilerplate.prototype.revertMousePosition = function (x, y) {\n        return { x: x / this.config.cssScaleX + this.config.offsetX,\n            y: y / this.config.cssScaleY + this.config.offsetY };\n    };\n    ;\n    /**\n     * Determine if any elements are currently being dragged (on mouse move or touch move).\n     *\n     * @method getDraggedElementCount\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {number} The number of elements that are currently being dragged.\n     **/\n    PlotBoilerplate.prototype.getDraggedElementCount = function () {\n        return this.draggedElements.length;\n    };\n    ;\n    /**\n     * (Helper) The mouse-down handler.\n     *\n     * It selects vertices for dragging.\n     *\n     * @method mouseDownHandler.\n     * @param {XMouseEvent} e - The event to handle\n     * @private\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.mouseDownHandler = function (e) {\n        var _self = this;\n        if (e.which != 1)\n            return; // Only react on left mouse or touch events\n        var p = _self.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));\n        if (!p)\n            return;\n        // Drag all selected elements?\n        if (p.typeName == 'vertex' && _self.vertices[p.vindex].attr.isSelected) {\n            // Multi drag\n            // for( var i in _self.vertices ) {\n            for (var i = 0; i < _self.vertices.length; i++) {\n                if (_self.vertices[i].attr.isSelected) {\n                    _self.draggedElements.push(new PlotBoilerplate.Draggable(_self.vertices[i], PlotBoilerplate.Draggable.VERTEX).setVIndex(i));\n                    _self.vertices[i].listeners.fireDragStartEvent(e);\n                }\n            }\n        }\n        else {\n            // Single drag\n            if (!_self.vertices[p.vindex].attr.draggable)\n                return;\n            _self.draggedElements.push(p);\n            if (p.typeName == 'bpath')\n                _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid).listeners.fireDragStartEvent(e);\n            else if (p.typeName == 'vertex')\n                _self.vertices[p.vindex].listeners.fireDragStartEvent(e);\n        }\n        _self.redraw();\n    };\n    ;\n    /**\n     * The mouse-drag handler.\n     *\n     * It moves selected elements around or performs the panning if the ctrl-key if\n     * hold down.\n     *\n     * @method mouseDragHandler.\n     * @param {XMouseEvent} e - The event to handle\n     * @private\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.mouseDragHandler = function (e) {\n        var _self = this;\n        var oldDragAmount = { x: e.params.dragAmount.x, y: e.params.dragAmount.y };\n        e.params.dragAmount.x /= _self.config.cssScaleX;\n        e.params.dragAmount.y /= _self.config.cssScaleY;\n        // Important note to: this.keyHandler.isDown('ctrl')\n        //    We should not use this for any input.\n        //    Reason: most browsers use [Ctrl]+[t] to create new browser tabs.\n        //            If so, the key-up event for [Ctrl] will be fired in the _new tab_,\n        //            not this one. So this tab will never receive any [Ctrl-down] events\n        //            until next keypress; the implication is, that [Ctrl] would still\n        //            considered to be pressed which is not true.\n        if (this.keyHandler.isDown('alt') || this.keyHandler.isDown('spacebar')) {\n            _self.setOffset(_self.draw.offset.clone().add(e.params.dragAmount));\n            _self.redraw();\n        }\n        else {\n            // Convert drag amount by scaling\n            // Warning: this possibly invalidates the dragEvent for other listeners!\n            //          Rethink the solution when other features are added.\n            e.params.dragAmount.x /= _self.draw.scale.x;\n            e.params.dragAmount.y /= _self.draw.scale.y;\n            for (var i in _self.draggedElements) {\n                var p = _self.draggedElements[i];\n                if (p.typeName == 'bpath') {\n                    _self.paths[p.pindex].moveCurvePoint(p.cindex, p.pid, new Vertex_1.Vertex(e.params.dragAmount.x, e.params.dragAmount.y));\n                    _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid).listeners.fireDragEvent(e);\n                }\n                else if (p.typeName == 'vertex') {\n                    if (!_self.vertices[p.vindex].attr.draggable)\n                        continue;\n                    _self.vertices[p.vindex].add(e.params.dragAmount);\n                    _self.vertices[p.vindex].listeners.fireDragEvent(e);\n                }\n            }\n        }\n        // Restore old event values!\n        e.params.dragAmount.x = oldDragAmount.x;\n        e.params.dragAmount.y = oldDragAmount.y;\n        _self.redraw();\n    };\n    ;\n    /**\n     * The mouse-up handler.\n     *\n     * It clears the dragging-selection.\n     *\n     * @method mouseUpHandler.\n     * @param {XMouseEvent} e - The event to handle\n     * @private\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.mouseUpHandler = function (e) {\n        var _self = this;\n        if (e.which != 1)\n            return; // Only react on left mouse;\n        if (!e.params.wasDragged) {\n            _self.handleClick(e); // e.params.pos.x, e.params.pos.y );\n        }\n        for (var i in _self.draggedElements) {\n            var p = _self.draggedElements[i];\n            if (p.typeName == 'bpath') {\n                _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid).listeners.fireDragEndEvent(e);\n            }\n            else if (p.typeName == 'vertex') {\n                _self.vertices[p.vindex].listeners.fireDragEndEvent(e);\n            }\n        }\n        _self.draggedElements = [];\n        _self.redraw();\n    };\n    ;\n    /**\n     * The mouse-wheel handler.\n     *\n     * It performs the zooming.\n     *\n     * @method mouseWheelHandler.\n     * @param {XMouseEvent} e - The event to handle\n     * @private\n     * @return {void}\n     **/\n    PlotBoilerplate.prototype.mouseWheelHandler = function (e) {\n        var zoomStep = 1.25; // Make configurable?\n        // CHANGED replaced _self by this\n        var _self = this;\n        var we = e;\n        if (we.deltaY < 0) {\n            _self.setZoom(_self.config.scaleX * zoomStep, _self.config.scaleY * zoomStep, new Vertex_1.Vertex(e.params.pos.x, e.params.pos.y));\n        }\n        else if (we.deltaY > 0) {\n            _self.setZoom(_self.config.scaleX / zoomStep, _self.config.scaleY / zoomStep, new Vertex_1.Vertex(e.params.pos.x, e.params.pos.y));\n        }\n        e.preventDefault();\n        _self.redraw();\n    };\n    ;\n    /**\n     * Set the new draw offset.\n     *\n     * Note: the function will not trigger any redraws.\n     *\n     * @param {Vertex} newOffset - The new draw offset to use.\n     **/\n    PlotBoilerplate.prototype.setOffset = function (newOffset) {\n        this.draw.offset.set(newOffset);\n        this.fill.offset.set(newOffset);\n        this.config.offsetX = newOffset.x;\n        this.config.offsetY = newOffset.y;\n    };\n    ;\n    /**\n    * Set a new zoom value (and re-adjust the draw offset).\n    *\n    * Note: the function will not trigger any redraws.\n    *\n    * @param {number} zoomFactorX - The new horizontal zoom value.\n    * @param {number} zoomFactorY - The new vertical zoom value.\n    * @param {Vertex} interactionPos - The position of mouse/touch interaction.\n    **/\n    PlotBoilerplate.prototype.setZoom = function (zoomFactorX, zoomFactorY, interactionPos) {\n        var oldPos = this.transformMousePosition(interactionPos.x, interactionPos.y);\n        this.draw.scale.x = this.fill.scale.x = this.config.scaleX = Math.max(zoomFactorX, 0.01);\n        this.draw.scale.y = this.fill.scale.y = this.config.scaleY = Math.max(zoomFactorY, 0.01);\n        var newPos = this.transformMousePosition(interactionPos.x, interactionPos.y);\n        var newOffsetX = this.draw.offset.x + (newPos.x - oldPos.x) * this.draw.scale.x;\n        var newOffsetY = this.draw.offset.y + (newPos.y - oldPos.y) * this.draw.scale.y;\n        this.setOffset({ x: newOffsetX, y: newOffsetY });\n    };\n    PlotBoilerplate.prototype.installInputListeners = function () {\n        var _self = this;\n        if (this.config.enableMouse) {\n            // Install a mouse handler on the canvas.\n            new MouseHandler_1.MouseHandler(this.eventCatcher ? this.eventCatcher : this.canvas)\n                .down(function (e) { _self.mouseDownHandler(e); })\n                .drag(function (e) { _self.mouseDragHandler(e); })\n                .up(function (e) { _self.mouseUpHandler(e); });\n        }\n        else {\n            _self.console.log('Mouse interaction disabled.');\n        }\n        if (this.config.enableMouseWheel) {\n            // Install a mouse handler on the canvas.\n            new MouseHandler_1.MouseHandler(this.eventCatcher ? this.eventCatcher : this.canvas)\n                .wheel(function (e) { _self.mouseWheelHandler(e); });\n        }\n        else {\n            _self.console.log('Mouse wheel interaction disabled.');\n        }\n        if (this.config.enableTouch) {\n            // Install a touch handler on the canvas.\n            var relPos_1 = function (pos) {\n                var bounds = _self.canvas.getBoundingClientRect();\n                return { x: pos.x - bounds.left,\n                    y: pos.y - bounds.top // _self.canvas.offsetTop\n                };\n            };\n            if (globalThis[\"AlloyFinger\"] && typeof globalThis[\"AlloyFinger\"] == \"function\") {\n                try {\n                    // Do not include AlloyFinger itself to the library\n                    // (17kb, but we want to keep this lib as tiny as possible).\n                    var AF = globalThis[\"AlloyFinger\"];\n                    var touchMovePos = null;\n                    var touchDownPos = null;\n                    var draggedElement = null;\n                    var multiTouchStartScale = null;\n                    var clearTouch_1 = function () {\n                        touchMovePos = null;\n                        touchDownPos = null;\n                        draggedElement = null;\n                        multiTouchStartScale = null;\n                        _self.draggedElements = [];\n                    };\n                    var af = new AF(this.eventCatcher ? this.eventCatcher : this.canvas, {\n                        touchStart: function (e) {\n                            if (e.touches.length == 1) {\n                                touchMovePos = new Vertex_1.Vertex(relPos_1({ x: e.touches[0].clientX, y: e.touches[0].clientY }));\n                                touchDownPos = new Vertex_1.Vertex(relPos_1({ x: e.touches[0].clientX, y: e.touches[0].clientY }));\n                                draggedElement = _self.locatePointNear(_self.transformMousePosition(touchMovePos.x, touchMovePos.y), PlotBoilerplate.DEFAULT_TOUCH_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));\n                                if (draggedElement && draggedElement.typeName == 'vertex') {\n                                    var draggingVertex = _self.vertices[draggedElement.vindex];\n                                    var fakeEvent = { params: { isTouchEvent: true, dragAmount: { x: 0, y: 0 }, wasDragged: false, mouseDownPos: touchDownPos.clone(), mouseDragPos: touchDownPos.clone(), vertex: draggingVertex } };\n                                    _self.draggedElements = [draggedElement];\n                                    draggingVertex.listeners.fireDragStartEvent(fakeEvent);\n                                }\n                            }\n                        },\n                        touchMove: function (e) {\n                            if (e.touches.length == 1 && draggedElement) {\n                                e.preventDefault();\n                                e.stopPropagation();\n                                var rel = relPos_1({ x: e.touches[0].clientX, y: e.touches[0].clientY }); //  points[0] );\n                                var trans = _self.transformMousePosition(rel.x, rel.y);\n                                var diff = new Vertex_1.Vertex(_self.transformMousePosition(touchMovePos.x, touchMovePos.y)).difference(trans);\n                                if (draggedElement.typeName == 'vertex') {\n                                    if (!_self.vertices[draggedElement.vindex].attr.draggable)\n                                        return;\n                                    _self.vertices[draggedElement.vindex].add(diff);\n                                    var draggingVertex = _self.vertices[draggedElement.vindex];\n                                    var fakeEvent = { isTouchEvent: true, params: { dragAmount: diff.clone(), wasDragged: true, mouseDownPos: touchDownPos.clone(), mouseDragPos: touchDownPos.clone().add(diff), vertex: draggingVertex } };\n                                    draggingVertex.listeners.fireDragEvent(fakeEvent);\n                                    _self.redraw();\n                                }\n                                touchMovePos = new Vertex_1.Vertex(rel);\n                            }\n                            else if (e.touches.length == 2) {\n                                // If at least two fingers touch and move, then change the draw offset (panning).\n                                e.preventDefault();\n                                e.stopPropagation();\n                                _self.setOffset(_self.draw.offset.clone().addXY(e.deltaX, e.deltaY)); // Apply zoom?\n                                _self.redraw();\n                            }\n                        },\n                        touchEnd: function (e) {\n                            // Note: e.touches.length is 0 here\n                            if (draggedElement && draggedElement.typeName == 'vertex') {\n                                var draggingVertex = _self.vertices[draggedElement.vindex];\n                                var fakeEvent = { isTouchEvent: true, params: { dragAmount: { x: 0, y: 0 }, wasDragged: false, mouseDownPos: touchDownPos.clone(), mouseDragPos: touchDownPos.clone(), vertex: draggingVertex } };\n                                // var rel : XYCoords = relPos( { x : e.touches[0].clientX, y : e.touches[0].clientY } ); //  points[0] );\n                                // var trans : XYCoords = _self.transformMousePosition( rel.x, rel.y ); \n                                // var diff : Vertex = new Vertex(_self.transformMousePosition( touchMovePos.x, touchMovePos.y )).difference(trans);\n                                // Check if vertex was moved\n                                if (touchMovePos && touchDownPos && touchDownPos.distance(touchMovePos) < 0.001) {\n                                    // if( e.touches.length == 1 && diff.x == 0 && diff.y == 0 ) {\n                                    draggingVertex.listeners.fireClickEvent(fakeEvent);\n                                }\n                                else {\n                                    draggingVertex.listeners.fireDragEndEvent(fakeEvent);\n                                }\n                            }\n                            clearTouch_1();\n                        },\n                        touchCancel: function (e) {\n                            clearTouch_1();\n                        },\n                        multipointStart: function (e) {\n                            multiTouchStartScale = _self.draw.scale.clone();\n                        },\n                        multipointEnd: function (e) {\n                            multiTouchStartScale = null;\n                        },\n                        pinch: function (e) {\n                            // For pinching there must be at least two touch items\n                            var fingerA = new Vertex_1.Vertex(e.touches.item(0).clientX, e.touches.item(0).clientY);\n                            var fingerB = new Vertex_1.Vertex(e.touches.item(1).clientX, e.touches.item(1).clientY);\n                            var center = new Line_1.Line(fingerA, fingerB).vertAt(0.5);\n                            _self.setZoom(multiTouchStartScale.x * e.zoom, multiTouchStartScale.y * e.zoom, center);\n                            _self.redraw();\n                        }\n                    });\n                }\n                catch (e) {\n                    console.error(\"Failed to initialize AlloyFinger!\");\n                    console.error(e);\n                }\n                ;\n            }\n            else if (globalThis[\"Touchy\"] && typeof globalThis[\"Touchy\"] == \"function\") {\n                console.error('[Deprecation] Found Touchy which is not supported any more. Please use AlloyFinger instead.');\n                // Convert absolute touch positions to relative DOM element position (relative to canvas)\n            }\n            else {\n                console.warn(\"Cannot initialize the touch handler. AlloyFinger is missig. Did you include it?\");\n            }\n        }\n        else {\n            _self.console.log('Touch interaction disabled.');\n        }\n        if (this.config.enableKeys) {\n            // Install key handler\n            this.keyHandler = new KeyHandler_1.KeyHandler({ trackAll: true })\n                .down('escape', function () {\n                _self.clearSelection(true);\n            })\n                .down('shift', function () {\n                _self.selectPolygon = new Polygon_1.Polygon();\n                _self.redraw();\n            })\n                .up('shift', function () {\n                // Find and select vertices in the drawn area\n                if (_self.selectPolygon == null)\n                    return;\n                _self.selectVerticesInPolygon(_self.selectPolygon);\n                _self.selectPolygon = null;\n                _self.redraw();\n            });\n        } // END IF enableKeys?\n        else {\n            _self.console.log('Keyboard interaction disabled.');\n        }\n    };\n    /**\n     * Creates a control GUI (a dat.gui instance) for this\n     * plot boilerplate instance.\n     *\n     * @method createGUI\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {dat.gui.GUI}\n     **/\n    PlotBoilerplate.prototype.createGUI = function () {\n        // This function moved to the helper utils.\n        // We do not want to include the whole dat.GUI package.\n        if (globalThis[\"utils\"] && typeof globalThis[\"utils\"].createGUI == \"function\")\n            return globalThis[\"utils\"].createGUI(this);\n        else\n            throw \"Cannot create dat.GUI instance; did you load the ./utils/creategui helper function an the dat.GUI library?\";\n    };\n    ;\n    var _a;\n    /** @constant {number} */\n    PlotBoilerplate.DEFAULT_CANVAS_WIDTH = 1024;\n    /** @constant {number} */\n    PlotBoilerplate.DEFAULT_CANVAS_HEIGHT = 768;\n    /** @constant {number} */\n    PlotBoilerplate.DEFAULT_CLICK_TOLERANCE = 8;\n    /** @constant {number} */\n    PlotBoilerplate.DEFAULT_TOUCH_TOLERANCE = 32;\n    /**\n     * A wrapper class for draggable items (mostly vertices).\n     * @private\n     **/\n    PlotBoilerplate.Draggable = (_a = /** @class */ (function () {\n            function class_1(item, typeName) {\n                this.item = item;\n                this.typeName = typeName;\n            }\n            ;\n            class_1.prototype.isVertex = function () { return this.typeName == PlotBoilerplate.Draggable.VERTEX; };\n            ;\n            class_1.prototype.setVIndex = function (vindex) { this.vindex = vindex; return this; };\n            ;\n            return class_1;\n        }()),\n        _a.VERTEX = 'vertex',\n        _a);\n    /**\n     * A set of helper functions.\n     **/\n    PlotBoilerplate.utils = {\n        /**\n         * Merge the elements in the 'extension' object into the 'base' object based on\n         * the keys of 'base'.\n         *\n         * @param {Object} base\n         * @param {Object} extension\n         * @return {Object} base extended by the new attributes.\n         **/\n        safeMergeByKeys: function (base, extension) {\n            for (var k in extension) {\n                if (!extension.hasOwnProperty(k))\n                    continue;\n                if (base.hasOwnProperty(k)) {\n                    var typ = typeof base[k];\n                    try {\n                        if (typ == 'boolean')\n                            base[k] = !!JSON.parse(extension[k]);\n                        else if (typ == 'number')\n                            base[k] = JSON.parse(extension[k]) * 1;\n                        else if (typ == 'function' && typeof extension[k] == 'function')\n                            base[k] = extension[k];\n                        else\n                            base[k] = extension[k];\n                    }\n                    catch (e) {\n                        console.error('error in key ', k, extension[k], e);\n                    }\n                }\n                else {\n                    base[k] = extension[k];\n                }\n            }\n            return base;\n        },\n        /**\n         * A helper function to scale elements (usually the canvas) using CSS.\n         *\n         * transform-origin is at (0,0).\n         *\n         * @param {HTMLElement} element - The DOM element to scale.\n         * @param {number} scaleX The - X scale factor.\n         * @param {number} scaleY The - Y scale factor.\n         * @return {void}\n         **/\n        setCSSscale: function (element, scaleX, scaleY) {\n            element.style['transform-origin'] = '0 0';\n            if (scaleX == 1.0 && scaleY == 1.0)\n                element.style.transform = null;\n            else\n                element.style.transform = 'scale(' + scaleX + ',' + scaleY + ')';\n        },\n        // A helper for fetching data from objects.\n        fetch: {\n            /**\n             * A helper function to the the object property value specified by the given key.\n             *\n             * @param {any} object   - The object to get the property's value from. Must not be null.\n             * @param {string} key      - The key of the object property (the name).\n             * @param {any}    fallback - A default value if the key does not exist.\n             **/\n            val: function (obj, key, fallback) {\n                if (!obj.hasOwnProperty(key))\n                    return fallback;\n                if (typeof obj[key] == 'undefined')\n                    return fallback;\n                return obj[key];\n            },\n            /**\n             * A helper function to the the object property numeric value specified by the given key.\n             *\n             * @param {any}    object   - The object to get the property's value from. Must not be null.\n             * @param {string} key      - The key of the object property (the name).\n             * @param {number} fallback - A default value if the key does not exist.\n             * @return {number}\n             **/\n            num: function (obj, key, fallback) {\n                if (!obj.hasOwnProperty(key))\n                    return fallback;\n                if (typeof obj[key] === 'number')\n                    return obj[key];\n                else {\n                    try {\n                        return JSON.parse(obj[key]) * 1;\n                    }\n                    catch (e) {\n                        return fallback;\n                    }\n                }\n            },\n            /**\n             * A helper function to the the object property boolean value specified by the given key.\n             *\n             * @param {any}     object   - The object to get the property's value from. Must not be null.\n             * @param {string}  key      - The key of the object property (the name).\n             * @param {boolean} fallback - A default value if the key does not exist.\n             * @return {boolean}\n             **/\n            bool: function (obj, key, fallback) {\n                if (!obj.hasOwnProperty(key))\n                    return fallback;\n                if (typeof obj[key] == 'boolean')\n                    return obj[key];\n                else {\n                    try {\n                        return !!JSON.parse(obj[key]);\n                    }\n                    catch (e) {\n                        return fallback;\n                    }\n                }\n            },\n            /**\n             * A helper function to the the object property function-value specified by the given key.\n             *\n             * @param {any}      object   - The object to get the property's value from. Must not be null.\n             * @param {string}   key      - The key of the object property (the name).\n             * @param {function} fallback - A default value if the key does not exist.\n             * @return {function}\n             **/\n            func: function (obj, key, fallback) {\n                if (!obj.hasOwnProperty(key))\n                    return fallback;\n                if (typeof obj[key] !== 'function')\n                    return fallback;\n                return obj[key];\n            }\n        },\n        /**\n         * Installs vertex listeners to the path's vertices so that controlpoints\n         * move with their path points when dragged.\n         *\n         * Bézier path points with attr.bezierAutoAdjust==true will have their\n         * two control points audo-updated if moved, too (keep path connections smooth).\n         *\n         * @param {BezierPath} bezierPath - The path to use auto-adjustment for.\n         **/\n        enableBezierPathAutoAdjust: function (bezierPath) {\n            for (var i = 0; i < bezierPath.bezierCurves.length; i++) {\n                // This should be wrapped into the BezierPath implementation.\n                bezierPath.bezierCurves[i].startPoint.listeners.addDragListener(function (e) {\n                    var cindex = bezierPath.locateCurveByStartPoint(e.params.vertex);\n                    bezierPath.bezierCurves[cindex].startPoint.addXY(-e.params.dragAmount.x, -e.params.dragAmount.y);\n                    bezierPath.moveCurvePoint(cindex * 1, bezierPath.START_POINT, e.params.dragAmount);\n                    bezierPath.updateArcLengths();\n                });\n                bezierPath.bezierCurves[i].startControlPoint.listeners.addDragListener(function (e) {\n                    var cindex = bezierPath.locateCurveByStartControlPoint(e.params.vertex);\n                    if (!bezierPath.bezierCurves[cindex].startPoint.attr.bezierAutoAdjust)\n                        return;\n                    bezierPath.adjustPredecessorControlPoint(cindex * 1, true, // obtain handle length?\n                    false // update arc lengths\n                    );\n                    bezierPath.updateArcLengths();\n                });\n                bezierPath.bezierCurves[i].endControlPoint.listeners.addDragListener(function (e) {\n                    var cindex = bezierPath.locateCurveByEndControlPoint(e.params.vertex);\n                    if (!bezierPath.bezierCurves[cindex % bezierPath.bezierCurves.length].endPoint.attr.bezierAutoAdjust)\n                        return;\n                    bezierPath.adjustSuccessorControlPoint(cindex * 1, true, // obtain handle length?\n                    false // update arc lengths\n                    );\n                    bezierPath.updateArcLengths();\n                });\n                if (i + 1 == bezierPath.bezierCurves.length) { // && !bezierPath.adjustCircular ) { \n                    // Move last control point with the end point (if not circular)\n                    bezierPath.bezierCurves[bezierPath.bezierCurves.length - 1].endPoint.listeners.addDragListener(function (e) {\n                        if (!bezierPath.adjustCircular) {\n                            var cindex = bezierPath.locateCurveByEndPoint(e.params.vertex);\n                            bezierPath.moveCurvePoint(cindex * 1, bezierPath.END_CONTROL_POINT, new Vertex_1.Vertex({ x: e.params.dragAmount.x, y: e.params.dragAmount.y }));\n                        }\n                        bezierPath.updateArcLengths();\n                    });\n                }\n            } // END for\n        }\n    }; // END utils\n    return PlotBoilerplate;\n}()); // END class PlotBoilerplate\nexports.PlotBoilerplate = PlotBoilerplate;\n//# sourceMappingURL=PlotBoilerplate.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2018-04-14\n * @modified 2018-11-17 Added the containsVert function.\n * @modified 2018-12-04 Added the toSVGString function.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2019-10-25 Added the scale function.\n * @modified 2019-11-06 JSDoc update.\n * @modified 2019-11-07 Added toCubicBezierPath(number) function.\n * @modified 2019-11-22 Added the rotate(number,Vertex) function.\n * @modified 2020-03-24 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-10-30 Added the `addVertex` function.\n * @modified 2020-10-31 Added the `getVertexAt` function.\n * @modified 2020-11-06 Added the `move` function.\n * @modified 2020-11-10 Added the `getBounds` function.\n * @modified 2020-11-11 Generalized `move(Vertex)` to `move(XYCoords)`.\n * @modified 2021-01-20 Added UID.\n * @modified 2021-01-29 Added the `signedArea` function (was global function in the demos before).\n * @modified 2021-01-29 Added the `isClockwise` function.\n * @modified 2021-01-29 Added the `area` function.\n * @modified 2021-01-29 Changed the param type for `containsVert` from Vertex to XYCoords.\n * @version 1.7.0\n *\n * @file Polygon\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Polygon = void 0;\nvar BezierPath_1 = require(\"./BezierPath\");\nvar Bounds_1 = require(\"./Bounds\");\nvar UIDGenerator_1 = require(\"./UIDGenerator\");\nvar Vertex_1 = require(\"./Vertex\");\n/**\n * @classdesc A polygon class. Any polygon consists of an array of vertices; polygons can be open or closed.\n *\n * @requires BezierPath\n * @requires Bounds\n * @requires SVGSerializabe\n * @requires UID\n * @requires UIDGenerator\n * @requires Vertex\n * @requires XYCoords\n */\nvar Polygon = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name Polygon\n     * @param {Vertex[]} vertices - An array of 2d vertices that shape the polygon.\n     * @param {boolean} isOpen - Indicates if the polygon should be rendered as an open or closed shape.\n     **/\n    function Polygon(vertices, isOpen) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"Polygon\";\n        this.uid = UIDGenerator_1.UIDGenerator.next();\n        if (typeof vertices == 'undefined')\n            vertices = [];\n        this.vertices = vertices;\n        this.isOpen = isOpen;\n    }\n    ;\n    /**\n     * Add a vertex to the end of the `vertices` array.\n     *\n     * @method addVert\n     * @param {Vertex} vert - The vertex to add.\n     * @instance\n     * @memberof Polygon\n     **/\n    Polygon.prototype.addVertex = function (vert) {\n        this.vertices.push(vert);\n    };\n    ;\n    /**\n     * Get the polygon vertex at the given position (index).\n     *\n     * The index may exceed the total vertex count, and will be wrapped around then (modulo).\n     *\n     * For k >= 0:\n     *  - getVertexAt( vertices.length )     == getVertexAt( 0 )\n     *  - getVertexAt( vertices.length + k ) == getVertexAt( k )\n     *  - getVertexAt( -k )                  == getVertexAt( vertices.length -k )\n     *\n     * @metho getVertexAt\n     * @param {number} index - The index of the desired vertex.\n     * @instance\n     * @memberof Polygon\n     * @return {Vertex} At the given index.\n     **/\n    Polygon.prototype.getVertexAt = function (index) {\n        if (index < 0)\n            return this.vertices[this.vertices.length - (Math.abs(index) % this.vertices.length)];\n        else\n            return this.vertices[index % this.vertices.length];\n    };\n    ;\n    /**\n     * Move the polygon's vertices by the given amount.\n     *\n     * @method move\n     * @param {XYCoords} amount - The amount to move.\n     * @instance\n     * @memberof Polygon\n     * @return {Polygon} this for chaining\n     **/\n    Polygon.prototype.move = function (vert) {\n        for (var i in this.vertices) {\n            this.vertices[i].add(vert);\n        }\n        return this;\n    };\n    ;\n    /**\n     * Check if the given vertex is inside this polygon.<br>\n     * <br>\n     * Ray-casting algorithm found at<br>\n     *    https://stackoverflow.com/questions/22521982/check-if-point-inside-a-polygon\n     *\n     * @method containsVert\n     * @param {XYCoords} vert - The vertex to check. The new x-component.\n     * @return {boolean} True if the passed vertex is inside this polygon. The polygon is considered closed.\n     * @instance\n     * @memberof Polygon\n     **/\n    Polygon.prototype.containsVert = function (vert) {\n        // ray-casting algorithm based on\n        //    http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html\n        var inside = false;\n        for (var i = 0, j = this.vertices.length - 1; i < this.vertices.length; j = i++) {\n            var xi = this.vertices[i].x, yi = this.vertices[i].y;\n            var xj = this.vertices[j].x, yj = this.vertices[j].y;\n            var intersect = ((yi > vert.y) != (yj > vert.y))\n                && (vert.x < (xj - xi) * (vert.y - yi) / (yj - yi) + xi);\n            if (intersect)\n                inside = !inside;\n        }\n        return inside;\n    };\n    ;\n    /**\n     * Calculate the area of the given polygon (unsigned).\n     *\n     * Note that this does not work for self-intersecting polygons.\n     *\n     * @method area\n     * @instance\n     * @memberof Polygon\n     * @return {number}\n     */\n    Polygon.prototype.area = function () {\n        // Found at:\n        //    https://stackoverflow.com/questions/16285134/calculating-polygon-area\n        /* let total : number = 0.0;\n        \n        for (var i = 0, l = this.vertices.length; i < l; i++) {\n            const addX = vertices[i].x;\n            const addY = vertices[(i + 1)%l].y;\n            const subX = vertices[(i + 1)%l].x;\n            const subY = vertices[i].y;\n    \n            total += (addX * addY * 0.5);\n            total -= (subX * subY * 0.5);\n        }\n        return Math.abs(total); */\n        return Polygon.utils.area(this.vertices);\n    };\n    ;\n    /**\n     * Calulate the signed polyon area by interpreting the polygon as a matrix\n     * and calculating its determinant.\n     *\n     * @method signedArea\n     * @instance\n     * @memberof Polygon\n     * @return {number}\n     */\n    Polygon.prototype.signedArea = function () {\n        return Polygon.utils.signedArea(this.vertices);\n        /* let sum : number = 0;\n        const n = this.vertices.length;\n        for (var i = 0; i < n; i++ ) {\n            const j = (i+1) % n;\n            sum += (this.vertices[j].x - this.vertices[i].x) * (this.vertices[i].y + this.vertices[j].y);\n        }\n        return sum; */\n    };\n    ;\n    /**\n     * Get the winding order of this polgon: clockwise or counterclockwise.\n     *\n     * @method isClockwise\n     * @instance\n     * @memberof Polygon\n     * @return {boolean}\n     */\n    Polygon.prototype.isClockwise = function () {\n        return Polygon.utils.signedArea(this.vertices) < 0;\n    };\n    ;\n    /**\n     * Scale the polygon relative to the given center.\n     *\n     * @method scale\n     * @param {number} factor - The scale factor.\n     * @param {Vertex} center - The center of scaling.\n     * @return {Polygon} this, for chaining.\n     * @instance\n     * @memberof Polygon\n     **/\n    Polygon.prototype.scale = function (factor, center) {\n        for (var i in this.vertices) {\n            if (typeof this.vertices[i].scale == 'function')\n                this.vertices[i].scale(factor, center);\n            else\n                console.log('There seems to be a null vertex!', this.vertices[i]);\n        }\n        return this;\n    };\n    ;\n    /**\n     * Rotate the polygon around the given center.\n     *\n     * @method rotate\n     * @param {number} angle  - The rotation angle.\n     * @param {Vertex} center - The center of rotation.\n     * @instance\n     * @memberof Polygon\n     * @return {Polygon} this, for chaining.\n     **/\n    Polygon.prototype.rotate = function (angle, center) {\n        for (var i in this.vertices) {\n            this.vertices[i].rotate(angle, center);\n        }\n        return this;\n    };\n    ;\n    /**\n     * Get the bounding box (bounds) of this polygon.\n     *\n     * @method getBounds\n     * @instance\n     * @memberof Polygon\n     * @return {Bounds} The rectangular bounds of this polygon.\n     **/\n    Polygon.prototype.getBounds = function () {\n        return Bounds_1.Bounds.computeFromVertices(this.vertices);\n    };\n    ;\n    /**\n     * Convert this polygon to a sequence of quadratic Bézier curves.<br>\n     * <br>\n     * The first vertex in the returned array is the start point.<br>\n     * The following sequence are pairs of control-point-and-end-point:\n     * <pre>startPoint, controlPoint0, pathPoint1, controlPoint1, pathPoint2, controlPoint2, ..., endPoint</pre>\n     *\n     * @method toQuadraticBezierData\n     * @return {Vertex[]}  An array of 2d vertices that shape the quadratic Bézier curve.\n     * @instance\n     * @memberof Polygon\n     **/\n    Polygon.prototype.toQuadraticBezierData = function () {\n        if (this.vertices.length < 3)\n            return [];\n        var qbezier = [];\n        var cc0 = this.vertices[0];\n        var cc1 = this.vertices[1];\n        var edgeCenter = new Vertex_1.Vertex(cc0.x + (cc1.x - cc0.x) / 2, cc0.y + (cc1.y - cc0.y) / 2);\n        qbezier.push(edgeCenter);\n        var limit = this.isOpen ? this.vertices.length : this.vertices.length + 1;\n        for (var t = 1; t < limit; t++) {\n            cc0 = this.vertices[t % this.vertices.length];\n            cc1 = this.vertices[(t + 1) % this.vertices.length];\n            var edgeCenter = new Vertex_1.Vertex(cc0.x + (cc1.x - cc0.x) / 2, cc0.y + (cc1.y - cc0.y) / 2);\n            qbezier.push(cc0);\n            qbezier.push(edgeCenter);\n            cc0 = cc1;\n        }\n        return qbezier;\n    };\n    ;\n    /**\n     * Convert this polygon to a quadratic bezier curve, represented as an SVG data string.\n     *\n     * @method toQuadraticBezierSVGString\n     * @return {string} The 'd' part for an SVG 'path' element.\n     * @instance\n     * @memberof Polygon\n     **/\n    Polygon.prototype.toQuadraticBezierSVGString = function () {\n        var qdata = this.toQuadraticBezierData();\n        if (qdata.length == 0)\n            return \"\";\n        var buffer = ['M ' + qdata[0].x + ' ' + qdata[0].y];\n        for (var i = 1; i < qdata.length; i += 2) {\n            buffer.push('Q ' + qdata[i].x + ' ' + qdata[i].y + ', ' + qdata[i + 1].x + ' ' + qdata[i + 1].y);\n        }\n        return buffer.join(' ');\n    };\n    ;\n    /**\n     * Convert this polygon to a sequence of cubic Bézier curves.<br>\n     * <br>\n     * The first vertex in the returned array is the start point.<br>\n     * The following sequence are triplets of (first-control-point, secnond-control-point, end-point):<br>\n     * <pre>startPoint, controlPoint0_0, controlPoint1_1, pathPoint1, controlPoint1_0, controlPoint1_1, ..., endPoint</pre>\n     *\n     * @method toCubicBezierData\n     * @param {number=} threshold - An optional threshold (default=1.0) how strong the curve segments\n     *                              should over-/under-drive. Should be between 0.0 and 1.0 for best\n     *                              results but other values are allowed.\n     * @return {Vertex[]}  An array of 2d vertices that shape the cubic Bézier curve.\n     * @instance\n     * @memberof Polygon\n     **/\n    Polygon.prototype.toCubicBezierData = function (threshold) {\n        if (typeof threshold == 'undefined')\n            threshold = 1.0;\n        if (this.vertices.length < 3)\n            return [];\n        var cbezier = [];\n        var a = this.vertices[0];\n        var b = this.vertices[1];\n        var edgeCenter = new Vertex_1.Vertex(a.x + (b.x - a.x) / 2, a.y + (b.y - a.y) / 2);\n        cbezier.push(edgeCenter);\n        var limit = this.isOpen ? this.vertices.length - 1 : this.vertices.length;\n        for (var t = 0; t < limit; t++) {\n            var a = this.vertices[t % this.vertices.length];\n            var b = this.vertices[(t + 1) % this.vertices.length];\n            var c = this.vertices[(t + 2) % this.vertices.length];\n            var aCenter = new Vertex_1.Vertex(a.x + (b.x - a.x) / 2, a.y + (b.y - a.y) / 2);\n            var bCenter = new Vertex_1.Vertex(b.x + (c.x - b.x) / 2, b.y + (c.y - b.y) / 2);\n            var a2 = new Vertex_1.Vertex(aCenter.x + (b.x - aCenter.x) * threshold, aCenter.y + (b.y - aCenter.y) * threshold);\n            var b0 = new Vertex_1.Vertex(bCenter.x + (b.x - bCenter.x) * threshold, bCenter.y + (b.y - bCenter.y) * threshold);\n            cbezier.push(a2);\n            cbezier.push(b0);\n            cbezier.push(bCenter);\n        }\n        return cbezier;\n    };\n    ;\n    /**\n     * Convert this polygon to a cubic bezier curve, represented as an SVG data string.\n     *\n     * @method toCubicBezierSVGString\n     * @return {string} The 'd' part for an SVG 'path' element.\n     * @instance\n     * @memberof Polygon\n     **/\n    Polygon.prototype.toCubicBezierSVGString = function (threshold) {\n        var qdata = this.toCubicBezierData(threshold);\n        if (qdata.length == 0)\n            return \"\";\n        var buffer = ['M ' + qdata[0].x + ' ' + qdata[0].y];\n        for (var i = 1; i < qdata.length; i += 3) {\n            buffer.push('C ' + qdata[i].x + ' ' + qdata[i].y + ', ' + qdata[i + 1].x + ' ' + qdata[i + 1].y + ', ' + qdata[i + 2].x + ' ' + qdata[i + 2].y);\n        }\n        return buffer.join(' ');\n    };\n    ;\n    /**\n     * Convert this polygon to a cubic bezier path instance.\n     *\n     * @method toCubicBezierPath\n     * @param {number} threshold - The threshold, usually from 0.0 to 1.0.\n     * @return {BezierPath}      - A bezier path instance.\n     * @instance\n     * @memberof Polygon\n     **/\n    Polygon.prototype.toCubicBezierPath = function (threshold) {\n        var qdata = this.toCubicBezierData(threshold);\n        // Conver the linear path vertices to a two-dimensional path array\n        var pathdata = [];\n        for (var i = 0; i + 3 < qdata.length; i += 3) {\n            pathdata.push([qdata[i], qdata[i + 3], qdata[i + 1], qdata[i + 2]]);\n        }\n        return BezierPath_1.BezierPath.fromArray(pathdata);\n    };\n    ;\n    /**\n     * Create an SVG representation of this polygon.\n     *\n     * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.\n     * @method toSVGString\n     * @param {object=} options - An optional set of options, like 'className'.\n     * @return {string} The SVG string.\n     * @instance\n     * @memberof Polygon\n     **/\n    Polygon.prototype.toSVGString = function (options) {\n        options = options || {};\n        var buffer = [];\n        buffer.push('<path');\n        if (options.className)\n            buffer.push(' class=\"' + options.className + '\"');\n        buffer.push(' d=\"');\n        if (this.vertices.length > 0) {\n            buffer.push('M ');\n            buffer.push(this.vertices[0].x.toString());\n            buffer.push(' ');\n            buffer.push(this.vertices[0].y.toString());\n            for (var i = 1; i < this.vertices.length; i++) {\n                buffer.push(' L ');\n                buffer.push(this.vertices[i].x.toString());\n                buffer.push(' ');\n                buffer.push(this.vertices[i].y.toString());\n            }\n            if (!this.isOpen) {\n                buffer.push(' Z');\n            }\n        }\n        buffer.push('\" />');\n        return buffer.join('');\n    };\n    ;\n    Polygon.utils = {\n        /**\n         * Calculate the area of the given polygon (unsigned).\n         *\n         * Note that this does not work for self-intersecting polygons.\n         *\n         * @name area\n         * @return {number}\n         */\n        area: function (vertices) {\n            // Found at:\n            //    https://stackoverflow.com/questions/16285134/calculating-polygon-area\n            var total = 0.0;\n            for (var i = 0, l = vertices.length; i < l; i++) {\n                var addX = vertices[i].x;\n                var addY = vertices[(i + 1) % l].y;\n                var subX = vertices[(i + 1) % l].x;\n                var subY = vertices[i].y;\n                total += (addX * addY * 0.5);\n                total -= (subX * subY * 0.5);\n            }\n            return Math.abs(total);\n        },\n        /**\n         * Calulate the signed polyon area by interpreting the polygon as a matrix\n         * and calculating its determinant.\n         *\n         * @name signedArea\n         * @return {number}\n         */\n        signedArea: function (vertices) {\n            var sum = 0;\n            var n = vertices.length;\n            for (var i = 0; i < n; i++) {\n                var j = (i + 1) % n;\n                sum += (vertices[j].x - vertices[i].x) * (vertices[i].y + vertices[j].y);\n            }\n            return sum;\n        }\n    };\n    return Polygon;\n}());\nexports.Polygon = Polygon;\n//# sourceMappingURL=Polygon.js.map","\"use strict\";\n/**\n * @author    Ikaros Kappler\n * @date_init 2012-10-17 (Wrote a first version of this in that year).\n * @date      2018-04-03 (Refactored the code into a new class).\n * @modified  2018-04-28 Added some documentation.\n * @modified  2019-09-11 Added the scaleToCentroid(Number) function (used by the walking triangle demo).\n * @modified  2019-09-12 Added beautiful JSDoc compliable comments.\n * @modified  2019-11-07 Added to toSVG(options) function to make Triangles renderable as SVG.\n * @modified  2019-12-09 Fixed the determinant() function. The calculation was just wrong.\n * @modified  2020-03-16 (Corona times) Added the 'fromArray' function.\n * @modified  2020-03-17 Added the Triangle.toPolygon() function.\n * @modified  2020-03-17 Added proper JSDoc comments.\n * @modified  2020-03-25 Ported this class from vanilla-JS to Typescript.\n * @modified  2020-05-09 Added the new Circle class (ported to Typescript from the demos).\n * @modified  2020-05-12 Added getIncircularTriangle() function.\n * @modified  2020-05-12 Added getIncircle() function.\n * @modified  2020-05-12 Fixed the signature of getCircumcirle(). Was still a generic object.\n * @modified  2020-06-18 Added the `getIncenter` function.\n * @modified  2020-12-28 Added the `getArea` function.\n * @modified  2021-01-20 Added UID.\n * @modified  2021-01-22 Always updating circumcircle when retieving it.\n * @version   2.5.1\n *\n * @file Triangle\n * @fileoverview A simple triangle class: three vertices.\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Triangle = void 0;\nvar Bounds_1 = require(\"./Bounds\");\nvar Circle_1 = require(\"./Circle\");\nvar Line_1 = require(\"./Line\");\nvar Polygon_1 = require(\"./Polygon\");\nvar UIDGenerator_1 = require(\"./UIDGenerator\");\nvar Vertex_1 = require(\"./Vertex\");\nvar geomutils_1 = require(\"./geomutils\");\n/**\n * @classdesc A triangle class for triangulations.\n *\n * The class was written for a Delaunay trinagulation demo so it might\n * contain some strange and unexpected functions.\n *\n * @requires Bounds\n * @requires Circle\n * @requires Line\n * @requires Vertex\n * @requires Polygon\n * @requires SVGSerializale\n * @requires UID\n * @requires UIDGenerator\n * @requires XYCoords\n * @requires geomutils\n *\n */\nvar Triangle = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name Triangle\n     * @param {Vertex} a - The first vertex of the triangle.\n     * @param {Vertex} b - The second vertex of the triangle.\n     * @param {Vertex} c - The third vertex of the triangle.\n     **/\n    function Triangle(a, b, c) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"Triangle\";\n        this.uid = UIDGenerator_1.UIDGenerator.next();\n        this.a = a;\n        this.b = b;\n        this.c = c;\n        this.calcCircumcircle();\n    }\n    /**\n     * Create a new triangle from the given array of vertices.\n     *\n     * The array must have at least three vertices, otherwise an error will be raised.\n     * This function will not create copies of the vertices.\n     *\n     * @method fromArray\n     * @static\n     * @param {Array<Vertex>} arr - The required array with at least three vertices.\n     * @memberof Vertex\n     * @return {Triangle}\n     **/\n    Triangle.fromArray = function (arr) {\n        if (arr.length < 3)\n            throw \"Cannot create triangle from array with less than three vertices (\" + arr.length + \")\";\n        return new Triangle(arr[0], arr[1], arr[2]);\n    };\n    ;\n    /**\n     * Get the area of this triangle. The returned area is never negative.\n     *\n     * If you are interested in the signed area, please consider using the\n     * `Triangle.utils.signedArea` helper function. This method just returns\n     * the absolute value of the signed area.\n     *\n     * @method getArea\n     * @instance\n     * @memberof Triangle\n     * @return {number} The non-negative area of this triangle.\n     */\n    Triangle.prototype.getArea = function () {\n        return Math.abs(Triangle.utils.signedArea(this.a.x, this.a.y, this.b.x, this.b.y, this.c.x, this.c.y));\n    };\n    ;\n    /**\n     * Get the centroid of this triangle.\n     *\n     * The centroid is the average midpoint for each side.\n     *\n     * @method getCentroid\n     * @return {Vertex} The centroid\n     * @instance\n     * @memberof Triangle\n     **/\n    Triangle.prototype.getCentroid = function () {\n        return new Vertex_1.Vertex((this.a.x + this.b.x + this.c.x) / 3, (this.a.y + this.b.y + this.c.y) / 3);\n    };\n    ;\n    /**\n     * Scale the triangle towards its centroid.\n     *\n     * @method scaleToCentroid\n     * @param {number} - The scale factor to use. That can be any scalar.\n     * @return {Triangle} this (for chaining)\n     * @instance\n     * @memberof Triangle\n     */\n    Triangle.prototype.scaleToCentroid = function (factor) {\n        var centroid = this.getCentroid();\n        this.a.scale(factor, centroid);\n        this.b.scale(factor, centroid);\n        this.c.scale(factor, centroid);\n        return this;\n    };\n    ;\n    /**\n     * Get the circumcircle of this triangle.\n     *\n     * The circumcircle is that unique circle on which all three\n     * vertices of this triangle are located on.\n     *\n     * Please note that for performance reasons any changes to vertices will not reflect in changes\n     * of the circumcircle (center or radius). Please call the calcCirumcircle() function\n     * after triangle vertex changes.\n     *\n     * @method getCircumcircle\n     * @return {Object} - { center:Vertex, radius:float }\n     * @instance\n     * @memberof Triangle\n     */\n    Triangle.prototype.getCircumcircle = function () {\n        // if( !this.center || !this.radius ) \n        this.calcCircumcircle();\n        return new Circle_1.Circle(this.center.clone(), this.radius);\n    };\n    ;\n    /**\n     * Check if this triangle and the passed triangle share an\n     * adjacent edge.\n     *\n     * For edge-checking Vertex.equals is used which uses an\n     * an epsilon for comparison.\n     *\n     * @method isAdjacent\n     * @param {Triangle} tri - The second triangle to check adjacency with.\n     * @return {boolean} - True if this and the passed triangle have at least one common edge.\n     * @instance\n     * @memberof Triangle\n     */\n    Triangle.prototype.isAdjacent = function (tri) {\n        var a = this.a.equals(tri.a) || this.a.equals(tri.b) || this.a.equals(tri.c);\n        var b = this.b.equals(tri.a) || this.b.equals(tri.b) || this.b.equals(tri.c);\n        var c = this.c.equals(tri.a) || this.c.equals(tri.b) || this.c.equals(tri.c);\n        return (a && b) || (a && c) || (b && c);\n    };\n    ;\n    /**\n     * Get that vertex of this triangle (a,b,c) that is not vert1 nor vert2 of\n     * the passed two.\n     *\n     * @method getThirdVertex\n     * @param {Vertex} vert1 - The first vertex.\n     * @param {Vertex} vert2 - The second vertex.\n     * @return {Vertex} - The third vertex of this triangle that makes up the whole triangle with vert1 and vert2.\n     * @instance\n     * @memberof Triangle\n     */\n    Triangle.prototype.getThirdVertex = function (vert1, vert2) {\n        if (this.a.equals(vert1) && this.b.equals(vert2) || this.a.equals(vert2) && this.b.equals(vert1))\n            return this.c;\n        if (this.b.equals(vert1) && this.c.equals(vert2) || this.b.equals(vert2) && this.c.equals(vert1))\n            return this.a;\n        //if( this.c.equals(vert1) && this.a.equals(vert2) || this.c.equals(vert2) && this.a.equals(vert1) )\n        return this.b;\n    };\n    ;\n    /**\n     * Re-compute the circumcircle of this triangle (if the vertices\n     * have changed).\n     *\n     * The circumcenter and radius are stored in this.center and\n     * this.radius. There is a third result: radius_squared (for internal computations).\n     *\n     * @method calcCircumcircle\n     * @return void\n     * @instance\n     * @memberof Triangle\n     */\n    Triangle.prototype.calcCircumcircle = function () {\n        // From\n        //    http://www.exaflop.org/docs/cgafaq/cga1.html\n        var A = this.b.x - this.a.x;\n        var B = this.b.y - this.a.y;\n        var C = this.c.x - this.a.x;\n        var D = this.c.y - this.a.y;\n        var E = A * (this.a.x + this.b.x) + B * (this.a.y + this.b.y);\n        var F = C * (this.a.x + this.c.x) + D * (this.a.y + this.c.y);\n        var G = 2.0 * (A * (this.c.y - this.b.y) - B * (this.c.x - this.b.x));\n        var dx, dy;\n        if (Math.abs(G) < Triangle.EPSILON) {\n            // Collinear - find extremes and use the midpoint\n            var bounds = this.bounds();\n            this.center = new Vertex_1.Vertex((bounds.min.x + bounds.max.x) / 2, (bounds.min.y + bounds.max.y) / 2);\n            dx = this.center.x - bounds.min.x;\n            dy = this.center.y - bounds.min.y;\n        }\n        else {\n            var cx = (D * E - B * F) / G;\n            var cy = (A * F - C * E) / G;\n            this.center = new Vertex_1.Vertex(cx, cy);\n            dx = this.center.x - this.a.x;\n            dy = this.center.y - this.a.y;\n        }\n        this.radius_squared = dx * dx + dy * dy;\n        this.radius = Math.sqrt(this.radius_squared);\n    };\n    ; // END calcCircumcircle\n    /**\n     * Check if the passed vertex is inside this triangle's\n     * circumcircle.\n     *\n     * @method inCircumcircle\n     * @param {Vertex} v - The vertex to check.\n     * @return {boolean}\n     * @instance\n     * @memberof Triangle\n     */\n    Triangle.prototype.inCircumcircle = function (v) {\n        var dx = this.center.x - v.x;\n        var dy = this.center.y - v.y;\n        var dist_squared = dx * dx + dy * dy;\n        return (dist_squared <= this.radius_squared);\n    };\n    ;\n    /**\n     * Get the rectangular bounds for this triangle.\n     *\n     * @method bounds\n     * @return {Bounds} - The min/max bounds of this triangle.\n     * @instance\n     * @memberof Triangle\n     */\n    Triangle.prototype.bounds = function () {\n        return new Bounds_1.Bounds(new Vertex_1.Vertex(Triangle.utils.min3(this.a.x, this.b.x, this.c.x), Triangle.utils.min3(this.a.y, this.b.y, this.c.y)), new Vertex_1.Vertex(Triangle.utils.max3(this.a.x, this.b.x, this.c.x), Triangle.utils.max3(this.a.y, this.b.y, this.c.y)));\n    };\n    ;\n    /**\n     * Convert this triangle to a polygon instance.\n     *\n     * Plase note that this conversion does not perform a deep clone.\n     *\n     * @method toPolygon\n     * @return {Polygon} A new polygon representing this triangle.\n     * @instance\n     * @memberof Triangle\n     **/\n    Triangle.prototype.toPolygon = function () {\n        return new Polygon_1.Polygon([this.a, this.b, this.c]);\n    };\n    ;\n    /**\n     * Get the determinant of this triangle.\n     *\n     * @method determinant\n     * @return {number} - The determinant (float).\n     * @instance\n     * @memberof Triangle\n     */\n    Triangle.prototype.determinant = function () {\n        // (b.y - a.y)*(c.x - b.x) - (c.y - b.y)*(b.x - a.x);\n        return (this.b.y - this.a.y) * (this.c.x - this.b.x) - (this.c.y - this.b.y) * (this.b.x - this.a.x);\n    };\n    ;\n    /**\n     * Checks if the passed vertex (p) is inside this triangle.\n     *\n     * Note: matrix determinants rock.\n     *\n     * @method containsPoint\n     * @param {Vertex} p - The vertex to check.\n     * @return {boolean}\n     * @instance\n     * @memberof Triangle\n     */\n    Triangle.prototype.containsPoint = function (p) {\n        return Triangle.utils.pointIsInTriangle(p.x, p.y, this.a.x, this.a.y, this.b.x, this.b.y, this.c.x, this.c.y);\n    };\n    ;\n    /**\n     * Get that inner triangle which defines the maximal incircle.\n     *\n     * @return {Triangle} The triangle of those points in this triangle that define the incircle.\n     */\n    Triangle.prototype.getIncircularTriangle = function () {\n        var lineA = new Line_1.Line(this.a, this.b);\n        var lineB = new Line_1.Line(this.b, this.c);\n        var lineC = new Line_1.Line(this.c, this.a);\n        var bisector1 = geomutils_1.geomutils.nsectAngle(this.b, this.a, this.c, 2)[0]; // bisector of first angle (in b)\n        var bisector2 = geomutils_1.geomutils.nsectAngle(this.c, this.b, this.a, 2)[0]; // bisector of second angle (in c)\n        var intersection = bisector1.intersection(bisector2);\n        // Find the closest points on one of the polygon lines (all have same distance by construction)\n        var circleIntersA = lineA.getClosestPoint(intersection);\n        var circleIntersB = lineB.getClosestPoint(intersection);\n        var circleIntersC = lineC.getClosestPoint(intersection);\n        return new Triangle(circleIntersA, circleIntersB, circleIntersC);\n    };\n    ;\n    /**\n     * Get the incircle of this triangle. That is the circle that touches each side\n     * of this triangle in exactly one point.\n     *\n     * Note this just calls getIncircularTriangle().getCircumcircle()\n     *\n     * @return {Circle} The incircle of this triangle.\n     */\n    Triangle.prototype.getIncircle = function () {\n        return this.getIncircularTriangle().getCircumcircle();\n    };\n    ;\n    /**\n     * Get the incenter of this triangle (which is the center of the circumcircle).\n     *\n     * Note: due to performance reasonst the incenter is buffered inside the triangle because\n     *       computing it is relatively expensive. If a, b or c have changed you should call the\n     *       calcCircumcircle() function first, otherwise you might get wrong results.\n     * @return Vertex The incenter of this triangle.\n     **/\n    Triangle.prototype.getIncenter = function () {\n        if (!this.center || !this.radius)\n            this.calcCircumcircle();\n        return this.center.clone();\n    };\n    ;\n    /**\n     * Converts this triangle into a human-readable string.\n     *\n     * @method toString\n     * @return {string}\n     * @instance\n     * @memberof Triangle\n     */\n    Triangle.prototype.toString = function () {\n        return '{ a : ' + this.a.toString() + ', b : ' + this.b.toString() + ', c : ' + this.c.toString() + '}';\n    };\n    ;\n    /**\n     * Create an SVG representation of this triangle.\n     *\n     * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.\n     * @method toSVGString\n     * @param {object=} options - An optional set of options, like 'className'.\n     * @return {string} The SVG string.\n     * @instance\n     * @memberof Triangle\n     **/\n    Triangle.prototype.toSVGString = function (options) {\n        options = options || {};\n        var buffer = [];\n        buffer.push('<path');\n        if (options.className)\n            buffer.push(' class=\"' + options.className + '\"');\n        buffer.push(' d=\"');\n        var vertices = [this.a, this.b, this.c];\n        if (vertices.length > 0) {\n            buffer.push('M ');\n            buffer.push(vertices[0].x);\n            buffer.push(' ');\n            buffer.push(vertices[0].y);\n            for (var i = 1; i < vertices.length; i++) {\n                buffer.push(' L ');\n                buffer.push(vertices[i].x);\n                buffer.push(' ');\n                buffer.push(vertices[i].y);\n            }\n            //if( !this.isOpen ) {\n            buffer.push(' Z');\n            //}\n        }\n        buffer.push('\" />');\n        return buffer.join('');\n    };\n    ;\n    /**\n     * An epsilon for comparison.\n     * This should be the same epsilon as in Vertex.\n     *\n     * @private\n     **/\n    Triangle.EPSILON = 1.0e-6;\n    Triangle.utils = {\n        // Used in the bounds() function.\n        max3: function (a, b, c) {\n            return (a >= b && a >= c) ? a : (b >= a && b >= c) ? b : c;\n        },\n        min3: function (a, b, c) {\n            return (a <= b && a <= c) ? a : (b <= a && b <= c) ? b : c;\n        },\n        signedArea: function (p0x, p0y, p1x, p1y, p2x, p2y) {\n            return 0.5 * (-p1y * p2x + p0y * (-p1x + p2x) + p0x * (p1y - p2y) + p1x * p2y);\n        },\n        /**\n         * Used by the containsPoint() function.\n         *\n         * @private\n         **/\n        pointIsInTriangle: function (px, py, p0x, p0y, p1x, p1y, p2x, p2y) {\n            //\n            // Point-in-Triangle test found at\n            //   http://stackoverflow.com/questions/2049582/how-to-determine-a-point-in-a-2d-triangle\n            // var area : number = 1/2*(-p1y*p2x + p0y*(-p1x + p2x) + p0x*(p1y - p2y) + p1x*p2y);\n            var area = Triangle.utils.signedArea(p0x, p0y, p1x, p1y, p2x, p2y);\n            var s = 1 / (2 * area) * (p0y * p2x - p0x * p2y + (p2y - p0y) * px + (p0x - p2x) * py);\n            var t = 1 / (2 * area) * (p0x * p1y - p0y * p1x + (p0y - p1y) * px + (p1x - p0x) * py);\n            return s > 0 && t > 0 && (1 - s - t) > 0;\n        }\n    };\n    return Triangle;\n}());\nexports.Triangle = Triangle;\n//# sourceMappingURL=Triangle.js.map","\"use strict\";\n/**\n * @classdesc A static UIDGenerator.\n *\n * @author  Ikaros Kappler\n * @date    2021-01-20\n * @version 1.0.0\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.UIDGenerator = void 0;\nvar UIDGenerator = /** @class */ (function () {\n    function UIDGenerator() {\n    }\n    UIDGenerator.next = function () { return \"\" + UIDGenerator.current++; };\n    ;\n    UIDGenerator.current = 0;\n    return UIDGenerator;\n}());\nexports.UIDGenerator = UIDGenerator;\n;\n//# sourceMappingURL=UIDGenerator.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2018-11-28\n * @modified 2018-12-04 Added the toSVGString function.\n * @modified 2020-03-25 Ported this class from vanilla-JS to Typescript.\n * @modified 2021-01-20 Added UID.\n * @version  1.1.0\n *\n * @file VEllipse\n * @fileoverview Ellipses with a center and an x- and a y-axis (stored as a vertex).\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.VEllipse = void 0;\nvar UIDGenerator_1 = require(\"./UIDGenerator\");\n/**\n * @classdesc An ellipse class based on two vertices [centerX,centerY] and [radiusX,radiusY].\n *\n * @requires SVGSerializable\n * @requires UID\n * @requires UIDGenerator\n * @requires Vertex\n * @requires XYCoords\n */\nvar VEllipse = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @param {Vertex} center The ellipses center.\n     * @param {Vertex} axis The x- and y-axis.\n     * @name VEllipse\n     **/\n    function VEllipse(center, axis) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"VEllipse\";\n        this.uid = UIDGenerator_1.UIDGenerator.next();\n        this.center = center;\n        this.axis = axis;\n    }\n    ;\n    /**\n     * Create an SVG representation of this ellipse.\n     *\n     * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.\n     * @param {object} options { className?:string }\n     * @return string The SVG string\n     */\n    VEllipse.prototype.toSVGString = function (options) {\n        options = options || {};\n        var buffer = [];\n        buffer.push('<ellipse');\n        if (options.className)\n            buffer.push(' class=\"' + options.className + '\"');\n        buffer.push(' cx=\"' + this.center.x + '\"');\n        buffer.push(' cy=\"' + this.center.y + '\"');\n        buffer.push(' rx=\"' + this.axis.x + '\"');\n        buffer.push(' ry=\"' + this.axis.y + '\"');\n        buffer.push(' />');\n        return buffer.join('');\n    };\n    ;\n    return VEllipse;\n}());\nexports.VEllipse = VEllipse;\n//# sourceMappingURL=VEllipse.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2019-01-30\n * @modified 2019-02-23 Added the toSVGString function, overriding Line.toSVGString.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2019-04-19 Added the clone function (overriding Line.clone()).\n * @modified 2019-09-02 Added the Vector.perp() function.\n * @modified 2019-09-02 Added the Vector.inverse() function.\n * @modified 2019-12-04 Added the Vector.inv() function.\n * @modified 2020-03-23 Ported to Typescript from JS.\n * @modified 2021-01-20 Added UID.\n * @version  1.3.0\n *\n * @file Vector\n * @public\n **/\nvar __extends = (this && this.__extends) || (function () {\n    var extendStatics = function (d, b) {\n        extendStatics = Object.setPrototypeOf ||\n            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n        return extendStatics(d, b);\n    };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Vector = void 0;\nvar VertTuple_1 = require(\"./VertTuple\");\nvar Vertex_1 = require(\"./Vertex\");\n/**\n * @classdesc A vector (Vertex,Vertex) is a line with a visible direction.<br>\n *            <br>\n *            Vectors are drawn with an arrow at their end point.<br>\n *            <b>The Vector class extends the Line class.</b>\n *\n * @requires Vertex, Line\n **/\nvar Vector = /** @class */ (function (_super) {\n    __extends(Vector, _super);\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name Vector\n     * @extends Line\n     * @param {Vertex} vertA - The start vertex of the vector.\n     * @param {Vertex} vertB - The end vertex of the vector.\n     **/\n    function Vector(vertA, vertB) {\n        var _this = _super.call(this, vertA, vertB, function (a, b) { return new Vector(a, b); }) || this;\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        _this.className = \"Vector\";\n        return _this;\n    }\n    ;\n    /**\n     * Get the perpendicular of this vector which is located at a.\n     *\n     * @param {Number} t The position on the vector.\n     * @return {Vector} A new vector being the perpendicular of this vector sitting on a.\n     **/\n    Vector.prototype.perp = function () {\n        var v = this.clone();\n        v.sub(this.a);\n        v = new Vector(new Vertex_1.Vertex(), new Vertex_1.Vertex(-v.b.y, v.b.x));\n        v.a.add(this.a);\n        v.b.add(this.a);\n        return v;\n    };\n    ;\n    /**\n     * The inverse of a vector is a vector witht the same magnitude but oppose direction.\n     *\n     * Please not that the origin of this vector changes here: a->b becomes b->a.\n     *\n     * @return {Vector}\n     **/\n    Vector.prototype.inverse = function () {\n        var tmp = this.a;\n        this.a = this.b;\n        this.b = tmp;\n        return this;\n    };\n    ;\n    /**\n     * This function computes the inverse of the vector, which means 'a' stays untouched.\n     *\n     * @return {Vector} this for chaining.\n     **/\n    Vector.prototype.inv = function () {\n        this.b.x = this.a.x - (this.b.x - this.a.x);\n        this.b.y = this.a.y - (this.b.y - this.a.y);\n        return this;\n    };\n    ;\n    /**\n     * Get the intersection if this vector and the specified vector.\n     *\n     * @method intersection\n     * @param {Vector} line The second vector.\n     * @return {Vertex} The intersection (may lie outside the end-points).\n     * @instance\n     * @memberof Line\n     **/\n    Vector.prototype.intersection = function (line) {\n        var denominator = this.denominator(line);\n        if (denominator == 0)\n            return null;\n        var a = this.a.y - line.a.y;\n        var b = this.a.x - line.a.x;\n        var numerator1 = ((line.b.x - line.a.x) * a) - ((line.b.y - line.a.y) * b);\n        var numerator2 = ((this.b.x - this.a.x) * a) - ((this.b.y - this.a.y) * b);\n        a = numerator1 / denominator; // NaN if parallel lines\n        b = numerator2 / denominator;\n        // TODO:\n        // FOR A VECTOR THE LINE-INTERSECTION MUST BE ON BOTH VECTORS\n        // if we cast these lines infinitely in both directions, they intersect here:\n        return new Vertex_1.Vertex(this.a.x + (a * (this.b.x - this.a.x)), this.a.y + (a * (this.b.y - this.a.y)));\n    };\n    ;\n    /**\n     * Create an SVG representation of this line.\n     *\n     * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.\n     * @method toSVGString\n     * @override\n     * @param {object=} options - A set of options, like 'className'.\n     * @return {string} The SVG string representation.\n     * @instance\n     * @memberof Vector\n     **/\n    Vector.prototype.toSVGString = function (options) {\n        options = options || {};\n        var buffer = [];\n        var vertices = Vector.utils.buildArrowHead(this.a, this.b, 8, 1.0, 1.0);\n        buffer.push('<g');\n        if (options.className)\n            buffer.push(' class=\"' + options.className + '\"');\n        buffer.push('>');\n        buffer.push('   <line');\n        buffer.push(' x1=\"' + this.a.x + '\"');\n        buffer.push(' y1=\"' + this.a.y + '\"');\n        buffer.push(' x2=\"' + vertices[0].x + '\"');\n        buffer.push(' y2=\"' + vertices[0].y + '\"');\n        buffer.push(' />');\n        // Add arrow head\n        buffer.push('   <polygon points=\"');\n        for (var i = 0; i < vertices.length; i++) {\n            if (i > 0)\n                buffer.push(' ');\n            buffer.push('' + vertices[i].x + ',' + vertices[i].y);\n        }\n        buffer.push('\"/>');\n        buffer.push('</g>');\n        return buffer.join('');\n    };\n    ;\n    Vector.utils = {\n        /**\n         * Generate a four-point arrow head, starting at the vector end minus the\n         * arrow head length.\n         *\n         * The first vertex in the returned array is guaranteed to be the located\n         * at the vector line end minus the arrow head length.\n         *\n         *\n         * Due to performance all params are required.\n         *\n         * The params scaleX and scaleY are required for the case that the scaling is not uniform (x and y\n         * scaling different). Arrow heads should not look distored on non-uniform scaling.\n         *\n         * If unsure use 1.0 for scaleX and scaleY (=no distortion).\n         * For headlen use 8, it's a good arrow head size.\n         *\n         * Example:\n         *    buildArrowHead( new Vertex(0,0), new Vertex(50,100), 8, 1.0, 1.0 )\n         *\n         * @param {Vertex} zA - The start vertex of the vector to calculate the arrow head for.\n         * @param {Vertex} zB - The end vertex of the vector.\n         * @param {number} headlen - The length of the arrow head (along the vector direction. A good value is 12).\n         * @param {number} scaleX  - The horizontal scaling during draw.\n         * @param {number} scaleY  - the vertical scaling during draw.\n         **/\n        buildArrowHead: function (zA, zB, headlen, scaleX, scaleY) {\n            var angle = Math.atan2((zB.y - zA.y) * scaleY, (zB.x - zA.x) * scaleX);\n            var vertices = [];\n            vertices.push(new Vertex_1.Vertex(zB.x * scaleX - (headlen) * Math.cos(angle), zB.y * scaleY - (headlen) * Math.sin(angle)));\n            vertices.push(new Vertex_1.Vertex(zB.x * scaleX - (headlen * 1.35) * Math.cos(angle - Math.PI / 8), zB.y * scaleY - (headlen * 1.35) * Math.sin(angle - Math.PI / 8)));\n            vertices.push(new Vertex_1.Vertex(zB.x * scaleX, zB.y * scaleY));\n            vertices.push(new Vertex_1.Vertex(zB.x * scaleX - (headlen * 1.35) * Math.cos(angle + Math.PI / 8), zB.y * scaleY - (headlen * 1.35) * Math.sin(angle + Math.PI / 8)));\n            return vertices;\n        }\n    };\n    return Vector;\n}(VertTuple_1.VertTuple));\nexports.Vector = Vector;\n//# sourceMappingURL=Vector.js.map","\"use strict\";\n/**\n * @author Ikaros Kappler\n * @date   2020-03-24\n * @modified 2020-05-04 Fixed a serious bug in the pointDistance function.\n * @modified 2020-05-12 The angle(line) param was still not optional. Changed that.\n * @modified 2020-11-11 Generalized the `add` and `sub` param from `Vertex` to `XYCoords`.\n * @modified 2020-12-04 Changed`vtutils.dist2` params from `Vertex` to `XYCoords` (generalized).\n * @modified 2020-12-04 Changed `getClosestT` param from `Vertex` to `XYCoords` (generalized).\n * @modified 2020-12-04 Added the `hasPoint(XYCoords)` function.\n * @modified 2021-01-20 Added UID.\n * @version 1.1.0\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.VertTuple = void 0;\nvar Vertex_1 = require(\"./Vertex\");\nvar UIDGenerator_1 = require(\"./UIDGenerator\");\n/**\n * @classdesc An abstract base classes for vertex tuple constructs, like Lines or Vectors.\n * @abstract\n * @requires SVGSerializable\n * @requires UID\n * @requires Vertex\n * @requires XYCoords\n */\nvar VertTuple = /** @class */ (function () {\n    /**\n     * Creates an instance.\n     *\n     * @constructor\n     * @name VertTuple\n     * @param {Vertex} a The tuple's first point.\n     * @param {Vertex} b The tuple's second point.\n     **/\n    function VertTuple(a, b, factory) {\n        this.uid = UIDGenerator_1.UIDGenerator.next();\n        this.a = a;\n        this.b = b;\n        this.factory = factory;\n    }\n    /**\n     * Get the length of this line.\n     *\n     * @method length\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.length = function () {\n        return Math.sqrt(Math.pow(this.b.x - this.a.x, 2) + Math.pow(this.b.y - this.a.y, 2));\n    };\n    ;\n    /**\n     * Set the length of this vector to the given amount. This only works if this\n     * vector is not a null vector.\n     *\n     * @method setLength\n     * @param {number} length - The desired length.\n     * @memberof VertTuple\n     * @return {T} this (for chaining)\n     **/\n    VertTuple.prototype.setLength = function (length) {\n        return this.scale(length / this.length());\n    };\n    ;\n    /**\n     * Substract the given vertex from this line's end points.\n     *\n     * @method sub\n     * @param {XYCoords} amount The amount (x,y) to substract.\n     * @return {VertTuple} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.sub = function (amount) {\n        this.a.sub(amount);\n        this.b.sub(amount);\n        return this;\n    };\n    ;\n    /**\n     * Add the given vertex to this line's end points.\n     *\n     * @method add\n     * @param {XYCoords} amount The amount (x,y) to add.\n     * @return {Line} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.add = function (amount) {\n        this.a.add(amount);\n        this.b.add(amount);\n        return this;\n    };\n    ;\n    /**\n     * Normalize this line (set to length 1).\n     *\n     * @method normalize\n     * @return {VertTuple} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.normalize = function () {\n        this.b.set(this.a.x + (this.b.x - this.a.x) / this.length(), this.a.y + (this.b.y - this.a.y) / this.length());\n        return this;\n    };\n    ;\n    /**\n     * Scale this line by the given factor.\n     *\n     * @method scale\n     * @param {number} factor The factor for scaling (1.0 means no scale).\n     * @return {VertTuple} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.scale = function (factor) {\n        this.b.set(this.a.x + (this.b.x - this.a.x) * factor, this.a.y + (this.b.y - this.a.y) * factor);\n        return this;\n    };\n    ;\n    /**\n     * Move this line to a new location.\n     *\n     * @method moveTo\n     * @param {Vertex} newA - The new desired location of 'a'. Vertex 'b' will be moved, too.\n     * @return {VertTuple} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.moveTo = function (newA) {\n        var diff = this.a.difference(newA);\n        this.a.add(diff);\n        this.b.add(diff);\n        return this;\n    };\n    ;\n    /**\n     * Get the angle between this and the passed line (in radians).\n     *\n     * @method angle\n     * @param {VertTuple} line - (optional) The line to calculate the angle to. If null the baseline (x-axis) will be used.\n     * @return {number} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.angle = function (line) {\n        if (line == null || typeof line == 'undefined') {\n            line = this.factory(new Vertex_1.Vertex(0, 0), new Vertex_1.Vertex(100, 0));\n        }\n        // Compute the angle from x axis and the return the difference :)\n        var v0 = this.b.clone().sub(this.a);\n        var v1 = line.b.clone().sub(line.a);\n        // Thank you, Javascript, for this second atan function. No additional math is needed here!\n        // The result might be negative, but isn't it usually nicer to determine angles in positive values only?\n        return Math.atan2(v1.x, v1.y) - Math.atan2(v0.x, v0.y);\n    };\n    ;\n    /**\n     * Get line point at position t in [0 ... 1]:<br>\n     * <pre>[P(0)]=[A]--------------------[P(t)]------[B]=[P(1)]</pre><br>\n     * <br>\n     * The counterpart of this function is Line.getClosestT(Vertex).\n     *\n     * @method vertAt\n     * @param {number} t The position scalar.\n     * @return {Vertex} The vertex a position t.\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.vertAt = function (t) {\n        return new Vertex_1.Vertex(this.a.x + (this.b.x - this.a.x) * t, this.a.y + (this.b.y - this.a.y) * t);\n    };\n    ;\n    /**\n     * Get the denominator of this and the given line.\n     *\n     * If the denominator is zero (or close to zero) both line are co-linear.\n     *\n     * @method denominator\n     * @param {VertTuple} line\n     * @instance\n     * @memberof VertTuple\n     * @return {Number}\n     **/\n    VertTuple.prototype.denominator = function (line) {\n        // http://jsfiddle.net/justin_c_rounds/Gd2S2/\n        return ((line.b.y - line.a.y) * (this.b.x - this.a.x)) - ((line.b.x - line.a.x) * (this.b.y - this.a.y));\n    };\n    ;\n    /**\n     * Checks if this and the given line are co-linear.\n     *\n     * The constant Vertex.EPSILON is used for tolerance.\n     *\n     * @method colinear\n     * @param {VertTuple} line\n     * @instance\n     * @memberof VertTuple\n     * @return true if both lines are co-linear.\n     */\n    VertTuple.prototype.colinear = function (line) {\n        return Math.abs(this.denominator(line)) < Vertex_1.Vertex.EPSILON;\n    };\n    ;\n    /**\n     * Get the closest position T from this line to the specified point.\n     *\n     * The counterpart for this function is Line.vertAt(Number).\n     *\n     * @name getClosetT\n     * @method getClosestT\n     * @param {XYCoords} p The point (vertex) to measure the distance to.\n     * @return {number} The line position t of minimal distance to p.\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.getClosestT = function (p) {\n        var l2 = VertTuple.vtutils.dist2(this.a, this.b);\n        if (l2 === 0)\n            return 0;\n        var t = ((p.x - this.a.x) * (this.b.x - this.a.x) + (p.y - this.a.y) * (this.b.y - this.a.y)) / l2;\n        // Do not wrap to [0,1] here.\n        // Other results are of interest, too.\n        // t = Math.max(0, Math.min(1, t));\n        return t;\n    };\n    ;\n    /**\n     * Check if the given point is located on this line. Optionally also check if\n     * that point is located between point `a` and `b`.\n     *\n     * @method hasPoint\n     * @param {Vertex} point The point to check.\n     * @param {boolean=} insideBoundsOnly If set to to true (default=false) the point must be between start and end point of the line.\n     * @return {boolean} True if the given point is on this line.\n     * @instance\n     * @memberof VertTuple\n     */\n    VertTuple.prototype.hasPoint = function (point, insideBoundsOnly) {\n        var t = this.getClosestT(point);\n        // Compare to pointDistance?\n        if (typeof insideBoundsOnly !== \"undefined\" && insideBoundsOnly) {\n            var distance = Math.sqrt(VertTuple.vtutils.dist2(point, this.vertAt(t)));\n            return distance < Vertex_1.Vertex.EPSILON && t >= 0 && t <= 1;\n        }\n        else {\n            return t >= 0 && t <= 1;\n        }\n    };\n    /**\n     * Get the closest point on this line to the specified point.\n     *\n     * @method getClosestPoint\n     * @param {Vertex} p The point (vertex) to measre the distance to.\n     * @return {Vertex} The point on the line that is closest to p.\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.getClosestPoint = function (p) {\n        var t = this.getClosestT(p);\n        return this.vertAt(t);\n    };\n    ;\n    /**\n     * The the minimal distance between this line and the specified point.\n     *\n     * @method pointDistance\n     * @param {Vertex} p The point (vertex) to measre the distance to.\n     * @return {number} The absolute minimal distance.\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.pointDistance = function (p) {\n        // Taken From:\n        // https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment\n        return Math.sqrt(VertTuple.vtutils.dist2(p, this.vertAt(this.getClosestT(p))));\n    };\n    ;\n    /**\n     * Create a deep clone of this instance.\n     *\n     * @method cloneLine\n     * @return {T} A type safe clone if this instance.\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.clone = function () {\n        return this.factory(this.a.clone(), this.b.clone());\n    };\n    ;\n    /**\n     * Create a string representation of this line.\n     *\n     * @method totring\n     * @return {string} The string representing this line.\n     * @instance\n     * @memberof VertTuple\n     **/\n    VertTuple.prototype.toString = function () {\n        return \"{ a : \" + this.a.toString() + \", b : \" + this.b.toString() + \" }\";\n    };\n    ;\n    /**\n     * @private\n     **/\n    VertTuple.vtutils = {\n        dist2: function (v, w) {\n            return (v.x - w.x) * (v.x - w.x) + (v.y - w.y) * (v.y - w.y);\n        }\n    };\n    return VertTuple;\n}());\nexports.VertTuple = VertTuple;\n//# sourceMappingURL=VertTuple.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2012-10-17\n * @modified 2018-04-03 Refactored the code of october 2012 into a new class.\n * @modified 2018-04-28 Added some documentation.\n * @modified 2018-08-16 Added the set() function.\n * @modified 2018-08-26 Added VertexAttr.\n * @modified 2018-10-31 Extended the constructor by object{x,y}.\n * @modified 2018-11-19 Extended the set(number,number) function to set(Vertex).\n * @modified 2018-11-28 Added 'this' to the VertexAttr constructor.\n * @modified 2018-12-05 Added the sub(...) function. Changed the signature of the add() function! add(Vertex) and add(number,number) are now possible.\n * @modified 2018-12-21 (It's winter solstice) Added the inv()-function.\n * @modified 2019-01-30 Added the setX(Number) and setY(Number) functions.\n * @modified 2019-02-19 Added the difference(Vertex) function.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2019-04-24 Added the randomVertex(ViewPort) function.\n * @modified 2019-11-07 Added toSVGString(object) function.\n * @modified 2019-11-18 Added the rotate(number,Vertex) function.\n * @modified 2019-11-21 Fixed a bug in the rotate(...) function (elements were moved).\n * @modified 2020-03-06 Added functions invX() and invY().\n * @modified 2020-03-23 Ported to Typescript from JS.\n * @modified 2020-05-26 Added functions addX(number) and addY(number).\n * @modifeid 2020-10-30 Change the warnings in `sub(...)` and `add(...)` into real errors.\n * @version  2.4.1\n *\n * @file Vertex\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Vertex = void 0;\nvar VertexAttr_1 = require(\"./VertexAttr\");\nvar UIDGenerator_1 = require(\"./UIDGenerator\");\nvar VertexListeners_1 = require(\"./VertexListeners\");\n/**\n * @classdesc A vertex is a pair of two numbers.<br>\n * <br>\n * It is used to identify a 2-dimensional point on the x-y-plane.\n *\n * @requires IVertexAttr\n * @requires SVGSerializable\n * @requires UID\n * @requires UIDGenerator\n * @requires VertexAttr\n * @requires VertexListeners\n * @requires XYCoords\n *\n */\nvar Vertex = /** @class */ (function () {\n    /**\n     * The constructor for the vertex class.\n     *\n     * @constructor\n     * @name Vertex\n     * @param {number} x - The x-coordinate of the new vertex.\n     * @param {number} y - The y-coordinate of the new vertex.\n     **/\n    function Vertex(x, y) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"Vertex\";\n        this.uid = UIDGenerator_1.UIDGenerator.next();\n        if (typeof x == 'undefined') {\n            this.x = 0;\n            this.y = 0;\n        }\n        else if (typeof x == 'number' && typeof y == 'number') {\n            this.x = x;\n            this.y = y;\n        }\n        else {\n            var tuple = x;\n            if (typeof tuple.x == \"number\" && typeof tuple.y == \"number\") {\n                this.x = tuple.x;\n                this.y = tuple.y;\n            }\n            else {\n                if (typeof x == 'number')\n                    this.x = x;\n                else if (typeof x == 'undefined')\n                    this.x = 0;\n                else\n                    this.x = NaN;\n                if (typeof y == 'number')\n                    this.y = y;\n                else if (typeof y == 'undefined')\n                    this.y = 0;\n                else\n                    this.y = NaN;\n            }\n        }\n        this.attr = new VertexAttr_1.VertexAttr();\n        this.listeners = new VertexListeners_1.VertexListeners(this);\n    }\n    ;\n    /**\n     * Set the x- and y- component of this vertex.\n     *\n     * @method set\n     * @param {number} x - The new x-component.\n     * @param {number} y - The new y-component.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.set = function (x, y) {\n        if (typeof x == 'number' && typeof y == 'number') {\n            this.x = x;\n            this.y = y;\n        }\n        else {\n            var tuple = x;\n            if (typeof tuple.x == \"number\" && typeof tuple.y == \"number\") {\n                this.x = tuple.x;\n                this.y = tuple.y;\n            }\n            else {\n                if (typeof x == 'number')\n                    this.x = x;\n                else if (typeof x == 'undefined')\n                    this.x = 0;\n                else\n                    this.x = NaN;\n                if (typeof y == 'number')\n                    this.y = y;\n                else if (typeof y == 'undefined')\n                    this.y = 0;\n                else\n                    this.y = NaN;\n            }\n        }\n        return this;\n    };\n    ;\n    /**\n     * Set the x-component of this vertex.\n     *\n     * @method setX\n     * @param {number} x - The new x-component.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.setX = function (x) {\n        this.x = x;\n        return this;\n    };\n    ;\n    /**\n     * Set the y-component of this vertex.\n     *\n     * @method setY\n     * @param {number} y - The new y-component.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.setY = function (y) {\n        this.y = y;\n        return this;\n    };\n    ;\n    /**\n     * Set the x-component if this vertex to the inverse of its value.\n     *\n     * @method invX\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.invX = function () {\n        this.x = -this.x;\n        return this;\n    };\n    ;\n    /**\n     * Set the y-component if this vertex to the inverse of its value.\n     *\n     * @method invY\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.invY = function () {\n        this.y = -this.y;\n        return this;\n    };\n    ;\n    /**\n     * Add the passed amount to x- and y- component of this vertex.<br>\n     * <br>\n     * This function works with add( {number}, {number} ) and\n     * add( {Vertex} ), as well.\n     *\n     * @method add\n     * @param {(number|Vertex)} x - The amount to add to x (or a vertex itself).\n     * @param {number=} y - The amount to add to y.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.add = function (x, y) {\n        if (typeof x == 'number' && typeof y == 'number') {\n            this.x += x;\n            this.y += y;\n        }\n        else {\n            var tuple = x;\n            if (typeof tuple.x == \"number\" && typeof tuple.y == \"number\") {\n                this.x += tuple.x;\n                this.y += tuple.y;\n            }\n            else {\n                if (typeof x == 'number')\n                    this.x += x;\n                else\n                    throw \"Cannot add \" + typeof x + \" to numeric x component!\";\n                if (typeof y == 'number')\n                    this.y += y;\n                else\n                    throw \"Cannot add \" + typeof y + \" to numeric y component!\";\n            }\n        }\n        return this;\n    };\n    ;\n    /**\n     * Add the passed amounts to the x- and y- components of this vertex.\n     *\n     * @method addXY\n     * @param {number} x - The amount to add to x.\n     * @param {number} y - The amount to add to y.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.addXY = function (amountX, amountY) {\n        this.x += amountX;\n        this.y += amountY;\n        return this;\n    };\n    ;\n    /**\n     * Add the passed amounts to the x-component of this vertex.\n     *\n     * @method addX\n     * @param {number} x - The amount to add to x.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.addX = function (amountX) {\n        this.x += amountX;\n        return this;\n    };\n    ;\n    /**\n     * Add the passed amounts to the y-component of this vertex.\n     *\n     * @method addY\n     * @param {number} y - The amount to add to y.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.addY = function (amountY) {\n        this.y += amountY;\n        return this;\n    };\n    ;\n    /**\n     * Substract the passed amount from x- and y- component of this vertex.<br>\n     * <br>\n     * This function works with sub( {number}, {number} ) and\n     * sub( {Vertex} ), as well.\n     *\n     * @method sub\n     * @param {(number|Vertex)} x - The amount to substract from x (or a vertex itself).\n     * @param {number=} y - The amount to substract from y.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.sub = function (x, y) {\n        if (typeof x == 'number' && typeof y == 'number') {\n            this.x -= x;\n            this.y -= y;\n        }\n        else {\n            var tuple = x;\n            if (typeof tuple.x == \"number\" && typeof tuple.y == \"number\") {\n                this.x -= tuple.x;\n                this.y -= tuple.y;\n            }\n            else {\n                if (typeof x == 'number')\n                    this.x -= x;\n                else\n                    throw \"Cannot add \" + typeof x + \" to numeric x component!\";\n                if (typeof y == 'number')\n                    this.y -= y;\n                else\n                    throw \"Cannot add \" + typeof y + \" to numeric y component!\";\n            }\n        }\n        return this;\n    };\n    ;\n    /**\n     * Check if this vertex equals the passed one.\n     * <br>\n     * This function uses an internal epsilon as tolerance.\n     *\n     * @method equals\n     * @param {Vertex} vertex - The vertex to compare this with.\n     * @return {boolean}\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.equals = function (vertex) {\n        var eqX = (Math.abs(this.x - vertex.x) < Vertex.EPSILON);\n        var eqY = (Math.abs(this.y - vertex.y) < Vertex.EPSILON);\n        var result = eqX && eqY;\n        return result;\n    };\n    ;\n    /**\n     * Create a copy of this vertex.\n     *\n     * @method clone\n     * @return {Vertex} A new vertex, an exact copy of this.\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.clone = function () {\n        return new Vertex(this.x, this.y);\n    };\n    ;\n    /**\n     * Get the distance to the passed point (in euclidean metric)\n     *\n     * @method distance\n     * @param {XYCoords} vert - The vertex to measure the distance to.\n     * @return {number}\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.distance = function (vert) {\n        return Math.sqrt(Math.pow(vert.x - this.x, 2) + Math.pow(vert.y - this.y, 2));\n    };\n    ;\n    /**\n     * Get the angle of this point (relative to (0,0) or to the given other origin point).\n     *\n     * @method angle\n     * @param {XYCoords} origin - The vertex to measure the angle from.\n     * @return {number}\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.angle = function (origin) {\n        var a = (typeof origin === \"undefined\" ? Math.PI / 2 - Math.atan2(this.x, this.y) : Math.PI / 2 - Math.atan2(origin.x - this.x, origin.y - this.y));\n        // Map to positive value\n        return a < 0 ? Math.PI * 2 + a : a;\n    };\n    ;\n    /**\n     * Get the difference to the passed point.<br>\n     * <br>\n     * The difference is (vert.x-this.x, vert.y-this.y).\n     *\n     * @method difference\n     * @param {Vertex} vert - The vertex to measure the x-y-difference to.\n     * @return {Vertex} A new vertex.\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.difference = function (vert) {\n        return new Vertex(vert.x - this.x, vert.y - this.y);\n    };\n    ;\n    /**\n     * This is a vector-like behavior and 'scales' this vertex\n     * towards/from a given center.\n     *\n     * @method scale\n     * @param {number} factor - The factor to 'scale' this vertex; 1.0 means no change.\n     * @param {Vertex=} center - The origin of scaling; default is (0,0).\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.scale = function (factor, center) {\n        if (!center || typeof center === \"undefined\")\n            center = new Vertex(0, 0);\n        this.x = center.x + (this.x - center.x) * factor;\n        this.y = center.y + (this.y - center.y) * factor;\n        return this;\n    };\n    ;\n    /**\n     * This is a vector-like behavior and 'rotates' this vertex\n     * around given center.\n     *\n     * @method rotate\n     * @param {number} angle - The angle to 'rotate' this vertex; 0.0 means no change.\n     * @param {Vertex=} center - The center of rotation; default is (0,0).\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.rotate = function (angle, center) {\n        if (!center || typeof center === \"undefined\")\n            center = new Vertex(0, 0);\n        this.sub(center);\n        angle += Math.atan2(this.y, this.x);\n        var len = this.distance(Vertex.ZERO); // {x:0,y:0});\n        var lenX = this.x;\n        var lenY = this.y;\n        this.x = len * Math.cos(angle);\n        this.y = len * Math.sin(angle);\n        this.add(center);\n        return this;\n    };\n    ;\n    /**\n     * Multiply both components of this vertex with the given scalar.<br>\n     * <br>\n     * Note: as in<br>\n     *    https://threejs.org/docs/#api/math/Vector2.multiplyScalar\n     *\n     * @method multiplyScalar\n     * @param {number} scalar - The scale factor; 1.0 means no change.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.multiplyScalar = function (scalar) {\n        this.x *= scalar;\n        this.y *= scalar;\n        return this;\n    };\n    ;\n    /**\n     * Round the two components x and y of this vertex.\n     *\n     * @method round\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.round = function () {\n        this.x = Math.round(this.x);\n        this.y = Math.round(this.y);\n        return this;\n    };\n    ;\n    /**\n     * Change this vertex (x,y) to its inverse (-x,-y).\n     *\n     * @method inv\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.inv = function () {\n        this.x = -this.x;\n        this.y = -this.y;\n        return this;\n    };\n    ;\n    /**\n     * Get a string representation of this vertex.\n     *\n     * @method toString\n     * @return {string} The string representation of this vertex.\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.toString = function () {\n        return '(' + this.x + ',' + this.y + ')';\n    };\n    ;\n    /**\n     * Convert this vertex to SVG code.\n     *\n     * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.\n     * @method toSVGString\n     * @param {object=} options - An optional set of options, like 'className'.\n     * @return {string} A string representing the SVG code for this vertex.\n     * @instance\n     * @memberof Vertex\n     **/\n    Vertex.prototype.toSVGString = function (options) {\n        options = options || {};\n        var buffer = [];\n        buffer.push('<circle');\n        if (options.className)\n            buffer.push(' class=\"' + options.className + '\"');\n        buffer.push(' cx=\"' + this.x + '\"');\n        buffer.push(' cy=\"' + this.y + '\"');\n        buffer.push(' r=\"2\"');\n        buffer.push(' />');\n        return buffer.join('');\n    };\n    ;\n    // END Vertex\n    /**\n     * Create a new random vertex inside the given viewport.\n     *\n     * @param {ViewPort} viewPort - A {min:Vertex, max:Vertex} viewport specifying the bounds.\n     * @return A new vertex with a random position.\n     **/\n    Vertex.randomVertex = function (viewPort) {\n        return new Vertex(viewPort.min.x + Math.random() * (viewPort.max.x - viewPort.min.x), viewPort.min.y + Math.random() * (viewPort.max.y - viewPort.min.y));\n    };\n    ;\n    Vertex.ZERO = new Vertex(0, 0);\n    /**\n     * An epsilon for comparison\n     *\n     * @private\n     * @readonly\n     **/\n    Vertex.EPSILON = 1.0e-6;\n    Vertex.utils = {\n        /**\n         * Generate a four-point arrow head, starting at the vector end minus the\n         * arrow head length.\n         *\n         * The first vertex in the returned array is guaranteed to be the located\n         * at the vector line end minus the arrow head length.\n         *\n         *\n         * Due to performance all params are required.\n         *\n         * The params scaleX and scaleY are required for the case that the scaling is not uniform (x and y\n         * scaling different). Arrow heads should not look distored on non-uniform scaling.\n         *\n         * If unsure use 1.0 for scaleX and scaleY (=no distortion).\n         * For headlen use 8, it's a good arrow head size.\n         *\n         * Example:\n         *    buildArrowHead( new Vertex(0,0), new Vertex(50,100), 8, 1.0, 1.0 )\n         *\n         * @param {Vertex} zA - The start vertex of the vector to calculate the arrow head for.\n         * @param {Vertex} zB - The end vertex of the vector.\n         * @param {number} headlen - The length of the arrow head (along the vector direction. A good value is 12).\n         * @param {number} scaleX  - The horizontal scaling during draw.\n         * @param {number} scaleY  - the vertical scaling during draw.\n         **/\n        // @DEPRECATED: use Vector.utils.buildArrowHead instead!!!\n        buildArrowHead: function (zA, zB, headlen, scaleX, scaleY) {\n            // console.warn('This function is deprecated! Use Vector.utils.buildArrowHead instead!');\n            var angle = Math.atan2((zB.y - zA.y) * scaleY, (zB.x - zA.x) * scaleX);\n            var vertices = [];\n            vertices.push(new Vertex(zB.x * scaleX - (headlen) * Math.cos(angle), zB.y * scaleY - (headlen) * Math.sin(angle)));\n            vertices.push(new Vertex(zB.x * scaleX - (headlen * 1.35) * Math.cos(angle - Math.PI / 8), zB.y * scaleY - (headlen * 1.35) * Math.sin(angle - Math.PI / 8)));\n            vertices.push(new Vertex(zB.x * scaleX, zB.y * scaleY));\n            vertices.push(new Vertex(zB.x * scaleX - (headlen * 1.35) * Math.cos(angle + Math.PI / 8), zB.y * scaleY - (headlen * 1.35) * Math.sin(angle + Math.PI / 8)));\n            return vertices;\n        }\n    };\n    return Vertex;\n}());\nexports.Vertex = Vertex;\n//# sourceMappingURL=Vertex.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2018-08-26\n * @modified 2018-11-17 Added the 'isSelected' attribute.\n * @modified 2018-11-27 Added the global model for instantiating with custom attributes.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2020-02-29 Added the 'selectable' attribute.\n * @modified 2020-03-23 Ported to Typescript from JS.\n * @version  1.1.1\n *\n * @file VertexAttr\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.VertexAttr = void 0;\n/**\n * @classdesc The VertexAttr is a helper class to wrap together additional attributes\n * to vertices that do not belong to the 'standard canonical' vertex implementation.<br>\n * <br>\n * This is some sort of 'userData' object, but the constructor uses a global model\n * to obtain a (configurable) default attribute set to all instances.<br>\n */\nvar VertexAttr = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * Attributes will be initialized as defined in the model object\n     * which serves as a singleton.\n     *\n     * @constructor\n     * @name VertexAttr\n     **/\n    function VertexAttr() {\n        this.draggable = true;\n        this.selectable = true;\n        this.isSelected = false;\n        this.visible = true;\n        for (var key in VertexAttr.model)\n            this[key] = VertexAttr.model[key];\n    }\n    ;\n    /**\n     * This is the global attribute model. Set these object on the initialization\n     * of your app to gain all VertexAttr instances have these attributes.\n     *\n     * @type {object}\n     **/\n    VertexAttr.model = {\n        draggable: true,\n        selectable: true,\n        isSelected: false,\n        visible: true\n    };\n    return VertexAttr;\n}());\nexports.VertexAttr = VertexAttr;\n//# sourceMappingURL=VertexAttr.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2018-08-27\n * @modified 2018-11-28 Added the vertex-param to the constructor and extended the event. Vertex events now have a 'params' attribute object.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2020-02-22 Added 'return this' to the add* functions (for chanining).\n * @modified 2020-03-23 Ported to Typescript from JS.\n * @modified 2020-11-17 Added the `click` handler.\n * @version  1.1.0\n *\n * @file VertexListeners\n * @public\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.VertexListeners = void 0;\n/**\n * @classdesc An event listeners wrapper. This is just a set of three listener\n *              queues (drag, dragStart, dragEnd) and their respective firing\n *              functions.\n *\n */\nvar VertexListeners = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name VertexListeners\n     * @param {Vertex} vertex - The vertex to use these listeners on (just a backward reference).\n     **/\n    function VertexListeners(vertex) {\n        this.click = [];\n        this.drag = [];\n        this.dragStart = [];\n        this.dragEnd = [];\n        this.vertex = vertex;\n    }\n    ;\n    /**\n     * Add a click listener.\n     *\n     * @method addClickListener\n     * @param {VertexListeners~dragListener} listener - The click listener to add (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.addClickListener = function (listener) {\n        VertexListeners._addListener(this.click, listener);\n        return this;\n    };\n    ;\n    /**\n     * The click listener is a function with a single drag event param.\n     * @callback VertexListeners~clickListener\n     * @param {Event} e - The (extended) click event.\n     */\n    /**\n     * Remove a drag listener.\n     *\n     * @method removeDragListener\n     * @param {VertexListeners~dragListener} listener - The drag listener to remove (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.removeClickListener = function (listener) {\n        this.click = VertexListeners._removeListener(this.click, listener);\n        return this;\n    };\n    ;\n    /**\n     * The click listener is a function with a single drag event param.\n     * @callback VertexListeners~clickListener\n     * @param {Event} e - The (extended) click event.\n     */\n    /**\n     * Add a drag listener.\n     *\n     * @method addDragListener\n     * @param {VertexListeners~dragListener} listener - The drag listener to add (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.addDragListener = function (listener) {\n        VertexListeners._addListener(this.drag, listener);\n        return this;\n    };\n    ;\n    /**\n     * The drag listener is a function with a single drag event param.\n     * @callback VertexListeners~dragListener\n     * @param {Event} e - The (extended) drag event.\n     */\n    /**\n     * Remove a drag listener.\n     *\n     * @method removeDragListener\n     * @param {VertexListeners~dragListener} listener - The drag listener to remove (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.removeDragListener = function (listener) {\n        this.drag = VertexListeners._removeListener(this.drag, listener);\n        return this;\n    };\n    ;\n    /**\n     * Add a dragStart listener.\n     *\n     * @method addDragListener\n     * @param {VertexListeners~dragStartListener} listener - The drag-start listener to add (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.addDragStartListener = function (listener) {\n        VertexListeners._addListener(this.dragStart, listener);\n        return this;\n    };\n    ;\n    /**\n     * The drag-start listener is a function with a single drag event param.\n     * @callback VertexListeners~dragStartListener\n     * @param {Event} e - The (extended) drag event.\n     */\n    /**\n     * Remove a dragStart listener.\n     *\n     * @method addDragStartListener\n     * @param {VertexListeners~dragListener} listener - The drag listener to remove (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.removeDragStartListener = function (listener) {\n        this.dragStart = VertexListeners._removeListener(this.dragStart, listener);\n        return this;\n    };\n    ;\n    /**\n     * Add a dragEnd listener.\n     *\n     * @method addDragListener\n     * @param {VertexListeners~dragEndListener} listener - The drag-end listener to add (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.addDragEndListener = function (listener) {\n        // this.dragEnd.push( listener );\n        VertexListeners._addListener(this.dragEnd, listener);\n        return this;\n    };\n    ;\n    /**\n     * The drag-end listener is a function with a single drag event param.\n     * @callback VertexListeners~dragEndListener\n     * @param {Event} e - The (extended) drag event.\n     */\n    /**\n    * Remove a drag listener.\n    *\n    * @method removeDragEndListener\n    * @param {VertexListeners~clickListener} listener - The drag listener to remove (a callback).\n    * @return {VertexListeners} this (for chaining)\n    * @instance\n    * @memberof VertexListeners\n    **/\n    VertexListeners.prototype.removeDragEndListener = function (listener) {\n        // this.drag.push( listener );\n        this.dragEnd = VertexListeners._removeListener(this.dragEnd, listener);\n        return this;\n    };\n    ;\n    /**\n     * Fire a click event with the given event instance to all\n     * installed click listeners.\n     *\n     * @method fireClickEvent\n     * @param {VertEvent|XMouseEvent} e - The click event itself to be fired to all installed drag listeners.\n     * @return {void}\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.fireClickEvent = function (e) {\n        VertexListeners._fireEvent(this, this.click, e);\n    };\n    ;\n    /**\n     * Fire a drag event with the given event instance to all\n     * installed drag listeners.\n     *\n     * @method fireDragEvent\n     * @param {VertEvent|XMouseEvent} e - The drag event itself to be fired to all installed drag listeners.\n     * @return {void}\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.fireDragEvent = function (e) {\n        VertexListeners._fireEvent(this, this.drag, e);\n    };\n    ;\n    /**\n     * Fire a dragStart event with the given event instance to all\n     * installed drag-start listeners.\n     *\n     * @method fireDragStartEvent\n     * @param {VertEvent|XMouseEvent} e - The drag-start event itself to be fired to all installed dragStart listeners.\n     * @return {void}\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.fireDragStartEvent = function (e) {\n        VertexListeners._fireEvent(this, this.dragStart, e);\n    };\n    ;\n    /**\n     * Fire a dragEnd event with the given event instance to all\n     * installed drag-end listeners.\n     *\n     * @method fireDragEndEvent\n     * @param {VertEvent|XMouseEvent} e - The drag-end event itself to be fired to all installed dragEnd listeners.\n     * @return {void}\n     * @instance\n     * @memberof VertexListeners\n     **/\n    VertexListeners.prototype.fireDragEndEvent = function (e) {\n        VertexListeners._fireEvent(this, this.dragEnd, e);\n    };\n    ;\n    /**\n     * @private\n     **/\n    VertexListeners._fireEvent = function (_self, listeners, e) {\n        var ve = e;\n        if (typeof ve.params == 'undefined')\n            ve.params = { vertex: _self.vertex };\n        else\n            ve.params.vertex = _self.vertex;\n        for (var i in listeners) {\n            listeners[i](ve);\n        }\n    };\n    ;\n    /**\n     * @private\n     */\n    VertexListeners._addListener = function (listeners, newListener) {\n        for (var i in listeners) {\n            if (listeners[i] == newListener)\n                return false;\n        }\n        listeners.push(newListener);\n        return true;\n    };\n    ;\n    /**\n     * @private\n     */\n    VertexListeners._removeListener = function (listeners, oldListener) {\n        for (var i = 0; i < listeners.length; i++) {\n            if (listeners[i] == oldListener)\n                return listeners.splice(i, 1);\n        }\n        return listeners;\n    };\n    ;\n    return VertexListeners;\n}());\nexports.VertexListeners = VertexListeners;\n//# sourceMappingURL=VertexListeners.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2018-04-22\n * @modified 2018-08-16 Added the curve() function to draw cubic bézier curves.\n * @modified 2018-10-23 Recognizing the offset param in the circle() function.\n * @modified 2018-11-27 Added the diamondHandle() function.\n * @modified 2018-11-28 Added the grid() function and the ellipse() function.\n * @modified 2018-11-30 Renamed the text() function to label() as it is not scaling.\n * @modified 2018-12-06 Added a test function for drawing arc in SVG style.\n * @modified 2018-12-09 Added the dot(Vertex,color) function (copied from Feigenbaum-plot-script).\n * @modified 2019-01-30 Added the arrow(Vertex,Vertex,color) function for drawing arrow heads.\n * @modified 2019-01-30 Added the image(Image,Vertex,Vertex) function for drawing images.\n * @modified 2019-04-27 Fixed a severe drawing bug in the arrow(...) function. Scaling arrows did not work properly.\n * @modified 2019-04-28 Added Math.round to the dot() drawing parameters to really draw a singlt dot.\n * @modified 2019-06-07 Fixed an issue in the cubicBezier() function. Paths were always closed.\n * @modified 2019-10-03 Added the beginDrawCycle hook.\n * @modified 2019-10-25 Polygons are no longer drawn with dashed lines (solid lines instead).\n * @modified 2019-11-18 Added the polyline function.\n * @modified 2019-11-22 Added a second workaround for th drawImage bug in Safari.\n * @modified 2019-12-07 Added the 'lineWidth' param to the line(...) function.\n * @modified 2019-12-07 Added the 'lineWidth' param to the cubicBezier(...) function.\n * @modified 2019-12-11 Added the 'color' param to the label(...) function.\n * @modified 2019-12-18 Added the quadraticBezier(...) function (for the sake of approximating Lissajous curves).\n * @modified 2019-12-20 Added the 'lineWidth' param to the polyline(...) function.\n * @modified 2020-01-09 Added the 'lineWidth' param to the ellipse(...) function.\n * @modified 2020-03-25 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-05-05 Added the 'lineWidth' param to the circle(...) function.\n * @modified 2020-05-12 Drawing any handles (square, circle, diamond) with lineWidth 1 now; this was not reset before.\n * @modified 2020-06-22 Added a context.clearRect() call to the clear() function; clearing with alpha channel did not work as expected.\n * @modified 2020-09-07 Added the circleArc(...) function to draw sections of circles.\n * @modified 2020-10-06 Removed the .closePath() instruction from the circleArc function.\n * @modified 2020-10-15 Re-added the text() function.\n * @modified 2020-10-28 Added the path(Path2D) function.\n * @modified 2020-12-28 Added the `singleSegment` mode (test).\n * @modified 2021-01-05 Added the image-loaded/broken check.\n * @modified 2021-01-24 Added the `setCurrentId` function from the `DrawLib` interface.\n * @version  1.8.3\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.drawutils = void 0;\nvar CubicBezierCurve_1 = require(\"./CubicBezierCurve\");\nvar Vertex_1 = require(\"./Vertex\");\n// Todo: rename this class to Drawutils\n/**\n * @classdesc A wrapper class for basic drawing operations.\n *\n * @requires CubicBzierCurvce\n * @requires Polygon\n * @requires SVGSerializable\n * @requires Vertex\n * @requires XYCoords\n */\nvar drawutils = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name drawutils\n     * @param {anvasRenderingContext2D} context - The drawing context.\n     * @param {boolean} fillShaped - Indicates if the constructed drawutils should fill all drawn shapes (if possible).\n     **/\n    function drawutils(context, fillShapes) {\n        this.ctx = context;\n        this.offset = new Vertex_1.Vertex(0, 0);\n        this.scale = new Vertex_1.Vertex(1, 1);\n        this.fillShapes = fillShapes;\n    }\n    ;\n    /**\n     * Called before each draw cycle.\n     * @param {UID=} uid - (optional) A UID identifying the currently drawn element(s).\n     **/\n    drawutils.prototype.beginDrawCycle = function (renderTime) {\n        // NOOP\n    };\n    ;\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * It is used by some libraries for identifying elemente on re-renders.\n     *\n     * @name setCurrentId\n     * @method\n     * @param {UID} uid - A UID identifying the currently drawn element(s).\n     **/\n    drawutils.prototype.setCurrentId = function (uid) {\n        // NOOP\n    };\n    ;\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * Determine the class name for further usage here.\n     *\n     * @name setCurrentClassName\n     * @method\n     * @param {string} className - A class name for further custom use cases.\n     **/\n    drawutils.prototype.setCurrentClassName = function (className) {\n        // NOOP\n    };\n    ;\n    /**\n     * Draw the line between the given two points with the specified (CSS-) color.\n     *\n     * @method line\n     * @param {Vertex} zA - The start point of the line.\n     * @param {Vertex} zB - The end point of the line.\n     * @param {string} color - Any valid CSS color string.\n     * @param {number} lineWidth? - [optional] The line's width.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    drawutils.prototype.line = function (zA, zB, color, lineWidth) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + zA.x * this.scale.x, this.offset.y + zA.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + zB.x * this.scale.x, this.offset.y + zB.y * this.scale.y);\n        this.ctx.strokeStyle = color;\n        this.ctx.lineWidth = lineWidth || 1;\n        this.ctx.stroke();\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method arrow\n     * @param {Vertex} zA - The start point of the arrow-line.\n     * @param {Vertex} zB - The end point of the arrow-line.\n     * @param {string} color - Any valid CSS color string.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    drawutils.prototype.arrow = function (zA, zB, color, lineWidth) {\n        var headlen = 8; // length of head in pixels\n        // var vertices = PlotBoilerplate.utils.buildArrowHead( zA, zB, headlen, this.scale.x, this.scale.y );\n        // var vertices : Array<Vertex> = Vertex.utils.buildArrowHead( zA, zB, headlen, this.scale.x, this.scale.y );\n        this.ctx.save();\n        this.ctx.beginPath();\n        var vertices = Vertex_1.Vertex.utils.buildArrowHead(zA, zB, headlen, this.scale.x, this.scale.y);\n        this.ctx.moveTo(this.offset.x + zA.x * this.scale.x, this.offset.y + zA.y * this.scale.y);\n        for (var i = 0; i < vertices.length; i++) {\n            this.ctx.lineTo(this.offset.x + vertices[i].x, this.offset.y + vertices[i].y);\n        }\n        this.ctx.lineTo(this.offset.x + vertices[0].x, this.offset.y + vertices[0].y);\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Draw an image at the given position with the given size.<br>\n     * <br>\n     * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method image\n     * @param {Image} image - The image object to draw.\n     * @param {Vertex} position - The position to draw the the upper left corner at.\n     * @param {Vertex} size - The x/y-size to draw the image with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    drawutils.prototype.image = function (image, position, size) {\n        if (!image.complete || !image.naturalWidth) {\n            // Avoid drawing un-unloaded or broken images\n            return;\n        }\n        this.ctx.save();\n        // Note that there is a Safari bug with the 3 or 5 params variant.\n        // Only the 9-param varaint works.\n        this.ctx.drawImage(image, 0, 0, image.naturalWidth - 1, // There is this horrible Safari bug (fixed in newer versions)\n        image.naturalHeight - 1, // To avoid errors substract 1 here.\n        this.offset.x + position.x * this.scale.x, this.offset.y + position.y * this.scale.y, size.x * this.scale.x, size.y * this.scale.y);\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Draw a rectangle.\n     *\n     * @param {Vertex} position - The upper left corner of the rectangle.\n     * @param {number} width - The width of the rectangle.\n     * @param {number} height - The height of the rectangle.\n     * @param {string} color - The color to use.\n     * @param {number=1} lineWidth - (optional) The line with to use (default is 1).\n     **/\n    drawutils.prototype.rect = function (position, width, height, color, lineWidth) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + position.x * this.scale.x, this.offset.y + position.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + (position.x + width) * this.scale.x, this.offset.y + position.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + (position.x + width) * this.scale.x, this.offset.y + (position.y + height) * this.scale.y);\n        this.ctx.lineTo(this.offset.x + position.x * this.scale.x, this.offset.y + (position.y + height) * this.scale.y);\n        // this.ctx.lineTo( this.offset.x+position.x*this.scale.x, this.offset.y+position.y*this.scale.y );\n        this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    };\n    ;\n    // +---------------------------------------------------------------------------------\n    // | This is the final helper function for drawing and filling stuff. It is not\n    // | intended to be used from the outside.\n    // |\n    // | When in draw mode it draws the current shape.\n    // | When in fill mode it fills the current shape.\n    // |\n    // | This function is usually only called internally.\n    // |\n    // | @param color A stroke/fill color to use.\n    // +-------------------------------\n    // TODO: convert this to a STATIC function.\n    drawutils.prototype._fillOrDraw = function (color) {\n        if (this.fillShapes) {\n            this.ctx.fillStyle = color;\n            this.ctx.fill();\n        }\n        else {\n            this.ctx.strokeStyle = color;\n            this.ctx.stroke();\n        }\n    };\n    ;\n    /**\n     * Draw the given (cubic) bézier curve.\n     *\n     * @method cubicBezier\n     * @param {Vertex} startPoint - The start point of the cubic Bézier curve\n     * @param {Vertex} endPoint   - The end point the cubic Bézier curve.\n     * @param {Vertex} startControlPoint - The start control point the cubic Bézier curve.\n     * @param {Vertex} endControlPoint   - The end control point the cubic Bézier curve.\n     * @param {string} color - The CSS color to draw the curve with.\n     * @param {number} lineWidth - (optional) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.cubicBezier = function (startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth) {\n        if (startPoint instanceof CubicBezierCurve_1.CubicBezierCurve) {\n            this.cubicBezier(startPoint.startPoint, startPoint.endPoint, startPoint.startControlPoint, startPoint.endControlPoint, color, lineWidth);\n            return;\n        }\n        // Draw curve\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + startPoint.x * this.scale.x, this.offset.y + startPoint.y * this.scale.y);\n        this.ctx.bezierCurveTo(this.offset.x + startControlPoint.x * this.scale.x, this.offset.y + startControlPoint.y * this.scale.y, this.offset.x + endControlPoint.x * this.scale.x, this.offset.y + endControlPoint.y * this.scale.y, this.offset.x + endPoint.x * this.scale.x, this.offset.y + endPoint.y * this.scale.y);\n        //this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 2;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Draw the given (quadratic) bézier curve.\n     *\n     * @method quadraticBezier\n     * @param {Vertex} startPoint   - The start point of the cubic Bézier curve\n     * @param {Vertex} controlPoint - The control point the cubic Bézier curve.\n     * @param {Vertex} endPoint     - The end control point the cubic Bézier curve.\n     * @param {string} color        - The CSS color to draw the curve with.\n     * @param {number|string} lineWidth - (optional) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.quadraticBezier = function (startPoint, controlPoint, endPoint, color, lineWidth) {\n        // Draw curve\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + startPoint.x * this.scale.x, this.offset.y + startPoint.y * this.scale.y);\n        this.ctx.quadraticCurveTo(this.offset.x + controlPoint.x * this.scale.x, this.offset.y + controlPoint.y * this.scale.y, this.offset.x + endPoint.x * this.scale.x, this.offset.y + endPoint.y * this.scale.y);\n        this.ctx.lineWidth = lineWidth || 2;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Draw the given (cubic) Bézier path.\n     *\n     * The given path must be an array with n*3+1 vertices, where n is the number of\n     * curves in the path:\n     * <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>\n     *\n     * @method cubicBezierPath\n     * @param {Vertex[]} path - The cubic bezier path as described above.\n     * @param {string} color - The CSS colot to draw the path with.\n     * @param {number=1} lineWidth - (optional) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.cubicBezierPath = function (path, color, lineWidth) {\n        if (!path || path.length == 0)\n            return;\n        // Draw curve\n        this.ctx.save();\n        this.ctx.beginPath();\n        var curve, startPoint, endPoint, startControlPoint, endControlPoint;\n        this.ctx.moveTo(this.offset.x + path[0].x * this.scale.x, this.offset.y + path[0].y * this.scale.y);\n        for (var i = 1; i < path.length; i += 3) {\n            startControlPoint = path[i];\n            endControlPoint = path[i + 1];\n            endPoint = path[i + 2];\n            this.ctx.bezierCurveTo(this.offset.x + startControlPoint.x * this.scale.x, this.offset.y + startControlPoint.y * this.scale.y, this.offset.x + endControlPoint.x * this.scale.x, this.offset.y + endControlPoint.y * this.scale.y, this.offset.x + endPoint.x * this.scale.x, this.offset.y + endPoint.y * this.scale.y);\n        }\n        this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Draw the given handle and handle point (used to draw interactive Bézier curves).\n     *\n     * The colors for this are fixed and cannot be specified.\n     *\n     * @method handle\n     * @param {Vertex} startPoint - The start of the handle.\n     * @param {Vertex} endPoint - The end point of the handle.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.handle = function (startPoint, endPoint) {\n        // Draw handles\n        // (No need to save and restore here)\n        this.point(startPoint, 'rgb(0,32,192)');\n        this.square(endPoint, 5, 'rgba(0,128,192,0.5)');\n    };\n    ;\n    /**\n     * Draw a handle line (with a light grey).\n     *\n     * @method handleLine\n     * @param {Vertex} startPoint - The start point to draw the handle at.\n     * @param {Vertex} endPoint - The end point to draw the handle at.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.handleLine = function (startPoint, endPoint) {\n        // Draw handle lines\n        this.line(startPoint, endPoint, 'rgb(192,192,192)');\n    };\n    ;\n    /**\n     * Draw a 1x1 dot with the specified (CSS-) color.\n     *\n     * @method dot\n     * @param {Vertex} p - The position to draw the dot at.\n     * @param {string} color - The CSS color to draw the dot with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.dot = function (p, color) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(Math.round(this.offset.x + this.scale.x * p.x), Math.round(this.offset.y + this.scale.y * p.y));\n        this.ctx.lineTo(Math.round(this.offset.x + this.scale.x * p.x + 1), Math.round(this.offset.y + this.scale.y * p.y + 1));\n        this.ctx.closePath();\n        this.ctx.lineWidth = 1;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Draw the given point with the specified (CSS-) color and radius 3.\n     *\n     * @method point\n     * @param {Vertex} p - The position to draw the point at.\n     * @param {string} color - The CSS color to draw the point with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.point = function (p, color) {\n        var radius = 3;\n        this.ctx.beginPath();\n        this.ctx.arc(this.offset.x + p.x * this.scale.x, this.offset.y + p.y * this.scale.y, radius, 0, 2 * Math.PI, false);\n        this.ctx.closePath();\n        this.ctx.lineWidth = 1;\n        this._fillOrDraw(color);\n    };\n    ;\n    /**\n     * Draw a circle with the specified (CSS-) color and radius.<br>\n     * <br>\n     * Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.\n     *\n     * @method circle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @param {number} lineWidth - The line width (optional, default=1).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.circle = function (center, radius, color, lineWidth) {\n        this.ctx.beginPath();\n        this.ctx.ellipse(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y, radius * this.scale.x, radius * this.scale.y, 0.0, 0.0, Math.PI * 2);\n        this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n    };\n    ;\n    /**\n     * Draw a circular arc (section of a circle) with the given CSS color.\n     *\n     * @method circleArc\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {number} startAngle - The angle to start at.\n     * @param {number} endAngle - The angle to end at.\n     * @param {string=#000000} color - The CSS color to draw the circle with.\n     * @param {number=1} lineWidth - The line width to use\n     // * @param {boolean=false} options.asSegment - If `true` then no beginPath and no draw will be applied (as part of larger path).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.circleArc = function (center, radius, startAngle, endAngle, color, lineWidth, options) {\n        if (!options || !options.asSegment) {\n            this.ctx.beginPath();\n        }\n        this.ctx.ellipse(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y, radius * this.scale.x, radius * this.scale.y, 0.0, startAngle, endAngle, false);\n        if (!options || !options.asSegment) {\n            // this.ctx.closePath();\n            this.ctx.lineWidth = lineWidth || 1;\n            this._fillOrDraw(color || '#000000');\n        }\n    };\n    ;\n    /**\n     * Draw an ellipse with the specified (CSS-) color and thw two radii.\n     *\n     * @method ellipse\n     * @param {Vertex} center - The center of the ellipse.\n     * @param {number} radiusX - The radius of the ellipse.\n     * @param {number} radiusY - The radius of the ellipse.\n     * @param {string} color - The CSS color to draw the ellipse with.\n     * @param {number} lineWidth=1 - An optional line width param (default is 1).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.ellipse = function (center, radiusX, radiusY, color, lineWidth) {\n        this.ctx.beginPath();\n        this.ctx.ellipse(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y, radiusX * this.scale.x, radiusY * this.scale.y, 0.0, 0.0, Math.PI * 2);\n        this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n    };\n    ;\n    /**\n     * Draw square at the given center, size and with the specified (CSS-) color.<br>\n     * <br>\n     * Note that if the x-scale and the y-scale are different the result will be a rectangle rather than a square.\n     *\n     * @method square\n     * @param {Vertex} center - The center of the square.\n     * @param {Vertex} size - The size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @param {number} lineWidth - The line with to use (optional, default is 1).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.square = function (center, size, color, lineWidth) {\n        this.ctx.beginPath();\n        this.ctx.rect(this.offset.x + (center.x - size / 2.0) * this.scale.x, this.offset.y + (center.y - size / 2.0) * this.scale.y, size * this.scale.x, size * this.scale.y);\n        this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n    };\n    ;\n    /**\n     * Draw a grid of horizontal and vertical lines with the given (CSS-) color.\n     *\n     * @method grid\n     * @param {Vertex} center - The center of the grid.\n     * @param {number} width - The total width of the grid (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal grid size.\n     * @param {number} sizeY - The vertical grid size.\n     * @param {string} color - The CSS color to draw the grid with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.grid = function (center, width, height, sizeX, sizeY, color) {\n        this.ctx.beginPath();\n        var yMin = -Math.ceil((height * 0.5) / sizeY) * sizeY;\n        var yMax = height / 2;\n        for (var x = -Math.ceil((width * 0.5) / sizeX) * sizeX; x < width / 2; x += sizeX) {\n            this.ctx.moveTo(this.offset.x + (center.x + x) * this.scale.x, this.offset.y + (center.y + yMin) * this.scale.y);\n            this.ctx.lineTo(this.offset.x + (center.x + x) * this.scale.x, this.offset.y + (center.y + yMax) * this.scale.y);\n        }\n        var xMin = -Math.ceil((width * 0.5) / sizeX) * sizeX; // -Math.ceil((height*0.5)/sizeY)*sizeY;\n        var xMax = width / 2; // height/2;\n        for (var y = -Math.ceil((height * 0.5) / sizeY) * sizeY; y < height / 2; y += sizeY) {\n            this.ctx.moveTo(this.offset.x + (center.x + xMin) * this.scale.x - 4, this.offset.y + (center.y + y) * this.scale.y);\n            this.ctx.lineTo(this.offset.x + (center.x + xMax) * this.scale.x + 4, this.offset.y + (center.y + y) * this.scale.y);\n        }\n        this.ctx.strokeStyle = color;\n        this.ctx.lineWidth = 1.0;\n        this.ctx.stroke();\n        this.ctx.closePath();\n    };\n    ;\n    /**\n     * Draw a raster of crosshairs in the given grid.<br>\n     *\n     * This works analogue to the grid() function\n     *\n     * @method raster\n     * @param {Vertex} center - The center of the raster.\n     * @param {number} width - The total width of the raster (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal raster size.\n     * @param {number} sizeY - The vertical raster size.\n     * @param {string} color - The CSS color to draw the raster with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.raster = function (center, width, height, sizeX, sizeY, color) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        var cx = 0, cy = 0;\n        for (var x = -Math.ceil((width * 0.5) / sizeX) * sizeX; x < width / 2; x += sizeX) {\n            cx++;\n            for (var y = -Math.ceil((height * 0.5) / sizeY) * sizeY; y < height / 2; y += sizeY) {\n                if (cx == 1)\n                    cy++;\n                // Draw a crosshair\n                this.ctx.moveTo(this.offset.x + (center.x + x) * this.scale.x - 4, this.offset.y + (center.y + y) * this.scale.y);\n                this.ctx.lineTo(this.offset.x + (center.x + x) * this.scale.x + 4, this.offset.y + (center.y + y) * this.scale.y);\n                this.ctx.moveTo(this.offset.x + (center.x + x) * this.scale.x, this.offset.y + (center.y + y) * this.scale.y - 4);\n                this.ctx.lineTo(this.offset.x + (center.x + x) * this.scale.x, this.offset.y + (center.y + y) * this.scale.y + 4);\n            }\n        }\n        this.ctx.strokeStyle = color;\n        this.ctx.lineWidth = 1.0;\n        this.ctx.stroke();\n        this.ctx.closePath();\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Draw a diamond handle (square rotated by 45°) with the given CSS color.\n     *\n     * It is an inherent feature of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped diamonds.\n     *\n     * @method diamondHandle\n     * @param {Vertex} center - The center of the diamond.\n     * @param {Vertex} size - The x/y-size of the diamond.\n     * @param {string} color - The CSS color to draw the diamond with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.diamondHandle = function (center, size, color) {\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + center.x * this.scale.x - size / 2.0, this.offset.y + center.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y - size / 2.0);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x + size / 2.0, this.offset.y + center.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y + size / 2.0);\n        this.ctx.closePath();\n        this.ctx.lineWidth = 1;\n        this._fillOrDraw(color);\n    };\n    ;\n    /**\n     * Draw a square handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent feature of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped squares.\n     *\n     * @method squareHandle\n     * @param {Vertex} center - The center of the square.\n     * @param {Vertex} size - The x/y-size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.squareHandle = function (center, size, color) {\n        this.ctx.beginPath();\n        this.ctx.rect(this.offset.x + center.x * this.scale.x - size / 2.0, this.offset.y + center.y * this.scale.y - size / 2.0, size, size);\n        this.ctx.closePath();\n        this.ctx.lineWidth = 1;\n        this._fillOrDraw(color);\n    };\n    ;\n    /**\n     * Draw a circle handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent feature of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped circles.\n     *\n     * @method circleHandle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.circleHandle = function (center, radius, color) {\n        radius = radius || 3;\n        this.ctx.beginPath();\n        this.ctx.arc(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y, radius, 0, 2 * Math.PI, false);\n        this.ctx.closePath();\n        this.ctx.lineWidth = 1;\n        this._fillOrDraw(color);\n    };\n    ;\n    /**\n     * Draw a crosshair with given radius and color at the given position.<br>\n     * <br>\n     * Note that the crosshair radius will not be affected by scaling.\n     *\n     * @method crosshair\n     * @param {XYCoords} center - The center of the crosshair.\n     * @param {number} radius - The radius of the crosshair.\n     * @param {string} color - The CSS color to draw the crosshair with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.crosshair = function (center, radius, color) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + center.x * this.scale.x - radius, this.offset.y + center.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x + radius, this.offset.y + center.y * this.scale.y);\n        this.ctx.moveTo(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y - radius);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y + radius);\n        this.ctx.strokeStyle = color;\n        this.ctx.lineWidth = 0.5;\n        this.ctx.stroke();\n        this.ctx.closePath();\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Draw a polygon.\n     *\n     * @method polygon\n     * @param {Polygon}  polygon - The polygon to draw.\n     * @param {string}   color - The CSS color to draw the polygon with.\n     * @param {string}   lineWidth - The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.polygon = function (polygon, color, lineWidth) {\n        this.polyline(polygon.vertices, polygon.isOpen, color, lineWidth);\n    };\n    ;\n    /**\n     * Draw a polygon line (alternative function to the polygon).\n     *\n     * @method polyline\n     * @param {Vertex[]} vertices   - The polygon vertices to draw.\n     * @param {boolan}   isOpen     - If true the polyline will not be closed at its end.\n     * @param {string}   color      - The CSS color to draw the polygon with.\n     * @param {number}   lineWidth  - The line width (default is 1.0);\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.polyline = function (vertices, isOpen, color, lineWidth) {\n        if (vertices.length <= 1)\n            return;\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.lineWidth = lineWidth || 1.0;\n        this.ctx.moveTo(this.offset.x + vertices[0].x * this.scale.x, this.offset.y + vertices[0].y * this.scale.y);\n        for (var i = 0; i < vertices.length; i++) {\n            this.ctx.lineTo(this.offset.x + vertices[i].x * this.scale.x, this.offset.y + vertices[i].y * this.scale.y);\n        }\n        if (!isOpen) // && vertices.length > 2 )\n            this.ctx.closePath();\n        this._fillOrDraw(color);\n        this.ctx.closePath();\n        this.ctx.setLineDash([]);\n        this.ctx.restore();\n    };\n    ;\n    drawutils.prototype.text = function (text, x, y, options) {\n        options = options || {};\n        this.ctx.save();\n        x = this.offset.x + x * this.scale.x;\n        y = this.offset.y + y * this.scale.y;\n        var color = options.color || 'black';\n        if (this.fillShapes) {\n            this.ctx.fillStyle = color;\n            this.ctx.fillText(text, x, y);\n        }\n        else {\n            this.ctx.strokeStyle = color;\n            this.ctx.strokeText(text, x, y);\n        }\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Draw a non-scaling text label at the given position.\n     *\n     * Note that these are absolute label positions, they are not affected by offset or scale.\n     *\n     * @method label\n     * @param {string} text - The text to draw.\n     * @param {number} x - The x-position to draw the text at.\n     * @param {number} y - The y-position to draw the text at.\n     * @param {number=} rotation - The (optional) rotation in radians (default=0).\n     * @param {string=} color - The color to render the text with (default=black).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutils.prototype.label = function (text, x, y, rotation, color) {\n        this.ctx.save();\n        this.ctx.translate(x, y);\n        if (typeof rotation != 'undefined')\n            this.ctx.rotate(rotation);\n        this.ctx.fillStyle = color || 'black';\n        if (this.fillShapes) {\n            this.ctx.fillText(text, 0, 0);\n        }\n        else {\n            this.ctx.strokeText(text, 0, 0);\n        }\n        this.ctx.restore();\n    };\n    ;\n    /**\n     * Due to gl compatibility there is a generic 'clear' function required\n     * to avoid accessing the context object itself directly.\n     *\n     * This function just fills the whole canvas with a single color.\n     *\n     * @param {string} color - The color to clear with.\n     **/\n    drawutils.prototype.clear = function (color) {\n        this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);\n        this.ctx.fillStyle = color;\n        this.ctx.fillRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);\n    };\n    ;\n    return drawutils;\n}());\nexports.drawutils = drawutils;\n//# sourceMappingURL=draw.js.map","\"use strict\";\n/**\n * @author   Ikaros Kappler\n * @date     2019-09-18\n * @modified 2019-10-03 Added the beginDrawCycle hook.\n * @modified 2020-03-25 Ported stub to Typescript.\n * @modified 2020-10-15 Re-added the text() function.\n * @modified 2021-01-24 Added the `setCurrentId` function.\n * @version  0.0.5\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.drawutilsgl = void 0;\nvar Vertex_1 = require(\"./Vertex\");\n/**\n * @classdesc A wrapper class for basic drawing operations. This is the WebGL\n * implementation whih sould work with shaders.\n *\n * @requires CubicBzierCurvce\n * @requires Polygon\n * @requires SVGSerializable\n * @requires Vertex\n * @requires XYCoords\n */\nvar drawutilsgl = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name drawutils\n     * @param {WebGLRenderingContext} context - The drawing context.\n     * @param {boolean} fillShaped - Indicates if the constructed drawutils should fill all drawn shapes (if possible).\n     **/\n    function drawutilsgl(context, fillShapes) {\n        this.gl = context;\n        this.offset = new Vertex_1.Vertex(0, 0);\n        this.scale = new Vertex_1.Vertex(1, 1);\n        this.fillShapes = fillShapes;\n        this._zindex = 0.0;\n        if (context == null || typeof context === 'undefined')\n            return;\n        this.glutils = new GLU(context);\n        // PROBLEM: CANNOT USE MULTIPLE SHADER PROGRAM INSTANCES ON THE SAME CONTEXT!\n        // SOLUTION: USE SHARED SHADER PROGRAM!!! ... somehow ...\n        // This needs to be considered in the overlying component; both draw-instances need to\n        // share their gl context.\n        // That's what the copyInstace(boolean) method is good for.\n        this._vertShader = this.glutils.compileShader(drawutilsgl.vertCode, this.gl.VERTEX_SHADER);\n        this._fragShader = this.glutils.compileShader(drawutilsgl.fragCode, this.gl.FRAGMENT_SHADER);\n        this._program = this.glutils.makeProgram(this._vertShader, this._fragShader);\n        // Create an empty buffer object\n        this.vertex_buffer = this.gl.createBuffer();\n        // Bind appropriate array buffer to it\n        // this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertex_buffer);\n        console.log('gl initialized');\n    }\n    ;\n    drawutilsgl.prototype._x2rel = function (x) { return (this.scale.x * x + this.offset.x) / this.gl.canvas.width * 2.0 - 1.0; };\n    ;\n    drawutilsgl.prototype._y2rel = function (y) { return (this.offset.y - this.scale.y * y) / this.gl.canvas.height * 2.0 - 1.0; };\n    ;\n    /**\n     * Creates a 'shallow' (non deep) copy of this instance. This implies\n     * that under the hood the same gl context and gl program will be used.\n     */\n    drawutilsgl.prototype.copyInstance = function (fillShapes) {\n        var copy = new drawutilsgl(null, fillShapes);\n        copy.gl = this.gl;\n        copy.glutils = this.glutils;\n        copy._vertShader = this._vertShader;\n        copy._fragShader = this._fragShader;\n        copy._program = this._program;\n        return copy;\n    };\n    ;\n    /**\n     * Called before each draw cycle.\n     * @param {number} renderTime\n     **/\n    drawutilsgl.prototype.beginDrawCycle = function (renderTime) {\n        this._zindex = 0.0;\n        this.renderTime = renderTime;\n    };\n    ;\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * It is used by some libraries for identifying elemente on re-renders.\n     *\n     * @name setCurrentId\n     * @method\n     * @param {UID} uid - A UID identifying the currently drawn element(s).es.\n     **/\n    drawutilsgl.prototype.setCurrentId = function (uid) {\n        // NOOP\n        this.curId = uid;\n    };\n    ;\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * Determine the class name for further usage here.\n     *\n     * @name setCurrentClassName\n     * @method\n     * @param {string} className - A class name for further custom use cases.\n     **/\n    drawutilsgl.prototype.setCurrentClassName = function (className) {\n        // NOOP\n    };\n    ;\n    /**\n     * Draw the line between the given two points with the specified (CSS-) color.\n     *\n     * @method line\n     * @param {Vertex} zA - The start point of the line.\n     * @param {Vertex} zB - The end point of the line.\n     * @param {string} color - Any valid CSS color string.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    drawutilsgl.prototype.line = function (zA, zB, color) {\n        var vertices = new Float32Array(6);\n        vertices[0] = this._x2rel(zA.x);\n        vertices[1] = this._y2rel(zA.y);\n        vertices[2] = this._zindex;\n        vertices[3] = this._x2rel(zB.x);\n        vertices[4] = this._y2rel(zB.y);\n        vertices[5] = this._zindex;\n        this._zindex += 0.001;\n        // Create an empty buffer object\n        // const vertex_buffer = this.gl.createBuffer();\n        // Bind appropriate array buffer to it\n        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertex_buffer);\n        // Pass the vertex data to the buffer\n        this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW);\n        // Bind vertex buffer object\n        // this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertex_buffer);\n        // Get the attribute location\n        var coord = this.gl.getAttribLocation(this._program, \"position\");\n        // Point an attribute to the currently bound VBO\n        this.gl.vertexAttribPointer(coord, 3, this.gl.FLOAT, false, 0, 0);\n        // Enable the attribute\n        this.gl.enableVertexAttribArray(coord);\n        // Unbind the buffer?\n        //this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);\n        // Set the view port\n        this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);\n        var uRotationVector = this.gl.getUniformLocation(this._program, \"uRotationVector\");\n        // let radians = currentAngle * Math.PI / 180.0;\n        var currentRotation = [0.0, 1.0];\n        //currentRotation[0] = Math.sin(radians);\n        //currentRotation[1] = Math.cos(radians);\n        this.gl.uniform2fv(uRotationVector, currentRotation);\n        this.gl.lineWidth(5);\n        // Draw the line\n        this.gl.drawArrays(this.gl.LINES, 0, vertices.length / 3);\n        // POINTS, LINE_STRIP, LINE_LOOP, LINES,\n        // TRIANGLE_STRIP,TRIANGLE_FAN, TRIANGLES\n    };\n    ;\n    /**\n     * Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method arrow\n     * @param {Vertex} zA - The start point of the arrow-line.\n     * @param {Vertex} zB - The end point of the arrow-line.\n     * @param {string} color - Any valid CSS color string.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    drawutilsgl.prototype.arrow = function (zA, zB, color) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw an image at the given position with the given size.<br>\n     * <br>\n     * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method image\n     * @param {Image} image - The image object to draw.\n     * @param {Vertex} position - The position to draw the the upper left corner at.\n     * @param {Vertex} size - The x/y-size to draw the image with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    drawutilsgl.prototype.image = function (image, position, size) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    // +---------------------------------------------------------------------------------\n    // | This is the final helper function for drawing and filling stuff. It is not\n    // | intended to be used from the outside.\n    // |\n    // | When in draw mode it draws the current shape.\n    // | When in fill mode it fills the current shape.\n    // |\n    // | This function is usually only called internally.\n    // |\n    // | @param color A stroke/fill color to use.\n    // +-------------------------------\n    drawutilsgl.prototype._fillOrDraw = function (color) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw the given (cubic) bézier curve.\n     *\n     * @method cubicBezier\n     * @param {Vertex} startPoint - The start point of the cubic Bézier curve\n     * @param {Vertex} endPoint   - The end point the cubic Bézier curve.\n     * @param {Vertex} startControlPoint - The start control point the cubic Bézier curve.\n     * @param {Vertex} endControlPoint   - The end control point the cubic Bézier curve.\n     * @param {string} color - The CSS color to draw the curve with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.cubicBezier = function (startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw the given (cubic) Bézier path.\n     *\n     * The given path must be an array with n*3+1 vertices, where n is the number of\n     * curves in the path:\n     * <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>\n     *\n     * @method cubicBezierPath\n     * @param {Vertex[]} path - The cubic bezier path as described above.\n     * @param {string} color - The CSS colot to draw the path with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.cubicBezierPath = function (path, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw the given handle and handle point (used to draw interactive Bézier curves).\n     *\n     * The colors for this are fixed and cannot be specified.\n     *\n     * @method handle\n     * @param {Vertex} startPoint - The start of the handle.\n     * @param {Vertex} endPoint - The end point of the handle.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.handle = function (startPoint, endPoint) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a handle line (with a light grey).\n     *\n     * @method handleLine\n     * @param {Vertex} startPoint - The start point to draw the handle at.\n     * @param {Vertex} endPoint - The end point to draw the handle at.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.handleLine = function (startPoint, endPoint) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a 1x1 dot with the specified (CSS-) color.\n     *\n     * @method dot\n     * @param {Vertex} p - The position to draw the dot at.\n     * @param {string} color - The CSS color to draw the dot with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.dot = function (p, color) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw the given point with the specified (CSS-) color and radius 3.\n     *\n     * @method point\n     * @param {Vertex} p - The position to draw the point at.\n     * @param {string} color - The CSS color to draw the point with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.point = function (p, color) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a circle with the specified (CSS-) color and radius.<br>\n     * <br>\n     * Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.\n     *\n     * @method circle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.circle = function (center, radius, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a circular arc (section of a circle) with the given CSS color.\n     *\n     * @method circleArc\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {number} startAngle - The angle to start at.\n     * @param {number} endAngle - The angle to end at.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.circleArc = function (center, radius, startAngle, endAngle, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw an ellipse with the specified (CSS-) color and thw two radii.\n     *\n     * @method ellipse\n     * @param {Vertex} center - The center of the ellipse.\n     * @param {number} radiusX - The radius of the ellipse.\n     * @param {number} radiusY - The radius of the ellipse.\n     * @param {string} color - The CSS color to draw the ellipse with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.ellipse = function (center, radiusX, radiusY, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw square at the given center, size and with the specified (CSS-) color.<br>\n     * <br>\n     * Note that if the x-scale and the y-scale are different the result will be a rectangle rather than a square.\n     *\n     * @method square\n     * @param {Vertex} center - The center of the square.\n     * @param {Vertex} size - The size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.square = function (center, size, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a grid of horizontal and vertical lines with the given (CSS-) color.\n     *\n     * @method grid\n     * @param {Vertex} center - The center of the grid.\n     * @param {number} width - The total width of the grid (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal grid size.\n     * @param {number} sizeY - The vertical grid size.\n     * @param {string} color - The CSS color to draw the grid with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.grid = function (center, width, height, sizeX, sizeY, color) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a raster of crosshairs in the given grid.<br>\n     *\n     * This works analogue to the grid() function\n     *\n     * @method raster\n     * @param {Vertex} center - The center of the raster.\n     * @param {number} width - The total width of the raster (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal raster size.\n     * @param {number} sizeY - The vertical raster size.\n     * @param {string} color - The CSS color to draw the raster with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.raster = function (center, width, height, sizeX, sizeY, color) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a diamond handle (square rotated by 45°) with the given CSS color.\n     *\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped diamonds.\n     *\n     * @method diamondHandle\n     * @param {Vertex} center - The center of the diamond.\n     * @param {Vertex} size - The x/y-size of the diamond.\n     * @param {string} color - The CSS color to draw the diamond with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.diamondHandle = function (center, size, color) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a square handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped squares.\n     *\n     * @method squareHandle\n     * @param {Vertex} center - The center of the square.\n     * @param {Vertex} size - The x/y-size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.squareHandle = function (center, size, color) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a circle handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped circles.\n     *\n     * @method circleHandle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.circleHandle = function (center, size, color) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a crosshair with given radius and color at the given position.<br>\n     * <br>\n     * Note that the crosshair radius will not be affected by scaling.\n     *\n     * @method crosshair\n     * @param {XYCoords} center - The center of the crosshair.\n     * @param {number} radius - The radius of the crosshair.\n     * @param {string} color - The CSS color to draw the crosshair with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.crosshair = function (center, radius, color) {\n        // NOT YET IMPLEMENTED\t\n    };\n    ;\n    /**\n     * Draw a polygon.\n     *\n     * @method polygon\n     * @param {Polygon} polygon - The polygon to draw.\n     * @param {string} color - The CSS color to draw the polygon with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.polygon = function (polygon, color, lineWidth) {\n        var vertices = new Float32Array(polygon.vertices.length * 3);\n        for (var i = 0; i < polygon.vertices.length; i++) {\n            vertices[i * 3 + 0] = this._x2rel(polygon.vertices[i].x);\n            vertices[i * 3 + 1] = this._y2rel(polygon.vertices[i].y);\n            vertices[i * 3 + 2] = this._zindex;\n        }\n        this._zindex += 0.001;\n        //console.log( vertices );\n        // Create an empty buffer object\n        // const vertex_buffer = this.gl.createBuffer();\n        // Bind appropriate array buffer to it\n        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertex_buffer);\n        // Pass the vertex data to the buffer\n        this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW);\n        // Bind vertex buffer object\n        // this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertex_buffer);\n        // Get the attribute location\n        var coord = this.gl.getAttribLocation(this._program, \"position\");\n        // Point an attribute to the currently bound VBO\n        this.gl.vertexAttribPointer(coord, 3, this.gl.FLOAT, false, 0, 0);\n        // Enable the attribute\n        this.gl.enableVertexAttribArray(coord);\n        // Unbind the buffer?\n        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);\n        // Set the view port\n        this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);\n        var uRotationVector = this.gl.getUniformLocation(this._program, \"uRotationVector\");\n        // let radians = currentAngle * Math.PI / 180.0;\n        var currentRotation = [0.0, 1.0];\n        //currentRotation[0] = Math.sin(radians);\n        //currentRotation[1] = Math.cos(radians);\n        this.gl.uniform2fv(uRotationVector, currentRotation);\n        // Draw the polygon\n        this.gl.drawArrays(this.gl.TRIANGLE_FAN, 0, vertices.length / 3);\n        // POINTS, LINE_STRIP, LINE_LOOP, LINES,\n        // TRIANGLE_STRIP,TRIANGLE_FAN, TRIANGLES\n    };\n    ;\n    /**\n     * Draw a polygon line (alternative function to the polygon).\n     *\n     * @method polyline\n     * @param {Vertex[]} vertices - The polygon vertices to draw.\n     * @param {boolan}   isOpen   - If true the polyline will not be closed at its end.\n     * @param {string}   color    - The CSS color to draw the polygon with.\n     * @param {number=}  lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    drawutilsgl.prototype.polyline = function (vertices, isOpen, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    drawutilsgl.prototype.text = function (text, x, y, options) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Draw a non-scaling text label at the given position.\n     *\n     * @method label\n     * @param {string} text - The text to draw.\n     * @param {number} x - The x-position to draw the text at.\n     * @param {number} y - The y-position to draw the text at.\n     * @param {number=} rotation - The (aoptional) rotation in radians.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    // +---------------------------------------------------------------------------------\n    // | Draw a non-scaling text label at the given position.\n    // +-------------------------------\n    drawutilsgl.prototype.label = function (text, x, y, rotation) {\n        // NOT YET IMPLEMENTED\n    };\n    ;\n    /**\n     * Due to gl compatibility there is a generic 'clear' function required\n     * to avoid accessing the context object itself directly.\n     *\n     * This function just fills the whole canvas with a single color.\n     *\n     * @param {string} color - The color to clear with.\n     **/\n    drawutilsgl.prototype.clear = function (color) {\n        // NOT YET IMPLEMENTED\n        // if( typeof color == 'string' )\n        // color = Color.parse(color); // Color class does not yet exist in TS\n        // Clear the canvas\n        this.gl.clearColor(1.0, 1.0, 1.0, 1.0);\n        // Enable the depth test\n        this.gl.enable(this.gl.DEPTH_TEST);\n        // Clear the color and depth buffer\n        this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);\n    };\n    ;\n    // Vertex shader source code\n    drawutilsgl.vertCode = \"\\n    precision mediump float;\\n\\n    attribute vec3 position;\\n\\n    uniform vec2 uRotationVector;\\n\\n    void main(void) {\\n\\tvec2 rotatedPosition = vec2(\\n\\t    position.x * uRotationVector.y +\\n\\t\\tposition.y * uRotationVector.x,\\n\\t    position.y * uRotationVector.y -\\n\\t\\tposition.x * uRotationVector.x\\n\\t);\\n\\n\\tgl_Position = vec4(rotatedPosition, position.z, 1.0);\\n    }\";\n    // Fragment shader source code\n    drawutilsgl.fragCode = \"\\n    precision highp float;\\n\\n    void main(void) {\\n\\tgl_FragColor = vec4(0.0,0.75,1.0,1.0);\\n    }\";\n    return drawutilsgl;\n}());\nexports.drawutilsgl = drawutilsgl;\n/**\n * Some GL helper utils.\n **/\nvar GLU = /** @class */ (function () {\n    function GLU(gl) {\n        this.gl = gl;\n    }\n    ;\n    GLU.prototype.bufferData = function (verts) {\n        // Create an empty buffer object\n        var vbuffer = this.gl.createBuffer();\n        // Bind appropriate array buffer to it\n        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vbuffer);\n        // Pass the vertex data to the buffer\n        this.gl.bufferData(this.gl.ARRAY_BUFFER, verts, this.gl.STATIC_DRAW);\n        // Unbind the buffer\n        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);\n        return vbuffer;\n    };\n    ;\n    /*=================== Shaders ====================*/\n    GLU.prototype.compileShader = function (shaderCode, shaderType) {\n        // Create a vertex shader object\n        var shader = this.gl.createShader(shaderType);\n        // Attach vertex shader source code\n        this.gl.shaderSource(shader, shaderCode);\n        // Compile the vertex shader\n        this.gl.compileShader(shader);\n        var vertStatus = this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS);\n        if (!vertStatus) {\n            console.warn(\"Error in shader:\" + this.gl.getShaderInfoLog(shader));\n            this.gl.deleteShader(shader);\n            return null;\n        }\n        return shader;\n    };\n    ;\n    GLU.prototype.makeProgram = function (vertShader, fragShader) {\n        // Create a shader program object to store\n        // the combined shader program\n        var program = this.gl.createProgram();\n        // Attach a vertex shader\n        this.gl.attachShader(program, vertShader);\n        // Attach a fragment shader\n        this.gl.attachShader(program, fragShader);\n        // Link both the programs\n        this.gl.linkProgram(program);\n        // Use the combined shader program object\n        this.gl.useProgram(program);\n        /*======= Do some cleanup ======*/\n        this.gl.detachShader(program, vertShader);\n        this.gl.detachShader(program, fragShader);\n        this.gl.deleteShader(vertShader);\n        this.gl.deleteShader(fragShader);\n        return program;\n    };\n    ;\n    return GLU;\n}());\n//# sourceMappingURL=drawgl.js.map","\"use strict\";\n/**\n * @author  Ikaros Kappler\n * @date    2019-02-03\n * @version 1.0.0\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.geomutils = void 0;\nvar Line_1 = require(\"./Line\");\nvar Triangle_1 = require(\"./Triangle\");\n/**\n * A collection of usefull geometry utilities.\n *\n * @global\n **/\nexports.geomutils = {\n    /**\n     * Compute the n-section of the angle – described as a triangle (A,B,C) – in point A.\n     *\n     * @param {Vertex} pA - The first triangle point.\n     * @param {Vertex} pB - The second triangle point.\n     * @param {Vertex} pC - The third triangle point.\n     * @param {number} n - The number of desired angle sections (example: 2 means the angle will be divided into two sections,\n     *                      means an returned array with length 1, the middle line).\n     *\n     * @return {Line[]} An array of n-1 lines secting the given angle in point A into n equal sized angle sections. The lines' first vertex is A.\n     */\n    nsectAngle: function (pA, pB, pC, n) {\n        var triangle = new Triangle_1.Triangle(pA, pB, pC);\n        var lineAB = new Line_1.Line(pA, pB);\n        var lineAC = new Line_1.Line(pA, pC);\n        // Compute the slope (theta) of line AB and line AC\n        var thetaAB = lineAB.angle();\n        var thetaAC = lineAC.angle();\n        // Compute the difference; this is the angle between AB and AC\n        var insideAngle = lineAB.angle(lineAC);\n        // We want the inner angles of the triangle, not the outer angle;\n        //   which one is which depends on the triangle 'direction'\n        var clockwise = triangle.determinant() > 0;\n        // For convenience convert the angle [-PI,PI] to [0,2*PI]\n        if (insideAngle < 0)\n            insideAngle = 2 * Math.PI + insideAngle;\n        if (!clockwise)\n            insideAngle = (2 * Math.PI - insideAngle) * (-1);\n        // Scale the rotated lines to the max leg length (looks better)\n        var lineLength = Math.max(lineAB.length(), lineAC.length());\n        var scaleFactor = lineLength / lineAB.length();\n        var result = [];\n        for (var i = 1; i < n; i++) {\n            // Compute the i-th inner sector line\n            result.push(new Line_1.Line(pA, pB.clone().rotate((-i * (insideAngle / n)), pA)).scale(scaleFactor));\n        }\n        return result;\n    }\n};\n//# sourceMappingURL=geomutils.js.map","\"use strict\";\n/**\n * Draws elements into an SVG node.\n *\n * @author   Ikaros Kappler\n * @date     2021-01-03\n * @modified 2021-01-24 Fixed the `fillShapes` attribute in the copyInstance function.\n * @modified 2021-01-26 Changed the `isPrimary` (default true) attribute to `isSecondary` (default false).\n * @modified 2021-02-03 Added the static `createSvg` function.\n * @modified 2021-02-03 Fixed the currentId='background' bug on the clear() function.\n * @modified 2021-02-03 Fixed CSSProperty `stroke-width` (was line-width before, which is wrong).\n * @modified 2021-02-03 Added the static `HEAD_XML` attribute.\n * @version  1.0.0\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.drawutilssvg = void 0;\nvar CircleSector_1 = require(\"../../CircleSector\");\nvar CubicBezierCurve_1 = require(\"../../CubicBezierCurve\");\nvar Vertex_1 = require(\"../../Vertex\");\n/**\n * @classdesc A helper class for basic SVG drawing operations. This class should\n * be compatible to the default 'draw' class.\n *\n * @requires CubicBzierCurvce\n * @requires Polygon\n * @requires SVGSerializable\n * @requires Vertex\n * @requires XYCoords\n */\nvar drawutilssvg = /** @class */ (function () {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name drawutilssvg\n     * @param {SVGElement} svgNode - The SVG node to use.\n     * @param {XYCoords} offset - The draw offset to use.\n     * @param {XYCoords} scale - The scale factors to use.\n     * @param {XYDimension} canvasSize - The initial canvas size (use setSize to change).\n     * @param {boolean} fillShapes - Indicates if the constructed drawutils should fill all drawn shapes (if possible).\n     * @param {DrawConfig} drawConfig - The default draw config to use for CSS fallback styles.\n     * @param {boolean=} isSecondary - (optional) Indicates if this is the primary or secondary instance. Only primary instances manage child nodes.\n     * @param {SVGElement=} gNode - (optional) Primary and seconday instances share the same &lt;g> node.\n     **/\n    function drawutilssvg(svgNode, offset, scale, canvasSize, fillShapes, drawConfig, isSecondary, gNode) {\n        this.svgNode = svgNode;\n        this.offset = new Vertex_1.Vertex(0, 0).set(offset);\n        this.scale = new Vertex_1.Vertex(1, 1).set(scale);\n        this.fillShapes = fillShapes;\n        this.isSecondary = isSecondary;\n        this.cache = new Map();\n        this.setSize(canvasSize);\n        if (isSecondary) {\n            this.gNode = gNode;\n        }\n        else {\n            this.addStyleDefs(drawConfig);\n            this.gNode = this.createSVGNode('g');\n            this.svgNode.appendChild(this.gNode);\n        }\n    }\n    ;\n    drawutilssvg.prototype.addStyleDefs = function (drawConfig) {\n        var nodeStyle = this.createSVGNode('style');\n        this.svgNode.appendChild(nodeStyle); // nodeDef);\n        // Which default styles to add? -> All from the DrawConfig.\n        // Compare with DrawConfig interface\n        var keys = {\n            'polygon': 'Polygon',\n            'triangle': 'Triangle',\n            'ellipse': 'Ellipse',\n            'circle': 'Circle',\n            'circleSector': 'CircleSector',\n            'vertex': 'Vertex',\n            'line': 'Line',\n            'vector': 'Vector',\n            'image': 'Image'\n        };\n        // Question: why isn't this working if the svgNode is created dynamically? (nodeStyle.sheet is null)\n        var rules = [];\n        for (var k in keys) {\n            var className = keys[k];\n            var drawSettings = drawConfig[k];\n            rules.push(\".\" + className + \" { fill : none; stroke: \" + drawSettings.color + \"; stroke-width: \" + drawSettings.lineWidth + \"px }\");\n        }\n        nodeStyle.innerHTML = rules.join(\"\\n\");\n    };\n    ;\n    /**\n     * Retieve an old (cached) element.\n     * Only if both – key and nodeName – match, the element will be returned (null otherwise).\n     *\n     * @method findElement\n     * @private\n     * @memberof drawutilssvg\n     * @instance\n     * @param {UID} key - The key of the desired element (used when re-drawing).\n     * @param {string} nodeName - The expected node name.\n     */\n    drawutilssvg.prototype.findElement = function (key, nodeName) {\n        var node = this.cache.get(key);\n        if (node && node.nodeName.toUpperCase() === nodeName.toUpperCase()) {\n            this.cache.delete(key);\n            return node;\n        }\n        return null;\n    };\n    /**\n     * Create a new DOM node &lt;svg&gt; in the SVG namespace.\n     *\n     * @method createSVGNode\n     * @private\n     * @memberof drawutilssvg\n     * @instance\n     * @param {string} nodeName - The node name (tag-name).\n     * @return {SVGElement} A new element in the SVG namespace with the given node name.\n     */\n    drawutilssvg.prototype.createSVGNode = function (nodeName) {\n        return document.createElementNS(\"http://www.w3.org/2000/svg\", nodeName);\n    };\n    ;\n    /**\n     * Make a new SVG node (or recycle an old one) with the given node name (circle, path, line, rect, ...).\n     *\n     * This function is used in draw cycles to re-use old DOM nodes (in hope to boost performance).\n     *\n     * @method makeNode\n     * @private\n     * @instance\n     * @memberof drawutilssvg\n     * @param {string} nodeName - The node name.\n     * @return {SVGElement} The new node, which is not yet added to any document.\n     */\n    drawutilssvg.prototype.makeNode = function (nodeName) {\n        // Try to find node in current DOM cache.\n        // Unique node keys are strictly necessary.\n        // Try to recycle an old element from cache.\n        var node = this.findElement(this.curId, nodeName);\n        if (!node) {\n            // If no such old elements exists (key not found, tag name not matching),\n            // then create a new one.\n            node = this.createSVGNode(nodeName);\n        }\n        return node;\n    };\n    ;\n    /**\n     * This is the final helper function for drawing and filling stuff and binding new\n     * nodes to the SVG document.\n     * It is not intended to be used from the outside.\n     *\n     * When in draw mode it draws the current shape.\n     * When in fill mode it fills the current shape.\n     *\n     * This function is usually only called internally.\n     *\n     * @method _bindFillDraw\n     * @private\n     * @instance\n     * @memberof drawutilssvg\n     * @param {SVGElement} node - The node to draw/fill and bind.\n     * @param {string} className - The class name(s) to use.\n     * @param {string} color - A stroke/fill color to use.\n     * @param {number=1} lineWidth - (optional) A line width to use for drawing (default is 1).\n     * @return {SVGElement} The node itself (for chaining).\n     */\n    drawutilssvg.prototype._bindFillDraw = function (node, className, color, lineWidth) {\n        if (this.curClassName) {\n            node.setAttribute('class', this.curClassName + \" \" + className);\n        }\n        else {\n            node.setAttribute('class', className);\n        }\n        node.setAttribute('fill', this.fillShapes ? color : 'none');\n        node.setAttribute('stroke', this.fillShapes ? 'none' : color);\n        node.setAttribute('stroke-width', \"\" + (lineWidth || 1));\n        if (this.curId) {\n            node.setAttribute('id', \"\" + this.curId); // Maybe React-style 'key' would be better?\n        }\n        if (!node.parentNode) {\n            // Attach to DOM only if not already attached\n            this.gNode.appendChild(node);\n        }\n        return node;\n    };\n    ;\n    /**\n     * Sets the size and view box of the document. Call this if canvas size changes.\n     *\n     * @method setSize\n     * @instance\n     * @memberof drawutilssvg\n     * @param {XYDimension} canvasSize - The new canvas size.\n     */\n    drawutilssvg.prototype.setSize = function (canvasSize) {\n        this.canvasSize = canvasSize;\n        this.svgNode.setAttribute('viewBox', \"0 0 \" + this.canvasSize.width + \" \" + this.canvasSize.height);\n        this.svgNode.setAttribute('width', \"\" + this.canvasSize.width);\n        this.svgNode.setAttribute('height', \"\" + this.canvasSize.height);\n    };\n    ;\n    /**\n     * Creates a 'shallow' (non deep) copy of this instance. This implies\n     * that under the hood the same gl context and gl program will be used.\n     */\n    drawutilssvg.prototype.copyInstance = function (fillShapes) {\n        var copy = new drawutilssvg(this.svgNode, this.offset, this.scale, this.canvasSize, fillShapes, null, // no DrawConfig\n        true, // isSecondary\n        this.gNode);\n        return copy;\n    };\n    ;\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * It is used by some libraries for identifying elemente on re-renders.\n     *\n     * @name setCurrentId\n     * @method\n     * @param {UID} uid - A UID identifying the currently drawn element(s).\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    drawutilssvg.prototype.setCurrentId = function (uid) {\n        this.curId = uid;\n    };\n    ;\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * Determine the class name for further usage here.\n     *\n     * @name setCurrentClassName\n     * @method\n     * @param {string} className - A class name for further custom use cases.\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    drawutilssvg.prototype.setCurrentClassName = function (className) {\n        this.curClassName = className;\n    };\n    ;\n    /**\n     * Called before each draw cycle.\n     * This is required for compatibility with other draw classes in the library.\n     *\n     * @name beginDrawCycle\n     * @method\n     * @param {UID=} uid - (optional) A UID identifying the currently drawn element(s).\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    drawutilssvg.prototype.beginDrawCycle = function (renderTime) {\n        // Clear non-recycable elements from last draw cycle.\n        this.cache.clear();\n    };\n    ;\n    drawutilssvg.prototype._x = function (x) { return this.offset.x + this.scale.x * x; };\n    drawutilssvg.prototype._y = function (y) { return this.offset.y + this.scale.y * y; };\n    /**\n     * Draw the line between the given two points with the specified (CSS-) color.\n     *\n     * @method line\n     * @param {Vertex} zA - The start point of the line.\n     * @param {Vertex} zB - The end point of the line.\n     * @param {string} color - Any valid CSS color string.\n     * @param {number=1} lineWidth? - [optional] The line's width.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    drawutilssvg.prototype.line = function (zA, zB, color, lineWidth) {\n        var line = this.makeNode('line');\n        line.setAttribute('x1', \"\" + this._x(zA.x));\n        line.setAttribute('y1', \"\" + this._y(zA.y));\n        line.setAttribute('x2', \"\" + this._x(zB.x));\n        line.setAttribute('y2', \"\" + this._y(zB.y));\n        return this._bindFillDraw(line, 'line', color, lineWidth || 1);\n    };\n    ;\n    /**\n     * Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method arrow\n     * @param {Vertex} zA - The start point of the arrow-line.\n     * @param {Vertex} zB - The end point of the arrow-line.\n     * @param {string} color - Any valid CSS color string.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    drawutilssvg.prototype.arrow = function (zA, zB, color, lineWidth) {\n        var node = this.makeNode('path');\n        var headlen = 8; // length of head in pixels\n        var vertices = Vertex_1.Vertex.utils.buildArrowHead(zA, zB, headlen, this.scale.x, this.scale.y);\n        var d = [\n            'M', this._x(zA.x), this._y(zA.y)\n        ];\n        for (var i = 0; i <= vertices.length; i++) {\n            d.push('L');\n            // Note: only use offset here (the vertices are already scaled)\n            d.push(this.offset.x + vertices[i % vertices.length].x);\n            d.push(this.offset.y + vertices[i % vertices.length].y);\n        }\n        node.setAttribute('d', d.join(' '));\n        return this._bindFillDraw(node, 'arrow', color, lineWidth || 1);\n    };\n    ;\n    /**\n     * Draw an image at the given position with the given size.<br>\n     * <br>\n     * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method image\n     * @param {Image} image - The image object to draw.\n     * @param {Vertex} position - The position to draw the the upper left corner at.\n     * @param {Vertex} size - The x/y-size to draw the image with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    drawutilssvg.prototype.image = function (image, position, size) {\n        var _this = this;\n        var node = this.makeNode('image');\n        // We need to re-adjust the image if it was not yet fully loaded before.\n        var setImageSize = function (image) {\n            if (image.naturalWidth) {\n                var ratioX = size.x / image.naturalWidth;\n                var ratioY = size.y / image.naturalHeight;\n                node.setAttribute('width', \"\" + image.naturalWidth * _this.scale.x);\n                node.setAttribute('height', \"\" + image.naturalHeight * _this.scale.y);\n                node.setAttribute('display', null); // Dislay when loaded\n                node.setAttribute('transform', \"translate(\" + _this._x(position.x) + \" \" + _this._y(position.y) + \") scale(\" + (ratioX) + \" \" + (ratioY) + \")\");\n            }\n        };\n        image.addEventListener('load', function (event) { setImageSize(image); });\n        // Safari has a transform-origin bug.\n        // Use x=0, y=0 and translate/scale instead (see above)\n        node.setAttribute('x', \"\" + 0);\n        node.setAttribute('y', \"\" + 0);\n        node.setAttribute('display', 'none'); // Hide before loaded\n        setImageSize(image);\n        node.setAttribute('href', image.src);\n        return this._bindFillDraw(node, 'image', null, null);\n    };\n    ;\n    /**\n     * Draw the given (cubic) bézier curve.\n     *\n     * @method cubicBezier\n     * @param {Vertex} startPoint - The start point of the cubic Bézier curve\n     * @param {Vertex} endPoint   - The end point the cubic Bézier curve.\n     * @param {Vertex} startControlPoint - The start control point the cubic Bézier curve.\n     * @param {Vertex} endControlPoint   - The end control point the cubic Bézier curve.\n     * @param {string} color - The CSS color to draw the curve with.\n     * @param {number} lineWidth - (optional) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.cubicBezier = function (startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth) {\n        if (startPoint instanceof CubicBezierCurve_1.CubicBezierCurve) {\n            return this.cubicBezier(startPoint.startPoint, startPoint.endPoint, startPoint.startControlPoint, startPoint.endControlPoint, color, lineWidth);\n        }\n        var node = this.makeNode('path');\n        // Draw curve\n        var d = [\n            'M', this._x(startPoint.x), this._y(startPoint.y),\n            'C', this._x(startControlPoint.x), this._y(startControlPoint.y), this._x(endControlPoint.x), this._y(endControlPoint.y), this._x(endPoint.x), this._y(endPoint.y)\n        ];\n        node.setAttribute('d', d.join(' '));\n        return this._bindFillDraw(node, 'cubierBezier', color, lineWidth);\n    };\n    ;\n    /**\n     * Draw the given (cubic) Bézier path.\n     *\n     * The given path must be an array with n*3+1 vertices, where n is the number of\n     * curves in the path:\n     * <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>\n     *\n     * @method cubicBezierPath\n     * @param {Vertex[]} path - The cubic bezier path as described above.\n     * @param {string} color - The CSS colot to draw the path with.\n     * @param {number=1} lineWidth - (optional) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.cubicBezierPath = function (path, color, lineWidth) {\n        var node = this.makeNode('path');\n        if (!path || path.length == 0)\n            return node;\n        // Draw curve\n        var d = [\n            'M', this._x(path[0].x), this._y(path[0].y)\n        ];\n        // Draw curve path\n        var startPoint, endPoint, startControlPoint, endControlPoint;\n        for (var i = 1; i < path.length; i += 3) {\n            startControlPoint = path[i];\n            endControlPoint = path[i + 1];\n            endPoint = path[i + 2];\n            d.push('C', this._x(startControlPoint.x), this._y(startControlPoint.y), this._x(endControlPoint.x), this._y(endControlPoint.y), this._x(endPoint.x), this._y(endPoint.y));\n        }\n        node.setAttribute('d', d.join(' '));\n        return this._bindFillDraw(node, 'cubicBezierPath', color, lineWidth || 1);\n    };\n    ;\n    /**\n     * Draw the given handle and handle point (used to draw interactive Bézier curves).\n     *\n     * The colors for this are fixed and cannot be specified.\n     *\n     * @method handle\n     * @param {Vertex} startPoint - The start of the handle.\n     * @param {Vertex} endPoint - The end point of the handle.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.handle = function (startPoint, endPoint) {\n        // TODO: redefine methods like these into an abstract class?\n        this.point(startPoint, 'rgb(0,32,192)');\n        this.square(endPoint, 5, 'rgba(0,128,192,0.5)');\n    };\n    ;\n    /**\n     * Draw a handle line (with a light grey).\n     *\n     * @method handleLine\n     * @param {Vertex} startPoint - The start point to draw the handle at.\n     * @param {Vertex} endPoint - The end point to draw the handle at.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.handleLine = function (startPoint, endPoint) {\n        this.line(startPoint, endPoint, 'rgb(192,192,192)');\n    };\n    ;\n    /**\n     * Draw a 1x1 dot with the specified (CSS-) color.\n     *\n     * @method dot\n     * @param {Vertex} p - The position to draw the dot at.\n     * @param {string} color - The CSS color to draw the dot with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.dot = function (p, color) {\n        var node = this.makeNode('line');\n        var d = [\n            'M', this._x(p.x), this._y(p.y),\n            'L', this._x(p.x + 1), this._y(p.y + 1)\n        ];\n        return this._bindFillDraw(node, 'dot', color, 1);\n    };\n    ;\n    /**\n     * Draw the given point with the specified (CSS-) color and radius 3.\n     *\n     * @method point\n     * @param {Vertex} p - The position to draw the point at.\n     * @param {string} color - The CSS color to draw the point with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.point = function (p, color) {\n        var radius = 3;\n        var node = this.makeNode('circle');\n        node.setAttribute('cx', \"\" + this._x(p.x));\n        node.setAttribute('cy', \"\" + this._y(p.y));\n        node.setAttribute('r', \"\" + radius);\n        return this._bindFillDraw(node, 'point', color, 1);\n    };\n    ;\n    /**\n     * Draw a circle with the specified (CSS-) color and radius.<br>\n     * <br>\n     * Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.\n     *\n     * @method circle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.circle = function (center, radius, color, lineWidth) {\n        var node = this.makeNode('circle');\n        node.setAttribute('cx', \"\" + this._x(center.x));\n        node.setAttribute('cy', \"\" + this._y(center.y));\n        node.setAttribute('r', \"\" + radius * this.scale.x); // y?\n        return this._bindFillDraw(node, 'circle', color, lineWidth || 1);\n    };\n    ;\n    /**\n     * Draw a circular arc (section of a circle) with the given CSS color.\n     *\n     * @method circleArc\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {number} startAngle - The angle to start at.\n     * @param {number} endAngle - The angle to end at.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.circleArc = function (center, radius, startAngle, endAngle, color, lineWidth) {\n        var node = this.makeNode('path');\n        var arcData = CircleSector_1.CircleSector.circleSectorUtils.describeSVGArc(this._x(center.x), this._y(center.y), radius * this.scale.x, // y?\n        startAngle, endAngle);\n        node.setAttribute('d', arcData.join(' '));\n        return this._bindFillDraw(node, 'circleArc', color, lineWidth || 1);\n    };\n    ;\n    /**\n     * Draw an ellipse with the specified (CSS-) color and thw two radii.\n     *\n     * @method ellipse\n     * @param {Vertex} center - The center of the ellipse.\n     * @param {number} radiusX - The radius of the ellipse.\n     * @param {number} radiusY - The radius of the ellipse.\n     * @param {string} color - The CSS color to draw the ellipse with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.ellipse = function (center, radiusX, radiusY, color, lineWidth) {\n        var node = this.makeNode('ellipse');\n        node.setAttribute('cx', \"\" + this._x(center.x));\n        node.setAttribute('cy', \"\" + this._y(center.y));\n        node.setAttribute('rx', \"\" + radiusX * this.scale.x);\n        node.setAttribute('ry', \"\" + radiusY * this.scale.y);\n        return this._bindFillDraw(node, 'ellipse', color, lineWidth || 1);\n    };\n    ;\n    /**\n     * Draw square at the given center, size and with the specified (CSS-) color.<br>\n     * <br>\n     * Note that if the x-scale and the y-scale are different the result will be a rectangle rather than a square.\n     *\n     * @method square\n     * @param {Vertex} center - The center of the square.\n     * @param {Vertex} size - The size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.square = function (center, size, color, lineWidth) {\n        var node = this.makeNode('rectangle');\n        node.setAttribute('x', \"\" + this._x(center.x - size / 2.0));\n        node.setAttribute('y', \"\" + this._y(center.y - size / 2.0));\n        node.setAttribute('width', \"\" + size * this.scale.x);\n        node.setAttribute('height', \"\" + size * this.scale.y);\n        return this._bindFillDraw(node, 'square', color, lineWidth || 1);\n    };\n    ;\n    /**\n     * Draw a grid of horizontal and vertical lines with the given (CSS-) color.\n     *\n     * @method grid\n     * @param {Vertex} center - The center of the grid.\n     * @param {number} width - The total width of the grid (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal grid size.\n     * @param {number} sizeY - The vertical grid size.\n     * @param {string} color - The CSS color to draw the grid with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.grid = function (center, width, height, sizeX, sizeY, color) {\n        var node = this.makeNode('path');\n        var d = [];\n        var yMin = -Math.ceil((height * 0.5) / sizeY) * sizeY;\n        var yMax = height / 2;\n        for (var x = -Math.ceil((width * 0.5) / sizeX) * sizeX; x < width / 2; x += sizeX) {\n            d.push('M', this._x(center.x + x), this._y(center.y + yMin));\n            d.push('L', this._x(center.x + x), this._y(center.y + yMax));\n        }\n        var xMin = -Math.ceil((width * 0.5) / sizeX) * sizeX;\n        var xMax = width / 2;\n        for (var y = -Math.ceil((height * 0.5) / sizeY) * sizeY; y < height / 2; y += sizeY) {\n            d.push('M', this._x(center.x + xMin), this._y(center.y + y));\n            d.push('L', this._x(center.x + xMax), this._y(center.y + y));\n        }\n        node.setAttribute('d', d.join(' '));\n        return this._bindFillDraw(node, 'grid', color, 1);\n    };\n    ;\n    /**\n     * Draw a raster of crosshairs in the given grid.<br>\n     *\n     * This works analogue to the grid() function\n     *\n     * @method raster\n     * @param {Vertex} center - The center of the raster.\n     * @param {number} width - The total width of the raster (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal raster size.\n     * @param {number} sizeY - The vertical raster size.\n     * @param {string} color - The CSS color to draw the raster with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.raster = function (center, width, height, sizeX, sizeY, color) {\n        var node = this.makeNode('path');\n        var d = [];\n        var cx = 0, cy = 0;\n        for (var x = -Math.ceil((width * 0.5) / sizeX) * sizeX; x < width / 2; x += sizeX) {\n            cx++;\n            for (var y = -Math.ceil((height * 0.5) / sizeY) * sizeY; y < height / 2; y += sizeY) {\n                if (cx == 1)\n                    cy++;\n                // Draw a crosshair\n                d.push('M', this._x(center.x + x) - 4, this._y(center.y + y));\n                d.push('L', this._x(center.x + x) + 4, this._y(center.y + y));\n                d.push('M', this._x(center.x + x), this._y(center.y + y) - 4);\n                d.push('L', this._x(center.x + x), this._y(center.y + y) + 4);\n            }\n        }\n        node.setAttribute('d', d.join(' '));\n        return this._bindFillDraw(node, 'raster', color, 1);\n    };\n    ;\n    /**\n     * Draw a diamond handle (square rotated by 45°) with the given CSS color.\n     *\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped diamonds.\n     *\n     * @method diamondHandle\n     * @param {Vertex} center - The center of the diamond.\n     * @param {Vertex} size - The x/y-size of the diamond.\n     * @param {string} color - The CSS color to draw the diamond with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.diamondHandle = function (center, size, color) {\n        var node = this.makeNode('path');\n        var d = [\n            'M', this._x(center.x) - size / 2.0, this._y(center.y),\n            'L', this._x(center.x), this._y(center.y) - size / 2.0,\n            'L', this._x(center.x) + size / 2.0, this._y(center.y),\n            'L', this._x(center.x), this._y(center.y) + size / 2.0,\n            'Z'\n        ];\n        ;\n        node.setAttribute('d', d.join(' '));\n        return this._bindFillDraw(node, 'diamondHandle', color, 1);\n    };\n    ;\n    /**\n     * Draw a square handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped squares.\n     *\n     * @method squareHandle\n     * @param {Vertex} center - The center of the square.\n     * @param {Vertex} size - The x/y-size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.squareHandle = function (center, size, color) {\n        var node = this.makeNode('rect');\n        node.setAttribute('x', \"\" + (this._x(center.x) - size / 2.0));\n        node.setAttribute('y', \"\" + (this._y(center.y) - size / 2.0));\n        node.setAttribute('width', \"\" + size);\n        node.setAttribute('height', \"\" + size);\n        return this._bindFillDraw(node, 'squareHandle', color, 1);\n    };\n    ;\n    /**\n     * Draw a circle handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped circles.\n     *\n     * @method circleHandle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.circleHandle = function (center, radius, color) {\n        radius = radius || 3;\n        var node = this.makeNode('circle');\n        node.setAttribute('cx', \"\" + this._x(center.x));\n        node.setAttribute('cy', \"\" + this._y(center.y));\n        node.setAttribute('r', \"\" + radius);\n        return this._bindFillDraw(node, 'circleHandle', color, 1);\n    };\n    ;\n    /**\n     * Draw a crosshair with given radius and color at the given position.<br>\n     * <br>\n     * Note that the crosshair radius will not be affected by scaling.\n     *\n     * @method crosshair\n     * @param {XYCoords} center - The center of the crosshair.\n     * @param {number} radius - The radius of the crosshair.\n     * @param {string} color - The CSS color to draw the crosshair with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.crosshair = function (center, radius, color) {\n        var node = this.makeNode('path');\n        var d = [\n            'M', this._x(center.x) - radius, this._y(center.y),\n            'L', this._x(center.x) + radius, this._y(center.y),\n            'M', this._x(center.x), this._y(center.y) - radius,\n            'L', this._x(center.x), this._y(center.y) + radius\n        ];\n        node.setAttribute('d', d.join(' '));\n        return this._bindFillDraw(node, 'crosshair', color, 0.5);\n    };\n    ;\n    /**\n     * Draw a polygon.\n     *\n     * @method polygon\n     * @param {Polygon} polygon - The polygon to draw.\n     * @param {string} color - The CSS color to draw the polygon with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.polygon = function (polygon, color, lineWidth) {\n        return this.polyline(polygon.vertices, polygon.isOpen, color, lineWidth);\n    };\n    ;\n    /**\n     * Draw a polygon line (alternative function to the polygon).\n     *\n     * @method polyline\n     * @param {Vertex[]} vertices - The polygon vertices to draw.\n     * @param {boolan}   isOpen   - If true the polyline will not be closed at its end.\n     * @param {string}   color    - The CSS color to draw the polygon with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.polyline = function (vertices, isOpen, color, lineWidth) {\n        var node = this.makeNode('path');\n        if (vertices.length == 0)\n            return node;\n        // Draw curve\n        var d = [\n            'M', this._x(vertices[0].x), this._y(vertices[0].y)\n        ];\n        var n = vertices.length;\n        for (var i = 1; i < n; i++) {\n            d.push('L', this._x(vertices[i].x), this._y(vertices[i].y));\n        }\n        if (!isOpen)\n            d.push('Z');\n        node.setAttribute('d', d.join(' '));\n        return this._bindFillDraw(node, 'polyline', color, lineWidth || 1);\n    };\n    ;\n    /**\n     * Draw a text label at the given relative position.\n     *\n     * @method label\n     * @param {string} text - The text to draw.\n     * @param {number} x - The x-position to draw the text at.\n     * @param {number} y - The y-position to draw the text at.\n     * @param {number=} rotation - The (optional) rotation in radians.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.text = function (text, x, y, options) {\n        options = options || {};\n        var color = options.color || 'black';\n        var node = this.makeNode('text');\n        node.setAttribute('x', \"\" + this._x(x));\n        node.setAttribute('y', \"\" + this._x(y));\n        node.innerHTML = text;\n        return this._bindFillDraw(node, 'text', color, 1);\n    };\n    ;\n    /**\n     * Draw a non-scaling text label at the given position.\n     *\n     * @method label\n     * @param {string} text - The text to draw.\n     * @param {number} x - The x-position to draw the text at.\n     * @param {number} y - The y-position to draw the text at.\n     * @param {number=} rotation - The (optional) rotation in radians.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    drawutilssvg.prototype.label = function (text, x, y, rotation) {\n        var node = this.makeNode('text');\n        // For some strange reason SVG rotation transforms use degrees instead of radians\n        node.setAttribute('transform', \"translate(\" + this.offset.x + \",\" + this.offset.y + \"), rotate(\" + rotation / Math.PI * 180 + \")\");\n        node.innerHTML = text;\n        return this._bindFillDraw(node, 'label', 'black', null);\n    };\n    ;\n    /**\n     * Due to gl compatibility there is a generic 'clear' function required\n     * to avoid accessing the context object itself directly.\n     *\n     * This function just fills the whole canvas with a single color.\n     *\n     * @param {string} color - The color to clear with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    drawutilssvg.prototype.clear = function (color) {\n        // If this isn't the primary handler then do not remove anything here.\n        // The primary handler will do that (no double work).\n        if (this.isSecondary) {\n            return;\n        }\n        // Clearing an SVG is equivalent to removing all its child elements.\n        for (var i = 0; i < this.gNode.childNodes.length; i++) {\n            // Hide all nodes here. Don't throw them away.\n            // We can probably re-use them in the next draw cycle.\n            var child = this.gNode.childNodes[i];\n            this.cache.set(child.getAttribute('id'), child);\n        }\n        this.removeAllChildNodes();\n        // Add a covering rect with the given background color\n        this.curId = 'background';\n        var node = this.makeNode('rect');\n        // For some strange reason SVG rotation transforms use degrees instead of radians\n        // Note that the background does not scale with the zoom level (always covers full element)\n        node.setAttribute('x', '0');\n        node.setAttribute('y', '0');\n        node.setAttribute('width', \"\" + this.canvasSize.width);\n        node.setAttribute('height', \"\" + this.canvasSize.height);\n        // Bind this special element into the document\n        this._bindFillDraw(node, this.curId, null, null);\n        node.setAttribute('fill', typeof color === \"undefined\" ? 'none' : color);\n        // Clear the current ID again\n        this.curId = null;\n        return node;\n    };\n    ;\n    /**\n     * A private helper function to clear all SVG nodes from the &gt;g> node.\n     *\n     * @private\n     */\n    drawutilssvg.prototype.removeAllChildNodes = function () {\n        while (this.gNode.firstChild) {\n            this.gNode.removeChild(this.gNode.lastChild);\n        }\n    };\n    ;\n    /**\n     * Create a new and empty `SVGElement` &lt;svg&gt; in the svg-namespace.\n     *\n     * @name createSvg\n     * @static\n     * @memberof drawutilssvg\n     * @return SVGElement\n     */\n    drawutilssvg.createSvg = function () {\n        return document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n    };\n    ;\n    drawutilssvg.HEAD_XML = [\n        '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>',\n        '<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" ',\n        '         \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">',\n        ''\n    ].join(\"\\n\");\n    return drawutilssvg;\n}());\nexports.drawutilssvg = drawutilssvg;\n//# sourceMappingURL=drawutilssvg.js.map","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","\"use strict\";\n/* Imports for webpack */\n\nglobalThis.UIDGenerator = require(\"./UIDGenerator.js\").geomutils;\nglobalThis.VertexAttr = require(\"./VertexAttr.js\").VertexAttr;\nglobalThis.VertexListeners = require(\"./VertexListeners.js\").VertexListeners;\nglobalThis.Vertex = require(\"./Vertex.js\").Vertex;\n\nglobalThis.Bounds = require(\"./Bounds.js\").Bounds;\nglobalThis.Grid = require(\"./Grid.js\").Grid;\nglobalThis.Line = require(\"./Line.js\").Line;\nglobalThis.Vector = require(\"./Vector.js\").Vector;\nglobalThis.CubicBezierCurve = require(\"./CubicBezierCurve.js\").CubicBezierCurve;\nglobalThis.BezierPath = require(\"./BezierPath.js\").BezierPath;\nglobalThis.Polygon = require(\"./Polygon.js\").Polygon;\nglobalThis.Triangle = require(\"./Triangle.js\").Triangle;\nglobalThis.VEllipse = require(\"./VEllipse.js\").VEllipse;\nglobalThis.Circle = require(\"./Circle.js\").Circle;\nglobalThis.CircleSector = require(\"./CircleSector.js\").CircleSector;\nglobalThis.PBImage = require(\"./PBImage.js\").PBImage;\nglobalThis.MouseHandler = require(\"./MouseHandler.js\").MouseHandler;\nglobalThis.KeyHandler = require(\"./KeyHandler.js\").KeyHandler;\nglobalThis.drawutils = require(\"./draw.js\").drawutils;\n// globalThis.drawutilsgl = require(\"./drawgl.js\").drawutilsgl;\n// globalThis.drawutilsgl = {};\nglobalThis.drawutilssvg = require(\"./utils/helpers/drawutilssvg.js\").drawutilssvg;\nglobalThis.geomutils = require(\"./geomutils.js\").geomutils;\nglobalThis.PlotBoilerplate = require(\"./PlotBoilerplate.js\").PlotBoilerplate;\n\n"],"sourceRoot":""}