Add Store MSIX packaging and dark/light theme for 2.9.0.
EOF Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
// Generates Store / MSIX PNG assets from assets/navis-icon.png.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"golang.org/x/image/draw"
|
||||
)
|
||||
|
||||
func main() {
|
||||
in := filepath.Join("assets", "navis-icon.png")
|
||||
outDir := filepath.Join("packaging", "msix", "Assets")
|
||||
if len(os.Args) > 1 {
|
||||
in = os.Args[1]
|
||||
}
|
||||
if len(os.Args) > 2 {
|
||||
outDir = os.Args[2]
|
||||
}
|
||||
f, err := os.Open(in)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
src, err := png.Decode(f)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
if err := os.MkdirAll(outDir, 0o755); err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
|
||||
square := map[string]int{
|
||||
"StoreLogo.png": 50,
|
||||
"Square44x44Logo.png": 44,
|
||||
"Square71x71Logo.png": 71,
|
||||
"Square150x150Logo.png": 150,
|
||||
"Square310x310Logo.png": 310,
|
||||
}
|
||||
for name, size := range square {
|
||||
if err := writePNG(filepath.Join(outDir, name), scaleContain(src, size, size, color.RGBA{12, 22, 19, 255})); err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
}
|
||||
// Wide tile + splash: brand mark centered on deep forest panel.
|
||||
if err := writePNG(filepath.Join(outDir, "Wide310x150Logo.png"), scaleContain(src, 310, 150, color.RGBA{12, 22, 19, 255})); err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
if err := writePNG(filepath.Join(outDir, "SplashScreen.png"), scaleContain(src, 620, 300, color.RGBA{12, 22, 19, 255})); err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
fmt.Println("Wrote Store assets to", outDir)
|
||||
}
|
||||
|
||||
func scaleContain(src image.Image, w, h int, bg color.Color) image.Image {
|
||||
dst := image.NewRGBA(image.Rect(0, 0, w, h))
|
||||
draw.Draw(dst, dst.Bounds(), &image.Uniform{C: bg}, image.Point{}, draw.Src)
|
||||
sb := src.Bounds()
|
||||
sw, sh := sb.Dx(), sb.Dy()
|
||||
scale := float64(w) / float64(sw)
|
||||
if float64(h)/float64(sh) < scale {
|
||||
scale = float64(h) / float64(sh)
|
||||
}
|
||||
// Keep icon smaller than full tile for padding.
|
||||
scale *= 0.72
|
||||
nw, nh := int(float64(sw)*scale), int(float64(sh)*scale)
|
||||
if nw < 1 {
|
||||
nw = 1
|
||||
}
|
||||
if nh < 1 {
|
||||
nh = 1
|
||||
}
|
||||
x, y := (w-nw)/2, (h-nh)/2
|
||||
resized := image.NewRGBA(image.Rect(0, 0, nw, nh))
|
||||
draw.CatmullRom.Scale(resized, resized.Bounds(), src, sb, draw.Over, nil)
|
||||
draw.Draw(dst, image.Rect(x, y, x+nw, y+nh), resized, image.Point{}, draw.Over)
|
||||
return dst
|
||||
}
|
||||
|
||||
func writePNG(path string, img image.Image) error {
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
return png.Encode(f, img)
|
||||
}
|
||||
|
||||
func fatal(err error) {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
Reference in New Issue
Block a user