mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
47 lines
112 KiB
JavaScript
47 lines
112 KiB
JavaScript
|
/*!
|
||
|
* @svgdotjs/svg.js - A lightweight library for manipulating and animating SVG.
|
||
|
* @version 3.1.2
|
||
|
* https://svgjs.dev/
|
||
|
*
|
||
|
* @copyright Wout Fierens <wout@mick-wout.com>
|
||
|
* @license MIT
|
||
|
*
|
||
|
* BUILT: Wed Jan 26 2022 23:19:07 GMT+0100 (Mitteleuropäische Normalzeit)
|
||
|
*/var SVG=function(){"use strict";const methods$1={};const names=[];function registerMethods(name,m){if(Array.isArray(name)){for(const _name of name){registerMethods(_name,m)}return}if(typeof name==="object"){for(const _name in name){registerMethods(_name,name[_name])}return}addMethodNames(Object.getOwnPropertyNames(m));methods$1[name]=Object.assign(methods$1[name]||{},m)}function getMethodsFor(name){return methods$1[name]||{}}function getMethodNames(){return[...new Set(names)]}function addMethodNames(_names){names.push(..._names)}function map(array,block){let i;const il=array.length;const result=[];for(i=0;i<il;i++){result.push(block(array[i]))}return result}function filter(array,block){let i;const il=array.length;const result=[];for(i=0;i<il;i++){if(block(array[i])){result.push(array[i])}}return result}function radians(d){return d%360*Math.PI/180}function degrees(r){return r*180/Math.PI%360}function camelCase(s){return s.toLowerCase().replace(/-(.)/g,function(m,g){return g.toUpperCase()})}function unCamelCase(s){return s.replace(/([A-Z])/g,function(m,g){return"-"+g.toLowerCase()})}function capitalize(s){return s.charAt(0).toUpperCase()+s.slice(1)}function proportionalSize(element,width,height,box){if(width==null||height==null){box=box||element.bbox();if(width==null){width=box.width/box.height*height}else if(height==null){height=box.height/box.width*width}}return{width:width,height:height}}function getOrigin(o,element){const origin=o.origin;let ox=o.ox!=null?o.ox:o.originX!=null?o.originX:"center";let oy=o.oy!=null?o.oy:o.originY!=null?o.originY:"center";if(origin!=null){[ox,oy]=Array.isArray(origin)?origin:typeof origin==="object"?[origin.x,origin.y]:[origin,origin]}const condX=typeof ox==="string";const condY=typeof oy==="string";if(condX||condY){const{height,width,x,y}=element.bbox();if(condX){ox=ox.includes("left")?x:ox.includes("right")?x+width:x+width/2}if(condY){oy=oy.includes("top")?y:oy.includes("bottom")?y+height:y+height/2}}return[ox,oy]}var utils={__proto__:null,map:map,filter:filter,radians:radians,degrees:degrees,camelCase:camelCase,unCamelCase:unCamelCase,capitalize:capitalize,proportionalSize:proportionalSize,getOrigin:getOrigin};const svg="http://www.w3.org/2000/svg";const html="http://www.w3.org/1999/xhtml";const xmlns="http://www.w3.org/2000/xmlns/";const xlink="http://www.w3.org/1999/xlink";const svgjs="http://svgjs.dev/svgjs";var namespaces={__proto__:null,svg:svg,html:html,xmlns:xmlns,xlink:xlink,svgjs:svgjs};const globals={window:typeof window==="undefined"?null:window,document:typeof document==="undefined"?null:document};function registerWindow(win=null,doc=null){globals.window=win;globals.document=doc}const save={};function saveWindow(){save.window=globals.window;save.document=globals.document}function restoreWindow(){globals.window=save.window;globals.document=save.document}function withWindow(win,fn){saveWindow();registerWindow(win,win.document);fn(win,win.document);restoreWindow()}function getWindow(){return globals.window}class Base{}const elements={};const root="___SYMBOL___ROOT___";function create(name,ns=svg){return globals.document.createElementNS(ns,name)}function makeInstance(element,isHTML=false){if(element instanceof Base)return element;if(typeof element==="object"){return adopter(element)}if(element==null){return new elements[root]}if(typeof element==="string"&&element.charAt(0)!=="<"){return adopter(globals.document.querySelector(element))}const wrapper=isHTML?globals.document.createElement("div"):create("svg");wrapper.innerHTML=element;element=adopter(wrapper.firstChild);wrapper.removeChild(wrapper.firstChild);return element}function nodeOrNew(name,node){return node&&node.ownerDocument&&node instanceof node.ownerDocument.defaultView.Node?node:create(name)}function adopt(node){if(!node)return null;if(node.instance instanceof Base)return node.instance;if(node.nodeName==="#document-fragment"){return new elements.Fragment(node)}let className=capitalize(node.nodeName||"Dom");if(className==="LinearGradient"||className==="RadialGradient"){className="Gradient"}else if(!elements[className
|
||
|
/*!
|
||
|
@licstart The following is the entire license notice for the JavaScript code in this file.
|
||
|
The code below is based on SVGPan Library 1.2 and was modified for doxygen
|
||
|
to support both zooming and panning via the mouse and via embedded buttons.
|
||
|
|
||
|
This code is licensed under the following BSD license:
|
||
|
|
||
|
Copyright 2009-2010 Andrea Leofreddi <a.leofreddi@itcharm.com>. 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.
|
||
|
|
||
|
THIS SOFTWARE IS PROVIDED BY Andrea Leofreddi ``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 Andrea Leofreddi 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.
|
||
|
|
||
|
The views and conclusions contained in the software and documentation are those of the
|
||
|
authors and should not be interpreted as representing official policies, either expressed
|
||
|
or implied, of Andrea Leofreddi.
|
||
|
|
||
|
@licend The above is the entire license notice for the JavaScript code in this file
|
||
|
*/
|
||
|
var root=document.documentElement;var state="none";var stateOrigin;var stateTf=root.createSVGMatrix();var cursorGrab=' url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAlQTFRFAAAA////////c3ilYwAAAAN0Uk5T//8A18oNQQAAAD1JREFUeNp0zlEKACAIA9Bt9z90bZBZkQj29qFBEuBOzQHSnWTTyckEfqUuZgFvslH4ch3qLCO/Kr8cAgwATw4Ax6XRCcoAAAAASUVORK5CYII="), move';var zoomSteps=10;var zoomInFactor;var zoomOutFactor;var windowWidth;var windowHeight;var svgDoc;var minZoom;var maxZoom;if(!window)window=this;function show(){if(window.innerHeight){windowWidth=window.innerWidth;windowHeight=window.innerHeight}else if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight}if(!windowWidth||!windowHeight){windowWidth=800;windowHeight=600}minZoom=Math.min(Math.min(viewHeight,windowHeight)/viewHeight,Math.min(viewWidth,windowWidth)/viewWidth);maxZoom=minZoom+1.5;zoomInFactor=Math.pow(maxZoom/minZoom,1/zoomSteps);zoomOutFactor=1/zoomInFactor;var g=svgDoc.getElementById("viewport");try{var bb=g.getBBox();var tx=(windowWidth-viewWidth*minZoom+8)/(2*minZoom);var ty=viewHeight+(windowHeight-viewHeight*minZoom)/(2*minZoom);var a="scale("+minZoom+") rotate(0) translate("+tx+" "+ty+")";g.setAttribute("transform",a)}catch(e){}}function init(evt){svgDoc=evt.target.ownerDocument;try{if(top.window&&top.window.registerShow){top.window.registerShow(sectionId,show)}}catch(e){}show();setAttributes(root,{onmousedown:"handleMouseDown(evt)",onmousemove:"handleMouseMove(evt)",onmouseup:"handleMouseUp(evt)"});if(window.addEventListener){if(navigator.userAgent.toLowerCase().indexOf("webkit")>=0||navigator.userAgent.toLowerCase().indexOf("opera")>=0||navigator.appVersion.indexOf("MSIE")!=-1){window.addEventListener("mousewheel",handleMouseWheel,false)}else{window.addEventListener("DOMMouseScroll",handleMouseWheel,false)}}}window.onresize=function(){if(svgDoc){show()}};function getEventPoint(evt){var p=root.createSVGPoint();p.x=evt.clientX;p.y=evt.clientY;return p}function setCTM(element,matrix){var s="matrix("+matrix.a+","+matrix.b+","+matrix.c+","+matrix.d+","+matrix.e+","+matrix.f+")";element.setAttribute("transform",s)}function setAttributes(element,attributes){for(i in attributes)element.setAttributeNS(null,i,attributes[i])}function doZoom(g,point,zoomFactor){var p=point.matrixTransform(g.getCTM().inverse());var k=root.createSVGMatrix().translate(p.x,p.y).scale(zoomFactor).translate(-p.x,-p.y);var n=g.getCTM().multiply(k);var s=Math.max(n.a,n.d);if(s>maxZoom)n=n.translate(p.x,p.y).scale(maxZoom/s).translate(-p.x,-p.y);else if(s<minZoom)n=n.translate(p.x,p.y).scale(minZoom/s).translate(-p.x,-p.y);setCTM(g,n);stateTf=stateTf.multiply(n.inverse())}function handleMouseWheel(evt){if(!evt)evt=window.evt;if(!evt.shiftKey)return;if(evt.preventDefault)evt.preventDefault();evt.returnValue=false;if(state!="pan"){var delta;if(evt.wheelDelta){delta=evt.wheelDelta/7200}else{delta=evt.detail/-180}var svgDoc=evt.target.ownerDocument;var g=svgDoc.getElementById("viewport");var p=getEventPoint(evt);doZoom(g,p,1+delta)}}function handleMouseMove(evt){if(evt.preventDefault)evt.preventDefault();evt.returnValue=false;var g=svgDoc.getElementById("viewport");if(state=="pan"){var p=getEventPoint(evt).matrixTransform(stateTf);setCTM(g,stateTf.inverse().translate(p.x-stateOrigin.x,p.y-stateOrigin.y))}}function handleMouseDown(evt){if(evt.preventDefault)evt.preventDefault();evt.returnValue=false;var g=svgDoc.getElementById("viewport");state="pan";stateTf=g.getCTM().inverse();stateOrigin=getEventPoint(evt).matrixTransform(stateTf);g.style.cursor=cursorGrab}function handleMouseUp(evt){if(evt.preventDefault)evt.preventDefault();evt.returnValue=false;var g=svgDoc.getElementById("viewport");g.style.cursor="default";state=""}function dumpMatrix(matrix){var s="[ "+matrix.a+", "+matrix.c+", "+matrix.e+"\n "+matrix.b+", "+matrix.d+", "+matrix.f+"\n 0, 0, 1 ]";return s}function handlePan(x,y){var g=svgDoc.getElementById("viewport");setCTM(g,g.getCTM().translat
|