fader: fix compact gauge alpha algo to compute the relative distance to the origin, no matter the direction

This commit is contained in:
jean-emmanuel 2016-11-22 18:36:57 +01:00
parent fc4ad56afb
commit 4066f0446e

View file

@ -166,7 +166,7 @@ Fader.prototype.draw = function(){
if (this.widgetData.horizontal) {
if (this.widgetData.compact) {
this.ctx.globalAlpha = 0.2 + 0.2 * Math.abs(d-o)/this.width
this.ctx.globalAlpha = 0.2 + 0.2 * Math.abs(d-o) / (d<o?o:this.width-o)
this.ctx.strokeStyle = this.colors.gauge
this.ctx.beginPath()
this.ctx.moveTo(d, m)
@ -230,7 +230,7 @@ Fader.prototype.draw = function(){
if (this.widgetData.compact) {
this.ctx.globalAlpha = 0.2 + 0.2 * Math.abs(d-o)/this.height
this.ctx.globalAlpha = 0.2 + 0.2 * Math.abs(d-o) / (d<o?o:this.height-o)
this.ctx.strokeStyle = this.colors.gauge
this.ctx.beginPath()
this.ctx.moveTo(m, d)