Documentation
¶
Overview ¶
Package moon produces images of the moon at different phases and provides information about the moon's location.
The phase of the moon is represented by a floating point number between -1.0 and 1.0 where the absolute value is the percentage of the moon that is visible. Both -1. and 1.0 represent a full moon. Negative numbers indicate a waxing moon and positive numbers indicate a waning moon. A full cycle from new moon to new moon is uses the values 0.0 - -1.0 as it waxes and 1.0 - 0.0 as it wanes.
This package has builtin images of the moon that are 64x64, 256x256, 1024x1025, and 1553x1553. The source image used is the smallest image that is at least big as the size requested. E.g., a 56x56 image will be scaled down from the 64x64 image while a 728x728 will be scaled down from the 1024x1024 image.
The source image of the moon is from https://www.pexels.com/photo/photo-of-full-moon-975012/.
Index ¶
- func Draw(size int, phase, shadow float64) image.Image
- func DrawFromImage(moon image.Image, phase, shadow float64) image.Image
- func DrawPhaseMask(gc *draw2dimg.GraphicContext, width, height int, phase float64)
- func FillMoonIcon(r draw.Image, light, shadow color.Color, phase float64) image.Image
- func StrokeMoonIcon(r draw.Image, light, shadow color.Color, phase float64)
- type Information
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Draw ¶
Draw returns an image of moon with the provided phase of the given size. The shadow is now much illumination the non-visible part should have. A shadow of 0 will make it pure black. A shadow of 1 will not shade it at all.
func DrawFromImage ¶
DrawFromImage is like Draw but the caller provides the image of the moon to use. Other than that is is like Draw.
func DrawPhaseMask ¶
func DrawPhaseMask(gc *draw2dimg.GraphicContext, width, height int, phase float64)
DrawPhaseMask draws a path in to gc for the requested phase of the moon that has the supplied width and height. Typically these are the same value. The mask is always drawn in the box {0,0} with the center of the moon at width/2, height/2. The calling function can then call gc.Stroke() or gc.Fill() to draw or fill in the path.
func FillMoonIcon ¶
FillMoonIcon draws a 2 color image of the moon with the illuminated portion being drawing in light and the shaded portion drawn in shado.
Types ¶
type Information ¶ added in v0.2.0
type Information struct {
Moonrise time.Time // When the moon will/did rise
Moonset time.Time // When the moon will/did set
Direction float64 // Direction to the moon
Elevation float64 // Elevation of the moon
Illumination float64 // How illuminated the moon is
Phase sampa.MoonPhase // The current phase
}
Information provides information about the moon. The illumination is a value between -1.0 and 1.0. The amount of illumination is the absolute value (e.g., -0.25 and 0.25 both indicate 25% illumination). If Illumination is negative then the moon is waxing. If positive the moon is waning. An illumination of 0.0 is a new moon and either -1.0 or 1.0 is a full moon.







