mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Remove more beans access, this time related to various PathStyle getters / setters.
This commit is contained in:
parent
c313e702c9
commit
ce74516228
4 changed files with 30 additions and 25 deletions
|
@ -142,8 +142,8 @@ var Item = this.Item = Base.extend({
|
||||||
setClipMask: function(clipMask) {
|
setClipMask: function(clipMask) {
|
||||||
this._clipMask = clipMask;
|
this._clipMask = clipMask;
|
||||||
if (this._clipMask) {
|
if (this._clipMask) {
|
||||||
this.fillColor = null;
|
this.setFillColor(null);
|
||||||
this.strokeColor = null;
|
this.setStrokeColor(null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -723,8 +723,8 @@ var Item = this.Item = Base.extend({
|
||||||
// since otherwise their stroke is drawn half transparent over their
|
// since otherwise their stroke is drawn half transparent over their
|
||||||
// fill.
|
// fill.
|
||||||
if (item.blendMode !== 'normal'
|
if (item.blendMode !== 'normal'
|
||||||
|| item.opacity < 1
|
|| item.opacity < 1
|
||||||
&& !(item.segments && (!item.fillColor || !item.strokeColor))) {
|
&& !(item.segments && (!item.getFillColor() || !item.getStrokeColor()))) {
|
||||||
var bounds = item.getStrokeBounds() || item.getBounds();
|
var bounds = item.getStrokeBounds() || item.getBounds();
|
||||||
if (!bounds.width || !bounds.height)
|
if (!bounds.width || !bounds.height)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -26,7 +26,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
fields[set] = function(value) {
|
fields[set] = function(value) {
|
||||||
if (this.item && this.item.children) {
|
if (this.item && this.item.children) {
|
||||||
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
||||||
this.item.children[i].getStyle()[set](value);
|
this.item.children[i]._style[set](value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this['_' + key] = isColor ? Color.read(arguments) : value;
|
this['_' + key] = isColor ? Color.read(arguments) : value;
|
||||||
|
@ -37,7 +37,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
if (this.item && this.item.children) {
|
if (this.item && this.item.children) {
|
||||||
var style;
|
var style;
|
||||||
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
||||||
var childStyle = this.item.children[i].getStyle()[get]();
|
var childStyle = this.item.children[i]._style[get]();
|
||||||
if (!style) {
|
if (!style) {
|
||||||
style = childStyle;
|
style = childStyle;
|
||||||
} else if (style != childStyle) {
|
} else if (style != childStyle) {
|
||||||
|
|
|
@ -66,12 +66,14 @@ var CompoundPath = this.CompoundPath = PathItem.extend({
|
||||||
Item.draw(this.children[i], ctx, param);
|
Item.draw(this.children[i], ctx, param);
|
||||||
}
|
}
|
||||||
firstChild.setCtxStyles(ctx);
|
firstChild.setCtxStyles(ctx);
|
||||||
if (firstChild.fillColor) {
|
var fillColor = firstChild.getFillColor(),
|
||||||
ctx.fillStyle = firstChild.fillColor.toCssString();
|
strokeColor = firstChild.getStrokeColor();
|
||||||
|
if (fillColor) {
|
||||||
|
ctx.fillStyle = fillColor.toCssString();
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
if (firstChild.strokeColor) {
|
if (strokeColor) {
|
||||||
ctx.strokeStyle = firstChild.strokeColor.toCssString();
|
ctx.strokeStyle = strokeColor.toCssString();
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,20 +393,22 @@ var Path = this.Path = PathItem.extend({
|
||||||
}
|
}
|
||||||
// If the path is part of a compound path or doesn't have a fill or
|
// If the path is part of a compound path or doesn't have a fill or
|
||||||
// stroke, there is no need to continue.
|
// stroke, there is no need to continue.
|
||||||
if (!param.compound && (this.fillColor || this.strokeColor)) {
|
var fillColor = this.getFillColor(),
|
||||||
|
strokeColor = this.getStrokeColor();
|
||||||
|
if (!param.compound && (fillColor || strokeColor)) {
|
||||||
this.setCtxStyles(ctx);
|
this.setCtxStyles(ctx);
|
||||||
ctx.save();
|
ctx.save();
|
||||||
// If the path only defines a strokeColor or a fillColor,
|
// If the path only defines a strokeColor or a fillColor,
|
||||||
// draw it directly with the globalAlpha set, otherwise
|
// draw it directly with the globalAlpha set, otherwise
|
||||||
// we will do it later when we composite the temporary canvas.
|
// we will do it later when we composite the temporary canvas.
|
||||||
if (!this.fillColor || !this.strokeColor)
|
if (!fillColor || !strokeColor)
|
||||||
ctx.globalAlpha = this.opacity;
|
ctx.globalAlpha = this.opacity;
|
||||||
if (this.fillColor) {
|
if (fillColor) {
|
||||||
ctx.fillStyle = this.fillColor.getCanvasStyle(ctx);
|
ctx.fillStyle = fillColor.getCanvasStyle(ctx);
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
if (this.strokeColor) {
|
if (strokeColor) {
|
||||||
ctx.strokeStyle = this.strokeColor.getCanvasStyle(ctx);
|
ctx.strokeStyle = strokeColor.getCanvasStyle(ctx);
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
|
@ -515,11 +517,11 @@ var Path = this.Path = PathItem.extend({
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
|
||||||
var styleNames = {
|
var styles = {
|
||||||
strokeWidth: 'lineWidth',
|
getStrokeWidth: 'lineWidth',
|
||||||
strokeJoin: 'lineJoin',
|
getStrokeJoin: 'lineJoin',
|
||||||
strokeCap: 'lineCap',
|
getStrokeCap: 'lineCap',
|
||||||
miterLimit: 'miterLimit'
|
getMiterLimit: 'miterLimit'
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -645,11 +647,12 @@ var Path = this.Path = PathItem.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setCtxStyles: function(ctx) {
|
setCtxStyles: function(context) {
|
||||||
for (var i in styleNames) {
|
for (var i in styles) {
|
||||||
var style;
|
var style;
|
||||||
if (style = this[i])
|
if (style = this[i]()) {
|
||||||
ctx[styleNames[i]] = style;
|
context[styles[i]] = style;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue