Comparing version 2.0.7-beta.5 to 2.0.7-beta.6
@@ -16,2 +16,3 @@ var Util = require('../util/index'); | ||
createPath: function createPath() {}, | ||
afterPath: function afterPath() {}, | ||
drawInner: function drawInner(context) { | ||
@@ -42,2 +43,3 @@ var self = this; | ||
} | ||
self.afterPath(context); | ||
}, | ||
@@ -44,0 +46,0 @@ |
@@ -90,2 +90,17 @@ var Util = require('../util/index'); | ||
context = context || self.get('context'); | ||
context.beginPath(); | ||
context.arc(x, y, r, startAngle, endAngle, clockwise); | ||
}, | ||
afterPath: function afterPath(context) { | ||
var attrs = this.__attrs; | ||
var x = attrs.x, | ||
y = attrs.y, | ||
r = attrs.r, | ||
startAngle = attrs.startAngle, | ||
endAngle = attrs.endAngle, | ||
clockwise = attrs.clockwise; | ||
context = context || this.get('context'); | ||
var diff = void 0; | ||
@@ -97,5 +112,2 @@ var x1 = void 0; | ||
context = context || self.get('context'); | ||
context.beginPath(); | ||
if (attrs.startArrow) { | ||
@@ -106,4 +118,2 @@ diff = Math.PI / 180; | ||
} | ||
// Calculate coordinates for start arrow | ||
x1 = _getArcX(x, r, startAngle + diff); | ||
@@ -115,3 +125,2 @@ y1 = _getArcY(y, r, startAngle + diff); | ||
} | ||
context.arc(x, y, r, startAngle, endAngle, clockwise); | ||
@@ -123,4 +132,2 @@ if (attrs.endArrow) { | ||
} | ||
// Calculate coordinates for start arrow | ||
x1 = _getArcX(x, r, endAngle + diff); | ||
@@ -127,0 +134,0 @@ y1 = _getArcY(y, r, endAngle + diff); |
@@ -88,10 +88,21 @@ var Util = require('../util/index'); | ||
} | ||
context.beginPath(); | ||
Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]); | ||
context.moveTo(p1[0], p1[1]); | ||
context.bezierCurveTo(p2[0], p2[1], p3[0], p3[1], p4[0], p4[1]); | ||
Arrow.addEndArrow(context, attrs, p3[0], p3[1], p4[0], p4[1]); | ||
}, | ||
afterPath: function afterPath(context) { | ||
var attrs = this.__attrs; | ||
var p1 = attrs.p1, | ||
p2 = attrs.p2, | ||
p3 = attrs.p3, | ||
p4 = attrs.p4; | ||
context = context || this.get('context'); | ||
if (attrs.startArrow) { | ||
Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]); | ||
} | ||
if (attrs.endArrow) { | ||
Arrow.addEndArrow(context, attrs, p3[0], p3[1], p4[0], p4[1]); | ||
} | ||
}, | ||
getPoint: function getPoint(t) { | ||
@@ -98,0 +109,0 @@ var attrs = this.__attrs; |
@@ -67,8 +67,20 @@ var Util = require('../util/index'); | ||
context.beginPath(); | ||
Arrow.addStartArrow(context, attrs, x2, y2, x1, y1); | ||
context.moveTo(x1, y1); | ||
context.lineTo(x2, y2); | ||
Arrow.addEndArrow(context, attrs, x1, y1, x2, y2); | ||
}, | ||
afterPath: function afterPath(context) { | ||
var attrs = this.__attrs; | ||
var x1 = attrs.x1, | ||
y1 = attrs.y1, | ||
x2 = attrs.x2, | ||
y2 = attrs.y2; | ||
context = context || this.get('context'); | ||
if (attrs.startArrow) { | ||
Arrow.addStartArrow(context, attrs, x2, y2, x1, y1); | ||
} | ||
if (attrs.endArrow) { | ||
Arrow.addEndArrow(context, attrs, x1, y1, x2, y2); | ||
} | ||
}, | ||
getPoint: function getPoint(t) { | ||
@@ -75,0 +87,0 @@ var attrs = this.__attrs; |
@@ -228,5 +228,3 @@ var Util = require('../util/index'); | ||
var self = this; | ||
var attrs = self.__attrs; | ||
var segments = self.get('segments'); | ||
if (!Util.isArray(segments)) return; | ||
@@ -237,28 +235,46 @@ | ||
context.beginPath(); | ||
var segmentsLen = segments.length; | ||
for (var i = 0; i < segmentsLen; i++) { | ||
segments[i].draw(context); | ||
} | ||
}, | ||
_addArrow: function _addArrow(startPoint, endPoint, tangent, context, isStartArrow) { | ||
var attrs = this.__attrs; | ||
if (Util.isFunction(tangent)) { | ||
var v = tangent(); | ||
if (isStartArrow) { | ||
Arrow.addStartArrow(context, attrs, startPoint.x - v[0], startPoint.y - v[1], startPoint.x, startPoint.y); | ||
} else { | ||
Arrow.addEndArrow(context, attrs, endPoint.x - v[0], endPoint.y - v[1], endPoint.x, endPoint.y); | ||
} | ||
} else { | ||
if (isStartArrow) { | ||
Arrow.addStartArrow(context, attrs, endPoint.x, endPoint.y, startPoint.x, startPoint.y); | ||
} else { | ||
Arrow.addEndArrow(context, attrs, startPoint.x, startPoint.y, endPoint.x, endPoint.y); | ||
} | ||
} | ||
}, | ||
afterPath: function afterPath(context) { | ||
var self = this; | ||
var attrs = self.__attrs; | ||
var segments = self.get('segments'); | ||
var path = attrs.path; | ||
var startPoint = void 0; | ||
var endPoint = void 0; | ||
var closed = false; | ||
context = context || self.get('context'); | ||
if (!Util.isArray(segments)) return; | ||
if (!attrs.startArrow && !attrs.endArrow) { | ||
return; | ||
} | ||
if (path[path.length - 1] === 'z' || path[path.length - 1] === 'Z' || attrs.fill) { | ||
// 闭合路径不绘制箭头 | ||
closed = true; | ||
return; | ||
} | ||
var segmentsLen = segments.length; | ||
if (segmentsLen > 1 && !closed) { | ||
startPoint = segments[0].endPoint; | ||
endPoint = segments[1].endPoint; | ||
Arrow.addStartArrow(context, attrs, endPoint.x, endPoint.y, startPoint.x, startPoint.y); | ||
if (segmentsLen > 1) { | ||
self._addArrow(segments[0].endPoint, segments[1].endPoint, segments[1].startTangent, context, true); | ||
} | ||
for (var i = 0, l = segmentsLen; i < l; i++) { | ||
segments[i].draw(context); | ||
if (segmentsLen > 1) { | ||
self._addArrow(segments[segmentsLen - 2].endPoint, segments[segmentsLen - 1].endPoint, segments[segmentsLen - 1].endTangent, context, false); | ||
} | ||
if (segmentsLen > 1 && !closed) { | ||
startPoint = segments[segmentsLen - 2].endPoint; | ||
endPoint = segments[segmentsLen - 1].endPoint; | ||
Arrow.addEndArrow(context, attrs, startPoint.x, startPoint.y, endPoint.x, endPoint.y); | ||
} | ||
} | ||
@@ -265,0 +281,0 @@ }); |
@@ -131,3 +131,2 @@ var Util = require('../util/index'); | ||
Arrow.addStartArrow(context, attrs, points[1][0], points[1][1], points[0][0], points[0][1]); | ||
context.moveTo(points[0][0], points[0][1]); | ||
@@ -138,4 +137,17 @@ for (i = 1, l = points.length - 1; i < l; i++) { | ||
context.lineTo(points[l][0], points[l][1]); | ||
Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]); | ||
}, | ||
afterPath: function afterPath(context) { | ||
var self = this; | ||
var attrs = self.__attrs; | ||
var points = attrs.points; | ||
var l = points.length - 1; | ||
context = context || self.get('context'); | ||
if (attrs.startArrow) { | ||
Arrow.addStartArrow(context, attrs, points[1][0], points[1][1], points[0][0], points[0][1]); | ||
} | ||
if (attrs.endArrow) { | ||
Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]); | ||
} | ||
}, | ||
getPoint: function getPoint(t) { | ||
@@ -142,0 +154,0 @@ var attrs = this.__attrs; |
@@ -89,8 +89,22 @@ var Util = require('../util/index'); | ||
context.beginPath(); | ||
Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]); | ||
context.moveTo(p1[0], p1[1]); | ||
context.quadraticCurveTo(p2[0], p2[1], p3[0], p3[1]); | ||
Arrow.addEndArrow(context, attrs, p2[0], p2[1], p3[0], p3[1]); | ||
}, | ||
afterPath: function afterPath(context) { | ||
var self = this; | ||
var attrs = self.__attrs; | ||
var p1 = attrs.p1, | ||
p2 = attrs.p2, | ||
p3 = attrs.p3; | ||
context = context || self.get('context'); | ||
if (attrs.startArrow) { | ||
Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]); | ||
} | ||
if (attrs.endArrow) { | ||
Arrow.addEndArrow(context, attrs, p2[0], p2[1], p3[0], p3[1]); | ||
} | ||
}, | ||
getPoint: function getPoint(t) { | ||
@@ -97,0 +111,0 @@ var attrs = this.__attrs; |
@@ -40,3 +40,3 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
rightY = y2 + arrowLength * sin(angle - arrowAngle / 2); | ||
ctx.beginPath(); | ||
// Draw left half of arrow | ||
@@ -53,7 +53,7 @@ ctx.moveTo(leftX - offsetX, leftY - offsetY); | ||
ctx.moveTo(x2, y2); | ||
ctx.stroke(); | ||
} | ||
} | ||
function _addMarker(ctx, attrs, x1, y1, x2, y2, arrow) { | ||
var shape = arrow.shape; | ||
function _addMarker(ctx, attrs, x1, y1, x2, y2, shape) { | ||
var marker = shape.__attrs; | ||
@@ -67,3 +67,3 @@ var method = marker.symbol; | ||
} | ||
var deg = void 0; | ||
var deg = 0; | ||
var x = x1 - x2; | ||
@@ -86,10 +86,12 @@ var y = y1 - y2; | ||
} | ||
ctx.save(); | ||
ctx.beginPath(); | ||
ctx.translate(markerX, markerY); | ||
ctx.rotate(deg); | ||
ctx.translate(-markerX, -markerY); | ||
ctx.translate(-arrow.dx || 0, -arrow.dy || 0); | ||
method(markerX, markerY, markerR, ctx, shape); | ||
ctx.setTransform(1, 0, 0, 1, 0, 0); | ||
ctx.fillStyle = ctx.strokeStyle; | ||
ctx.fillStyle = shape.attr('fill') || ctx.strokeStyle; | ||
ctx.fill(); | ||
ctx.restore(); | ||
} | ||
@@ -96,0 +98,0 @@ |
@@ -48,3 +48,2 @@ var Util = require('../../util/index'); | ||
var lambda = xp * xp / (rx * rx) + yp * yp / (ry * ry); | ||
if (lambda > 1) { | ||
@@ -54,5 +53,5 @@ rx *= Math.sqrt(lambda); | ||
} | ||
var diff = rx * rx * (yp * yp) + ry * ry * (xp * xp); | ||
var f = Math.sqrt((rx * rx * (ry * ry) - diff) / diff); | ||
var f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) / (rx * rx * (yp * yp) + ry * ry * (xp * xp))); | ||
if (fa === fs) { | ||
@@ -75,9 +74,2 @@ f *= -1; | ||
var dTheta = vAngle(u, v); | ||
if (vRatio(u, v) <= -1) { | ||
dTheta = Math.PI; | ||
} | ||
if (vRatio(u, v) >= 1) { | ||
dTheta = 0; | ||
} | ||
if (fs === 0 && dTheta > 0) { | ||
@@ -341,5 +333,33 @@ dTheta = dTheta - 2 * Math.PI; | ||
this.command = 'A'; | ||
this.params = getArcParams(preEndPoint, point, fa, fs, rx, ry, psi); | ||
this.subStart = preSegment.subStart; | ||
var params = getArcParams(preEndPoint, point, fa, fs, rx, ry, psi); | ||
this.params = params; | ||
var start = preSegment.subStart; | ||
this.subStart = start; | ||
this.endPoint = point; | ||
var startAngle = params[5] % (Math.PI * 2); | ||
if (Util.isNumberEqual(startAngle, Math.PI * 2)) { | ||
startAngle = 0; | ||
} | ||
var endAngle = params[6] % (Math.PI * 2); | ||
if (Util.isNumberEqual(endAngle, Math.PI * 2)) { | ||
endAngle = 0; | ||
} | ||
var d = 0.001; | ||
this.startTangent = function () { | ||
if (fs === 0) { | ||
d *= -1; | ||
} | ||
var dx = params[3] * Math.cos(startAngle - d) + params[1]; | ||
var dy = params[4] * Math.sin(startAngle - d) + params[2]; | ||
return [dx - start.x, dy - start.y]; | ||
}; | ||
this.endTangent = function () { | ||
var endAngle = params[6]; | ||
if (endAngle - Math.PI * 2 < 0.0001) { | ||
endAngle = 0; | ||
} | ||
var dx = params[3] * Math.cos(startAngle + endAngle + d) + params[1]; | ||
var dy = params[4] * Math.sin(startAngle + endAngle - d) + params[2]; | ||
return [preEndPoint.x - dx, preEndPoint.y - dy]; | ||
}; | ||
break; | ||
@@ -346,0 +366,0 @@ } |
{ | ||
"name": "@antv/g", | ||
"version": "2.0.7-beta.5", | ||
"version": "2.0.7-beta.6", | ||
"description": "A canvas library which providing 2d draw for G2.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -16,2 +16,3 @@ const Util = require('../util/index'); | ||
createPath() {}, | ||
afterPath() {}, | ||
drawInner(context) { | ||
@@ -42,2 +43,3 @@ const self = this; | ||
} | ||
self.afterPath(context); | ||
}, | ||
@@ -44,0 +46,0 @@ /** |
@@ -74,2 +74,11 @@ const Util = require('../util/index'); | ||
const { x, y, r, startAngle, endAngle, clockwise } = attrs; | ||
context = context || self.get('context'); | ||
context.beginPath(); | ||
context.arc(x, y, r, startAngle, endAngle, clockwise); | ||
}, | ||
afterPath(context) { | ||
const attrs = this.__attrs; | ||
const { x, y, r, startAngle, endAngle, clockwise } = attrs; | ||
context = context || this.get('context'); | ||
let diff; | ||
@@ -81,5 +90,2 @@ let x1; | ||
context = context || self.get('context'); | ||
context.beginPath(); | ||
if (attrs.startArrow) { | ||
@@ -90,4 +96,2 @@ diff = Math.PI / 180; | ||
} | ||
// Calculate coordinates for start arrow | ||
x1 = _getArcX(x, r, startAngle + diff); | ||
@@ -99,3 +103,2 @@ y1 = _getArcY(y, r, startAngle + diff); | ||
} | ||
context.arc(x, y, r, startAngle, endAngle, clockwise); | ||
@@ -107,4 +110,2 @@ if (attrs.endArrow) { | ||
} | ||
// Calculate coordinates for start arrow | ||
x1 = _getArcX(x, r, endAngle + diff); | ||
@@ -111,0 +112,0 @@ y1 = _getArcY(y, r, endAngle + diff); |
@@ -92,10 +92,17 @@ const Util = require('../util/index'); | ||
} | ||
context.beginPath(); | ||
Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]); | ||
context.moveTo(p1[0], p1[1]); | ||
context.bezierCurveTo(p2[0], p2[1], p3[0], p3[1], p4[0], p4[1]); | ||
Arrow.addEndArrow(context, attrs, p3[0], p3[1], p4[0], p4[1]); | ||
}, | ||
afterPath(context) { | ||
const attrs = this.__attrs; | ||
const { p1, p2, p3, p4 } = attrs; | ||
context = context || this.get('context'); | ||
if (attrs.startArrow) { | ||
Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]); | ||
} | ||
if (attrs.endArrow) { | ||
Arrow.addEndArrow(context, attrs, p3[0], p3[1], p4[0], p4[1]); | ||
} | ||
}, | ||
getPoint(t) { | ||
@@ -102,0 +109,0 @@ const attrs = this.__attrs; |
@@ -55,8 +55,16 @@ const Util = require('../util/index'); | ||
context.beginPath(); | ||
Arrow.addStartArrow(context, attrs, x2, y2, x1, y1); | ||
context.moveTo(x1, y1); | ||
context.lineTo(x2, y2); | ||
Arrow.addEndArrow(context, attrs, x1, y1, x2, y2); | ||
}, | ||
afterPath(context) { | ||
const attrs = this.__attrs; | ||
const { x1, y1, x2, y2 } = attrs; | ||
context = context || this.get('context'); | ||
if (attrs.startArrow) { | ||
Arrow.addStartArrow(context, attrs, x2, y2, x1, y1); | ||
} | ||
if (attrs.endArrow) { | ||
Arrow.addEndArrow(context, attrs, x1, y1, x2, y2); | ||
} | ||
}, | ||
getPoint(t) { | ||
@@ -63,0 +71,0 @@ const attrs = this.__attrs; |
@@ -232,5 +232,3 @@ const Util = require('../util/index'); | ||
const self = this; | ||
const attrs = self.__attrs; | ||
const segments = self.get('segments'); | ||
if (!Util.isArray(segments)) return; | ||
@@ -241,27 +239,53 @@ | ||
context.beginPath(); | ||
const segmentsLen = segments.length; | ||
for (let i = 0; i < segmentsLen; i++) { | ||
segments[i].draw(context); | ||
} | ||
}, | ||
_addArrow(startPoint, endPoint, tangent, context, isStartArrow) { | ||
const attrs = this.__attrs; | ||
if (Util.isFunction(tangent)) { | ||
const v = tangent(); | ||
if (isStartArrow) { | ||
Arrow.addStartArrow(context, attrs, startPoint.x - v[0], startPoint.y - v[1], startPoint.x, startPoint.y); | ||
} else { | ||
Arrow.addEndArrow(context, attrs, endPoint.x - v[0], endPoint.y - v[1], endPoint.x, endPoint.y); | ||
} | ||
} else { | ||
if (isStartArrow) { | ||
Arrow.addStartArrow(context, attrs, endPoint.x, endPoint.y, startPoint.x, startPoint.y); | ||
} else { | ||
Arrow.addEndArrow(context, attrs, startPoint.x, startPoint.y, endPoint.x, endPoint.y); | ||
} | ||
} | ||
}, | ||
afterPath(context) { | ||
const self = this; | ||
const attrs = self.__attrs; | ||
const segments = self.get('segments'); | ||
const path = attrs.path; | ||
let startPoint; | ||
let endPoint; | ||
let closed = false; | ||
context = context || self.get('context'); | ||
if (!Util.isArray(segments)) return; | ||
if (!attrs.startArrow && !attrs.endArrow) { | ||
return; | ||
} | ||
if (path[path.length - 1] === 'z' || path[path.length - 1] === 'Z' || attrs.fill) { // 闭合路径不绘制箭头 | ||
closed = true; | ||
return; | ||
} | ||
const segmentsLen = segments.length; | ||
if (segmentsLen > 1 && !closed) { | ||
startPoint = segments[0].endPoint; | ||
endPoint = segments[1].endPoint; | ||
Arrow.addStartArrow(context, attrs, endPoint.x, endPoint.y, startPoint.x, startPoint.y); | ||
if (segmentsLen > 1) { | ||
self._addArrow( | ||
segments[0].endPoint, | ||
segments[1].endPoint, | ||
segments[1].startTangent, | ||
context, true); | ||
} | ||
for (let i = 0, l = segmentsLen; i < l; i++) { | ||
segments[i].draw(context); | ||
if (segmentsLen > 1) { | ||
self._addArrow( | ||
segments[ segmentsLen - 2 ].endPoint, | ||
segments[ segmentsLen - 1 ].endPoint, | ||
segments[segmentsLen - 1].endTangent, | ||
context, false); | ||
} | ||
if (segmentsLen > 1 && !closed) { | ||
startPoint = segments[ segmentsLen - 2 ].endPoint; | ||
endPoint = segments[ segmentsLen - 1 ].endPoint; | ||
Arrow.addEndArrow(context, attrs, startPoint.x, startPoint.y, endPoint.x, endPoint.y); | ||
} | ||
} | ||
@@ -268,0 +292,0 @@ }); |
@@ -131,3 +131,2 @@ const Util = require('../util/index'); | ||
Arrow.addStartArrow(context, attrs, points[1][0], points[1][1], points[0][0], points[0][1]); | ||
context.moveTo(points[0][0], points[0][1]); | ||
@@ -138,4 +137,18 @@ for (i = 1, l = points.length - 1; i < l; i++) { | ||
context.lineTo(points[l][0], points[l][1]); | ||
Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]); | ||
}, | ||
afterPath(context) { | ||
const self = this; | ||
const attrs = self.__attrs; | ||
const points = attrs.points; | ||
const l = points.length - 1; | ||
context = context || self.get('context'); | ||
if (attrs.startArrow) { | ||
Arrow.addStartArrow(context, attrs, points[1][0], points[1][1], points[0][0], points[0][1]); | ||
} | ||
if (attrs.endArrow) { | ||
Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]); | ||
} | ||
}, | ||
getPoint(t) { | ||
@@ -142,0 +155,0 @@ const attrs = this.__attrs; |
@@ -93,8 +93,20 @@ const Util = require('../util/index'); | ||
context.beginPath(); | ||
Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]); | ||
context.moveTo(p1[0], p1[1]); | ||
context.quadraticCurveTo(p2[0], p2[1], p3[0], p3[1]); | ||
Arrow.addEndArrow(context, attrs, p2[0], p2[1], p3[0], p3[1]); | ||
}, | ||
afterPath(context) { | ||
const self = this; | ||
const attrs = self.__attrs; | ||
const { p1, p2, p3 } = attrs; | ||
context = context || self.get('context'); | ||
if (attrs.startArrow) { | ||
Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]); | ||
} | ||
if (attrs.endArrow) { | ||
Arrow.addEndArrow(context, attrs, p2[0], p2[1], p3[0], p3[1]); | ||
} | ||
}, | ||
getPoint(t) { | ||
@@ -101,0 +113,0 @@ const attrs = this.__attrs; |
@@ -37,3 +37,3 @@ const Marker = require('../marker'); | ||
rightY = y2 + (arrowLength * sin(angle - (arrowAngle / 2))); | ||
ctx.beginPath(); | ||
// Draw left half of arrow | ||
@@ -50,7 +50,7 @@ ctx.moveTo(leftX - offsetX, leftY - offsetY); | ||
ctx.moveTo(x2, y2); | ||
ctx.stroke(); | ||
} | ||
} | ||
function _addMarker(ctx, attrs, x1, y1, x2, y2, arrow) { | ||
const shape = arrow.shape; | ||
function _addMarker(ctx, attrs, x1, y1, x2, y2, shape) { | ||
const marker = shape.__attrs; | ||
@@ -64,3 +64,3 @@ let method = marker.symbol; | ||
} | ||
let deg; | ||
let deg = 0; | ||
const x = x1 - x2; | ||
@@ -83,10 +83,12 @@ const y = y1 - y2; | ||
} | ||
ctx.save(); | ||
ctx.beginPath(); | ||
ctx.translate(markerX, markerY); | ||
ctx.rotate(deg); | ||
ctx.translate(-markerX, -markerY); | ||
ctx.translate(-arrow.dx || 0, -arrow.dy || 0); | ||
method(markerX, markerY, markerR, ctx, shape); | ||
ctx.setTransform(1, 0, 0, 1, 0, 0); | ||
ctx.fillStyle = ctx.strokeStyle; | ||
ctx.fillStyle = shape.attr('fill') || ctx.strokeStyle; | ||
ctx.fill(); | ||
ctx.restore(); | ||
} | ||
@@ -93,0 +95,0 @@ |
@@ -46,3 +46,2 @@ const Util = require('../../util/index'); | ||
const lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry); | ||
if (lambda > 1) { | ||
@@ -52,5 +51,5 @@ rx *= Math.sqrt(lambda); | ||
} | ||
const diff = (rx * rx) * (yp * yp) + (ry * ry) * (xp * xp); | ||
let f = Math.sqrt((((rx * rx) * (ry * ry)) - diff) / diff); | ||
let f = Math.sqrt((((rx * rx) * (ry * ry)) - ((rx * rx) * (yp * yp)) - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp) + (ry * ry) * (xp * xp))); | ||
if (fa === fs) { | ||
@@ -73,9 +72,2 @@ f *= -1; | ||
let dTheta = vAngle(u, v); | ||
if (vRatio(u, v) <= -1) { | ||
dTheta = Math.PI; | ||
} | ||
if (vRatio(u, v) >= 1) { | ||
dTheta = 0; | ||
} | ||
if (fs === 0 && dTheta > 0) { | ||
@@ -337,5 +329,33 @@ dTheta = dTheta - 2 * Math.PI; | ||
this.command = 'A'; | ||
this.params = getArcParams(preEndPoint, point, fa, fs, rx, ry, psi); | ||
this.subStart = preSegment.subStart; | ||
const params = getArcParams(preEndPoint, point, fa, fs, rx, ry, psi); | ||
this.params = params; | ||
const start = preSegment.subStart; | ||
this.subStart = start; | ||
this.endPoint = point; | ||
let startAngle = params[5] % (Math.PI * 2); | ||
if (Util.isNumberEqual(startAngle, Math.PI * 2)) { | ||
startAngle = 0; | ||
} | ||
let endAngle = params[6] % (Math.PI * 2); | ||
if (Util.isNumberEqual(endAngle, Math.PI * 2)) { | ||
endAngle = 0; | ||
} | ||
let d = 0.001; | ||
this.startTangent = function() { | ||
if (fs === 0) { | ||
d *= -1; | ||
} | ||
const dx = params[3] * Math.cos(startAngle - d) + params[1]; | ||
const dy = params[4] * Math.sin(startAngle - d) + params[2]; | ||
return [ dx - start.x, dy - start.y ]; | ||
}; | ||
this.endTangent = function() { | ||
let endAngle = params[6]; | ||
if (endAngle - Math.PI * 2 < 0.0001) { | ||
endAngle = 0; | ||
} | ||
const dx = params[3] * Math.cos(startAngle + endAngle + d) + params[1]; | ||
const dy = params[4] * Math.sin(startAngle + endAngle - d) + params[2]; | ||
return [ preEndPoint.x - dx, preEndPoint.y - dy ]; | ||
}; | ||
break; | ||
@@ -342,0 +362,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 too big to display
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
1068151
27621