Skip to content

Commit

Permalink
Merge pull request #104 from DerDakon/dashes
Browse files Browse the repository at this point in the history
Reworked dash code
  • Loading branch information
rurseekatze committed Mar 13, 2016
2 parents ba9edee + 8de9dd0 commit 2b17d1b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions kothic/renderer/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ Kothic.path = (function () {
};
}

function moveTo(ctx, point, dashes) {
ctx.moveTo(point[0], point[1]);
if (dashes) {
setDashPattern(point, dashes);
}
}

function dashTo(ctx, point) {
var pt = dashPattern,
dx = point[0] - pt.x,
Expand Down Expand Up @@ -169,7 +162,8 @@ Kothic.path = (function () {
screenPoint = Kothic.geom.transformPoint(point, ws, hs);

if (j === 0) {
moveTo(ctx, screenPoint, dashes);
ctx.moveTo(screenPoint[0], screenPoint[1]);
setDashPattern(screenPoint, dashes);
} else if (dashes) {
dashTo(ctx, screenPoint);
} else {
Expand All @@ -188,9 +182,11 @@ Kothic.path = (function () {
point = points[j] || points[0];
screenPoint = Kothic.geom.transformPoint(point, ws, hs);

if (j === 0 || (!fill &&
checkSameBoundary(point, prevPoint, granularity))) {
moveTo(ctx, screenPoint, dashes);
if (j === 0) {
ctx.moveTo(screenPoint[0], screenPoint[1]);
setDashPattern(screenPoint, dashes);
} else if (!fill && checkSameBoundary(point, prevPoint, granularity)) {
ctx.moveTo(screenPoint[0], screenPoint[1]);
} else if (fill || !dashes) {
ctx.lineTo(screenPoint[0], screenPoint[1]);
} else {
Expand Down

0 comments on commit 2b17d1b

Please sign in to comment.