I'm on a roll!
This commit is contained in:
parent
353ece7390
commit
c6f0ef5ec1
1 changed files with 23 additions and 7 deletions
|
@ -1,9 +1,6 @@
|
|||
import math
|
||||
import cairo
|
||||
|
||||
CLUSTER_WIDTH = 1280
|
||||
CLUSTER_HEIGHT = 480
|
||||
|
||||
class Gauge():
|
||||
__slots = 'x', 'y', 'radius',
|
||||
|
||||
|
@ -20,16 +17,19 @@ class Gauge():
|
|||
self.radius = radius
|
||||
|
||||
def _gradient(self):
|
||||
gradient = cairo.LinearGradient(0, 0, 2 * self.radius, 2 * self.radius)
|
||||
gradient = cairo.LinearGradient(self.x - self.radius,
|
||||
self.y - self.radius,
|
||||
self.x + self.radius,
|
||||
self.y + self.radius)
|
||||
|
||||
for stop in self.BEZEL_GRADIENT_STOPS:
|
||||
gradient.add_color_stop_rgba(*stop)
|
||||
|
||||
return gradient
|
||||
|
||||
def _draw_face(self, cr: cairo.Context):
|
||||
arc = (self.radius,
|
||||
self.radius,
|
||||
def draw_bg(self, cr: cairo.Context):
|
||||
arc = (self.x,
|
||||
self.y,
|
||||
self.radius - self.BEZEL_WIDTH,
|
||||
0,
|
||||
2.0 * math.pi)
|
||||
|
@ -44,3 +44,19 @@ class Gauge():
|
|||
cr.set_line_width(self.BEZEL_WIDTH)
|
||||
cr.arc(*arc)
|
||||
cr.stroke()
|
||||
|
||||
class Cluster():
|
||||
WIDTH = 1280
|
||||
HEIGHT = 480
|
||||
|
||||
__slots__ = 'gauges',
|
||||
|
||||
def __init__(self):
|
||||
self.gauges = list()
|
||||
|
||||
for x in (self.HEIGHT / 2, self.WIDTH - self.HEIGHT / 2):
|
||||
self.gauges.append(Gauge(x, self.HEIGHT / 2, self.HEIGHT / 2))
|
||||
|
||||
def draw_bg(self, cr: cairo.Context):
|
||||
for gauge in self.gauges:
|
||||
gauge.draw_bg(cr)
|
||||
|
|
Loading…
Add table
Reference in a new issue