diff --git a/py/hexagram/cluster.py b/py/hexagram/cluster.py index b09f532..0256ad0 100644 --- a/py/hexagram/cluster.py +++ b/py/hexagram/cluster.py @@ -7,6 +7,7 @@ from hexagram.pattern import HexagonPattern from hexagram.gauge import Gauge from hexagram.dial import Dial from hexagram.speedo import Speedo +from hexagram.tacho import Tacho class ShiftIndicator(Gauge): LIGHT_WIDTH = 48 @@ -73,12 +74,10 @@ class Cluster(): self.HEIGHT / 2, 180.0) - self.tacho = Dial(self.WIDTH - self.HEIGHT / 2, - self.HEIGHT / 2, - self.HEIGHT / 2, - 232.0 * (math.pi / 180.0), - 488.0 * (math.pi / 180.0), - 8000) + self.tacho = Tacho(self.WIDTH - self.HEIGHT / 2, + self.HEIGHT / 2, + self.HEIGHT / 2, + 8000) self.gauges.append(self.speedo) self.gauges.append(self.tacho) diff --git a/py/hexagram/dial.py b/py/hexagram/dial.py index 149ccd8..e290e2f 100644 --- a/py/hexagram/dial.py +++ b/py/hexagram/dial.py @@ -3,13 +3,12 @@ import cairo from hexagram.gauge import Gauge -ANGLE_OFFSET = math.pi / 2 - class Dial(Gauge): __slots = 'x', 'y', 'radius', 'min_angle', 'max_angle', 'max_value', - BEZEL_WIDTH = 16 + ANGLE_OFFSET = math.pi / 2 + BEZEL_WIDTH = 16 BEZEL_GRADIENT_STOPS = ( (0, 1.0, 0.4, 1.0, 1.0), (1, 0.4, 0.0, 0.4, 0.0) @@ -36,13 +35,12 @@ class Dial(Gauge): def draw_number(self, cr: cairo.Context, radius: float, value: float, text: str): scale = value / self.max_value - angle = self.min_angle + ((self.max_angle - self.min_angle) * scale) - ANGLE_OFFSET + angle = self.min_angle + ((self.max_angle - self.min_angle) * scale) - self.ANGLE_OFFSET cr.set_source_rgb(1, 1, 1) cr.move_to(self.x + radius * self.radius * math.cos(angle) - 20, self.y + radius * self.radius * math.sin(angle)) - #cr.rotate(angle + ANGLE_OFFSET) cr.show_text(text) cr.stroke() diff --git a/py/hexagram/speedo.py b/py/hexagram/speedo.py index 8394528..0a243e1 100644 --- a/py/hexagram/speedo.py +++ b/py/hexagram/speedo.py @@ -12,7 +12,7 @@ class Speedo(Dial): MIN_ANGLE = 232.0 * (math.pi / 180.0) MAX_ANGLE = 488.0 * (math.pi / 180.0) - FONT_FACE = "Helvetica" + FONT_FACE = "Muli" __slots__ = 'units', @@ -24,7 +24,10 @@ class Speedo(Dial): def draw_bg(self, cr: cairo.Context): super().draw_bg(cr) - cr.select_font_face(self.FONT_FACE) + cr.select_font_face(self.FONT_FACE, + cairo.FontSlant.ITALIC, + cairo.FontWeight.BOLD) + cr.set_font_size(self.radius * 0.1) cr.set_source_rgb(1, 1, 1)