sunlightmap

package
v0.0.0-...-b75ae3a Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: MIT Imports: 12 Imported by: 0

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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

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

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

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

func PngGetColorAt(filename string, x int, y int) color.RGBA

PngGetColorAt finds the RGBA values in a png at a specified position

func ReturnStaticPngBase64

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

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

func WriteStaticPng(slm *sunlightmap, pathfileext string) (err error)

WriteStaticPng is called with a sunlightmap struct and writes a single sunlightmap in png format.

Types

type Pixel

type Pixel struct {
	R uint8
	G uint8
	B uint8
	A uint8
}

Pixel holds color information in RGBA format

Jump to

Keyboard shortcuts

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