@antv/g-plugin-canvas-path-generator
Advanced tools
Comparing version 1.1.26 to 1.1.27
@@ -94,11 +94,4 @@ import { DisplayObject, Shape, AbstractRendererPlugin } from '@antv/g-lite'; | ||
var _parsedStyle$path = parsedStyle.path, | ||
curve = _parsedStyle$path.curve, | ||
zCommandIndexes = _parsedStyle$path.zCommandIndexes; | ||
var path = [].concat(curve); | ||
zCommandIndexes.forEach(function (zIndex, index) { | ||
// @ts-ignore | ||
path.splice(zIndex + index + 1, 0, ['Z']); | ||
}); // @ts-ignore | ||
var isClosed = path.length && path[path.length - 1][0] === 'Z'; | ||
absolutePath = _parsedStyle$path.absolutePath, | ||
segments = _parsedStyle$path.segments; | ||
var startOffsetX = 0; | ||
@@ -136,19 +129,83 @@ var startOffsetY = 0; | ||
for (var i = 0; i < path.length; i++) { | ||
var params = path[i]; | ||
for (var i = 0; i < absolutePath.length; i++) { | ||
var params = absolutePath[i]; | ||
var command = params[0]; | ||
var nextSegment = absolutePath[i + 1]; | ||
var useStartOffset = i === 0 && startOffsetX !== 0 && startOffsetY !== 0; | ||
var useEndOffset = (i === absolutePath.length - 1 || nextSegment && (nextSegment[0] === 'M' || nextSegment[0] === 'Z')) && endOffsetX !== 0 && endOffsetY !== 0; | ||
switch (command) { | ||
case 'M': | ||
context.moveTo(params[1] - defX + startOffsetX, params[2] - defY + startOffsetY); | ||
// Use start marker offset | ||
if (useStartOffset) { | ||
context.moveTo(params[1] - defX + startOffsetX, params[2] - defY + startOffsetY); | ||
context.lineTo(params[1] - defX, params[2] - defY); | ||
} else { | ||
context.moveTo(params[1] - defX, params[2] - defY); | ||
} | ||
break; | ||
case 'L': | ||
if (useEndOffset) { | ||
context.lineTo(params[1] - defX + endOffsetX, params[2] - defY + endOffsetY); | ||
} else { | ||
context.lineTo(params[1] - defX, params[2] - defY); | ||
} | ||
break; | ||
case 'Q': | ||
context.quadraticCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY); | ||
if (useEndOffset) { | ||
context.lineTo(params[3] - defX + endOffsetX, params[4] - defY + endOffsetY); | ||
} | ||
break; | ||
case 'C': | ||
// the last C command | ||
var offsetX = i === path.length - (isClosed ? 2 : 1) ? endOffsetX : 0; | ||
var offsetY = i === path.length - (isClosed ? 2 : 1) ? endOffsetY : 0; | ||
context.bezierCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY, params[5] - defX + offsetX, params[6] - defY + offsetY); | ||
context.bezierCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY, params[5] - defX, params[6] - defY); | ||
if (useEndOffset) { | ||
context.lineTo(params[5] - defX + endOffsetX, params[6] - defY + endOffsetY); | ||
} | ||
break; | ||
// @ts-ignore | ||
case 'A': | ||
{ | ||
var arcParams = segments[i].arcParams; | ||
var cx = arcParams.cx, | ||
cy = arcParams.cy, | ||
rx = arcParams.rx, | ||
ry = arcParams.ry, | ||
startAngle = arcParams.startAngle, | ||
endAngle = arcParams.endAngle, | ||
xRotation = arcParams.xRotation, | ||
sweepFlag = arcParams.sweepFlag; // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse | ||
if (context.ellipse) { | ||
context.ellipse(cx - defX, cy - defY, rx, ry, xRotation, startAngle, endAngle, !!(1 - sweepFlag)); | ||
} else { | ||
// @see https://stackoverflow.com/a/47494351 | ||
var r = rx > ry ? rx : ry; | ||
var scaleX = rx > ry ? 1 : rx / ry; | ||
var scaleY = rx > ry ? ry / rx : 1; | ||
context.translate(cx - defX, cy - defY); | ||
context.rotate(xRotation); | ||
context.scale(scaleX, scaleY); | ||
context.arc(0, 0, r, startAngle, endAngle, !!(1 - sweepFlag)); | ||
context.scale(1 / scaleX, 1 / scaleY); | ||
context.rotate(-xRotation); | ||
context.translate(-(cx - defX), -(cy - defY)); | ||
} | ||
if (useEndOffset) { | ||
context.lineTo(params[6] - defX + endOffsetX, params[7] - defY + endOffsetY); | ||
} | ||
break; | ||
} | ||
case 'Z': | ||
@@ -155,0 +212,0 @@ context.closePath(); |
@@ -98,11 +98,4 @@ 'use strict'; | ||
var _parsedStyle$path = parsedStyle.path, | ||
curve = _parsedStyle$path.curve, | ||
zCommandIndexes = _parsedStyle$path.zCommandIndexes; | ||
var path = [].concat(curve); | ||
zCommandIndexes.forEach(function (zIndex, index) { | ||
// @ts-ignore | ||
path.splice(zIndex + index + 1, 0, ['Z']); | ||
}); // @ts-ignore | ||
var isClosed = path.length && path[path.length - 1][0] === 'Z'; | ||
absolutePath = _parsedStyle$path.absolutePath, | ||
segments = _parsedStyle$path.segments; | ||
var startOffsetX = 0; | ||
@@ -140,19 +133,83 @@ var startOffsetY = 0; | ||
for (var i = 0; i < path.length; i++) { | ||
var params = path[i]; | ||
for (var i = 0; i < absolutePath.length; i++) { | ||
var params = absolutePath[i]; | ||
var command = params[0]; | ||
var nextSegment = absolutePath[i + 1]; | ||
var useStartOffset = i === 0 && startOffsetX !== 0 && startOffsetY !== 0; | ||
var useEndOffset = (i === absolutePath.length - 1 || nextSegment && (nextSegment[0] === 'M' || nextSegment[0] === 'Z')) && endOffsetX !== 0 && endOffsetY !== 0; | ||
switch (command) { | ||
case 'M': | ||
context.moveTo(params[1] - defX + startOffsetX, params[2] - defY + startOffsetY); | ||
// Use start marker offset | ||
if (useStartOffset) { | ||
context.moveTo(params[1] - defX + startOffsetX, params[2] - defY + startOffsetY); | ||
context.lineTo(params[1] - defX, params[2] - defY); | ||
} else { | ||
context.moveTo(params[1] - defX, params[2] - defY); | ||
} | ||
break; | ||
case 'L': | ||
if (useEndOffset) { | ||
context.lineTo(params[1] - defX + endOffsetX, params[2] - defY + endOffsetY); | ||
} else { | ||
context.lineTo(params[1] - defX, params[2] - defY); | ||
} | ||
break; | ||
case 'Q': | ||
context.quadraticCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY); | ||
if (useEndOffset) { | ||
context.lineTo(params[3] - defX + endOffsetX, params[4] - defY + endOffsetY); | ||
} | ||
break; | ||
case 'C': | ||
// the last C command | ||
var offsetX = i === path.length - (isClosed ? 2 : 1) ? endOffsetX : 0; | ||
var offsetY = i === path.length - (isClosed ? 2 : 1) ? endOffsetY : 0; | ||
context.bezierCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY, params[5] - defX + offsetX, params[6] - defY + offsetY); | ||
context.bezierCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY, params[5] - defX, params[6] - defY); | ||
if (useEndOffset) { | ||
context.lineTo(params[5] - defX + endOffsetX, params[6] - defY + endOffsetY); | ||
} | ||
break; | ||
// @ts-ignore | ||
case 'A': | ||
{ | ||
var arcParams = segments[i].arcParams; | ||
var cx = arcParams.cx, | ||
cy = arcParams.cy, | ||
rx = arcParams.rx, | ||
ry = arcParams.ry, | ||
startAngle = arcParams.startAngle, | ||
endAngle = arcParams.endAngle, | ||
xRotation = arcParams.xRotation, | ||
sweepFlag = arcParams.sweepFlag; // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse | ||
if (context.ellipse) { | ||
context.ellipse(cx - defX, cy - defY, rx, ry, xRotation, startAngle, endAngle, !!(1 - sweepFlag)); | ||
} else { | ||
// @see https://stackoverflow.com/a/47494351 | ||
var r = rx > ry ? rx : ry; | ||
var scaleX = rx > ry ? 1 : rx / ry; | ||
var scaleY = rx > ry ? ry / rx : 1; | ||
context.translate(cx - defX, cy - defY); | ||
context.rotate(xRotation); | ||
context.scale(scaleX, scaleY); | ||
context.arc(0, 0, r, startAngle, endAngle, !!(1 - sweepFlag)); | ||
context.scale(1 / scaleX, 1 / scaleY); | ||
context.rotate(-xRotation); | ||
context.translate(-(cx - defX), -(cy - defY)); | ||
} | ||
if (useEndOffset) { | ||
context.lineTo(params[6] - defX + endOffsetX, params[7] - defY + endOffsetY); | ||
} | ||
break; | ||
} | ||
case 'Z': | ||
@@ -159,0 +216,0 @@ context.closePath(); |
@@ -97,11 +97,4 @@ (function (global, factory) { | ||
var _parsedStyle$path = parsedStyle.path, | ||
curve = _parsedStyle$path.curve, | ||
zCommandIndexes = _parsedStyle$path.zCommandIndexes; | ||
var path = [].concat(curve); | ||
zCommandIndexes.forEach(function (zIndex, index) { | ||
// @ts-ignore | ||
path.splice(zIndex + index + 1, 0, ['Z']); | ||
}); // @ts-ignore | ||
var isClosed = path.length && path[path.length - 1][0] === 'Z'; | ||
absolutePath = _parsedStyle$path.absolutePath, | ||
segments = _parsedStyle$path.segments; | ||
var startOffsetX = 0; | ||
@@ -139,19 +132,83 @@ var startOffsetY = 0; | ||
for (var i = 0; i < path.length; i++) { | ||
var params = path[i]; | ||
for (var i = 0; i < absolutePath.length; i++) { | ||
var params = absolutePath[i]; | ||
var command = params[0]; | ||
var nextSegment = absolutePath[i + 1]; | ||
var useStartOffset = i === 0 && startOffsetX !== 0 && startOffsetY !== 0; | ||
var useEndOffset = (i === absolutePath.length - 1 || nextSegment && (nextSegment[0] === 'M' || nextSegment[0] === 'Z')) && endOffsetX !== 0 && endOffsetY !== 0; | ||
switch (command) { | ||
case 'M': | ||
context.moveTo(params[1] - defX + startOffsetX, params[2] - defY + startOffsetY); | ||
// Use start marker offset | ||
if (useStartOffset) { | ||
context.moveTo(params[1] - defX + startOffsetX, params[2] - defY + startOffsetY); | ||
context.lineTo(params[1] - defX, params[2] - defY); | ||
} else { | ||
context.moveTo(params[1] - defX, params[2] - defY); | ||
} | ||
break; | ||
case 'L': | ||
if (useEndOffset) { | ||
context.lineTo(params[1] - defX + endOffsetX, params[2] - defY + endOffsetY); | ||
} else { | ||
context.lineTo(params[1] - defX, params[2] - defY); | ||
} | ||
break; | ||
case 'Q': | ||
context.quadraticCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY); | ||
if (useEndOffset) { | ||
context.lineTo(params[3] - defX + endOffsetX, params[4] - defY + endOffsetY); | ||
} | ||
break; | ||
case 'C': | ||
// the last C command | ||
var offsetX = i === path.length - (isClosed ? 2 : 1) ? endOffsetX : 0; | ||
var offsetY = i === path.length - (isClosed ? 2 : 1) ? endOffsetY : 0; | ||
context.bezierCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY, params[5] - defX + offsetX, params[6] - defY + offsetY); | ||
context.bezierCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY, params[5] - defX, params[6] - defY); | ||
if (useEndOffset) { | ||
context.lineTo(params[5] - defX + endOffsetX, params[6] - defY + endOffsetY); | ||
} | ||
break; | ||
// @ts-ignore | ||
case 'A': | ||
{ | ||
var arcParams = segments[i].arcParams; | ||
var cx = arcParams.cx, | ||
cy = arcParams.cy, | ||
rx = arcParams.rx, | ||
ry = arcParams.ry, | ||
startAngle = arcParams.startAngle, | ||
endAngle = arcParams.endAngle, | ||
xRotation = arcParams.xRotation, | ||
sweepFlag = arcParams.sweepFlag; // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse | ||
if (context.ellipse) { | ||
context.ellipse(cx - defX, cy - defY, rx, ry, xRotation, startAngle, endAngle, !!(1 - sweepFlag)); | ||
} else { | ||
// @see https://stackoverflow.com/a/47494351 | ||
var r = rx > ry ? rx : ry; | ||
var scaleX = rx > ry ? 1 : rx / ry; | ||
var scaleY = rx > ry ? ry / rx : 1; | ||
context.translate(cx - defX, cy - defY); | ||
context.rotate(xRotation); | ||
context.scale(scaleX, scaleY); | ||
context.arc(0, 0, r, startAngle, endAngle, !!(1 - sweepFlag)); | ||
context.scale(1 / scaleX, 1 / scaleY); | ||
context.rotate(-xRotation); | ||
context.translate(-(cx - defX), -(cy - defY)); | ||
} | ||
if (useEndOffset) { | ||
context.lineTo(params[6] - defX + endOffsetX, params[7] - defY + endOffsetY); | ||
} | ||
break; | ||
} | ||
case 'Z': | ||
@@ -158,0 +215,0 @@ context.closePath(); |
@@ -1,1 +0,1 @@ | ||
!function(t,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],a):a(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.CanvasPathGenerator={}),t.window.G)}(this,(function(t,a){"use strict";function e(t,a){return e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},e(t,a)}function n(t,a){var e=a.r;t.arc(e,e,e,0,2*Math.PI,!1)}function r(t,a){var e=a.rx,n=a.ry;if(t.ellipse)t.ellipse(e,n,e,n,0,0,2*Math.PI,!1);else{var r=e>n?e:n,o=e>n?1:e/n,i=e>n?n/e:1;t.save(),t.scale(o,i),t.arc(0,0,r,0,2*Math.PI)}}function o(t,e){var n,r,o=e.x1,i=e.y1,s=e.x2,c=e.y2,h=e.defX,f=void 0===h?0:h,p=e.defY,d=void 0===p?0:p,l=e.markerStart,v=e.markerEnd,M=e.markerStartOffset,u=e.markerEndOffset,m=0,y=0,O=0,P=0,T=0;l&&l instanceof a.DisplayObject&&M&&(n=s-o,r=c-i,T=Math.atan2(r,n),m=Math.cos(T)*(M||0),y=Math.sin(T)*(M||0)),v&&v instanceof a.DisplayObject&&u&&(n=o-s,r=i-c,T=Math.atan2(r,n),O=Math.cos(T)*(u||0),P=Math.sin(T)*(u||0)),t.moveTo(o-f+m,i-d+y),t.lineTo(s-f+O,c-d+P)}function i(t,e){var n=e.defX,r=void 0===n?0:n,o=e.defY,i=void 0===o?0:o,s=e.markerStart,c=e.markerEnd,h=e.markerStartOffset,f=e.markerEndOffset,p=e.path,d=p.zCommandIndexes,l=[].concat(p.curve);d.forEach((function(t,a){l.splice(t+a+1,0,["Z"])}));var v,M,u=l.length&&"Z"===l[l.length-1][0],m=0,y=0,O=0,P=0,T=0;if(s&&s instanceof a.DisplayObject&&h){var S=s.parentNode.getStartTangent(),b=S[0],g=S[1];v=b[0]-g[0],M=b[1]-g[1],T=Math.atan2(M,v),m=Math.cos(T)*(h||0),y=Math.sin(T)*(h||0)}if(c&&c instanceof a.DisplayObject&&f){var I=c.parentNode.getEndTangent(),E=I[0],k=I[1];v=E[0]-k[0],M=E[1]-k[1],T=Math.atan2(M,v),O=Math.cos(T)*(f||0),P=Math.sin(T)*(f||0)}for(var j=0;l.length>j;j++){var G=l[j];switch(G[0]){case"M":t.moveTo(G[1]-r+m,G[2]-i+y);break;case"C":t.bezierCurveTo(G[1]-r,G[2]-i,G[3]-r,G[4]-i,G[5]-r+(j===l.length-(u?2:1)?O:0),G[6]-i+(j===l.length-(u?2:1)?P:0));break;case"Z":t.closePath()}}}function s(t,e){var n,r,o=e.defX,i=void 0===o?0:o,s=e.defY,c=void 0===s?0:s,h=e.markerStart,f=e.markerEnd,p=e.markerStartOffset,d=e.markerEndOffset,l=e.points.points,v=l.length,M=l[0][0]-i,u=l[0][1]-c,m=l[v-1][0]-i,y=l[v-1][1]-c,O=0,P=0,T=0,S=0,b=0;h&&h instanceof a.DisplayObject&&p&&(n=l[1][0]-l[0][0],r=l[1][1]-l[0][1],b=Math.atan2(r,n),O=Math.cos(b)*(p||0),P=Math.sin(b)*(p||0)),f&&f instanceof a.DisplayObject&&d&&(n=l[v-1][0]-l[0][0],r=l[v-1][1]-l[0][1],b=Math.atan2(r,n),T=Math.cos(b)*(d||0),S=Math.sin(b)*(d||0)),t.moveTo(M+(O||T),u+(P||S));for(var g=1;v-1>g;g++){var I=l[g];t.lineTo(I[0]-i,I[1]-c)}t.lineTo(m,y)}function c(t,e){var n,r,o=e.defX,i=void 0===o?0:o,s=e.defY,c=void 0===s?0:s,h=e.markerStart,f=e.markerEnd,p=e.markerStartOffset,d=e.markerEndOffset,l=e.points.points,v=l.length,M=l[0][0]-i,u=l[0][1]-c,m=l[v-1][0]-i,y=l[v-1][1]-c,O=0,P=0,T=0,S=0,b=0;h&&h instanceof a.DisplayObject&&p&&(n=l[1][0]-l[0][0],r=l[1][1]-l[0][1],b=Math.atan2(r,n),O=Math.cos(b)*(p||0),P=Math.sin(b)*(p||0)),f&&f instanceof a.DisplayObject&&d&&(n=l[v-2][0]-l[v-1][0],r=l[v-2][1]-l[v-1][1],b=Math.atan2(r,n),T=Math.cos(b)*(d||0),S=Math.sin(b)*(d||0)),t.moveTo(M+O,u+P);for(var g=1;v-1>g;g++){var I=l[g];t.lineTo(I[0]-i,I[1]-c)}t.lineTo(m+T,y+S)}function h(t,a){var e=a.radius,n=a.width,r=a.height,o=n,i=r;if(e&&e.some((function(t){return 0!==t}))){var s=n>0?1:-1,c=r>0?1:-1,h=s+c===0,f=e.map((function(t){return a=t,e=0,n=Math.min(Math.abs(o)/2,Math.abs(i)/2),e>a?e:a>n?n:a;var a,e,n})),p=f[0],d=f[1],l=f[2],v=f[3];t.moveTo(s*p,0),t.lineTo(o-s*d,0),0!==d&&t.arc(o-s*d,c*d,d,-c*Math.PI/2,s>0?0:Math.PI,h),t.lineTo(o,i-c*l),0!==l&&t.arc(o-s*l,i-c*l,l,s>0?0:Math.PI,c>0?Math.PI/2:1.5*Math.PI,h),t.lineTo(s*v,i),0!==v&&t.arc(s*v,i-c*v,v,c>0?Math.PI/2:-Math.PI/2,s>0?Math.PI:0,h),t.lineTo(0,c*p),0!==p&&t.arc(s*p,c*p,p,s>0?Math.PI:0,c>0?1.5*Math.PI:Math.PI/2,h)}else t.rect(0,0,o,i)}var f=function(t){var f,p;function d(){for(var a,e=arguments.length,n=new Array(e),r=0;e>r;r++)n[r]=arguments[r];return(a=t.call.apply(t,[this].concat(n))||this).name="canvas-path-generator",a}p=t,(f=d).prototype=Object.create(p.prototype),f.prototype.constructor=f,e(f,p);var l=d.prototype;return l.init=function(){var t,e=((t={})[a.Shape.CIRCLE]=n,t[a.Shape.ELLIPSE]=r,t[a.Shape.RECT]=h,t[a.Shape.LINE]=o,t[a.Shape.POLYLINE]=c,t[a.Shape.POLYGON]=s,t[a.Shape.PATH]=i,t[a.Shape.TEXT]=void 0,t[a.Shape.GROUP]=void 0,t[a.Shape.IMAGE]=void 0,t[a.Shape.HTML]=void 0,t[a.Shape.MESH]=void 0,t);this.context.pathGeneratorFactory=e},l.destroy=function(){delete this.context.pathGeneratorFactory},d}(a.AbstractRendererPlugin);t.Plugin=f,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.CanvasPathGenerator={}),t.window.G)}(this,(function(t,e){"use strict";function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function n(t,e){var a=e.r;t.arc(a,a,a,0,2*Math.PI,!1)}function r(t,e){var a=e.rx,n=e.ry;if(t.ellipse)t.ellipse(a,n,a,n,0,0,2*Math.PI,!1);else{var r=a>n?a:n,o=a>n?1:a/n,i=a>n?n/a:1;t.save(),t.scale(o,i),t.arc(0,0,r,0,2*Math.PI)}}function o(t,a){var n,r,o=a.x1,i=a.y1,s=a.x2,c=a.y2,h=a.defX,f=void 0===h?0:h,l=a.defY,p=void 0===l?0:l,d=a.markerStart,v=a.markerEnd,M=a.markerStartOffset,u=a.markerEndOffset,T=0,m=0,y=0,P=0,b=0;d&&d instanceof e.DisplayObject&&M&&(n=s-o,r=c-i,b=Math.atan2(r,n),T=Math.cos(b)*(M||0),m=Math.sin(b)*(M||0)),v&&v instanceof e.DisplayObject&&u&&(n=o-s,r=i-c,b=Math.atan2(r,n),y=Math.cos(b)*(u||0),P=Math.sin(b)*(u||0)),t.moveTo(o-f+T,i-p+m),t.lineTo(s-f+y,c-p+P)}function i(t,a){var n,r,o=a.defX,i=void 0===o?0:o,s=a.defY,c=void 0===s?0:s,h=a.markerStart,f=a.markerEnd,l=a.markerStartOffset,p=a.markerEndOffset,d=a.path,v=d.absolutePath,M=d.segments,u=0,T=0,m=0,y=0,P=0;if(h&&h instanceof e.DisplayObject&&l){var b=h.parentNode.getStartTangent(),O=b[0],S=b[1];n=O[0]-S[0],r=O[1]-S[1],P=Math.atan2(r,n),u=Math.cos(P)*(l||0),T=Math.sin(P)*(l||0)}if(f&&f instanceof e.DisplayObject&&p){var g=f.parentNode.getEndTangent(),k=g[0],I=g[1];n=k[0]-I[0],r=k[1]-I[1],P=Math.atan2(r,n),m=Math.cos(P)*(p||0),y=Math.sin(P)*(p||0)}for(var E=0;v.length>E;E++){var j=v[E],x=v[E+1],G=0===E&&0!==u&&0!==T,L=(E===v.length-1||x&&("M"===x[0]||"Z"===x[0]))&&0!==m&&0!==y;switch(j[0]){case"M":G?(t.moveTo(j[1]-i+u,j[2]-c+T),t.lineTo(j[1]-i,j[2]-c)):t.moveTo(j[1]-i,j[2]-c);break;case"L":L?t.lineTo(j[1]-i+m,j[2]-c+y):t.lineTo(j[1]-i,j[2]-c);break;case"Q":t.quadraticCurveTo(j[1]-i,j[2]-c,j[3]-i,j[4]-c),L&&t.lineTo(j[3]-i+m,j[4]-c+y);break;case"C":t.bezierCurveTo(j[1]-i,j[2]-c,j[3]-i,j[4]-c,j[5]-i,j[6]-c),L&&t.lineTo(j[5]-i+m,j[6]-c+y);break;case"A":var D=M[E].arcParams,A=D.cx,C=D.cy,w=D.rx,Y=D.ry,_=D.startAngle,N=D.endAngle,R=D.xRotation,X=D.sweepFlag;if(t.ellipse)t.ellipse(A-i,C-c,w,Y,R,_,N,!!(1-X));else{var F=w>Y?w:Y,H=w>Y?1:w/Y,q=w>Y?Y/w:1;t.translate(A-i,C-c),t.rotate(R),t.scale(H,q),t.arc(0,0,F,_,N,!!(1-X)),t.scale(1/H,1/q),t.rotate(-R),t.translate(-(A-i),-(C-c))}L&&t.lineTo(j[6]-i+m,j[7]-c+y);break;case"Z":t.closePath()}}}function s(t,a){var n,r,o=a.defX,i=void 0===o?0:o,s=a.defY,c=void 0===s?0:s,h=a.markerStart,f=a.markerEnd,l=a.markerStartOffset,p=a.markerEndOffset,d=a.points.points,v=d.length,M=d[0][0]-i,u=d[0][1]-c,T=d[v-1][0]-i,m=d[v-1][1]-c,y=0,P=0,b=0,O=0,S=0;h&&h instanceof e.DisplayObject&&l&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],S=Math.atan2(r,n),y=Math.cos(S)*(l||0),P=Math.sin(S)*(l||0)),f&&f instanceof e.DisplayObject&&p&&(n=d[v-1][0]-d[0][0],r=d[v-1][1]-d[0][1],S=Math.atan2(r,n),b=Math.cos(S)*(p||0),O=Math.sin(S)*(p||0)),t.moveTo(M+(y||b),u+(P||O));for(var g=1;v-1>g;g++){var k=d[g];t.lineTo(k[0]-i,k[1]-c)}t.lineTo(T,m)}function c(t,a){var n,r,o=a.defX,i=void 0===o?0:o,s=a.defY,c=void 0===s?0:s,h=a.markerStart,f=a.markerEnd,l=a.markerStartOffset,p=a.markerEndOffset,d=a.points.points,v=d.length,M=d[0][0]-i,u=d[0][1]-c,T=d[v-1][0]-i,m=d[v-1][1]-c,y=0,P=0,b=0,O=0,S=0;h&&h instanceof e.DisplayObject&&l&&(n=d[1][0]-d[0][0],r=d[1][1]-d[0][1],S=Math.atan2(r,n),y=Math.cos(S)*(l||0),P=Math.sin(S)*(l||0)),f&&f instanceof e.DisplayObject&&p&&(n=d[v-2][0]-d[v-1][0],r=d[v-2][1]-d[v-1][1],S=Math.atan2(r,n),b=Math.cos(S)*(p||0),O=Math.sin(S)*(p||0)),t.moveTo(M+y,u+P);for(var g=1;v-1>g;g++){var k=d[g];t.lineTo(k[0]-i,k[1]-c)}t.lineTo(T+b,m+O)}function h(t,e){var a=e.radius,n=e.width,r=e.height,o=n,i=r;if(a&&a.some((function(t){return 0!==t}))){var s=n>0?1:-1,c=r>0?1:-1,h=s+c===0,f=a.map((function(t){return e=t,a=0,n=Math.min(Math.abs(o)/2,Math.abs(i)/2),a>e?a:e>n?n:e;var e,a,n})),l=f[0],p=f[1],d=f[2],v=f[3];t.moveTo(s*l,0),t.lineTo(o-s*p,0),0!==p&&t.arc(o-s*p,c*p,p,-c*Math.PI/2,s>0?0:Math.PI,h),t.lineTo(o,i-c*d),0!==d&&t.arc(o-s*d,i-c*d,d,s>0?0:Math.PI,c>0?Math.PI/2:1.5*Math.PI,h),t.lineTo(s*v,i),0!==v&&t.arc(s*v,i-c*v,v,c>0?Math.PI/2:-Math.PI/2,s>0?Math.PI:0,h),t.lineTo(0,c*l),0!==l&&t.arc(s*l,c*l,l,s>0?Math.PI:0,c>0?1.5*Math.PI:Math.PI/2,h)}else t.rect(0,0,o,i)}var f=function(t){var f,l;function p(){for(var e,a=arguments.length,n=new Array(a),r=0;a>r;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="canvas-path-generator",e}l=t,(f=p).prototype=Object.create(l.prototype),f.prototype.constructor=f,a(f,l);var d=p.prototype;return d.init=function(){var t,a=((t={})[e.Shape.CIRCLE]=n,t[e.Shape.ELLIPSE]=r,t[e.Shape.RECT]=h,t[e.Shape.LINE]=o,t[e.Shape.POLYLINE]=c,t[e.Shape.POLYGON]=s,t[e.Shape.PATH]=i,t[e.Shape.TEXT]=void 0,t[e.Shape.GROUP]=void 0,t[e.Shape.IMAGE]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.pathGeneratorFactory=a},d.destroy=function(){delete this.context.pathGeneratorFactory},p}(e.AbstractRendererPlugin);t.Plugin=f,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@antv/g-plugin-canvas-path-generator", | ||
"version": "1.1.26", | ||
"version": "1.1.27", | ||
"description": "A G plugin of path generator with Canvas2D API", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@antv/g-math": "^1.7.26", | ||
"@antv/g-math": "^1.7.27", | ||
"@antv/util": "^3.2.4", | ||
@@ -47,3 +47,3 @@ "tslib": "^2.3.1" | ||
}, | ||
"gitHead": "4373901fa61181c6f32291d976b353b9fd9aaca7" | ||
"gitHead": "e7c23dd07f888b9e46a27a4f79ec80ed2db62fc7" | ||
} |
Sorry, the diff of this file is not supported yet
55052
1081
57
Updated@antv/g-math@^1.7.27