Yevhenii Nadtochii
03/18/2024, 5:38 PMMichael Paus
03/19/2024, 9:10 AMYevhenii Nadtochii
03/19/2024, 10:21 AM22x22
used by Compose not even mentioned anywhere.
In Compose guide, they use drawing (256x256) instead of an icon, and it looks bigger than the default icons located near.Michael Paus
03/19/2024, 11:01 AMYan Pujante
03/19/2024, 1:05 PMYan Pujante
03/19/2024, 1:06 PMYan Pujante
03/19/2024, 1:08 PM// render a single icon with the size
fun renderIcon(size: Int, filename: String) {
val html = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body style="margin:0;overflow:hidden">
<img style="padding; margin:0" src="${rootDir}/composeApp/src/commonMain/resources/images/logo.svg" width="$size" height="$size"></img>
</body>
</html>
""".trimIndent()
val inputFile = file("${layout.buildDirectory.get().asFile}/icon.html")
inputFile.writeText(html)
println(inputFile)
exec {
commandLine(
"/Applications/Google <http://Chrome.app/Contents/MacOS/Google|Chrome.app/Contents/MacOS/Google> Chrome",
"--headless",
"--screenshot=$filename",
"--window-size=$size,$size",
"--default-background-color=0x000000",
inputFile.toString()
)
}
}
val iconsetDir = "${layout.buildDirectory.get().asFile}/workout-timer.iconset"
// render all icons required for iconset
tasks.register("iconset") {
doLast {
// make sure the folder exists
mkdir(iconsetDir)
// generate each icon
arrayOf(512, 256, 128, 32, 16).forEach { size ->
renderIcon(size * 2, "$iconsetDir/icon_${size}x${size}@2x.png")
renderIcon(size, "$iconsetDir/icon_${size}x${size}.png")
}
}
}
// render the .icns file needed for macOS
val icnsTask = tasks.register("icns") {
doLast {
exec {
commandLine("iconutil", "-c", "icns", iconsetDir)
workingDir = layout.buildDirectory.get().asFile
}
}
dependsOn("iconset")
}
Michael Paus
03/19/2024, 7:35 PMsips -z 128 128 -s format png $MASTER_ICON --out appIcon.iconset/icon_128x128.png
where MASTER_ICON is some SVG icon file.Yan Pujante
03/20/2024, 1:11 PMYan Pujante
03/20/2024, 1:25 PMAlexander Maryanovsky
03/20/2024, 2:31 PM