A gauge needle, of sorts!
This commit is contained in:
parent
265b27196c
commit
dbe473224b
1 changed files with 24 additions and 0 deletions
|
@ -55,6 +55,30 @@ class Dial(Gauge):
|
|||
|
||||
cr.stroke()
|
||||
|
||||
def draw_needle(self, cr: cairo.Context, min_radius: float, max_radius: float, value: float):
|
||||
angle = self.min_angle + \
|
||||
((self.max_angle - self.min_angle) * (value / self.max_value)) \
|
||||
- self.ANGLE_OFFSET - 4 * (math.pi / 180.0)
|
||||
|
||||
angle_start = angle - 4 * (math.pi / 180.0)
|
||||
angle_end = angle + 4 * (math.pi / 180.0)
|
||||
|
||||
cr.set_source_rgba(1, 1, 1, 0.75)
|
||||
|
||||
cr.move_to(self.x + (min_radius * self.radius) * math.cos(angle_start),
|
||||
self.y + (min_radius * self.radius) * math.sin(angle_start))
|
||||
|
||||
cr.line_to(self.x + (max_radius * self.radius) * math.cos(angle),
|
||||
self.y + (max_radius * self.radius) * math.sin(angle))
|
||||
|
||||
cr.line_to(self.x + (max_radius * self.radius) * math.cos(angle_end),
|
||||
self.y + (max_radius * self.radius) * math.sin(angle_end))
|
||||
|
||||
cr.line_to(self.x + (min_radius * self.radius) * math.cos(angle_end),
|
||||
self.y + (min_radius * self.radius) * math.sin(angle_end))
|
||||
|
||||
cr.fill()
|
||||
|
||||
def draw_bg(self, cr: cairo.Context):
|
||||
arc = (self.x,
|
||||
self.y,
|
||||
|
|
Loading…
Add table
Reference in a new issue