Skip to content

Commit

Permalink
rework dash code
Browse files Browse the repository at this point in the history
This does some restructuring and cleanups to make the code more similar to what
is current upstream, where the custom dash code was entirely dropped in favor of
native dashing done through the browser.
  • Loading branch information
DerDakon committed Mar 6, 2016
1 parent 1da2300 commit 52e8b01
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 @@ -172,7 +165,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 @@ -191,9 +185,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 52e8b01

Please sign in to comment.