sunlightlib

package module
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 11 Imported by: 0

README

sunlightlib

The repo for sunlightlib.

Documentation

Overview

Package sunlightlib 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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(width int, visualization string, zeitpunkte []time.Time) (slm sunlightlib)

New returns the sunlightlib struct with default values. The height is always half of the width. visualization has currently only 'static' implemented ('animated' to follow)

func NewStatic

func NewStatic(width int, zeitpunkt time.Time) (slm sunlightlib)

NewStatic is a convenience method to return a single static sunlightlib

TODO(cpr): implement animated version (e.g. gif)

Example
slms := NewStatic(360, time.Now().Local())
fmt.Println(slms.visualization)
Output:

static

func ReturnStaticPngBase64

func ReturnStaticPngBase64(slm *sunlightlib) (retval string, err error)

ReturnStaticPngBase64 is called with a sunlightlib struct and returns a base64 encoded string of a single sunlightlib 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

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL