knob: zoom pxscaling bug fix

This commit is contained in:
jean-emmanuel 2017-04-27 10:16:10 +02:00
parent 4219694389
commit edea36cc29
2 changed files with 9 additions and 9 deletions

View file

@ -28,7 +28,7 @@ var DisplayKnob = class extends Knob {
this.ctx.beginPath()
this.ctx.fillStyle = this.colors.raised
this.ctx.strokeStyle = this.colors.raised
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - this.gaugeWidth * 1.5 * PXSCALE - 2 * PXSCALE, 0, Math.PI * 2)
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - this.gaugeWidth * 1.5, 0, Math.PI * 2)
this.ctx.fill()
this.ctx.globalAlpha = 0.3
this.ctx.lineWidth = 1.1 * PXSCALE

View file

@ -162,23 +162,23 @@ module.exports = class Knob extends _sliders_base {
if (this.widgetData.compact) {
this.ctx.lineWidth = this.gaugeWidth * PXSCALE
this.ctx.lineWidth = this.gaugeWidth
this.ctx.globalAlpha = 0.3
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.track
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (this.gaugeWidth + this.margin) * PXSCALE, min, max)
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - this.gaugeWidth - this.margin * PXSCALE, min, max)
this.ctx.stroke()
this.ctx.globalAlpha = 0.2 + 0.2 * Math.abs(d-o) / (d<o?o-min:max-o)
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.gauge
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (this.gaugeWidth + this.margin) * PXSCALE, Math.min(o,d), Math.max(o,d))
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - this.gaugeWidth - this.margin * PXSCALE, Math.min(o,d), Math.max(o,d))
this.ctx.stroke()
this.ctx.lineWidth = 1 * PXSCALE
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.track
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (this.gaugeWidth/2 + this.margin) * PXSCALE, min, max)
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - this.gaugeWidth/2 - this.margin * PXSCALE, min, max)
this.ctx.stroke()
@ -186,7 +186,7 @@ module.exports = class Knob extends _sliders_base {
this.ctx.beginPath()
this.ctx.strokeStyle = this.colors.gauge
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - (this.gaugeWidth/2 + this.margin) * PXSCALE, Math.min(o,d), Math.max(o,d))
this.ctx.arc(this.width / 2, this.height / 2, this.minDimension / 2 - this.gaugeWidth/2 - this.margin * PXSCALE, Math.min(o,d), Math.max(o,d))
this.ctx.stroke()
this.ctx.beginPath()
@ -194,9 +194,9 @@ module.exports = class Knob extends _sliders_base {
this.ctx.strokeStyle = this.colors.knob
this.ctx.lineWidth = 1 * PXSCALE
let r1 = this.minDimension / 2 - (this.gaugeWidth/2 + this.margin) * PXSCALE,
r2 = this.minDimension / 2 - (this.gaugeWidth * 1.5 + this.margin) * PXSCALE,
a = 2 * Math.PI - d
let r1 = this.minDimension / 2 - this.gaugeWidth/2 - this.margin * PXSCALE,
r2 = this.minDimension / 2 - this.gaugeWidth * 1.5 - this.margin * PXSCALE,
a = 2 * Math.PI - d
this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))