Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion cmd/mark/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@ func run() error {
return fmt.Errorf("%s: %w", *src, err)
}

onNavy := shadowOn(drawing, stack, navy)

var stale []string
for name, l := range sizes {
img, err := cut(drawing, stack, l.size, l.clear, navy)
src := onNavy
if l.clear {
src = drawing
}
img, err := cut(src, stack, l.size, l.clear, navy)
if err != nil {
return fmt.Errorf("%s: %w", name, err)
}
Expand Down Expand Up @@ -142,6 +148,29 @@ func stackOf(drawing image.Image) (image.Rectangle, error) {
return box, nil
}

// shadowOn is the drawing for the tile: its shadow is a light grey ring, drawn for a light ground,
// which on the navy reads as a halo; a shadow is never lighter than what it falls on. The ring is
// the grey in the stack's bottom quarter - the white top disk is grey too, but at the top - and
// becomes the navy with a sixteenth of the ring's light in it, a rim as the avatar's was.
func shadowOn(drawing image.Image, stack image.Rectangle, navy color.RGBA) image.Image {
const light = 0.06
out := image.NewNRGBA(drawing.Bounds())
draw.Draw(out, out.Bounds(), drawing, drawing.Bounds().Min, draw.Src)
band := stack.Min.Y + stack.Dy()*3/4
for y := band; y < stack.Max.Y; y++ {
for x := stack.Min.X; x < stack.Max.X; x++ {
c := out.NRGBAAt(x, y)
hi, lo := max(c.R, c.G, c.B), min(c.R, c.G, c.B)
if c.A == 0 || hi-lo > 24 || hi < 96 {
continue
}
mix := func(n, g uint8) uint8 { return uint8(float64(n) + light*(float64(g)-float64(n)) + 0.5) }
out.SetNRGBA(x, y, color.NRGBA{mix(navy.R, c.R), mix(navy.G, c.G), mix(navy.B, c.B), c.A})
}
}
return out
}

// cut is the stack centered on a square of size pixels, a fifth of its size around it, on the
// navy or on nothing.
func cut(drawing image.Image, stack image.Rectangle, size int, clear bool, navy color.RGBA) (*image.RGBA, error) {
Expand Down
Binary file modified logos/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified logos/favicon-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified logos/favicon-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified logos/mark-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified logos/mark-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading