* @function LevelRenderer.Shape.prototype.brush * @description 绘制图形。 * * @param {CanvasRenderingContext2D} ctx - Context2D 上下文。 * @param {boolean} isHighlight - 是否使用高亮属性。 * @param {function} updateCallback - 需要异步加载资源的 shape 可以通过这个 callback(e),让painter更新视图,base.brush 没用,需要的话重
(ctx, isHighlight)
| 260 | * @param {function} updateCallback - 需要异步加载资源的 shape 可以通过这个 callback(e),让painter更新视图,base.brush 没用,需要的话重载 brush。 |
| 261 | */ |
| 262 | brush(ctx, isHighlight) { |
| 263 | |
| 264 | var style = this.beforeBrush(ctx, isHighlight); |
| 265 | |
| 266 | ctx.beginPath(); |
| 267 | this.buildPath(ctx, style); |
| 268 | |
| 269 | switch (style.brushType) { |
| 270 | /* jshint ignore:start */ |
| 271 | case 'both': |
| 272 | this.setCtxGlobalAlpha(ctx, "fill", style); |
| 273 | ctx.fill(); |
| 274 | if (style.lineWidth > 0) { |
| 275 | this.setCtxGlobalAlpha(ctx, "stroke", style); |
| 276 | ctx.stroke(); |
| 277 | } |
| 278 | this.setCtxGlobalAlpha(ctx, "reset", style); |
| 279 | break; |
| 280 | case 'stroke': |
| 281 | this.setCtxGlobalAlpha(ctx, "stroke", style); |
| 282 | style.lineWidth > 0 && ctx.stroke(); |
| 283 | this.setCtxGlobalAlpha(ctx, "reset", style); |
| 284 | break; |
| 285 | /* jshint ignore:end */ |
| 286 | default: |
| 287 | this.setCtxGlobalAlpha(ctx, "fill", style); |
| 288 | ctx.fill(); |
| 289 | this.setCtxGlobalAlpha(ctx, "reset", style); |
| 290 | break; |
| 291 | } |
| 292 | |
| 293 | this.drawText(ctx, style, this.style); |
| 294 | |
| 295 | this.afterBrush(ctx); |
| 296 | } |
| 297 | |
| 298 | |
| 299 | /** |
no test coverage detected