mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Inline drawDashes() code.
This commit is contained in:
parent
24c0d0f87e
commit
ad2abfb71f
1 changed files with 8 additions and 13 deletions
|
@ -1429,18 +1429,6 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
|||
drawSegment(0);
|
||||
}
|
||||
|
||||
// XXX: Make this work with global matrices?
|
||||
function drawDashes(ctx, path, dashArray, dashOffset) {
|
||||
var flattener = new PathFlattener(path),
|
||||
from = dashOffset, to,
|
||||
i = 0;
|
||||
while (from < flattener.length) {
|
||||
to = from + dashArray[(i++) % dashArray.length];
|
||||
flattener.drawPart(ctx, from, to);
|
||||
from = to + dashArray[(i++) % dashArray.length];
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
draw: function(ctx, param) {
|
||||
if (!param.compound)
|
||||
|
@ -1476,7 +1464,14 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
|||
// We cannot use the path created by drawSegments above
|
||||
// Use CurveFlatteners to draw dashed paths:
|
||||
ctx.beginPath();
|
||||
drawDashes(ctx, this, dashArray, style._dashOffset);
|
||||
var flattener = new PathFlattener(this),
|
||||
from = style._dashOffset, to,
|
||||
i = 0;
|
||||
while (from < flattener.length) {
|
||||
to = from + dashArray[(i++) % dashArray.length];
|
||||
flattener.drawPart(ctx, from, to);
|
||||
from = to + dashArray[(i++) % dashArray.length];
|
||||
}
|
||||
}
|
||||
ctx.stroke();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue