faders/meter: add css variable --gauge-opacity to allow setting a fixed gauge opacity for meters and compact faders

This commit is contained in:
jean-emmanuel 2018-04-07 11:46:23 +02:00
parent c2e9232a90
commit 5ba26e19d7
8 changed files with 24 additions and 5 deletions

View file

@ -225,7 +225,7 @@ module.exports = class Fader extends Slider {
if (this.getProp('compact')) {
this.ctx.globalAlpha = (dashed ? .3 : .2) + 0.2 * Math.abs(d-o) / (d<o?o:height-o)
this.ctx.globalAlpha = this.colors.gaugeOpacity || (dashed ? .3 : .2) + 0.2 * Math.abs(d-o) / (d<o?o:height-o)
this.ctx.strokeStyle = this.colors.gradient || this.colors.gauge
this.ctx.beginPath()

View file

@ -44,7 +44,7 @@ var RangeFader = class RangeFader extends Fader {
if (this.getProp('compact')) {
this.ctx.globalAlpha = (dashed ? .3 : .2) + 0.2 * Math.abs(d-d2) / height
this.ctx.globalAlpha = this.colors.gaugeOpacity || (dashed ? .3 : .2) + 0.2 * Math.abs(d-d2) / height
this.ctx.strokeStyle = this.colors.gauge
this.ctx.beginPath()
this.ctx.moveTo(m, d2)

View file

@ -177,6 +177,7 @@ class Slider extends Canvas {
this.colors.gauge = style.getPropertyValue('--color-gauge')
this.colors.knob = style.getPropertyValue('--color-knob')
this.colors.pips = style.getPropertyValue('--color-pips')
this.colors.gaugeOpacity = style.getPropertyValue('--gauge-opacity')
super.cacheCanvasStyle(style)