(layer = null, options = null)
| 663 | action.handler(this) |
| 664 | } |
| 665 | setBrush(layer = null, options = null) { |
| 666 | if (options == null) { |
| 667 | options = this.options |
| 668 | } |
| 669 | if (layer) { |
| 670 | layer.ctx.lineCap = "round" |
| 671 | layer.ctx.lineJoin = "round" |
| 672 | layer.ctx.lineWidth = options.brush_size / this.containerScale |
| 673 | layer.ctx.fillStyle = options.color |
| 674 | layer.ctx.strokeStyle = options.color |
| 675 | var sharpness = parseInt(options.sharpness * options.brush_size) |
| 676 | layer.ctx.filter = sharpness == 0 ? `none` : `blur(${sharpness}px)` |
| 677 | layer.ctx.globalAlpha = 1 - options.opacity |
| 678 | layer.ctx.globalCompositeOperation = "source-over" |
| 679 | var tool = IMAGE_EDITOR_TOOLS.find((t) => t.id == options.tool) |
| 680 | if (tool && tool.setBrush) { |
| 681 | tool.setBrush(editor, layer) |
| 682 | } |
| 683 | } else { |
| 684 | Object.values(["drawing", "overlay"]) |
| 685 | .map((name) => this.layers[name]) |
| 686 | .forEach((l) => { |
| 687 | this.setBrush(l) |
| 688 | }) |
| 689 | } |
| 690 | } |
| 691 | get ctx_overlay() { |
| 692 | return this.layers.overlay.ctx |
| 693 | } |
no outgoing calls
no test coverage detected