Deftly manoeuvred and muscled for rank

This commit is contained in:
XANTRONIX Development 2024-01-01 19:20:35 -05:00
parent ec0baaef3e
commit 490390a433
3 changed files with 13 additions and 13 deletions

View file

@ -99,3 +99,10 @@ class Dial(Gauge):
def draw_fg(self, cr: cairo.Context): def draw_fg(self, cr: cairo.Context):
self.draw_needle(cr, 0.5, 0.89, self.value) self.draw_needle(cr, 0.5, 0.89, self.value)
class BottomDial(Dial):
def draw_fg(self, cr: cairo.Context):
min_radius = 0.8
max_radius = 0.9
self.draw_needle(cr, min_radius, max_radius, self.MAX_VALUE - self.value)

View file

@ -2,9 +2,9 @@ import enum
import math import math
import cairo import cairo
from hexagram.dial import Dial from hexagram.dial import BottomDial
class FuelGauge(Dial): class FuelGauge(BottomDial):
MIN_ANGLE = 144.0 * (math.pi / 180.0) MIN_ANGLE = 144.0 * (math.pi / 180.0)
MAX_ANGLE = 216.0 * (math.pi / 180.0) MAX_ANGLE = 216.0 * (math.pi / 180.0)
@ -75,9 +75,3 @@ class FuelGauge(Dial):
cr.set_source_rgb(1, 1, 1) cr.set_source_rgb(1, 1, 1)
self.draw_mark(cr, min_radius, 0.87, self.max_value - level) self.draw_mark(cr, min_radius, 0.87, self.max_value - level)
def draw_fg(self, cr: cairo.Context):
min_radius = 0.8
max_radius = 0.9
self.draw_needle(cr, min_radius, max_radius, self.MAX_VALUE - self.value)

View file

@ -2,9 +2,9 @@ import enum
import math import math
import cairo import cairo
from hexagram.dial import Dial from hexagram.dial import BottomDial
class ThermoGauge(Dial): class ThermoGauge(BottomDial):
MIN_ANGLE = 144.0 * (math.pi / 180.0) MIN_ANGLE = 144.0 * (math.pi / 180.0)
MAX_ANGLE = 216.0 * (math.pi / 180.0) MAX_ANGLE = 216.0 * (math.pi / 180.0)
@ -17,6 +17,8 @@ class ThermoGauge(Dial):
def __init__(self, x: float, y: float, radius: float): def __init__(self, x: float, y: float, radius: float):
super().__init__(x, y, radius, self.MIN_ANGLE, self.MAX_ANGLE, self.MAX_VALUE - self.MIN_VALUE) super().__init__(x, y, radius, self.MIN_ANGLE, self.MAX_ANGLE, self.MAX_VALUE - self.MIN_VALUE)
self.value = self.MIN_VALUE
def draw_value(self, cr: cairo.Context, radius: float, value: float, text: str, x_offset: float, y_offset: float): def draw_value(self, cr: cairo.Context, radius: float, value: float, text: str, x_offset: float, y_offset: float):
scale = (self.max_value - value) / self.max_value scale = (self.max_value - value) / self.max_value
angle = self.min_angle + ((self.max_angle - self.min_angle) * scale) - self.ANGLE_OFFSET angle = self.min_angle + ((self.max_angle - self.min_angle) * scale) - self.ANGLE_OFFSET
@ -70,6 +72,3 @@ class ThermoGauge(Dial):
cr.set_source_rgb(1, 1, 1) cr.set_source_rgb(1, 1, 1)
self.draw_mark(cr, 0.83, 0.87, self.max_value - level) self.draw_mark(cr, 0.83, 0.87, self.max_value - level)
def draw_fg(self, cr: cairo.Context):
pass