MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / setBrush

Method setBrush

ui/media/js/image-editor.js:665–690  ·  view source on GitHub ↗
(layer = null, options = null)

Source from the content-addressed store, hash-verified

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 }

Callers 5

setSizeMethod · 0.95
setImgMethod · 0.95
selectOptionMethod · 0.95
image-editor.jsFile · 0.80
rewindToMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected