Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IntensityFunc ¶
IntensityFunc is a function that calculates the intensity of a pixel based on the distance between the pixel and the nearest LED. The intensity is a value between 0 and 1, where 0 is the lowest intensity and 1 is the highest intensity.
For examples of intensity functions visualized, see https://www.desmos.com/calculator/thw9ho0ivd.
func NewCubicIntensity ¶
func NewCubicIntensity(maxDistance float64) IntensityFunc
NewCubicIntensity creates a new IntensityFunc that calculates the intensity of a pixel based on the distance between the pixel and the nearest LED. The intensity is calculated using a cubic function.
func NewLinearIntensity ¶
func NewLinearIntensity(maxDistance float64) IntensityFunc
NewLinearIntensity creates a new IntensityFunc that calculates the intensity of a pixel based on the distance between the pixel and the nearest LED. The intensity is calculated using a linear function.
func NewStepIntensity ¶
func NewStepIntensity(maxDistance float64) IntensityFunc
NewStepIntensity creates a new IntensityFunc that calculates the intensity of a pixel based on the distance between the pixel and the nearest LED. The intensity is 1 if the distance is less than the max distance, and 0 otherwise.
type LEDCanvas ¶
type LEDCanvas struct {
// contains filtered or unexported fields
}
LEDCanvas is a canvas of LED points.
func NewLEDCanvas ¶
func NewLEDCanvas(ledPositions []image.Point, opts LEDCanvasOpts) (*LEDCanvas, error)
NewLEDCanvas creates a new LEDCanvas from the given LED positions.
ledPositions is a slice of points, where each point represents the position of an LED.
func (*LEDCanvas) CanvasBounds ¶
Bounds returns the bounds of the image canvas.
func (*LEDCanvas) LEDBounds ¶
LEDBounds returns the boundary box of the LEDs on the LED canvas. The boundary box is the smallest rectangle that contains all LEDs.
type LEDCanvasAnimated ¶
type LEDCanvasAnimated struct { C <-chan animation.Frame[LEDStrip] // contains filtered or unexported fields }
LEDCanvas wraps an LEDCanvas and provides animation capabilities. Frames are sent to the C channel.
func NewLEDCanvasAnimated ¶
func NewLEDCanvasAnimated(ledPositions []image.Point, opts LEDCanvasOpts) (*LEDCanvasAnimated, error)
NewLEDCanvasAnimated creates a new LEDCanvasAnimated.
type LEDCanvasOpts ¶
type LEDCanvasOpts struct { // Intensity is the intensity function used to calculate the intensity of a // pixel based on the distance between the pixel and the nearest LED. Intensity IntensityFunc // Average is the averaging function used to average the colors of the // pixels that are within the radius of an LED. Average xcolor.AveragingFunc // PPI is the number of pixels per inch of the final LED canvas. The higher // the PPI, the higher the resolution of the final LED canvas. PPI float64 }
LEDCanvasOpts is a set of options for creating a new LEDCanvas.
type LEDStrip ¶
LEDStrip is a strip of LEDs. It is represented as a slice of colors, where each color represents the color of an LED.
type PtDistance ¶
PtDistance is a pair of points and the distance between them.
func FindMinDistance ¶
func FindMinDistance(points []image.Point) PtDistance
FindMinDistance returns the pair of points with the smallest distance between them. It runs in O(n^2) time.