MindMap/frontend/node_modules/vditor/dist/js/smiles-drawer/smiles-drawer.min.js

72 lines
246 KiB
JavaScript
Raw Normal View History

(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module){"use strict";var _Mathmin=Math.min,_Mathmax=Math.max;const Drawer=require("./src/Drawer"),Parser=require("./src/Parser"),ReactionParser=require("./src/ReactionParser"),SvgDrawer=require("./src/SvgDrawer"),ReactionDrawer=require("./src/ReactionDrawer"),SmiDrawer=require("./src/SmilesDrawer"),GaussDrawer=require("./src/GaussDrawer");var canUseDOM=!!("undefined"!=typeof window&&window.document&&window.document.createElement),SmilesDrawer={Version:"1.0.0"};SmilesDrawer.Drawer=Drawer,SmilesDrawer.Parser=Parser,SmilesDrawer.SvgDrawer=SvgDrawer,SmilesDrawer.ReactionDrawer=ReactionDrawer,SmilesDrawer.ReactionParser=ReactionParser,SmilesDrawer.GaussDrawer=GaussDrawer,SmilesDrawer.clean=function(smiles){return smiles.replace(/[^A-Za-z0-9@\.\+\-\?!\(\)\[\]\{\}/\\=#\$:\*]/g,"")},SmilesDrawer.apply=function(options,selector="canvas[data-smiles]",themeName="light",onError=null){let smilesDrawer=new Drawer(options),elements=document.querySelectorAll(selector);for(var i=0;i<elements.length;i++){let element=elements[i];SmilesDrawer.parse(element.getAttribute("data-smiles"),function(tree){smilesDrawer.draw(tree,element,themeName,!1)},function(err){onError&&onError(err)})}},SmilesDrawer.parse=function(smiles,successCallback,errorCallback){try{successCallback&&successCallback(Parser.parse(smiles))}catch(err){errorCallback&&errorCallback(err)}},SmilesDrawer.parseReaction=function(reactionSmiles,successCallback,errorCallback){try{successCallback&&successCallback(ReactionParser.parse(reactionSmiles))}catch(err){errorCallback&&errorCallback(err)}},canUseDOM&&(window.SmilesDrawer=SmilesDrawer,window.SmiDrawer=SmiDrawer),SmilesDrawer.SmiDrawer=SmiDrawer,Array.prototype.fill||Object.defineProperty(Array.prototype,"fill",{value:function(value){if(null==this)throw new TypeError("this is null or not defined");for(var O=Object(this),len=O.length>>>0,start=arguments[1],relativeStart=start>>0,k=0>relativeStart?_Mathmax(len+relativeStart,0):_Mathmin(relativeStart,len),end=arguments[2],relativeEnd=void 0===end?len:end>>0,final=0>relativeEnd?_Mathmax(len+relativeEnd,0):_Mathmin(relativeEnd,len);k<final;)O[k]=value,k++;return O}}),module.exports=SmilesDrawer},{"./src/Drawer":6,"./src/GaussDrawer":10,"./src/Parser":15,"./src/ReactionDrawer":18,"./src/ReactionParser":19,"./src/SmilesDrawer":23,"./src/SvgDrawer":24}],2:[function(require,module,exports){var _NumberMAX_VALUE=Number.MAX_VALUE,_Mathsin=Math.sin,_Mathatan=Math.atan2,_Mathpow=Math.pow,_Mathcos=Math.cos,_Mathsqrt=Math.sqrt,_Mathfloor=Math.floor,_Mathround=Math.round,_MathPI=Math.PI,_Mathabs=Math.abs,_Mathmin2=Math.min,_Mathmax2=Math.max;/**
* chroma.js - JavaScript library for color conversions
*
* Copyright (c) 2011-2019, Gregor Aisch
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name Gregor Aisch may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* -------------------------------------------------------
*
* chroma.js includes colors from colorbrewer2.org, which are released under
* the following license:
*
* Copyright (c) 2002 Cynthia Brewer, Mark Harrower,
* and The Pennsylvania State University.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* ------------------------------------------------------
*
* Named colors are taken from X11 Color Names.
* http://www.w3.org/TR/css3-color/#svg-color
*
* @preserve
*/(function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):(global="undefined"==typeof globalThis?global||self:globalThis,global.chroma=factory())})(this,function(){'use strict';var _Mathsign=Math.sign,_Mathlog=Math.log,_NumberNaN=Number.NaN;function rgb2lrgb(c){var abs=_Mathabs(c);return .04045>abs?c/12.92:(sign$1(c)||1)*pow$8((abs+.055)/1.055,2.4)}function lrgb2rgb(c){var abs=_Mathabs(c);return .0031308<abs?(sign(c)||1)*(1.055*pow$7(abs,1/2.4)-.055):12.92*c}function __range__(left,right,inclusive){for(var range=[],ascending=left<right,end=inclusive?ascending?right+1:right-1:right,i=left;ascending?i<end:i>end;ascending?i++:i--)range.push(i);return range}for(var limit$2=function(x,min,max){return void 0===min&&(min=0),void 0===max&&(max=1),x<min?min:x>max?max:x},limit$1=limit$2,clip_rgb$3=function(rgb){rgb._clipped=!1,rgb._unclipped=rgb.slice(0);for(var i=0;3>=i;i++)3>i?((0>rgb[i]||255<rgb[i])&&(rgb._clipped=!0),rgb[i]=limit$1(rgb[i],0,255)):3===i&&(rgb[i]=limit$1(rgb[i],0,1));return rgb},classToType={},i$1=0,list$1=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"],name;i$1<list$1.length;i$1+=1)name=list$1[i$1],classToType["[object "+name+"]"]=name.toLowerCase();var type$p=function(obj){return classToType[Object.prototype.toString.call(obj)]||"object"},PI$2=_MathPI,utils={clip_rgb:clip_rgb$3,limit:limit$2,type:type$p,unpack:function(args,keyOrder){return void 0===keyOrder&&(keyOrder=null),3<=args.length?Array.prototype.slice.call(args):"object"==type$p(args[0])&&keyOrder?keyOrder.split("").filter(function(k){return void 0!==args[0][k]}).map(function(k){return args[0][k]}):args[0]},last:function(args){if(2>args.length)return null;var l=args.length-1;return"string"==type$p(args[l])?args[l].toLowerCase():null},PI:PI$2,TWOPI:2*PI$2,PITHIRD:PI$2/3,DEG2RAD:PI$2/180,RAD2DEG:180/PI$2},input$h={format:{},autodetect:[]},last$3=utils.last,clip_rgb$2=utils.clip_rgb,type$m=utils.type,_input=input$h,Color$D=function(){for(var args=[],len=arguments.length;len--;)args[len]=arguments[len];var me=this;if("object"===type$m(args[0])&&args[0].constructor&&args[0].constructor===this.constructor)return args[0];var mode=last$3(args),autodetect=!1;if(!mode){autodetect=!0,_input.sorted||(_input.autodetect=_input.autodetect.sort(function(a,b){return b.p-a.p}),_input.sorted=!0);for(var i=0,list=_input.autodetect,chk;i<list.length&&(chk=list[i],mode=chk.test.apply(chk,args),!mode);i+=1);}if(_input.format[mode]){var rgb=_input.format[mode].apply(null,autodetect?args:args.slice(0,-1));me._rgb=clip_rgb$2(rgb)}else throw new Error("unknown format: "+args);3===me._rgb.length&&me._rgb.push(1)};Color$D.prototype.toString=function(){return"function"==type$m(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var Color_1=Color$D,chroma$k=function(){for(var args=[],len=arguments.length;len--;)args[len]=arguments[len];return new(Function.prototype.bind.apply(chroma$k.Color,[null].concat(args)))};chroma$k.Color=Color_1,chroma$k.version="2.4.2";var chroma_1=chroma$k,unpack$A=utils.unpack,max$2=_Mathmax2,unpack$z=utils.unpack,Color$C=Color_1,input$g=input$h,unpack$y=utils.unpack,type$l=utils.type,rgb2cmyk=function(){for(var args=[],len=arguments.length;len--;)args[len]=arguments[len];var ref=unpack$A(args,"rgb"),r=ref[0],g=ref[1],b=ref[2];r/=255,g/=255,b/=255;var k=1-max$2(r,max$2(g,b)),f=1>k?1/(1-k):0,c=(1-r-k)*f,m=(1-g-k)*f,y=(1-b-k)*f;return[c,m,y,k]};Color$C.prototype.cmyk=function(){return rgb2cmyk(this._rgb)},chroma_1.cmyk=function(){for(var args=[],len=arguments.length;len--;)args[len]=arguments[len];return new(Function.prototype.bind.apply(Color$C,[null].concat(args,["cmyk"])))},input$g.format.cmyk=function(){for(var args=[],len=arguments.length;len--;)args[len]=arguments[len];args=unpack$z(args,"cmyk");var c=args[0],m=args[1],y=args[2],k=args[3],alpha=4<args.length?args[4]:1;return 1===k?[0,0,0,alpha]:[1<=c?0:255*(1-c)*(1-k),1<=m?0:255*(1-m)*(1-k),1<=y?0:255*(1-y)*(1-k),alpha]},input$g.autodetect.push({p:2,test:function()
.element {
font: ${this.opts.fontSizeLarge}pt ${this.opts.fontFamily};
}
.sub {
font: ${this.opts.fontSizeSmall}pt ${this.opts.fontFamily};
}
`)),this.svg?this.svg.appendChild(this.style):(this.container=document.createElementNS("http://www.w3.org/2000/svg","g"),container.appendChild(this.style))}constructSvg(){let defs=document.createElementNS("http://www.w3.org/2000/svg","defs"),masks=document.createElementNS("http://www.w3.org/2000/svg","mask"),background=document.createElementNS("http://www.w3.org/2000/svg","g"),highlights=document.createElementNS("http://www.w3.org/2000/svg","g"),paths=document.createElementNS("http://www.w3.org/2000/svg","g"),vertices=document.createElementNS("http://www.w3.org/2000/svg","g"),pathChildNodes=this.paths,mask=document.createElementNS("http://www.w3.org/2000/svg","rect");mask.setAttributeNS(null,"x",this.minX),mask.setAttributeNS(null,"y",this.minY),mask.setAttributeNS(null,"width",this.maxX-this.minX),mask.setAttributeNS(null,"height",this.maxY-this.minY),mask.setAttributeNS(null,"fill","white"),masks.appendChild(mask),masks.setAttributeNS(null,"id",this.uid+"-text-mask");for(let path of pathChildNodes)paths.appendChild(path);for(let backgroundItem of this.backgroundItems)background.appendChild(backgroundItem);for(let highlight of this.highlights)highlights.appendChild(highlight);for(let vertex of this.vertices)vertices.appendChild(vertex);for(let mask of this.maskElements)masks.appendChild(mask);for(let gradient of this.gradients)defs.appendChild(gradient);return paths.setAttributeNS(null,"mask","url(#"+this.uid+"-text-mask)"),this.updateViewbox(this.opts.scale),background.setAttributeNS(null,"style",`transform: translateX(${this.minX}px) translateY(${this.minY}px)`),this.svg?void(this.svg.appendChild(defs),this.svg.appendChild(masks),this.svg.appendChild(background),this.svg.appendChild(highlights),this.svg.appendChild(paths),this.svg.appendChild(vertices)):(this.container.appendChild(defs),this.container.appendChild(masks),this.container.appendChild(background),this.container.appendChild(paths),this.container.appendChild(vertices),this.container)}addLayer(svg){this.backgroundItems.push(svg.firstChild)}createGradient(line){let gradient=document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),gradientUrl=this.uid+`-line-${this.gradientId++}`,l=line.getLeftVector(),r=line.getRightVector(),fromX=l.x,fromY=l.y,toX=r.x,toY=r.y;gradient.setAttributeNS(null,"id",gradientUrl),gradient.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),gradient.setAttributeNS(null,"x1",fromX),gradient.setAttributeNS(null,"y1",fromY),gradient.setAttributeNS(null,"x2",toX),gradient.setAttributeNS(null,"y2",toY);let firstStop=document.createElementNS("http://www.w3.org/2000/svg","stop");firstStop.setAttributeNS(null,"stop-color",this.themeManager.getColor(line.getLeftElement())||this.themeManager.getColor("C")),firstStop.setAttributeNS(null,"offset","20%");let secondStop=document.createElementNS("http://www.w3.org/2000/svg","stop");return secondStop.setAttributeNS(null,"stop-color",this.themeManager.getColor(line.getRightElement()||this.themeManager.getColor("C"))),secondStop.setAttributeNS(null,"offset","100%"),gradient.appendChild(firstStop),gradient.appendChild(secondStop),this.gradients.push(gradient),gradientUrl}createSubSuperScripts(text,shift){let elem=document.createElementNS("http://www.w3.org/2000/svg","tspan");return elem.setAttributeNS(null,"baseline-shift",shift),elem.appendChild(document.createTextNode(text)),elem.setAttributeNS(null,"class","sub"),elem}static createUnicodeCharge(n){return 1===n?"\u207A":-1===n?"\u207B":1<n?SvgWrapper.createUnicodeSuperscript(n)+"\u207A":-1>n?SvgWrapper.createUnicodeSuperscript(n)+"\u207B":""}determineDimensions(vertices){for(var i=0;i<vertices.length;i++){if(!vertices[i].value.isDrawn)continue;let p=vertices[i].position;this.maxX<p.x&&(this.maxX=p.x),this.maxY<p.y&&(this.maxY=p.y),this.minX>p.x&&(this.minX=p.x),this.minY>p.y&&(this.minY=p.y)}let padding=this.opts.padding;this.maxX+=padding,this.maxY+=padding,this.minX-=padding,this.minY-=padding,this.drawingWidth=this.maxX-this.minX,this.drawingHeight=this.maxY-this.minY}updateViewbox(scale){let x=this.minX,y=this.minY,wi
font: 5px Droid Sans, sans-serif;
`),textElem.appendChild(document.createTextNode(text)),this.vertices.push(textElem)}drawRing(x,y,s){let circleElem=document.createElementNS("http://www.w3.org/2000/svg","circle"),radius=MathHelper.apothemFromSideLength(this.opts.bondLength,s);circleElem.setAttributeNS(null,"cx",x),circleElem.setAttributeNS(null,"cy",y),circleElem.setAttributeNS(null,"r",radius-this.opts.bondSpacing),circleElem.setAttributeNS(null,"stroke",this.themeManager.getColor("C")),circleElem.setAttributeNS(null,"stroke-width",this.opts.bondThickness),circleElem.setAttributeNS(null,"fill","none"),this.paths.push(circleElem)}drawLine(line,dashed=!1,gradient=null,linecap="round"){let opts=this.opts,stylesArr=[["stroke-width",this.opts.bondThickness],["stroke-linecap",linecap],["stroke-dasharray",dashed?"5, 5":"none"]],l=line.getLeftVector(),r=line.getRightVector(),fromX=l.x,fromY=l.y,toX=r.x,toY=r.y,styles=stylesArr.map(sub=>sub.join(":")).join(";"),lineElem=document.createElementNS("http://www.w3.org/2000/svg","line");lineElem.setAttributeNS(null,"x1",fromX),lineElem.setAttributeNS(null,"y1",fromY),lineElem.setAttributeNS(null,"x2",toX),lineElem.setAttributeNS(null,"y2",toY),lineElem.setAttributeNS(null,"style",styles),this.paths.push(lineElem),null==gradient&&(gradient=this.createGradient(line,fromX,fromY,toX,toY)),lineElem.setAttributeNS(null,"stroke",`url('#${gradient}')`)}drawPoint(x,y,elementName){let r=.75;x-r<this.minX&&(this.minX=x-r),x+r>this.maxX&&(this.maxX=x+r),y-r<this.minY&&(this.minY=y-r),y+r>this.maxY&&(this.maxY=y+r);let mask=document.createElementNS("http://www.w3.org/2000/svg","circle");mask.setAttributeNS(null,"cx",x),mask.setAttributeNS(null,"cy",y),mask.setAttributeNS(null,"r","1.5"),mask.setAttributeNS(null,"fill","black"),this.maskElements.push(mask);let point=document.createElementNS("http://www.w3.org/2000/svg","circle");point.setAttributeNS(null,"cx",x),point.setAttributeNS(null,"cy",y),point.setAttributeNS(null,"r",r),point.setAttributeNS(null,"fill",this.themeManager.getColor(elementName)),this.vertices.push(point)}drawText(x,y,elementName,hydrogens,direction,isTerminal,charge,isotope,totalVertices,attachedPseudoElement={}){let text=[],display=elementName;for(let key in 0!==charge&&null!==charge&&(display+=SvgWrapper.createUnicodeCharge(charge)),0!==isotope&&null!==isotope&&(display=SvgWrapper.createUnicodeSuperscript(isotope)+display),text.push([display,elementName]),1===hydrogens?text.push(["H","H"]):1<hydrogens&&text.push(["H"+SvgWrapper.createUnicodeSubscript(hydrogens),"H"]),1===charge&&"N"===elementName&&attachedPseudoElement.hasOwnProperty("0O")&&attachedPseudoElement.hasOwnProperty("0O-1")&&(attachedPseudoElement={"0O":{element:"O",count:2,hydrogenCount:0,previousElement:"C",charge:""}},charge=0),attachedPseudoElement){if(!attachedPseudoElement.hasOwnProperty(key))continue;let pe=attachedPseudoElement[key],display=pe.element;1<pe.count&&(display+=SvgWrapper.createUnicodeSubscript(pe.count)),""!==pe.charge&&(display+=SvgWrapper.createUnicodeCharge(charge)),text.push([display,pe.element]),1===pe.hydrogenCount?text.push(["H","H"]):1<pe.hydrogenCount&&text.push(["H"+SvgWrapper.createUnicodeSubscript(pe.hydrogenCount),"H"])}this.write(text,direction,x,y,1===totalVertices)}write(text,direction,x,y,singleVertex){let bbox=SvgWrapper.measureText(text[0][1],this.opts.fontSizeLarge,this.opts.fontFamily);"left"===direction&&text[0][0]!==text[0][1]&&(bbox.width*=2),singleVertex?(x+bbox.width*text.length>this.maxX&&(this.maxX=x+bbox.width*text.length),x-bbox.width/2<this.minX&&(this.minX=x-bbox.width/2),y-bbox.height<this.minY&&(this.minY=y-bbox.height),y+bbox.height>this.maxY&&(this.maxY=y+bbox.height)):("right"===direction?"left"!=direction&&(x+bbox.width*text.length>this.maxX&&(this.maxX=x+bbox.width*text.length),x-bbox.width/2<this.minX&&(this.minX=x-bbox.width/2)):(x+bbox.width*text.length>this.maxX&&(this.maxX=x+bbox.width*text.length),x-bbox.width*text.length<this.minX&&(this.minX=x-bbox.width*text.length)),y-bbox.height<this.minY&&(this.minY=y-bbox.height),y+bbox.height>this.maxY&&(this.maxY=y+bbox.height)
.text {
font: ${fontSize}pt ${fontFamily};
dominant-baseline: ideographic;
}
`)),svg.appendChild(style);let textElem=document.createElementNS("http://www.w3.org/2000/svg","text");textElem.setAttributeNS(null,"class","text");let maxLineWidth=0,totalHeight=0,lines=[];return text.split("\n").forEach(line=>{let dims=SvgWrapper.measureText(line,fontSize,fontFamily,1);if(dims.width>=maxWidth){let totalWordsWidth=0,maxWordsHeight=0,words=line.split(" "),offset=0;for(let i=0,wordDims;i<words.length;i++)wordDims=SvgWrapper.measureText(words[i],fontSize,fontFamily,1),totalWordsWidth+wordDims.width>maxWidth&&(lines.push({text:words.slice(offset,i).join(" "),width:totalWordsWidth,height:maxWordsHeight}),totalWordsWidth=0,maxWordsHeight=0,offset=i),wordDims.height>maxWordsHeight&&(maxWordsHeight=wordDims.height),totalWordsWidth+=wordDims.width;offset<words.length&&lines.push({text:words.slice(offset,words.length).join(" "),width:totalWordsWidth,height:maxWordsHeight})}else lines.push({text:line,width:dims.width,height:dims.height})}),lines.forEach(line=>{totalHeight+=line.height;let tspanElem=document.createElementNS("http://www.w3.org/2000/svg","tspan");tspanElem.setAttributeNS(null,"fill",themeManager.getColor("C")),tspanElem.textContent=line.text,tspanElem.setAttributeNS(null,"x","0px"),tspanElem.setAttributeNS(null,"y",`${totalHeight}px`),textElem.appendChild(tspanElem),line.width>maxLineWidth&&(maxLineWidth=line.width)}),svg.appendChild(textElem),{svg:svg,width:maxLineWidth,height:totalHeight}}}module.exports=SvgWrapper},{"./Line":12,"./MathHelper":13,"./UtilityFunctions":27,"./Vector2":28}],26:[function(require,module){"use strict";module.exports=class{constructor(colors,theme){this.colors=colors,this.theme=this.colors[theme]}getColor(key){return key&&(key=key.toUpperCase(),key in this.theme)?this.theme[key]:this.theme.C}setTheme(theme){this.colors.hasOwnProperty(theme)&&(this.theme=this.colors[theme])}}},{}],27:[function(require,module){"use strict";module.exports={getChargeText:function(charge){return 1===charge?"+":2===charge?"2+":-1===charge?"-":-2===charge?"2-":""}}},{}],28:[function(require,module){"use strict";var _Mathsin5=Math.sin,_Mathcos5=Math.cos,_Mathacos=Math.acos,_Mathsqrt4=Math.sqrt;class Vector2{constructor(x,y){0==arguments.length?(this.x=0,this.y=0):1==arguments.length?(this.x=x.x,this.y=x.y):(this.x=x,this.y=y)}clone(){return new Vector2(this.x,this.y)}toString(){return"("+this.x+","+this.y+")"}add(vec){return this.x+=vec.x,this.y+=vec.y,this}subtract(vec){return this.x-=vec.x,this.y-=vec.y,this}divide(scalar){return this.x/=scalar,this.y/=scalar,this}multiply(v){return this.x*=v.x,this.y*=v.y,this}multiplyScalar(scalar){return this.x*=scalar,this.y*=scalar,this}invert(){return this.x=-this.x,this.y=-this.y,this}angle(){return Math.atan2(this.y,this.x)}distance(vec){return _Mathsqrt4((vec.x-this.x)*(vec.x-this.x)+(vec.y-this.y)*(vec.y-this.y))}distanceSq(vec){return(vec.x-this.x)*(vec.x-this.x)+(vec.y-this.y)*(vec.y-this.y)}clockwise(vec){let a=this.y*vec.x,b=this.x*vec.y;if(a>b)return-1;return a===b?0:1}relativeClockwise(center,vec){let a=(this.y-center.y)*(vec.x-center.x),b=(this.x-center.x)*(vec.y-center.y);if(a>b)return-1;return a===b?0:1}rotate(angle){let tmp=new Vector2(0,0),cosAngle=_Mathcos5(angle),sinAngle=_Mathsin5(angle);return tmp.x=this.x*cosAngle-this.y*sinAngle,tmp.y=this.x*sinAngle+this.y*cosAngle,this.x=tmp.x,this.y=tmp.y,this}rotateAround(angle,vec){let s=_Mathsin5(angle),c=_Mathcos5(angle);this.x-=vec.x,this.y-=vec.y;let x=this.x*c-this.y*s,y=this.x*s+this.y*c;return this.x=x+vec.x,this.y=y+vec.y,this}rotateTo(vec,center,offsetAngle=0){this.x+=.001,this.y-=.001;let a=Vector2.subtract(this,center),b=Vector2.subtract(vec,center),angle=Vector2.angle(b,a);return this.rotateAround(angle+offsetAngle,center),this}rotateAwayFrom(vec,center,angle){this.rotateAround(angle,center);let distSqA=this.distanceSq(vec);this.rotateAround(-2*angle,center);let distSqB=this.distanceSq(vec);distSqB<distSqA&&this.rotateAround(2*angle,center)}getRotateAwayFromAngle(vec,center,angle){let tmp=this.clone();tmp.rotateAround(angle,center);let distSqA=tmp.distanceSq(vec);tmp.rotateAround(-
//# sourceMappingURL=smiles-drawer.min.js.map