May as well commit that!
This commit is contained in:
parent
acc27cb94b
commit
f3d33400d7
2 changed files with 24 additions and 0 deletions
|
@ -31,6 +31,19 @@ class Dial(Gauge):
|
|||
|
||||
return gradient
|
||||
|
||||
def draw_number(self, cr: cairo.Context, radius: float, value: float, text: str):
|
||||
angle = self.min_angle + ((self.max_angle - self.min_angle) * value) - 1.658;
|
||||
|
||||
cr.set_source_rgb(1, 1, 1)
|
||||
cr.move_to(self.x + radius * self.radius * math.cos(angle),
|
||||
self.y + radius * self.radius * math.sin(angle))
|
||||
|
||||
cr.save()
|
||||
cr.rotate(angle + 1.658)
|
||||
cr.show_text(text)
|
||||
cr.stroke()
|
||||
cr.restore()
|
||||
|
||||
def draw_bg(self, cr: cairo.Context):
|
||||
arc = (self.x,
|
||||
self.y,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import enum
|
||||
import math
|
||||
import cairo
|
||||
|
||||
from hexagram.cluster import Dial
|
||||
|
||||
|
@ -18,3 +19,13 @@ class Speedo(Dial):
|
|||
|
||||
self.units = units
|
||||
self.max_speed = max_speed
|
||||
|
||||
def draw_bg(self, cr: cairo.Context):
|
||||
super().draw_bg(cr)
|
||||
|
||||
cr.select_font_face("Helvetica")
|
||||
cr.set_font_size(self.radius * 0.125)
|
||||
cr.set_source_rgb(1, 1, 1)
|
||||
|
||||
for speed in range(0, int(self.max_speed), 50):
|
||||
self.draw_number(cr, 0.75, speed, str(int(speed)))
|
||||
|
|
Loading…
Add table
Reference in a new issue