From 490390a433b38815ce76b9e466ef92110ad8ffe7 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 1 Jan 2024 19:20:35 -0500 Subject: [PATCH] Deftly manoeuvred and muscled for rank --- py/hexagram/dial.py | 7 +++++++ py/hexagram/fuel.py | 10 ++-------- py/hexagram/thermo.py | 9 ++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/py/hexagram/dial.py b/py/hexagram/dial.py index 1e9c1da..6ff0f29 100644 --- a/py/hexagram/dial.py +++ b/py/hexagram/dial.py @@ -99,3 +99,10 @@ class Dial(Gauge): def draw_fg(self, cr: cairo.Context): 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) diff --git a/py/hexagram/fuel.py b/py/hexagram/fuel.py index 0bffb5a..db0e3c1 100644 --- a/py/hexagram/fuel.py +++ b/py/hexagram/fuel.py @@ -2,9 +2,9 @@ import enum import math 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) MAX_ANGLE = 216.0 * (math.pi / 180.0) @@ -75,9 +75,3 @@ class FuelGauge(Dial): cr.set_source_rgb(1, 1, 1) 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) diff --git a/py/hexagram/thermo.py b/py/hexagram/thermo.py index 4985f7d..92c78fc 100644 --- a/py/hexagram/thermo.py +++ b/py/hexagram/thermo.py @@ -2,9 +2,9 @@ import enum import math 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) MAX_ANGLE = 216.0 * (math.pi / 180.0) @@ -17,6 +17,8 @@ class ThermoGauge(Dial): 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) + self.value = self.MIN_VALUE + 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 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) self.draw_mark(cr, 0.83, 0.87, self.max_value - level) - - def draw_fg(self, cr: cairo.Context): - pass