mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
cmd/gio: add support for iOS App Store icons
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -246,10 +246,10 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo) (err error) {
|
|||||||
iconSnip := ""
|
iconSnip := ""
|
||||||
if _, err := os.Stat(icon); err == nil {
|
if _, err := os.Stat(icon); err == nil {
|
||||||
err := buildIcons(resDir, icon, []iconVariant{
|
err := buildIcons(resDir, icon, []iconVariant{
|
||||||
{filepath.Join("mipmap-hdpi", "ic_launcher.png"), 72},
|
{path: filepath.Join("mipmap-hdpi", "ic_launcher.png"), size: 72},
|
||||||
{filepath.Join("mipmap-xhdpi", "ic_launcher.png"), 96},
|
{path: filepath.Join("mipmap-xhdpi", "ic_launcher.png"), size: 96},
|
||||||
{filepath.Join("mipmap-xxhdpi", "ic_launcher.png"), 144},
|
{path: filepath.Join("mipmap-xxhdpi", "ic_launcher.png"), size: 144},
|
||||||
{filepath.Join("mipmap-xxxhdpi", "ic_launcher.png"), 192},
|
{path: filepath.Join("mipmap-xxxhdpi", "ic_launcher.png"), size: 192},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+8
-1
@@ -7,6 +7,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
|
"image/color"
|
||||||
"image/png"
|
"image/png"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -204,6 +205,7 @@ var allArchs = map[string]arch{
|
|||||||
type iconVariant struct {
|
type iconVariant struct {
|
||||||
path string
|
path string
|
||||||
size int
|
size int
|
||||||
|
fill bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildIcons(baseDir, icon string, variants []iconVariant) error {
|
func buildIcons(baseDir, icon string, variants []iconVariant) error {
|
||||||
@@ -221,7 +223,12 @@ func buildIcons(baseDir, icon string, variants []iconVariant) error {
|
|||||||
v := v
|
v := v
|
||||||
resizes.Go(func() (err error) {
|
resizes.Go(func() (err error) {
|
||||||
scaled := image.NewNRGBA(image.Rectangle{Max: image.Point{X: v.size, Y: v.size}})
|
scaled := image.NewNRGBA(image.Rectangle{Max: image.Point{X: v.size, Y: v.size}})
|
||||||
draw.CatmullRom.Scale(scaled, scaled.Bounds(), img, img.Bounds(), draw.Src, nil)
|
op := draw.Src
|
||||||
|
if v.fill {
|
||||||
|
op = draw.Over
|
||||||
|
draw.Draw(scaled, scaled.Bounds(), &image.Uniform{color.White}, image.Point{}, draw.Src)
|
||||||
|
}
|
||||||
|
draw.CatmullRom.Scale(scaled, scaled.Bounds(), img, img.Bounds(), op, nil)
|
||||||
path := filepath.Join(baseDir, v.path)
|
path := filepath.Join(baseDir, v.path)
|
||||||
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
|
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+5
-3
@@ -232,9 +232,11 @@ func iosIcons(bi *buildInfo, tmpDir, appDir, icon string) (string, error) {
|
|||||||
}
|
}
|
||||||
appIcon := filepath.Join(assets, "AppIcon.appiconset")
|
appIcon := filepath.Join(assets, "AppIcon.appiconset")
|
||||||
err := buildIcons(appIcon, icon, []iconVariant{
|
err := buildIcons(appIcon, icon, []iconVariant{
|
||||||
{"ios_2x.png", 120},
|
{path: "ios_2x.png", size: 120},
|
||||||
{"ios_3x.png", 180},
|
{path: "ios_3x.png", size: 180},
|
||||||
{"ios_store.png", 1024},
|
// The App Store icon is not allowed to contain
|
||||||
|
// transparent pixels.
|
||||||
|
{path: "ios_store.png", size: 1024, fill: true},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
Reference in New Issue
Block a user