Rename draw_number, draw_value to draw_legend
Rename draw_number, draw_value to draw_legend in main dial and bottom dial
This commit is contained in:
parent
597c25914a
commit
1342a1191c
5 changed files with 9 additions and 9 deletions
|
@ -44,8 +44,8 @@ class Dial(Gauge):
|
|||
(self.max_angle - self.min_angle) * (adj / adj_max) \
|
||||
- self.ANGLE_OFFSET
|
||||
|
||||
def draw_number(self, cr: cairo.Context, radius: float, value: float, text: str):
|
||||
angle = self.angle(value)
|
||||
def draw_legend(self, cr: cairo.Context, radius: float, value: float, text: str):
|
||||
|
||||
cr.move_to(self.x + radius * self.radius * math.cos(angle) - 20,
|
||||
self.y + radius * self.radius * math.sin(angle))
|
||||
|
@ -120,7 +120,7 @@ class BottomDial(Dial):
|
|||
def angle(self, value: float):
|
||||
return super().angle((self.max_value - value) + self.min_value)
|
||||
|
||||
def draw_value(self, cr: cairo.Context, radius: float, value: float, text: str, x_offset: float=0.0, y_offset: float=0.0):
|
||||
def draw_legend(self, cr: cairo.Context, radius: float, value: float, text: str, x_offset: float=0.0, y_offset: float=0.0):
|
||||
angle = self.angle(value)
|
||||
|
||||
cr.move_to(self.x + radius * self.radius * math.cos(angle) + x_offset,
|
||||
|
|
|
@ -29,10 +29,10 @@ class FuelGauge(BottomDial):
|
|||
cr.set_font_size(self.radius * 0.1)
|
||||
|
||||
cr.set_source_rgb(1, 0, 0)
|
||||
self.draw_value(cr, 0.75, 0, "0", -5, 5)
|
||||
self.draw_legend(cr, 0.75, 0, "0", -5, 5)
|
||||
|
||||
cr.set_source_rgb(1, 1, 1)
|
||||
self.draw_value(cr, 0.75, 15, "1", -10, 5)
|
||||
self.draw_legend(cr, 0.75, 15, "1", -10, 5)
|
||||
|
||||
cr.set_line_width(6.0)
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class Speedo(Dial):
|
|||
self.draw_mark(cr, min_radius, 0.87, speed)
|
||||
|
||||
for speed in range(0, int(self.max_value)+1, 20):
|
||||
self.draw_number(cr, 0.68, speed, "%d" % int(speed))
|
||||
self.draw_legend(cr, 0.68, speed, "%d" % int(speed))
|
||||
|
||||
def _draw_text(self, cr: cairo.Context, x: float, y: float, text: str, size: float):
|
||||
cr.select_font_face("Muli",
|
||||
|
|
|
@ -22,7 +22,7 @@ class Tacho(Dial):
|
|||
self.gear: Gear = Gear.N
|
||||
self.shift_mode: ShiftMode = ShiftMode.NORMAL
|
||||
|
||||
def draw_number(self, cr: cairo.Context, radius: float, value: float, text: str):
|
||||
def draw_legend(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) - Dial.ANGLE_OFFSET
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Tacho(Dial):
|
|||
if speed >= self.redline:
|
||||
cr.set_source_rgb(1.0, 0.1, 0.1)
|
||||
|
||||
self.draw_number(cr, 0.69, speed, "%d" % int(speed / 1000))
|
||||
self.draw_legend(cr, 0.69, speed, "%d" % int(speed / 1000))
|
||||
|
||||
def gear_text(self):
|
||||
text = ''
|
||||
|
|
|
@ -28,10 +28,10 @@ class Thermometer(BottomDial):
|
|||
cr.set_font_size(self.radius * 0.1)
|
||||
|
||||
cr.set_source_rgb(1, 1, 1)
|
||||
self.draw_value(cr, 0.78, self.min_value, "C")
|
||||
self.draw_legend(cr, 0.78, self.min_value, "C")
|
||||
|
||||
cr.set_source_rgb(1, 0, 0)
|
||||
self.draw_value(cr, 0.75, self.max_value, "H", -15, 5)
|
||||
self.draw_legend(cr, 0.75, self.max_value, "H", -15, 5)
|
||||
|
||||
cr.set_line_width(6.0)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue