pix

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pix represents pixels and provide palette extraction for a list of pixels.

Package pix ...

Package pix represents a single pixel - its color value and location in an HSV color space.

Package pix ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorToHSVSpace

func ColorToHSVSpace(color blcolor.Color) (float64, float64, float64)

ColorToHSVSpace converts a color value to HSV color space coordinates.

func HSVSpaceToColor

func HSVSpaceToColor(x, y, z float64) blcolor.Color

HSVSpaceToColor returns a color from a set of HSV color space coordinates.

func PaletteFromColorList

func PaletteFromColorList(colors blcolor.Palette, k int, method PaletteMethod) blcolor.Palette

PaletteFromColorList generates a palette from a list of colors.

func PaletteFromPixelList

func PaletteFromPixelList(pixels PixelList, k int, method PaletteMethod) blcolor.Palette

PaletteFromPixelList generates a palette from a list of Pixels.

Types

type PaletteMethod

type PaletteMethod int

PaletteMethod is the method used to determine which color value to pick from each cluster for the palette.

const (
	PaletteMethodAverage PaletteMethod = iota
	PaletteMethodClosest
	PaletteMethodRandom
)

PaletteMethods are the three different PaletteMethods.

type Pixel

type Pixel struct {
	X, Y, Z float64

	Color blcolor.Color
	// contains filtered or unexported fields
}

Pixel is a single pixel, color value and location in HSV color space.

func NewNullPixel

func NewNullPixel(x, y, z float64) *Pixel

NewNullPixel creates a new pixel with a specified HSV color space location, but black color.

func NewPixel

func NewPixel(color blcolor.Color) *Pixel

NewPixel creates a new pixel from a color value, calculating its initial space in 3d

func (*Pixel) Distance

func (p *Pixel) Distance(p2 *Pixel) float64

Distance the Euclidian distance from this pixel to another pixel.

func (*Pixel) Equal

func (p *Pixel) Equal(p1 *Pixel) bool

Equal are this pixel equal to another (within a small delta)

func (*Pixel) Project

func (p *Pixel) Project(fl, centerZ float64) (float64, float64)

Project projects a pixel to a screen x, y coordinate.

func (*Pixel) ProjectWithScale

func (p *Pixel) ProjectWithScale(fl, centerZ float64) (float64, float64, float64)

ProjectWithScale projects a pixel to a screen x, y coordinate and also passes back the scale value.

func (*Pixel) Reset

func (p *Pixel) Reset()

Reset resets the pixel to its original location.

type PixelList

type PixelList []*Pixel

PixelList is a list of pixels.

func NewPixelList

func NewPixelList() PixelList

NewPixelList creates a new PixelList.

func NewPixelListFromColors

func NewPixelListFromColors(colors blcolor.Palette) PixelList

NewPixelListFromColors creates a new PixelList from a list of colors.

func (*PixelList) Add

func (p *PixelList) Add(pixel *Pixel)

Add adds a pixel to this list.

func (*PixelList) AddColor

func (p *PixelList) AddColor(color blcolor.Color)

AddColor adds a new pixel to the list based on the given color.

func (*PixelList) AddColors

func (p *PixelList) AddColors(colors blcolor.Palette)

AddColors adds a new pixel to this list for each color in the given color list.

func (*PixelList) AddNullPixel

func (p *PixelList) AddNullPixel(x, y, z float64)

AddNullPixel adds a null pixel to this list at the given coords.

func (PixelList) Average

func (p PixelList) Average() *Pixel

Average finds the average (mean) location of all the pixels in this list.

func (PixelList) Equal

func (p PixelList) Equal(p1 PixelList) bool

Equal ...

func (PixelList) Reset

func (p PixelList) Reset()

Reset resets all the pixels in this list to their initial values.

func (PixelList) Reverse

func (p PixelList) Reverse()

Reverse reverses the order of this PixelList.

func (PixelList) RotateX

func (p PixelList) RotateX(angle float64)

RotateX rotates the list around the x-axis.

func (PixelList) RotateY

func (p PixelList) RotateY(angle float64)

RotateY rotates the list around the y-axis.

func (PixelList) RotateZ

func (p PixelList) RotateZ(angle float64)

RotateZ rotates the list around the z-axis.

func (PixelList) Scale

func (p PixelList) Scale(s float64)

Scale ...

func (PixelList) Sort

func (p PixelList) Sort()

Sort sorts the list in z-order.

Jump to

Keyboard shortcuts

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