Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
文字显示策略
  • Loading branch information
kener committed Jul 22, 2014
1 parent a243372 commit b813474
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/shape/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ define(
ctx.fill();
}

if (style.text) {
this.drawText(ctx, style, this.style);
}
this.drawText(ctx, style, this.style);

ctx.restore();
};
Expand Down Expand Up @@ -437,6 +435,9 @@ define(
* @param {Object} normalStyle 默认样式,用于定位文字显示
*/
Base.prototype.drawText = function (ctx, style, normalStyle) {
if (style.text == undefined || style.text === false ) {
return;
}
// 字体颜色策略
var textColor = style.textColor || style.color || style.strokeColor;
ctx.fillStyle = textColor;
Expand Down
4 changes: 1 addition & 3 deletions src/shape/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ define(
this.style.height = height;


if (style.text) {
this.drawText(ctx, style, this.style);
}
this.drawText(ctx, style, this.style);

ctx.restore();
}
Expand Down
4 changes: 1 addition & 3 deletions src/shape/Polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ define(
ctx.stroke();
}

if (style.text) {
this.drawText(ctx, style, this.style);
}
this.drawText(ctx, style, this.style);

ctx.restore();

Expand Down
2 changes: 1 addition & 1 deletion src/shape/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ define(
);
}

if (typeof style.text == 'undefined') {
if (style.text == undefined || style.text === false) {
return;
}

Expand Down

0 comments on commit b813474

Please sign in to comment.