@antv/g-plugin-canvas-path-generator
Advanced tools
Comparing version 1.3.21 to 1.3.22-next.0
@@ -6,13 +6,11 @@ import { __read, __extends, __spreadArray } from 'tslib'; | ||
function generatePath$6(context, parsedStyle) { | ||
var r = parsedStyle.r; | ||
context.arc(r, r, r, 0, Math.PI * 2, false); | ||
var cx = parsedStyle.cx, cy = parsedStyle.cy, r = parsedStyle.r; | ||
context.arc(cx, cy, r, 0, Math.PI * 2, false); | ||
} | ||
function generatePath$5(context, parsedStyle) { | ||
var rxInPixels = parsedStyle.rx, ryInPixels = parsedStyle.ry; | ||
var rx = rxInPixels; | ||
var ry = ryInPixels; | ||
var cx = parsedStyle.cx, cy = parsedStyle.cy, rx = parsedStyle.rx, ry = parsedStyle.ry; | ||
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse | ||
if (context.ellipse) { | ||
context.ellipse(rx, ry, rx, ry, 0, 0, Math.PI * 2, false); | ||
context.ellipse(cx, cy, rx, ry, 0, 0, Math.PI * 2, false); | ||
} | ||
@@ -26,3 +24,3 @@ else { | ||
context.scale(scaleX, scaleY); | ||
context.arc(r, r, r, 0, Math.PI * 2); | ||
context.arc(cx, cy, r, 0, Math.PI * 2); | ||
} | ||
@@ -32,3 +30,3 @@ } | ||
function generatePath$4(context, parsedStyle) { | ||
var x1 = parsedStyle.x1, y1 = parsedStyle.y1, x2 = parsedStyle.x2, y2 = parsedStyle.y2, _a = parsedStyle.defX, defX = _a === void 0 ? 0 : _a, _b = parsedStyle.defY, defY = _b === void 0 ? 0 : _b, markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var x1 = parsedStyle.x1, y1 = parsedStyle.y1, x2 = parsedStyle.x2, y2 = parsedStyle.y2, markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var startOffsetX = 0; | ||
@@ -55,9 +53,9 @@ var startOffsetY = 0; | ||
} | ||
context.moveTo(x1 - defX + startOffsetX, y1 - defY + startOffsetY); | ||
context.lineTo(x2 - defX + endOffsetX, y2 - defY + endOffsetY); | ||
context.moveTo(x1 + startOffsetX, y1 + startOffsetY); | ||
context.lineTo(x2 + endOffsetX, y2 + endOffsetY); | ||
} | ||
function generatePath$3(context, parsedStyle) { | ||
var _a = parsedStyle.defX, defX = _a === void 0 ? 0 : _a, _b = parsedStyle.defY, defY = _b === void 0 ? 0 : _b, markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var _c = parsedStyle.path, absolutePath = _c.absolutePath, segments = _c.segments; | ||
var markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var _a = parsedStyle.path, absolutePath = _a.absolutePath, segments = _a.segments; | ||
var startOffsetX = 0; | ||
@@ -71,3 +69,3 @@ var startOffsetY = 0; | ||
if (markerStart && isDisplayObject(markerStart) && markerStartOffset) { | ||
var _d = __read(markerStart.parentNode.getStartTangent(), 2), p1 = _d[0], p2 = _d[1]; | ||
var _b = __read(markerStart.parentNode.getStartTangent(), 2), p1 = _b[0], p2 = _b[1]; | ||
x = p1[0] - p2[0]; | ||
@@ -80,3 +78,3 @@ y = p1[1] - p2[1]; | ||
if (markerEnd && isDisplayObject(markerEnd) && markerEndOffset) { | ||
var _e = __read(markerEnd.parentNode.getEndTangent(), 2), p1 = _e[0], p2 = _e[1]; | ||
var _c = __read(markerEnd.parentNode.getEndTangent(), 2), p1 = _c[0], p2 = _c[1]; | ||
x = p1[0] - p2[0]; | ||
@@ -101,7 +99,7 @@ y = p1[1] - p2[1]; | ||
if (useStartOffset) { | ||
context.moveTo(params[1] - defX + startOffsetX, params[2] - defY + startOffsetY); | ||
context.lineTo(params[1] - defX, params[2] - defY); | ||
context.moveTo(params[1] + startOffsetX, params[2] + startOffsetY); | ||
context.lineTo(params[1], params[2]); | ||
} | ||
else { | ||
context.moveTo(params[1] - defX, params[2] - defY); | ||
context.moveTo(params[1], params[2]); | ||
} | ||
@@ -111,18 +109,18 @@ break; | ||
if (useEndOffset) { | ||
context.lineTo(params[1] - defX + endOffsetX, params[2] - defY + endOffsetY); | ||
context.lineTo(params[1] + endOffsetX, params[2] + endOffsetY); | ||
} | ||
else { | ||
context.lineTo(params[1] - defX, params[2] - defY); | ||
context.lineTo(params[1], params[2]); | ||
} | ||
break; | ||
case 'Q': | ||
context.quadraticCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY); | ||
context.quadraticCurveTo(params[1], params[2], params[3], params[4]); | ||
if (useEndOffset) { | ||
context.lineTo(params[3] - defX + endOffsetX, params[4] - defY + endOffsetY); | ||
context.lineTo(params[3] + endOffsetX, params[4] + endOffsetY); | ||
} | ||
break; | ||
case 'C': | ||
context.bezierCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY, params[5] - defX, params[6] - defY); | ||
context.bezierCurveTo(params[1], params[2], params[3], params[4], params[5], params[6]); | ||
if (useEndOffset) { | ||
context.lineTo(params[5] - defX + endOffsetX, params[6] - defY + endOffsetY); | ||
context.lineTo(params[5] + endOffsetX, params[6] + endOffsetY); | ||
} | ||
@@ -135,3 +133,3 @@ break; | ||
if (context.ellipse) { | ||
context.ellipse(cx - defX, cy - defY, rx, ry, xRotation, startAngle, endAngle, !!(1 - sweepFlag)); | ||
context.ellipse(cx, cy, rx, ry, xRotation, startAngle, endAngle, !!(1 - sweepFlag)); | ||
} | ||
@@ -143,3 +141,3 @@ else { | ||
var scaleY = rx > ry ? ry / rx : 1; | ||
context.translate(cx - defX, cy - defY); | ||
context.translate(cx, cy); | ||
context.rotate(xRotation); | ||
@@ -150,6 +148,6 @@ context.scale(scaleX, scaleY); | ||
context.rotate(-xRotation); | ||
context.translate(-(cx - defX), -(cy - defY)); | ||
context.translate(-cx, -cy); | ||
} | ||
if (useEndOffset) { | ||
context.lineTo(params[6] - defX + endOffsetX, params[7] - defY + endOffsetY); | ||
context.lineTo(params[6] + endOffsetX, params[7] + endOffsetY); | ||
} | ||
@@ -166,9 +164,9 @@ break; | ||
function generatePath$2(context, parsedStyle) { | ||
var _a = parsedStyle.defX, defX = _a === void 0 ? 0 : _a, _b = parsedStyle.defY, defY = _b === void 0 ? 0 : _b, markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var points = parsedStyle.points.points; | ||
var length = points.length; | ||
var x1 = points[0][0] - defX; | ||
var y1 = points[0][1] - defY; | ||
var x2 = points[length - 1][0] - defX; | ||
var y2 = points[length - 1][1] - defY; | ||
var x1 = points[0][0]; | ||
var y1 = points[0][1]; | ||
var x2 = points[length - 1][0]; | ||
var y2 = points[length - 1][1]; | ||
var startOffsetX = 0; | ||
@@ -198,3 +196,3 @@ var startOffsetY = 0; | ||
var point = points[i]; | ||
context.lineTo(point[0] - defX, point[1] - defY); | ||
context.lineTo(point[0], point[1]); | ||
} | ||
@@ -205,9 +203,9 @@ context.lineTo(x2, y2); | ||
function generatePath$1(context, parsedStyle) { | ||
var _a = parsedStyle.defX, defX = _a === void 0 ? 0 : _a, _b = parsedStyle.defY, defY = _b === void 0 ? 0 : _b, markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var points = parsedStyle.points.points; | ||
var length = points.length; | ||
var x1 = points[0][0] - defX; | ||
var y1 = points[0][1] - defY; | ||
var x2 = points[length - 1][0] - defX; | ||
var y2 = points[length - 1][1] - defY; | ||
var x1 = points[0][0]; | ||
var y1 = points[0][1]; | ||
var x2 = points[length - 1][0]; | ||
var y2 = points[length - 1][1]; | ||
var startOffsetX = 0; | ||
@@ -237,3 +235,3 @@ var startOffsetY = 0; | ||
var point = points[i]; | ||
context.lineTo(point[0] - defX, point[1] - defY); | ||
context.lineTo(point[0], point[1]); | ||
} | ||
@@ -244,3 +242,3 @@ context.lineTo(x2 + endOffsetX, y2 + endOffsetY); | ||
function generatePath(context, parsedStyle) { | ||
var radius = parsedStyle.radius, width = parsedStyle.width, height = parsedStyle.height; | ||
var x = parsedStyle.x, y = parsedStyle.y, radius = parsedStyle.radius, width = parsedStyle.width, height = parsedStyle.height; | ||
var w = width; | ||
@@ -251,3 +249,3 @@ var h = height; | ||
// Canvas support negative width/height of rect | ||
context.rect(0, 0, w, h); | ||
context.rect(x, y, w, h); | ||
} | ||
@@ -261,18 +259,18 @@ else { | ||
}), 4), tlr = _a[0], trr = _a[1], brr = _a[2], blr = _a[3]; | ||
context.moveTo(signX * tlr, 0); | ||
context.lineTo(w - signX * trr, 0); | ||
context.moveTo(signX * tlr + x, y); | ||
context.lineTo(w - signX * trr + x, y); | ||
if (trr !== 0) { | ||
context.arc(w - signX * trr, signY * trr, trr, (-signY * Math.PI) / 2, signX > 0 ? 0 : Math.PI, sweepFlag); | ||
context.arc(w - signX * trr + x, signY * trr + y, trr, (-signY * Math.PI) / 2, signX > 0 ? 0 : Math.PI, sweepFlag); | ||
} | ||
context.lineTo(w, h - signY * brr); | ||
context.lineTo(w + x, h - signY * brr + y); | ||
if (brr !== 0) { | ||
context.arc(w - signX * brr, h - signY * brr, brr, signX > 0 ? 0 : Math.PI, signY > 0 ? Math.PI / 2 : 1.5 * Math.PI, sweepFlag); | ||
context.arc(w - signX * brr + x, h - signY * brr + y, brr, signX > 0 ? 0 : Math.PI, signY > 0 ? Math.PI / 2 : 1.5 * Math.PI, sweepFlag); | ||
} | ||
context.lineTo(signX * blr, h); | ||
context.lineTo(signX * blr + x, h + y); | ||
if (blr !== 0) { | ||
context.arc(signX * blr, h - signY * blr, blr, signY > 0 ? Math.PI / 2 : -Math.PI / 2, signX > 0 ? Math.PI : 0, sweepFlag); | ||
context.arc(signX * blr + x, h - signY * blr + y, blr, signY > 0 ? Math.PI / 2 : -Math.PI / 2, signX > 0 ? Math.PI : 0, sweepFlag); | ||
} | ||
context.lineTo(0, signY * tlr); | ||
context.lineTo(x, signY * tlr + y); | ||
if (tlr !== 0) { | ||
context.arc(signX * tlr, signY * tlr, tlr, signX > 0 ? Math.PI : 0, signY > 0 ? Math.PI * 1.5 : Math.PI / 2, sweepFlag); | ||
context.arc(signX * tlr + x, signY * tlr + y, tlr, signX > 0 ? Math.PI : 0, signY > 0 ? Math.PI * 1.5 : Math.PI / 2, sweepFlag); | ||
} | ||
@@ -279,0 +277,0 @@ } |
@@ -8,13 +8,11 @@ 'use strict'; | ||
function generatePath$6(context, parsedStyle) { | ||
var r = parsedStyle.r; | ||
context.arc(r, r, r, 0, Math.PI * 2, false); | ||
var cx = parsedStyle.cx, cy = parsedStyle.cy, r = parsedStyle.r; | ||
context.arc(cx, cy, r, 0, Math.PI * 2, false); | ||
} | ||
function generatePath$5(context, parsedStyle) { | ||
var rxInPixels = parsedStyle.rx, ryInPixels = parsedStyle.ry; | ||
var rx = rxInPixels; | ||
var ry = ryInPixels; | ||
var cx = parsedStyle.cx, cy = parsedStyle.cy, rx = parsedStyle.rx, ry = parsedStyle.ry; | ||
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse | ||
if (context.ellipse) { | ||
context.ellipse(rx, ry, rx, ry, 0, 0, Math.PI * 2, false); | ||
context.ellipse(cx, cy, rx, ry, 0, 0, Math.PI * 2, false); | ||
} | ||
@@ -28,3 +26,3 @@ else { | ||
context.scale(scaleX, scaleY); | ||
context.arc(r, r, r, 0, Math.PI * 2); | ||
context.arc(cx, cy, r, 0, Math.PI * 2); | ||
} | ||
@@ -34,3 +32,3 @@ } | ||
function generatePath$4(context, parsedStyle) { | ||
var x1 = parsedStyle.x1, y1 = parsedStyle.y1, x2 = parsedStyle.x2, y2 = parsedStyle.y2, _a = parsedStyle.defX, defX = _a === void 0 ? 0 : _a, _b = parsedStyle.defY, defY = _b === void 0 ? 0 : _b, markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var x1 = parsedStyle.x1, y1 = parsedStyle.y1, x2 = parsedStyle.x2, y2 = parsedStyle.y2, markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var startOffsetX = 0; | ||
@@ -57,9 +55,9 @@ var startOffsetY = 0; | ||
} | ||
context.moveTo(x1 - defX + startOffsetX, y1 - defY + startOffsetY); | ||
context.lineTo(x2 - defX + endOffsetX, y2 - defY + endOffsetY); | ||
context.moveTo(x1 + startOffsetX, y1 + startOffsetY); | ||
context.lineTo(x2 + endOffsetX, y2 + endOffsetY); | ||
} | ||
function generatePath$3(context, parsedStyle) { | ||
var _a = parsedStyle.defX, defX = _a === void 0 ? 0 : _a, _b = parsedStyle.defY, defY = _b === void 0 ? 0 : _b, markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var _c = parsedStyle.path, absolutePath = _c.absolutePath, segments = _c.segments; | ||
var markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var _a = parsedStyle.path, absolutePath = _a.absolutePath, segments = _a.segments; | ||
var startOffsetX = 0; | ||
@@ -73,3 +71,3 @@ var startOffsetY = 0; | ||
if (markerStart && gLite.isDisplayObject(markerStart) && markerStartOffset) { | ||
var _d = tslib.__read(markerStart.parentNode.getStartTangent(), 2), p1 = _d[0], p2 = _d[1]; | ||
var _b = tslib.__read(markerStart.parentNode.getStartTangent(), 2), p1 = _b[0], p2 = _b[1]; | ||
x = p1[0] - p2[0]; | ||
@@ -82,3 +80,3 @@ y = p1[1] - p2[1]; | ||
if (markerEnd && gLite.isDisplayObject(markerEnd) && markerEndOffset) { | ||
var _e = tslib.__read(markerEnd.parentNode.getEndTangent(), 2), p1 = _e[0], p2 = _e[1]; | ||
var _c = tslib.__read(markerEnd.parentNode.getEndTangent(), 2), p1 = _c[0], p2 = _c[1]; | ||
x = p1[0] - p2[0]; | ||
@@ -103,7 +101,7 @@ y = p1[1] - p2[1]; | ||
if (useStartOffset) { | ||
context.moveTo(params[1] - defX + startOffsetX, params[2] - defY + startOffsetY); | ||
context.lineTo(params[1] - defX, params[2] - defY); | ||
context.moveTo(params[1] + startOffsetX, params[2] + startOffsetY); | ||
context.lineTo(params[1], params[2]); | ||
} | ||
else { | ||
context.moveTo(params[1] - defX, params[2] - defY); | ||
context.moveTo(params[1], params[2]); | ||
} | ||
@@ -113,18 +111,18 @@ break; | ||
if (useEndOffset) { | ||
context.lineTo(params[1] - defX + endOffsetX, params[2] - defY + endOffsetY); | ||
context.lineTo(params[1] + endOffsetX, params[2] + endOffsetY); | ||
} | ||
else { | ||
context.lineTo(params[1] - defX, params[2] - defY); | ||
context.lineTo(params[1], params[2]); | ||
} | ||
break; | ||
case 'Q': | ||
context.quadraticCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY); | ||
context.quadraticCurveTo(params[1], params[2], params[3], params[4]); | ||
if (useEndOffset) { | ||
context.lineTo(params[3] - defX + endOffsetX, params[4] - defY + endOffsetY); | ||
context.lineTo(params[3] + endOffsetX, params[4] + endOffsetY); | ||
} | ||
break; | ||
case 'C': | ||
context.bezierCurveTo(params[1] - defX, params[2] - defY, params[3] - defX, params[4] - defY, params[5] - defX, params[6] - defY); | ||
context.bezierCurveTo(params[1], params[2], params[3], params[4], params[5], params[6]); | ||
if (useEndOffset) { | ||
context.lineTo(params[5] - defX + endOffsetX, params[6] - defY + endOffsetY); | ||
context.lineTo(params[5] + endOffsetX, params[6] + endOffsetY); | ||
} | ||
@@ -137,3 +135,3 @@ break; | ||
if (context.ellipse) { | ||
context.ellipse(cx - defX, cy - defY, rx, ry, xRotation, startAngle, endAngle, !!(1 - sweepFlag)); | ||
context.ellipse(cx, cy, rx, ry, xRotation, startAngle, endAngle, !!(1 - sweepFlag)); | ||
} | ||
@@ -145,3 +143,3 @@ else { | ||
var scaleY = rx > ry ? ry / rx : 1; | ||
context.translate(cx - defX, cy - defY); | ||
context.translate(cx, cy); | ||
context.rotate(xRotation); | ||
@@ -152,6 +150,6 @@ context.scale(scaleX, scaleY); | ||
context.rotate(-xRotation); | ||
context.translate(-(cx - defX), -(cy - defY)); | ||
context.translate(-cx, -cy); | ||
} | ||
if (useEndOffset) { | ||
context.lineTo(params[6] - defX + endOffsetX, params[7] - defY + endOffsetY); | ||
context.lineTo(params[6] + endOffsetX, params[7] + endOffsetY); | ||
} | ||
@@ -168,9 +166,9 @@ break; | ||
function generatePath$2(context, parsedStyle) { | ||
var _a = parsedStyle.defX, defX = _a === void 0 ? 0 : _a, _b = parsedStyle.defY, defY = _b === void 0 ? 0 : _b, markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var points = parsedStyle.points.points; | ||
var length = points.length; | ||
var x1 = points[0][0] - defX; | ||
var y1 = points[0][1] - defY; | ||
var x2 = points[length - 1][0] - defX; | ||
var y2 = points[length - 1][1] - defY; | ||
var x1 = points[0][0]; | ||
var y1 = points[0][1]; | ||
var x2 = points[length - 1][0]; | ||
var y2 = points[length - 1][1]; | ||
var startOffsetX = 0; | ||
@@ -200,3 +198,3 @@ var startOffsetY = 0; | ||
var point = points[i]; | ||
context.lineTo(point[0] - defX, point[1] - defY); | ||
context.lineTo(point[0], point[1]); | ||
} | ||
@@ -207,9 +205,9 @@ context.lineTo(x2, y2); | ||
function generatePath$1(context, parsedStyle) { | ||
var _a = parsedStyle.defX, defX = _a === void 0 ? 0 : _a, _b = parsedStyle.defY, defY = _b === void 0 ? 0 : _b, markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var markerStart = parsedStyle.markerStart, markerEnd = parsedStyle.markerEnd, markerStartOffset = parsedStyle.markerStartOffset, markerEndOffset = parsedStyle.markerEndOffset; | ||
var points = parsedStyle.points.points; | ||
var length = points.length; | ||
var x1 = points[0][0] - defX; | ||
var y1 = points[0][1] - defY; | ||
var x2 = points[length - 1][0] - defX; | ||
var y2 = points[length - 1][1] - defY; | ||
var x1 = points[0][0]; | ||
var y1 = points[0][1]; | ||
var x2 = points[length - 1][0]; | ||
var y2 = points[length - 1][1]; | ||
var startOffsetX = 0; | ||
@@ -239,3 +237,3 @@ var startOffsetY = 0; | ||
var point = points[i]; | ||
context.lineTo(point[0] - defX, point[1] - defY); | ||
context.lineTo(point[0], point[1]); | ||
} | ||
@@ -246,3 +244,3 @@ context.lineTo(x2 + endOffsetX, y2 + endOffsetY); | ||
function generatePath(context, parsedStyle) { | ||
var radius = parsedStyle.radius, width = parsedStyle.width, height = parsedStyle.height; | ||
var x = parsedStyle.x, y = parsedStyle.y, radius = parsedStyle.radius, width = parsedStyle.width, height = parsedStyle.height; | ||
var w = width; | ||
@@ -253,3 +251,3 @@ var h = height; | ||
// Canvas support negative width/height of rect | ||
context.rect(0, 0, w, h); | ||
context.rect(x, y, w, h); | ||
} | ||
@@ -263,18 +261,18 @@ else { | ||
}), 4), tlr = _a[0], trr = _a[1], brr = _a[2], blr = _a[3]; | ||
context.moveTo(signX * tlr, 0); | ||
context.lineTo(w - signX * trr, 0); | ||
context.moveTo(signX * tlr + x, y); | ||
context.lineTo(w - signX * trr + x, y); | ||
if (trr !== 0) { | ||
context.arc(w - signX * trr, signY * trr, trr, (-signY * Math.PI) / 2, signX > 0 ? 0 : Math.PI, sweepFlag); | ||
context.arc(w - signX * trr + x, signY * trr + y, trr, (-signY * Math.PI) / 2, signX > 0 ? 0 : Math.PI, sweepFlag); | ||
} | ||
context.lineTo(w, h - signY * brr); | ||
context.lineTo(w + x, h - signY * brr + y); | ||
if (brr !== 0) { | ||
context.arc(w - signX * brr, h - signY * brr, brr, signX > 0 ? 0 : Math.PI, signY > 0 ? Math.PI / 2 : 1.5 * Math.PI, sweepFlag); | ||
context.arc(w - signX * brr + x, h - signY * brr + y, brr, signX > 0 ? 0 : Math.PI, signY > 0 ? Math.PI / 2 : 1.5 * Math.PI, sweepFlag); | ||
} | ||
context.lineTo(signX * blr, h); | ||
context.lineTo(signX * blr + x, h + y); | ||
if (blr !== 0) { | ||
context.arc(signX * blr, h - signY * blr, blr, signY > 0 ? Math.PI / 2 : -Math.PI / 2, signX > 0 ? Math.PI : 0, sweepFlag); | ||
context.arc(signX * blr + x, h - signY * blr + y, blr, signY > 0 ? Math.PI / 2 : -Math.PI / 2, signX > 0 ? Math.PI : 0, sweepFlag); | ||
} | ||
context.lineTo(0, signY * tlr); | ||
context.lineTo(x, signY * tlr + y); | ||
if (tlr !== 0) { | ||
context.arc(signX * tlr, signY * tlr, tlr, signX > 0 ? Math.PI : 0, signY > 0 ? Math.PI * 1.5 : Math.PI / 2, sweepFlag); | ||
context.arc(signX * tlr + x, signY * tlr + y, tlr, signX > 0 ? Math.PI : 0, signY > 0 ? Math.PI * 1.5 : Math.PI / 2, sweepFlag); | ||
} | ||
@@ -281,0 +279,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!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";var a=function(t,e){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])},a(t,e)};function r(t,e){var a="function"==typeof Symbol&&t[Symbol.iterator];if(!a)return t;var r,n,o=a.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(a=o.return)&&a.call(o)}finally{if(n)throw n.error}}return i}function n(t,e){var a=e.r;t.arc(a,a,a,0,2*Math.PI,!1)}function o(t,e){var a=e.rx,r=e.ry;if(t.ellipse)t.ellipse(a,r,a,r,0,0,2*Math.PI,!1);else{var n=a>r?a:r,o=a>r?1:a/r,i=a>r?r/a:1;t.save(),t.scale(o,i),t.arc(n,n,n,0,2*Math.PI)}}function i(t,a){var r=a.x1,n=a.y1,o=a.x2,i=a.y2,s=a.defX,c=void 0===s?0:s,l=a.defY,h=void 0===l?0:l,f=a.markerStart,p=a.markerEnd,v=a.markerStartOffset,u=a.markerEndOffset,d=0,M=0,y=0,T=0,m=0;f&&e.isDisplayObject(f)&&v&&(d=Math.cos(m=Math.atan2(i-n,o-r))*(v||0),M=Math.sin(m)*(v||0)),p&&e.isDisplayObject(p)&&u&&(y=Math.cos(m=Math.atan2(n-i,r-o))*(u||0),T=Math.sin(m)*(u||0)),t.moveTo(r-c+d,n-h+M),t.lineTo(o-c+y,i-h+T)}function s(t,a){var n=a.defX,o=void 0===n?0:n,i=a.defY,s=void 0===i?0:i,c=a.markerStart,l=a.markerEnd,h=a.markerStartOffset,f=a.markerEndOffset,p=a.path,v=p.absolutePath,u=p.segments,d=0,M=0,y=0,T=0,m=0;if(c&&e.isDisplayObject(c)&&h){var P=r(c.parentNode.getStartTangent(),2);d=Math.cos(m=Math.atan2((b=P[0])[1]-(O=P[1])[1],b[0]-O[0]))*(h||0),M=Math.sin(m)*(h||0)}if(l&&e.isDisplayObject(l)&&f){var b,O,S=r(l.parentNode.getEndTangent(),2);y=Math.cos(m=Math.atan2((b=S[0])[1]-(O=S[1])[1],b[0]-O[0]))*(f||0),T=Math.sin(m)*(f||0)}for(var g=0;v.length>g;g++){var k=v[g],E=v[g+1],I=0===g&&(0!==d||0!==M),x=(g===v.length-1||E&&("M"===E[0]||"Z"===E[0]))&&0!==y&&0!==T;switch(k[0]){case"M":I?(t.moveTo(k[1]-o+d,k[2]-s+M),t.lineTo(k[1]-o,k[2]-s)):t.moveTo(k[1]-o,k[2]-s);break;case"L":x?t.lineTo(k[1]-o+y,k[2]-s+T):t.lineTo(k[1]-o,k[2]-s);break;case"Q":t.quadraticCurveTo(k[1]-o,k[2]-s,k[3]-o,k[4]-s),x&&t.lineTo(k[3]-o+y,k[4]-s+T);break;case"C":t.bezierCurveTo(k[1]-o,k[2]-s,k[3]-o,k[4]-s,k[5]-o,k[6]-s),x&&t.lineTo(k[5]-o+y,k[6]-s+T);break;case"A":var j=u[g].arcParams,w=j.cx,G=j.cy,A=j.rx,L=j.ry,C=j.startAngle,D=j.endAngle,_=j.xRotation,Y=j.sweepFlag;if(t.ellipse)t.ellipse(w-o,G-s,A,L,_,C,D,!!(1-Y));else{var N=A>L?A:L,R=A>L?1:A/L,X=A>L?L/A:1;t.translate(w-o,G-s),t.rotate(_),t.scale(R,X),t.arc(0,0,N,C,D,!!(1-Y)),t.scale(1/R,1/X),t.rotate(-_),t.translate(-(w-o),-(G-s))}x&&t.lineTo(k[6]-o+y,k[7]-s+T);break;case"Z":t.closePath()}}}function c(t,a){var r=a.defX,n=void 0===r?0:r,o=a.defY,i=void 0===o?0:o,s=a.markerStart,c=a.markerEnd,l=a.markerStartOffset,h=a.markerEndOffset,f=a.points.points,p=f.length,v=f[0][0]-n,u=f[0][1]-i,d=f[p-1][0]-n,M=f[p-1][1]-i,y=0,T=0,m=0,P=0,b=0;s&&e.isDisplayObject(s)&&l&&(y=Math.cos(b=Math.atan2(f[1][1]-f[0][1],f[1][0]-f[0][0]))*(l||0),T=Math.sin(b)*(l||0)),c&&e.isDisplayObject(c)&&h&&(m=Math.cos(b=Math.atan2(f[p-1][1]-f[0][1],f[p-1][0]-f[0][0]))*(h||0),P=Math.sin(b)*(h||0)),t.moveTo(v+(y||m),u+(T||P));for(var O=1;p-1>O;O++){var S=f[O];t.lineTo(S[0]-n,S[1]-i)}t.lineTo(d,M)}function l(t,a){var r=a.defX,n=void 0===r?0:r,o=a.defY,i=void 0===o?0:o,s=a.markerStart,c=a.markerEnd,l=a.markerStartOffset,h=a.markerEndOffset,f=a.points.points,p=f.length,v=f[0][0]-n,u=f[0][1]-i,d=f[p-1][0]-n,M=f[p-1][1]-i,y=0,T=0,m=0,P=0,b=0;s&&e.isDisplayObject(s)&&l&&(y=Math.cos(b=Math.atan2(f[1][1]-f[0][1],f[1][0]-f[0][0]))*(l||0),T=Math.sin(b)*(l||0)),c&&e.isDisplayObject(c)&&h&&(m=Math.cos(b=Math.atan2(f[p-2][1]-f[p-1][1],f[p-2][0]-f[p-1][0]))*(h||0),P=Math.sin(b)*(h||0)),t.moveTo(v+y,u+T);for(var O=1;p-1>O;O++){var S=f[O];t.lineTo(S[0]-n,S[1]-i)}t.lineTo(d+m,M+P)}var h=function(t,e,a){return e>t?e:t>a?a:t};function f(t,e){var a=e.radius,n=e.width,o=e.height,i=n,s=o;if(a&&a.some((function(t){return 0!==t}))){var c=n>0?1:-1,l=o>0?1:-1,f=c+l===0,p=r(a.map((function(t){return h(t,0,Math.min(Math.abs(i)/2,Math.abs(s)/2))})),4),v=p[0],u=p[1],d=p[2],M=p[3];t.moveTo(c*v,0),t.lineTo(i-c*u,0),0!==u&&t.arc(i-c*u,l*u,u,-l*Math.PI/2,c>0?0:Math.PI,f),t.lineTo(i,s-l*d),0!==d&&t.arc(i-c*d,s-l*d,d,c>0?0:Math.PI,l>0?Math.PI/2:1.5*Math.PI,f),t.lineTo(c*M,s),0!==M&&t.arc(c*M,s-l*M,M,l>0?Math.PI/2:-Math.PI/2,c>0?Math.PI:0,f),t.lineTo(0,l*v),0!==v&&t.arc(c*v,l*v,v,c>0?Math.PI:0,l>0?1.5*Math.PI:Math.PI/2,f)}else t.rect(0,0,i,s)}var p=function(t){function h(){var e=t.apply(this,function(t,e,a){if(a||2===arguments.length)for(var r,n=0,o=e.length;o>n;n++)!r&&n in e||(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}([],r(arguments),!1))||this;return e.name="canvas-path-generator",e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+e+" is not a constructor or null");function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(h,t),h.prototype.init=function(){var t,a=((t={})[e.Shape.CIRCLE]=n,t[e.Shape.ELLIPSE]=o,t[e.Shape.RECT]=f,t[e.Shape.LINE]=i,t[e.Shape.POLYLINE]=l,t[e.Shape.POLYGON]=c,t[e.Shape.PATH]=s,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},h.prototype.destroy=function(){delete this.context.pathGeneratorFactory},h}(e.AbstractRendererPlugin);t.Plugin=p})); | ||
!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";var e=function(t,a){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,a){t.__proto__=a}||function(t,a){for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&(t[e]=a[e])},e(t,a)};function r(t,a){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,n,o=e.call(t),i=[];try{for(;(void 0===a||a-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(e=o.return)&&e.call(o)}finally{if(n)throw n.error}}return i}function n(t,a){t.arc(a.cx,a.cy,a.r,0,2*Math.PI,!1)}function o(t,a){var e=a.cx,r=a.cy,n=a.rx,o=a.ry;if(t.ellipse)t.ellipse(e,r,n,o,0,0,2*Math.PI,!1);else{var i=n>o?n:o,s=n>o?1:n/o,c=n>o?o/n:1;t.save(),t.scale(s,c),t.arc(e,r,i,0,2*Math.PI)}}function i(t,e){var r=e.x1,n=e.y1,o=e.x2,i=e.y2,s=e.markerStart,c=e.markerEnd,l=e.markerStartOffset,h=e.markerEndOffset,f=0,p=0,u=0,v=0,y=0;s&&a.isDisplayObject(s)&&l&&(f=Math.cos(y=Math.atan2(i-n,o-r))*(l||0),p=Math.sin(y)*(l||0)),c&&a.isDisplayObject(c)&&h&&(u=Math.cos(y=Math.atan2(n-i,r-o))*(h||0),v=Math.sin(y)*(h||0)),t.moveTo(r+f,n+p),t.lineTo(o+u,i+v)}function s(t,e){var n=e.markerStart,o=e.markerEnd,i=e.markerStartOffset,s=e.markerEndOffset,c=e.path,l=c.absolutePath,h=c.segments,f=0,p=0,u=0,v=0,y=0;if(n&&a.isDisplayObject(n)&&i){var M=r(n.parentNode.getStartTangent(),2);f=Math.cos(y=Math.atan2((d=M[0])[1]-(T=M[1])[1],d[0]-T[0]))*(i||0),p=Math.sin(y)*(i||0)}if(o&&a.isDisplayObject(o)&&s){var d,T,m=r(o.parentNode.getEndTangent(),2);u=Math.cos(y=Math.atan2((d=m[0])[1]-(T=m[1])[1],d[0]-T[0]))*(s||0),v=Math.sin(y)*(s||0)}for(var P=0;l.length>P;P++){var b=l[P],O=l[P+1],S=0===P&&(0!==f||0!==p),g=(P===l.length-1||O&&("M"===O[0]||"Z"===O[0]))&&0!==u&&0!==v;switch(b[0]){case"M":S?(t.moveTo(b[1]+f,b[2]+p),t.lineTo(b[1],b[2])):t.moveTo(b[1],b[2]);break;case"L":g?t.lineTo(b[1]+u,b[2]+v):t.lineTo(b[1],b[2]);break;case"Q":t.quadraticCurveTo(b[1],b[2],b[3],b[4]),g&&t.lineTo(b[3]+u,b[4]+v);break;case"C":t.bezierCurveTo(b[1],b[2],b[3],b[4],b[5],b[6]),g&&t.lineTo(b[5]+u,b[6]+v);break;case"A":var k=h[P].arcParams,E=k.cx,I=k.cy,x=k.rx,j=k.ry,w=k.startAngle,G=k.endAngle,A=k.xRotation,L=k.sweepFlag;if(t.ellipse)t.ellipse(E,I,x,j,A,w,G,!!(1-L));else{var C=x>j?x:j,D=x>j?1:x/j,_=x>j?j/x:1;t.translate(E,I),t.rotate(A),t.scale(D,_),t.arc(0,0,C,w,G,!!(1-L)),t.scale(1/D,1/_),t.rotate(-A),t.translate(-E,-I)}g&&t.lineTo(b[6]+u,b[7]+v);break;case"Z":t.closePath()}}}function c(t,e){var r=e.markerStart,n=e.markerEnd,o=e.markerStartOffset,i=e.markerEndOffset,s=e.points.points,c=s.length,l=s[0][0],h=s[0][1],f=s[c-1][0],p=s[c-1][1],u=0,v=0,y=0,M=0,d=0;r&&a.isDisplayObject(r)&&o&&(u=Math.cos(d=Math.atan2(s[1][1]-s[0][1],s[1][0]-s[0][0]))*(o||0),v=Math.sin(d)*(o||0)),n&&a.isDisplayObject(n)&&i&&(y=Math.cos(d=Math.atan2(s[c-1][1]-s[0][1],s[c-1][0]-s[0][0]))*(i||0),M=Math.sin(d)*(i||0)),t.moveTo(l+(u||y),h+(v||M));for(var T=1;c-1>T;T++){var m=s[T];t.lineTo(m[0],m[1])}t.lineTo(f,p)}function l(t,e){var r=e.markerStart,n=e.markerEnd,o=e.markerStartOffset,i=e.markerEndOffset,s=e.points.points,c=s.length,l=s[0][0],h=s[0][1],f=s[c-1][0],p=s[c-1][1],u=0,v=0,y=0,M=0,d=0;r&&a.isDisplayObject(r)&&o&&(u=Math.cos(d=Math.atan2(s[1][1]-s[0][1],s[1][0]-s[0][0]))*(o||0),v=Math.sin(d)*(o||0)),n&&a.isDisplayObject(n)&&i&&(y=Math.cos(d=Math.atan2(s[c-2][1]-s[c-1][1],s[c-2][0]-s[c-1][0]))*(i||0),M=Math.sin(d)*(i||0)),t.moveTo(l+u,h+v);for(var T=1;c-1>T;T++){var m=s[T];t.lineTo(m[0],m[1])}t.lineTo(f+y,p+M)}var h=function(t,a,e){return a>t?a:t>e?e:t};function f(t,a){var e=a.x,n=a.y,o=a.radius,i=a.width,s=a.height,c=i,l=s;if(o&&o.some((function(t){return 0!==t}))){var f=i>0?1:-1,p=s>0?1:-1,u=f+p===0,v=r(o.map((function(t){return h(t,0,Math.min(Math.abs(c)/2,Math.abs(l)/2))})),4),y=v[0],M=v[1],d=v[2],T=v[3];t.moveTo(f*y+e,n),t.lineTo(c-f*M+e,n),0!==M&&t.arc(c-f*M+e,p*M+n,M,-p*Math.PI/2,f>0?0:Math.PI,u),t.lineTo(c+e,l-p*d+n),0!==d&&t.arc(c-f*d+e,l-p*d+n,d,f>0?0:Math.PI,p>0?Math.PI/2:1.5*Math.PI,u),t.lineTo(f*T+e,l+n),0!==T&&t.arc(f*T+e,l-p*T+n,T,p>0?Math.PI/2:-Math.PI/2,f>0?Math.PI:0,u),t.lineTo(e,p*y+n),0!==y&&t.arc(f*y+e,p*y+n,y,f>0?Math.PI:0,p>0?1.5*Math.PI:Math.PI/2,u)}else t.rect(e,n,c,l)}var p=function(t){function h(){var a=t.apply(this,function(t,a,e){if(e||2===arguments.length)for(var r,n=0,o=a.length;o>n;n++)!r&&n in a||(r||(r=Array.prototype.slice.call(a,0,n)),r[n]=a[n]);return t.concat(r||Array.prototype.slice.call(a))}([],r(arguments),!1))||this;return a.name="canvas-path-generator",a}return function(t,a){if("function"!=typeof a&&null!==a)throw new TypeError("Class extends value "+a+" is not a constructor or null");function r(){this.constructor=t}e(t,a),t.prototype=null===a?Object.create(a):(r.prototype=a.prototype,new r)}(h,t),h.prototype.init=function(){var t,e=((t={})[a.Shape.CIRCLE]=n,t[a.Shape.ELLIPSE]=o,t[a.Shape.RECT]=f,t[a.Shape.LINE]=i,t[a.Shape.POLYLINE]=l,t[a.Shape.POLYGON]=c,t[a.Shape.PATH]=s,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},h.prototype.destroy=function(){delete this.context.pathGeneratorFactory},h}(a.AbstractRendererPlugin);t.Plugin=p})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "@antv/g-plugin-canvas-path-generator", | ||
"version": "1.3.21", | ||
"version": "1.3.22-next.0", | ||
"description": "A G plugin of path generator with Canvas2D API", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
"tslib": "^2.5.3", | ||
"@antv/g-lite": "1.2.21", | ||
"@antv/g-lite": "1.3.0-next.0", | ||
"@antv/g-math": "2.0.2" | ||
@@ -40,0 +40,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
94242
630
2
+ Added@antv/g-lite@1.3.0-next.0(transitive)
- Removed@antv/g-lite@1.2.21(transitive)
Updated@antv/g-lite@1.3.0-next.0