Comparing version 1.0.7 to 1.0.8
@@ -1,7 +0,7 @@ | ||
// https://d3js.org/d3-path/ v1.0.7 Copyright 2018 Mike Bostock | ||
// https://d3js.org/d3-path/ v1.0.8 Copyright 2019 Mike Bostock | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.d3 = global.d3 || {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
(global = global || self, factory(global.d3 = global.d3 || {})); | ||
}(this, function (exports) { 'use strict'; | ||
@@ -92,3 +92,3 @@ var pi = Math.PI, | ||
arc: function(x, y, r, a0, a1, ccw) { | ||
x = +x, y = +y, r = +r; | ||
x = +x, y = +y, r = +r, ccw = !!ccw; | ||
var dx = r * Math.cos(a0), | ||
@@ -142,2 +142,2 @@ dy = r * Math.sin(a0), | ||
}))); | ||
})); |
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-path/ v1.0.7 Copyright 2018 Mike Bostock | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.d3=t.d3||{})}(this,function(t){"use strict";var i=Math.PI,s=2*i,h=s-1e-6;function _(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function e(){return new _}_.prototype=e.prototype={constructor:_,moveTo:function(t,i){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+i)},closePath:function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,i){this._+="L"+(this._x1=+t)+","+(this._y1=+i)},quadraticCurveTo:function(t,i,s,h){this._+="Q"+ +t+","+ +i+","+(this._x1=+s)+","+(this._y1=+h)},bezierCurveTo:function(t,i,s,h,_,e){this._+="C"+ +t+","+ +i+","+ +s+","+ +h+","+(this._x1=+_)+","+(this._y1=+e)},arcTo:function(t,s,h,_,e){t=+t,s=+s,h=+h,_=+_,e=+e;var n=this._x1,o=this._y1,r=h-t,a=_-s,u=n-t,c=o-s,f=u*u+c*c;if(e<0)throw new Error("negative radius: "+e);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=s);else if(f>1e-6)if(Math.abs(c*r-a*u)>1e-6&&e){var x=h-n,y=_-o,M=r*r+a*a,l=x*x+y*y,d=Math.sqrt(M),p=Math.sqrt(f),v=e*Math.tan((i-Math.acos((M+f-l)/(2*d*p)))/2),b=v/p,w=v/d;Math.abs(b-1)>1e-6&&(this._+="L"+(t+b*u)+","+(s+b*c)),this._+="A"+e+","+e+",0,0,"+ +(c*x>u*y)+","+(this._x1=t+w*r)+","+(this._y1=s+w*a)}else this._+="L"+(this._x1=t)+","+(this._y1=s);else;},arc:function(t,_,e,n,o,r){t=+t,_=+_;var a=(e=+e)*Math.cos(n),u=e*Math.sin(n),c=t+a,f=_+u,x=1^r,y=r?n-o:o-n;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+c+","+f:(Math.abs(this._x1-c)>1e-6||Math.abs(this._y1-f)>1e-6)&&(this._+="L"+c+","+f),e&&(y<0&&(y=y%s+s),y>h?this._+="A"+e+","+e+",0,1,"+x+","+(t-a)+","+(_-u)+"A"+e+","+e+",0,1,"+x+","+(this._x1=c)+","+(this._y1=f):y>1e-6&&(this._+="A"+e+","+e+",0,"+ +(y>=i)+","+x+","+(this._x1=t+e*Math.cos(o))+","+(this._y1=_+e*Math.sin(o))))},rect:function(t,i,s,h){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+i)+"h"+ +s+"v"+ +h+"h"+-s+"Z"},toString:function(){return this._}},t.path=e,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
// https://d3js.org/d3-path/ v1.0.8 Copyright 2019 Mike Bostock | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t=t||self).d3=t.d3||{})}(this,function(t){"use strict";var i=Math.PI,s=2*i,h=s-1e-6;function e(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function _(){return new e}e.prototype=_.prototype={constructor:e,moveTo:function(t,i){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+i)},closePath:function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,i){this._+="L"+(this._x1=+t)+","+(this._y1=+i)},quadraticCurveTo:function(t,i,s,h){this._+="Q"+ +t+","+ +i+","+(this._x1=+s)+","+(this._y1=+h)},bezierCurveTo:function(t,i,s,h,e,_){this._+="C"+ +t+","+ +i+","+ +s+","+ +h+","+(this._x1=+e)+","+(this._y1=+_)},arcTo:function(t,s,h,e,_){t=+t,s=+s,h=+h,e=+e,_=+_;var n=this._x1,o=this._y1,r=h-t,a=e-s,u=n-t,f=o-s,c=u*u+f*f;if(_<0)throw new Error("negative radius: "+_);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=s);else if(c>1e-6)if(Math.abs(f*r-a*u)>1e-6&&_){var x=h-n,y=e-o,M=r*r+a*a,l=x*x+y*y,d=Math.sqrt(M),p=Math.sqrt(c),v=_*Math.tan((i-Math.acos((M+c-l)/(2*d*p)))/2),b=v/p,w=v/d;Math.abs(b-1)>1e-6&&(this._+="L"+(t+b*u)+","+(s+b*f)),this._+="A"+_+","+_+",0,0,"+ +(f*x>u*y)+","+(this._x1=t+w*r)+","+(this._y1=s+w*a)}else this._+="L"+(this._x1=t)+","+(this._y1=s);else;},arc:function(t,e,_,n,o,r){t=+t,e=+e,r=!!r;var a=(_=+_)*Math.cos(n),u=_*Math.sin(n),f=t+a,c=e+u,x=1^r,y=r?n-o:o-n;if(_<0)throw new Error("negative radius: "+_);null===this._x1?this._+="M"+f+","+c:(Math.abs(this._x1-f)>1e-6||Math.abs(this._y1-c)>1e-6)&&(this._+="L"+f+","+c),_&&(y<0&&(y=y%s+s),y>h?this._+="A"+_+","+_+",0,1,"+x+","+(t-a)+","+(e-u)+"A"+_+","+_+",0,1,"+x+","+(this._x1=f)+","+(this._y1=c):y>1e-6&&(this._+="A"+_+","+_+",0,"+ +(y>=i)+","+x+","+(this._x1=t+_*Math.cos(o))+","+(this._y1=e+_*Math.sin(o))))},rect:function(t,i,s,h){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+i)+"h"+ +s+"v"+ +h+"h"+-s+"Z"},toString:function(){return this._}},t.path=_,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "d3-path", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Serialize Canvas path commands to SVG.", | ||
@@ -30,2 +30,6 @@ "keywords": [ | ||
}, | ||
"files": [ | ||
"dist/**/*.js", | ||
"src/**/*.js" | ||
], | ||
"scripts": { | ||
@@ -38,7 +42,7 @@ "pretest": "rollup -c", | ||
"devDependencies": { | ||
"eslint": "5", | ||
"rollup": "0.64", | ||
"rollup-plugin-terser": "1", | ||
"eslint": "6", | ||
"rollup": "1", | ||
"rollup-plugin-terser": "5", | ||
"tape": "4" | ||
} | ||
} |
@@ -38,44 +38,42 @@ # d3-path | ||
[Try d3-path in your browser.](https://tonicdev.com/npm/d3-path) | ||
## API Reference | ||
<a name="path" href="#path">#</a> d3.<b>path</b>() [<>](https://github.com/d3/d3-path/blob/master/src/path.js "Source") | ||
<a name="path" href="#path">#</a> d3.<b>path</b>() · [Source](https://github.com/d3/d3-path/blob/master/src/path.js), [Examples](https://observablehq.com/@d3/d3-path) | ||
Constructs a new path serializer that implements [CanvasPathMethods](http://www.w3.org/TR/2dcontext/#canvaspathmethods). | ||
<a name="path_moveTo" href="#path_moveTo">#</a> <i>path</i>.<b>moveTo</b>(<i>x</i>, <i>y</i>) [<>](https://github.com/d3/d3-path/blob/master/src/path.js#L18 "Source") | ||
<a name="path_moveTo" href="#path_moveTo">#</a> <i>path</i>.<b>moveTo</b>(<i>x</i>, <i>y</i>) | ||
Move to the specified point ⟨*x*, *y*⟩. Equivalent to [*context*.moveTo](http://www.w3.org/TR/2dcontext/#dom-context-2d-moveto) and SVG’s [“moveto” command](http://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands). | ||
<a name="path_closePath" href="#path_closePath">#</A> <i>path</i>.<b>closePath</b>() [<>](https://github.com/d3/d3-path/blob/master/src/path.js#L21 "Source") | ||
<a name="path_closePath" href="#path_closePath">#</A> <i>path</i>.<b>closePath</b>() | ||
Ends the current subpath and causes an automatic straight line to be drawn from the current point to the initial point of the current subpath. Equivalent to [*context*.closePath](http://www.w3.org/TR/2dcontext/#dom-context-2d-closepath) and SVG’s [“closepath” command](http://www.w3.org/TR/SVG/paths.html#PathDataClosePathCommand). | ||
<a name="path_lineTo" href="#path_lineTo">#</a> <i>path</i>.<b>lineTo</b>(<i>x</i>, <i>y</i>) [<>](https://github.com/d3/d3-path/blob/master/src/path.js#L27 "Source") | ||
<a name="path_lineTo" href="#path_lineTo">#</a> <i>path</i>.<b>lineTo</b>(<i>x</i>, <i>y</i>) | ||
Draws a straight line from the current point to the specified point ⟨*x*, *y*⟩. Equivalent to [*context*.lineTo](http://www.w3.org/TR/2dcontext/#dom-context-2d-lineto) and SVG’s [“lineto” command](http://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands). | ||
<a name="path_quadraticCurveTo" href="#path_quadraticCurveTo">#</a> <i>path</i>.<b>quadraticCurveTo</b>(<i>cpx</i>, <i>cpy</i>, <i>x</i>, <i>y</i>) [<>](https://github.com/d3/d3-path/blob/master/src/path.js#L30 "Source") | ||
<a name="path_quadraticCurveTo" href="#path_quadraticCurveTo">#</a> <i>path</i>.<b>quadraticCurveTo</b>(<i>cpx</i>, <i>cpy</i>, <i>x</i>, <i>y</i>) | ||
Draws a quadratic Bézier segment from the current point to the specified point ⟨*x*, *y*⟩, with the specified control point ⟨*cpx*, *cpy*⟩. Equivalent to [*context*.quadraticCurveTo](http://www.w3.org/TR/2dcontext/#dom-context-2d-quadraticcurveto) and SVG’s [quadratic Bézier curve commands](http://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands). | ||
<a name="path_bezierCurveTo" href="#path_bezierCurveTo">#</a> <i>path</i>.<b>bezierCurveTo</b>(<i>cpx1</i>, <i>cpy1</i>, <i>cpx2</i>, <i>cpy2</i>, <i>x</i>, <i>y</i>) [<>](https://github.com/d3/d3-path/blob/master/src/path.js#L33 "Source") | ||
<a name="path_bezierCurveTo" href="#path_bezierCurveTo">#</a> <i>path</i>.<b>bezierCurveTo</b>(<i>cpx1</i>, <i>cpy1</i>, <i>cpx2</i>, <i>cpy2</i>, <i>x</i>, <i>y</i>) | ||
Draws a cubic Bézier segment from the current point to the specified point ⟨*x*, *y*⟩, with the specified control points ⟨*cpx1*, *cpy1*⟩ and ⟨*cpx2*, *cpy2*⟩. Equivalent to [*context*.bezierCurveTo](http://www.w3.org/TR/2dcontext/#dom-context-2d-beziercurveto) and SVG’s [cubic Bézier curve commands](http://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands). | ||
<a name="path_arcTo" href="#path_arcTo">#</a> <i>path</i>.<b>arcTo</b>(<i>x1</i>, <i>y1</i>, <i>x2</i>, <i>y2</i>, <i>radius</i>) [<>](https://github.com/d3/d3-path/blob/master/src/path.js#L36 "Source") | ||
<a name="path_arcTo" href="#path_arcTo">#</a> <i>path</i>.<b>arcTo</b>(<i>x1</i>, <i>y1</i>, <i>x2</i>, <i>y2</i>, <i>radius</i>) | ||
Draws a circular arc segment with the specified *radius* that starts tangent to the line between the current point and the specified point ⟨*x1*, *y1*⟩ and ends tangent to the line between the specified points ⟨*x1*, *y1*⟩ and ⟨*x2*, *y2*⟩. If the first tangent point is not equal to the current point, a straight line is drawn between the current point and the first tangent point. Equivalent to [*context*.arcTo](http://www.w3.org/TR/2dcontext/#dom-context-2d-arcto) and uses SVG’s [elliptical arc curve commands](http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands). | ||
<a name="path_arc" href="#path_arc">#</a> <i>path</i>.<b>arc</b>(<i>x</i>, <i>y</i>, <i>radius</i>, <i>startAngle</i>, <i>endAngle</i>[, <i>anticlockwise</i>]) [<>](https://github.com/d3/d3-path/blob/master/src/path.js#L84 "Source") | ||
<a name="path_arc" href="#path_arc">#</a> <i>path</i>.<b>arc</b>(<i>x</i>, <i>y</i>, <i>radius</i>, <i>startAngle</i>, <i>endAngle</i>[, <i>anticlockwise</i>]) | ||
Draws a circular arc segment with the specified center ⟨*x*, *y*⟩, *radius*, *startAngle* and *endAngle*. If *anticlockwise* is true, the arc is drawn in the anticlockwise direction; otherwise, it is drawn in the clockwise direction. If the current point is not equal to the starting point of the arc, a straight line is drawn from the current point to the start of the arc. Equivalent to [*context*.arc](http://www.w3.org/TR/2dcontext/#dom-context-2d-arc) and uses SVG’s [elliptical arc curve commands](http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands). | ||
<a name="path_rect" href="#path_rect">#</a> <i>path</i>.<b>rect</b>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>) [<>](https://github.com/d3/d3-path/blob/master/src/path.js#L122 "Source") | ||
<a name="path_rect" href="#path_rect">#</a> <i>path</i>.<b>rect</b>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>) | ||
Creates a new subpath containing just the four points ⟨*x*, *y*⟩, ⟨*x* + *w*, *y*⟩, ⟨*x* + *w*, *y* + *h*⟩, ⟨*x*, *y* + *h*⟩, with those four points connected by straight lines, and then marks the subpath as closed. Equivalent to [*context*.rect](http://www.w3.org/TR/2dcontext/#dom-context-2d-rect) and uses SVG’s [“lineto” commands](http://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands). | ||
<a name="path_toString" href="#path_toString">#</a> <i>path</i>.<b>toString</b>() [<>](https://github.com/d3/d3-path/blob/master/src/path.js#L125 "Source") | ||
<a name="path_toString" href="#path_toString">#</a> <i>path</i>.<b>toString</b>() | ||
Returns the string representation of this *path* according to SVG’s [path data specification](http://www.w3.org/TR/SVG/paths.html#PathData). |
@@ -85,3 +85,3 @@ var pi = Math.PI, | ||
arc: function(x, y, r, a0, a1, ccw) { | ||
x = +x, y = +y, r = +r; | ||
x = +x, y = +y, r = +r, ccw = !!ccw; | ||
var dx = r * Math.cos(a0), | ||
@@ -88,0 +88,0 @@ dy = r * Math.sin(a0), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20208
7
243
79