def create_normal_surfaces(self,
context, vis_width, vis_height, star_width):
rgba1 = context.get_border_color(Gtk.StateFlags.NORMAL)
rgba0 = context.get_color(Gtk.StateFlags.ACTIVE)
lin = cairo.LinearGradient(0, 0, 0, vis_height)
lin.add_color_stop_rgb(0, rgba0.red, rgba0.green, rgba0.blue)
lin.add_color_stop_rgb(1, rgba1.red, rgba1.green, rgba1.blue)
# paint full
full_surf = cairo.ImageSurface(
cairo.FORMAT_ARGB32, vis_width, vis_height)
cr = cairo.Context(full_surf)
cr.set_source(lin)
cr.set_line_width(1)
if self.rounded:
cr.set_line_join(cairo.LINE_CAP_ROUND)
for i in range(self.n_stars):
x = 1 + i * (star_width + self.spacing)
self.layout(cr, x + 1, 1, star_width - 2, vis_height - 2)
cr.stroke_preserve()
cr.fill()
del cr
# paint empty
empty_surf = cairo.ImageSurface(
cairo.FORMAT_ARGB32, vis_width, vis_height)
cr = cairo.Context(empty_surf)
cr.set_source(lin)
cr.set_line_width(1)
if self.rounded:
cr.set_line_join(cairo.LINE_CAP_ROUND)
for i in range(self.n_stars):
x = 1 + i * (star_width + self.spacing)
self.layout(cr, x + 1, 1, star_width - 2, vis_height - 2)
cr.stroke()
del cr
return full_surf, empty_surf
评论列表
文章目录