clone

an offline map explorer where each world, from a game map to a city's open data, ships as one .atlas file

archive/golden-reference
atlas / internal / basemap / style.go
style.go 2.5K
1package basemap23import "image/color"45// Role names what a feature is to the ground: not which dataset it came6// from, but which stroke of the drawing it belongs to. The curated tables7// in arcgismap assign roles; this package only knows how each one draws.8type Role string910const (11 RoleBackground Role = "background"12 RoleParcel Role = "parcel"13 RolePark Role = "park"14 RoleWater Role = "water"15 RoleStreet Role = "street"16 RoleTrail Role = "trail"17 RoleBoundary Role = "boundary"18)1920// Style is how one role draws: a fill for ground, a stroke for lines and21// rims, widths in pixels at the reference zoom. Dash is the on/off rhythm22// of a dashed stroke, zero for solid.23type Style struct {24 Fill color.NRGBA25 Stroke color.NRGBA26 StrokeWidth float6427 Dash [2]float6428}2930// referenceZoom is the zoom the style table's widths are spelled at. A31// render at another depth scales them, so a stroke keeps its ground truth32// -- constant world width -- however deep the pyramid goes.33const referenceZoom = 63435// Background is the ground everything else draws upon: a step off the36// app's own near-black, so the map reads as a surface and the palette37// accents stay the information.38var Background = color.NRGBA{R: 0x14, G: 0x18, B: 0x1d, A: 0xff}3940// styles is the whole drawing, keyed by role. The colors keep to the app's41// identity: neutral grays for the everyday linework, the warm earth tone42// for trails, navy for water, and the cerulean accent spent on exactly one43// line -- the city's own boundary.44var styles = map[Role]Style{45 RoleParcel: {Stroke: color.NRGBA{R: 0x23, G: 0x2a, B: 0x31, A: 0xff}, StrokeWidth: 1},46 RolePark: {Fill: color.NRGBA{R: 0x1f, G: 0x2b, B: 0x22, A: 0xff}},47 RoleWater: {Fill: color.NRGBA{R: 0x15, G: 0x25, B: 0x39, A: 0xff}, Stroke: color.NRGBA{R: 0x1f, G: 0x38, B: 0x52, A: 0xff}, StrokeWidth: 1},48 RoleStreet: {Stroke: color.NRGBA{R: 0x3d, G: 0x44, B: 0x4d, A: 0xff}, StrokeWidth: 2.5},49 RoleTrail: {Stroke: color.NRGBA{R: 0x8a, G: 0x6a, B: 0x44, A: 0xff}, StrokeWidth: 1.5, Dash: [2]float64{6, 4}},50 RoleBoundary: {Stroke: color.NRGBA{R: 0x3a, G: 0xa5, B: 0xc9, A: 0xff}, StrokeWidth: 3.5},51}5253// zOrder is the order roles land on the ground: texture first, then ground54// covers, water over parks so lakes punch through, streets over water for55// bridges, trails above streets, and the boundary on top as the one accent.56var zOrder = []Role{RoleParcel, RolePark, RoleWater, RoleStreet, RoleTrail, RoleBoundary}