-
Notifications
You must be signed in to change notification settings - Fork 32
/
svg.path.min.js
5 lines (5 loc) · 3.56 KB
/
svg.path.min.js
1
2
3
4
5
/** svg.path.js - v0.6.0 - 2014-08-15
* http://otm.github.io/svg.path.js/
* Copyright (c) 2014 Nils Lagerkvist; Licensed under the MIT license /
*/
(function(){var a=Function.prototype.call.bind(Array.prototype.slice);SVG.extend(SVG.Path,{M:function(b){return b=1===arguments.length?[b.x,b.y]:a(arguments),this.addSegment("M",b,this._redrawEnabled),1===this._segments.length?this.plot("M"+b[0]+" "+b[1]):this},m:function(b){return b=1===arguments.length?[b.x,b.y]:a(arguments),this.addSegment("m",b,this._redrawEnabled),1===this._segments.length?this.plot("m"+b[0]+" "+b[1]):this},L:function(b){return b=1===arguments.length?[b.x,b.y]:a(arguments),this.addSegment("L",b,this._redrawEnabled)},l:function(b){return b=1===arguments.length?[b.x,b.y]:a(arguments),this.addSegment("l",b,this._redrawEnabled)},H:function(a){return this.addSegment("H",[a],this._redrawEnabled)},h:function(a){return this.addSegment("h",[a],this._redrawEnabled)},V:function(a){return this.addSegment("V",[a],this._redrawEnabled)},v:function(a){return this.addSegment("v",[a],this._redrawEnabled)},C:function(b,c,d){return d=3===arguments.length?[b.x,b.y,c.x,c.y,d.x,d.y]:a(arguments),this.addSegment("C",d,this._redrawEnabled)},c:function(b,c,d){return d=3===arguments.length?[b.x,b.y,c.x,c.y,d.x,d.y]:a(arguments),this.addSegment("c",d,this._redrawEnabled)},S:function(b,c){return c=2===arguments.length?[b.x,b.y,c.x,c.y]:a(arguments),this.addSegment("S",c,this._redrawEnabled)},s:function(b,c){return c=2===arguments.length?[b.x,b.y,c.x,c.y]:a(arguments),this.addSegment("s",c,this._redrawEnabled)},Q:function(b,c){return c=2===arguments.length?[b.x,b.y,c.x,c.y]:a(arguments),this.addSegment("Q",c,this._redrawEnabled)},q:function(b,c){return c=2===arguments.length?[b.x,b.y,c.x,c.y]:a(arguments),this.addSegment("q",c,this._redrawEnabled)},T:function(b){return b=1===arguments.length?[b.x,b.y]:a(arguments),this.addSegment("T",b,this._redrawEnabled)},t:function(b){return b=1===arguments.length?[b.x,b.y]:a(arguments),this.addSegment("t",b,this._redrawEnabled)},A:function(b,c,d,e,f,g){return g=6===arguments.length?[b,c,d,e,f,g.x,g.y]:a(arguments),this.addSegment("A",g,this._redrawEnabled)},a:function(b,c,d,e,f,g){return g=6===arguments.length?[b,c,d,e,f,g.x,g.y]:a(arguments),this.addSegment("a",g,this._redrawEnabled)},Z:function(){return this.addSegment("Z",[],this._redrawEnabled)},addSegment:function(a,b,c){var d={type:a,coords:b};return this._segments||(this._segments=[]),this._segments.push(d),c!==!1&&this._drawSegment(d),this},clear:function(){return this._segments&&(this._segments.length=0),this._lastSegment=null,this.plot()},getSegmentCount:function(){return this._segments.length},getSegment:function(a){return this._segments[a]},removeSegment:function(a){return this._segments.splice(a,1),this.redraw()},replaceSegment:function(a,b){return this._segments.splice(a,1,b),this.redraw()},drawAnimated:function(a){a=a||{},a.duration=a.duration||"1000",a.easing=a.easing||"<>",a.delay=a.delay||0;var b=this.length();this.stroke({width:2,dasharray:b+" "+b,dashoffset:b});var c=this.animate(a.duration,a.easing,a.delay);return c.stroke({dashoffset:0}),this},update:function(a){return a===!0&&(this._redrawEnabled=!1),a===!1&&(this._redrawEnabled=!0),!!this._redrawEnabled},redraw:function(){return this._lastSegment=null,this.attr("d",""),this._drawSegment(this._segments)},_drawSegment:function(a){var b="",c=this._lastSegment;Array.isArray(a)||(a=[a]);for(var d=0;d<a.length;d+=1)b+=c===a[d].type?" "+a[d].coords.join(" "):" "+a[d].type+a[d].coords.join(" "),c=a[d].type;return this._lastSegment=c,this.attr("d",(this.attr("d")||"")+b)}})}).call(this);