Documentation ¶
Overview ¶
Package sunlightmap merges two image files of a sphere in mercator projection as if that sphere revolves around the sun, producing an approximate day- and night-visualization.
Index ¶
- func New(width int, visualization string, zeitpunkte []time.Time) (slm sunlightmap)
- func NewStatic(width int, zeitpunkt time.Time) (slm sunlightmap)
- func PngGetColorAt(filename string, x int, y int) color.RGBA
- func ReturnStaticPngBase64(slm *sunlightmap) (retval string, err error)
- func WriteStaticPng(slm *sunlightmap, pathfileext string) (err error)
- type Pixel
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns the sunlightmap struct with default values. The height is always half of the width. visualization has currently only 'static' implemented ('animated' to follow)
func NewStatic ¶
NewStatic is a convenience method to return a single static sunlightmap
TODO(cpr): implement animated version (e.g. gif)
Example ¶
slms := NewStatic(360, time.Now().Local()) fmt.Println(slms.visualization)
Output: static
func PngGetColorAt ¶
PngGetColorAt finds the RGBA values in a png at a specified position
func ReturnStaticPngBase64 ¶
ReturnStaticPngBase64 is called with a sunlightmap struct and returns a base64 encoded string of a single sunlightmap in png format.
Example ¶
handler := func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") slm := NewStatic(720, time.Now().Local()) encoded, _ := ReturnStaticPngBase64(&slm) html := "<html><body><img src='data:image/png;base64," + encoded + "' /><p>" fmt.Fprint(w, html) } w := httptest.NewRecorder() req := httptest.NewRequest("GET", "http://example.com", nil) handler(w, req) resp := w.Result() fmt.Println(resp.StatusCode)
Output: 200
func WriteStaticPng ¶
WriteStaticPng is called with a sunlightmap struct and writes a single sunlightmap in png format.