[gnome-music/wip/mschraal/searchview-bugfixes: 2/3] artistart: Fix up the default icons



commit 49b8420f37db2e568111f23f98aee2bfa12cddde
Author: Marinus Schraal <mschraal gnome org>
Date:   Tue Aug 6 15:45:19 2019 +0200

    artistart: Fix up the default icons
    
    Add a background and a border.
    
    Also make ArtistArt and ArtistArt cache more similar.

 gnomemusic/albumartcache.py | 21 +++++++++++----------
 gnomemusic/artistart.py     | 28 +++++++++++++++++-----------
 2 files changed, 28 insertions(+), 21 deletions(-)
---
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index 13b6678b..75e90f52 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -95,26 +95,27 @@ def _make_icon_frame(icon_surface, art_size=None, scale=1, default_icon=False):
     ctx.set_source_rgba(0, 0, 0, 0.7)
     ctx.stroke_preserve()
 
-    # fill the center
-    ctx.set_source_rgb(1, 1, 1)
-    ctx.fill()
-
     matrix = cairo.Matrix()
 
     if default_icon:
-        matrix.translate(-w * (1 / 3), -h * (1 / 3))
-        ctx.set_operator(cairo.Operator.DIFFERENCE)
+        ctx.set_source_rgb(1, 1, 1)
+        ctx.fill()
+        ctx.set_source_rgba(0, 0, 0, 0.3)
+        ctx.mask_surface(icon_surface, w / 3, h / 3)
+        ctx.fill()
     else:
         matrix.scale(
             icon_w / ((w - border * 2) * scale),
             icon_h / ((h - border * 2) * scale))
         matrix.translate(-border, -border)
+        ctx.set_source_surface(icon_surface, 0, 0)
+
+        pattern = ctx.get_source()
+        pattern.set_matrix(matrix)
+        ctx.fill()
 
-    ctx.set_source_surface(icon_surface, 0, 0)
-    pattern = ctx.get_source()
-    pattern.set_matrix(matrix)
     ctx.rectangle(border, border, w - border * 2, h - border * 2)
-    ctx.fill()
+    ctx.clip()
 
     return surface
 
diff --git a/gnomemusic/artistart.py b/gnomemusic/artistart.py
index 18a7e1ad..907cbc42 100644
--- a/gnomemusic/artistart.py
+++ b/gnomemusic/artistart.py
@@ -52,25 +52,31 @@ def _make_icon_frame(icon_surface, art_size=None, scale=1, default_icon=False):
     surface.set_device_scale(scale, scale)
     ctx = cairo.Context(surface)
 
-    ctx.arc(w / 2, h / 2, w / 2, 0, 2 * pi)
-    ctx.clip()
-
     matrix = cairo.Matrix()
 
+    line_width = 0.6
+    ctx.new_sub_path()
+    ctx.arc(w / 2, h / 2, (w / 2) - line_width, 0, 2 * pi)
+    ctx.set_source_rgba(0, 0, 0, 0.7)
+    ctx.set_line_width(line_width)
+    ctx.stroke_preserve()
+
     if default_icon:
-        ctx.set_source_rgb(0, 0, 0)
+        ctx.set_source_rgb(1, 1, 1)
+        ctx.fill()
+        ctx.set_source_rgba(0, 0, 0, 0.3)
+        ctx.mask_surface(icon_surface, w / 3, h / 3)
         ctx.fill()
-        matrix.translate(-w * 1 / 3, -h * 1 / 3)
-        ctx.set_operator(cairo.Operator.DIFFERENCE)
     else:
         matrix.scale(icon_w / (w * scale), icon_h / (h * scale))
+        ctx.set_source_surface(icon_surface, 0, 0)
 
-    ctx.set_source_surface(icon_surface, 0, 0)
+        pattern = ctx.get_source()
+        pattern.set_matrix(matrix)
+        ctx.fill()
 
-    pattern = ctx.get_source()
-    pattern.set_matrix(matrix)
-    ctx.rectangle(0, 0, w, h)
-    ctx.fill()
+    ctx.arc(w / 2, h / 2, w / 2, 0, 2 * pi)
+    ctx.clip()
 
     return surface
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]