mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Unroll loop in Path#_setStyles().
This commit is contained in:
parent
e89b2e5be1
commit
466857659c
1 changed files with 15 additions and 17 deletions
|
@ -1386,11 +1386,24 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
_setStyles: function(ctx) {
|
||||||
|
var style = this._style,
|
||||||
|
width = style.getStrokeWidth(),
|
||||||
|
join = style.getStrokeJoin(),
|
||||||
|
cap = style.getStrokeCap(),
|
||||||
|
limit = style.getMiterLimit();
|
||||||
|
if (width != null) ctx.lineWidth = width;
|
||||||
|
if (join) ctx.lineJoin = join;
|
||||||
|
if (cap) ctx.lineCap = cap;
|
||||||
|
if (limit) ctx.miterLimit = limit;
|
||||||
|
},
|
||||||
|
|
||||||
draw: function(ctx, param) {
|
draw: function(ctx, param) {
|
||||||
if (!param.compound)
|
if (!param.compound)
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
|
||||||
// TODO: Can't we access _style._strokeColor, as we do in strokeBounds?
|
// TODO: Can't we access _style._strokeColor, as we do in
|
||||||
|
// strokeBounds?
|
||||||
var fillColor = this.getFillColor(),
|
var fillColor = this.getFillColor(),
|
||||||
strokeColor = this.getStrokeColor(),
|
strokeColor = this.getStrokeColor(),
|
||||||
dashArray = this.getDashArray() || [], // TODO: Always defined?
|
dashArray = this.getDashArray() || [], // TODO: Always defined?
|
||||||
|
@ -1437,7 +1450,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, new function() { // Inject methods that require scoped privates
|
}, new function() { // Path Smoothing
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Solves a tri-diagonal system for one of coordinates (x or y) of first
|
* Solves a tri-diagonal system for one of coordinates (x or y) of first
|
||||||
|
@ -1465,22 +1478,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
|
||||||
var styles = {
|
|
||||||
getStrokeWidth: 'lineWidth',
|
|
||||||
getStrokeJoin: 'lineJoin',
|
|
||||||
getStrokeCap: 'lineCap',
|
|
||||||
getMiterLimit: 'miterLimit'
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_setStyles: function(ctx) {
|
|
||||||
for (var i in styles) {
|
|
||||||
var style = this._style[i]();
|
|
||||||
if (style)
|
|
||||||
ctx[styles[i]] = style;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Note: Documentation for smooth() is in PathItem
|
// Note: Documentation for smooth() is in PathItem
|
||||||
smooth: function() {
|
smooth: function() {
|
||||||
// This code is based on the work by Oleg V. Polikarpotchkin,
|
// This code is based on the work by Oleg V. Polikarpotchkin,
|
||||||
|
|
Loading…
Reference in a new issue