cr = self.cr
cr.save()
- cr.set_source_rgba(fill_color[0], fill_color[1], fill_color[2],
- fill_color[3])
+ r, g, b, a = self.color_to_rgba(fill_color)
+ cr.set_source_rgba(r, g, b, a)
cr.arc(cx, cy, size, 0, 2 * pi)
cr.fill()
cr.restore()
cr.stroke()
def draw_rect_from_center(self, cx, cy, width, height, theta=0,
- fill=True, fill_color=[1, 1, 1],
- stroke=False, stroke_color=[0, 0, 0]):
+ fill=True, fill_color=[1, 1, 1, 0.8],
+ stroke=False, stroke_color=[0, 0, 0, 0.5]):
cr = self.cr
mx = width / 2.0
if fill:
cr.rectangle(0, 0, width, height)
- cr.set_source_rgba(fill_color[0], fill_color[1], fill_color[2], 0.8)
+ r, g, b, a = self.color_to_rgba(fill_color)
+ cr.set_source_rgba(r, g, b, a)
cr.fill()
if stroke:
cr.rectangle(0, 0, width, height)
- cr.set_source_rgba(stroke_color[0], stroke_color[1], stroke_color[2], 0.5)
+ r, g, b, a = self.color_to_rgba(stroke_color)
+ cr.set_source_rgba(r, g, b, a)
cr.stroke()
- self.draw_dot(0, 0, 3.0, list(stroke_color) + [0.5])
+ self.draw_dot(0, 0, 3.0, stroke_color)
cr.restore()
- def draw_rect(self, x, y, width, height, fill=True, fill_color=[1, 1, 1],
- stroke=False, stroke_color=[0, 0, 0]):
+ def draw_rect(self, x, y, width, height, fill=True, fill_color=[1, 1, 1, 0.8],
+ stroke=False, stroke_color=[0, 0, 0, 0.5]):
cr = self.cr
cr.save()
if fill:
cr.rectangle(0, 0, width, height)
- cr.set_source_rgba(fill_color[0], fill_color[1], fill_color[2], 0.8)
+ r, g, b, a = self.color_to_rgba(fill_color)
+ cr.set_source_rgba(r, g, b, a)
cr.fill()
if stroke:
cr.rectangle(0, 0, width, height)
- cr.set_source_rgba(stroke_color[0], stroke_color[1], stroke_color[2], 0.5)
+ r, g, b, a = self.color_to_rgba(stroke_color)
+ cr.set_source_rgba(r, g, b, a)
cr.stroke()
- self.draw_dot(0, 0, 3.0, list(stroke_color) + [0.5])
+ self.draw_dot(0, 0, 3.0, stroke_color)
cr.restore()
cr.save()
cr.translate(rx, ry)
cr.rotate(theta)
- self.draw_rect(0, -descent, width, ascent, fill_color=[1, 1, 1, 0.1], stroke=bounding_box)
- cr.set_source_rgba(color[0], color[1], color[2], 0.8)
+ self.draw_rect(0, -descent, width, ascent, fill_color=[1, 1, 1, 0.8], stroke=bounding_box)
+ r, g, b, a = self.color_to_rgba(color)
+ cr.set_source_rgba(r, g, b, a)
cr.move_to(0, 0)
cr.show_text(text)
cr.fill()