shithub: puzzles

Download patch

ref: 241f68b543de62a800ff5cbf6c06580d45ab8a13
parent: 1d509dc81961f182629bf0bfd48eed7941122fab
author: Ben Harris <[email protected]>
date: Sat Dec 10 16:46:34 EST 2022

Properly-styled icons for KaiOS

These are built alongside other icons as part of the GTK build.  It
builds new icon sizes of 44 and 88 pixels and then uses ImageMagick to
round off the corners and add a shadow in accordance with the KaiOS
design guide.

--- a/icons/icons.cmake
+++ b/icons/icons.cmake
@@ -81,7 +81,7 @@
 add_custom_target(icons)
 
 # All sizes of icon we make for any purpose.
-set(all_icon_sizes 96 48 32 16)
+set(all_icon_sizes 96 88 48 44 32 16)
 
 # Sizes of icon we put into the Windows .ico files.
 set(win_icon_sizes 48 32 16)
@@ -88,7 +88,9 @@
 
 # Border thickness for each icon size.
 set(border_96 4)
+set(border_88 4)
 set(border_48 4)
+set(border_44 4)
 set(border_32 2)
 set(border_16 1)
 
@@ -246,6 +248,31 @@
       ${icon_srcdir}/cicon.pl
       ${cicon_pl_infiles})
   list(APPEND output_icon_files ${icon_bindir}/${name}-icon.c)
+
+  # Make the KaiOS icons, which have rounded corners and shadows
+  # https://developer.kaiostech.com/docs/design-guide/launcher-icon
+  foreach(size 56 112)
+    math(EXPR srciconsize "${size} * 44 / 56")
+    math(EXPR borderwidth "(${size} - ${srciconsize}) / 2")
+    math(EXPR cornerradius "${size} * 5 / 56")
+    math(EXPR sizeminusone "${srciconsize} - 1")
+    math(EXPR shadowspread "${size} * 4 / 56")
+    math(EXPR shadowoffset "${size} * 2 / 56")
+    add_custom_command(OUTPUT ${icon_bindir}/${name}-${size}kai.png
+      COMMAND ${CONVERT}
+        ${icon_bindir}/${name}-${srciconsize}d24.png
+        -alpha Opaque
+        "\\(" -size ${srciconsize}x${srciconsize} -depth 8 canvas:none
+           -draw "roundRectangle 0,0,${sizeminusone},${sizeminusone},${cornerradius},${cornerradius}" "\\)"
+        -compose dst-in -composite
+        -compose over -bordercolor transparent -border ${borderwidth}
+        "\\(" +clone -background black
+           -shadow 30x${shadowspread}+0+${shadowoffset} "\\)"
+        +swap -background none -flatten -crop '${size}x${size}+0+0!' -depth 8
+        ${icon_bindir}/${name}-${size}kai.png
+      DEPENDS ${icon_bindir}/${name}-${srciconsize}d24.png)
+    list(APPEND output_icon_files ${icon_bindir}/${name}-${size}kai.png)
+  endforeach()
 
   add_custom_target(${name}-icons DEPENDS ${output_icon_files})
   add_dependencies(icons ${name}-icons)