From 63cfcb1b1d81a5cf509f5617199cb106e714cffd Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 16 Jul 2025 14:20:50 +0200 Subject: [PATCH] fader: compact radius tweaks --- src/client/widgets/sliders/fader.js | 50 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/client/widgets/sliders/fader.js b/src/client/widgets/sliders/fader.js index 96171ff1..aae63baa 100644 --- a/src/client/widgets/sliders/fader.js +++ b/src/client/widgets/sliders/fader.js @@ -308,6 +308,30 @@ class Fader extends Slider { this.ctx.rect(this.gaugePadding, d, width - this.gaugePadding * 2, knobHeight) this.ctx.fill() + let x, y, w, h, + rad = PXSCALE * this.cssVars.borderRadius + + // border radius: clip gauge & knob + if (rad > 0) { + x = this.gaugePadding + y = this.gaugePadding + w = width - this.gaugePadding * 2 + h = height - this.gaugePadding * 2 + this.ctx.beginPath() + this.ctx.moveTo(x + rad, y) + this.ctx.arcTo(x + w, y, x + w, y + h, rad) + this.ctx.arcTo(x + w, y + h, x, y + h, rad) + this.ctx.arcTo(x, y + h, x, y, rad) + this.ctx.arcTo(x, y, x + w, y, rad) + this.ctx.closePath() + + var tmpOp = this.ctx.globalCompositeOperation + this.ctx.globalCompositeOperation = 'destination-in' + this.ctx.fillStyle = '#ffffff' + this.ctx.globalAlpha = 1 + this.ctx.fill() + this.ctx.globalCompositeOperation = tmpOp + } // stroke if (this.cssVars.lineWidth) { @@ -315,32 +339,6 @@ class Fader extends Slider { this.ctx.globalAlpha = this.cssVars.alphaStroke this.ctx.strokeStyle = this.cssVars.colorStroke - let x, y, w, h, - rad = PXSCALE * this.cssVars.borderRadius - - if (rad > 0) { - // bordeRadius: clip gauge & knob - x = this.gaugePadding - y = this.gaugePadding - w = width - this.gaugePadding * 2 - h = height - this.gaugePadding * 2 - this.ctx.beginPath() - this.ctx.moveTo(x + rad, y) - this.ctx.arcTo(x + w, y, x + w, y + h, rad) - this.ctx.arcTo(x + w, y + h, x, y + h, rad) - this.ctx.arcTo(x, y + h, x, y, rad) - this.ctx.arcTo(x, y, x + w, y, rad) - this.ctx.closePath() - - var tmpOp = this.ctx.globalCompositeOperation - this.ctx.globalCompositeOperation = 'destination-in' - this.ctx.globalAlpha = 1 - this.ctx.fill() - this.ctx.globalCompositeOperation = tmpOp - this.ctx.globalAlpha = this.cssVars.alphaStroke - } - - // draw stroke x = 0.5 * this.cssVars.lineWidth y = 0.5 * this.cssVars.lineWidth