def draw_icon(ctx, x, y, width, height, rgb, symbol, aspect=1.0, corner_radius=20): # Draw the bottom Layer: ctx.set_source_rgb(*rgb) draw_rounded_rectangle(ctx, x, y, width, height, aspect, corner_radius) ctx.fill() # Make the bottom layer fade to the left, upper corner. add_shadow(ctx, width, height, 0, 0, a1=0.8, a2=0.1) # Draw the Top-Layer: ctx.set_source_rgb(*rgb) draw_rounded_rectangle( ctx, x + 2, y + 2, width - width / 12, height - height / 12, aspect, corner_radius ) ctx.fill() # ADd some glow point on top: radial = cairo.RadialGradient( width / 2, 0, width / 10000, width / 2, width / 4, width / 3 * 2 ) radial.add_color_stop_rgba(0, 1, 1, 1, 0.4) radial.add_color_stop_rgba(1, 0, 0, 0, 0.1) ctx.set_source(radial) ctx.paint() # Add some nice shadows left and bottom: add_shadow(ctx, width / 2, height, width / 2, height - height / 4) add_shadow(ctx, 0, height / 2, width / 7, height / 2) # Now draw the center text: for idx, alpha in enumerate([0.5, 0.9]): ctx.set_source_rgba(idx, idx, idx, alpha) offset = height / 7 * (1 - idx) draw_center_text( ctx, width - offset, height - 0.5 * offset, symbol, font_size=height * 0.6 )
def _render_missing(self, widget, ctx): alloc = self.get_allocation() w, h = alloc.width, alloc.height widget.set_size_request(w - w / 10, h - h / 10) ctx.set_source_rgba(0, 0, 0, 0.1) draw_center_text(ctx, w, h, 'тНи', font_size=300)