Canvas-based seasonal weather effects + demo page
Server picks variant from Lisbon-local date (rain/petals/jacaranda/motes/leaves) and renders behind content via a canvas particle layer. Each variant has a hand-drawn silhouette so shapes are recognizable. /weather demo route exposes variant + intensity + phase pickers, locking the time-of-day phase override.
This commit is contained in:
39
internal/web/season.go
Normal file
39
internal/web/season.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package web
|
||||
|
||||
import "time"
|
||||
|
||||
// Weather is the seasonal effect rendered behind the page. Tuned for Lisbon:
|
||||
// winter is rainy (not snowy), May gets its own jacaranda variant since the
|
||||
// city turns purple for a few weeks each year, and September stays in summer
|
||||
// because Portugal's dry spell runs all the way through it.
|
||||
type Weather struct {
|
||||
Season string // "winter" | "spring" | "summer" | "autumn"
|
||||
Variant string // "rain" | "petals" | "jacaranda" | "motes" | "leaves"
|
||||
Intensity string // "light" | "medium" | "heavy"
|
||||
}
|
||||
|
||||
var lisbon = func() *time.Location {
|
||||
loc, err := time.LoadLocation("Europe/Lisbon")
|
||||
if err != nil {
|
||||
return time.UTC
|
||||
}
|
||||
return loc
|
||||
}()
|
||||
|
||||
func currentWeather(now time.Time) Weather {
|
||||
t := now.In(lisbon)
|
||||
var season, variant string
|
||||
switch t.Month() {
|
||||
case time.December, time.January, time.February:
|
||||
season, variant = "winter", "rain"
|
||||
case time.March, time.April:
|
||||
season, variant = "spring", "petals"
|
||||
case time.May:
|
||||
season, variant = "spring", "jacaranda"
|
||||
case time.June, time.July, time.August, time.September:
|
||||
season, variant = "summer", "motes"
|
||||
default: // Oct, Nov
|
||||
season, variant = "autumn", "leaves"
|
||||
}
|
||||
return Weather{Season: season, Variant: variant, Intensity: "heavy"}
|
||||
}
|
||||
Reference in New Issue
Block a user