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.
This commit is contained in:
Ben Harris
2022-12-10 21:46:34 +00:00
parent 1d509dc819
commit 241f68b543

View File

@ -81,14 +81,16 @@ set(untangle_crop 320x320 164x164+3+116)
add_custom_target(icons) add_custom_target(icons)
# All sizes of icon we make for any purpose. # 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. # Sizes of icon we put into the Windows .ico files.
set(win_icon_sizes 48 32 16) set(win_icon_sizes 48 32 16)
# Border thickness for each icon size. # Border thickness for each icon size.
set(border_96 4) set(border_96 4)
set(border_88 4)
set(border_48 4) set(border_48 4)
set(border_44 4)
set(border_32 2) set(border_32 2)
set(border_16 1) set(border_16 1)
@ -247,6 +249,31 @@ function(build_icon name)
${cicon_pl_infiles}) ${cicon_pl_infiles})
list(APPEND output_icon_files ${icon_bindir}/${name}-icon.c) 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_custom_target(${name}-icons DEPENDS ${output_icon_files})
add_dependencies(icons ${name}-icons) add_dependencies(icons ${name}-icons)
endfunction() endfunction()