Documentation
¶
Index ¶
- Variables
- func ACT(pal color.Palette) []byte
- func BasicPalette() (pal color.Palette)
- func Convert(img image.Image) (image.Image, error)
- func ConvertBasic(img image.Image) (image.Image, error)
- func ConvertBurn(img image.Image) (image.Image, error)
- func ConvertCustom(img image.Image, pal color.Palette) (image.Image, error)
- func ConvertGeneral(img image.Image) (image.Image, error)
- func ConvertPlan9(img image.Image) (image.Image, error)
- func GPL(pal color.Palette, paletteName string) (string, error)
- func GeneralPalette() (pal color.Palette)
- func Generate(img image.Image, N int) (color.Palette, error)
- func GenerateUpTo(img image.Image, N int) (color.Palette, error)
- func Median(colors []color.Color) (color.Color, error)
- func Median3(colors []color.Color) (color.Color, color.Color, color.Color, error)
- func Reduce(img image.Image, n int) (image.Image, error)
- func Render(pal color.Palette) image.Image
- func RenderWithConfig(pal color.Palette, blockSize, colorsPerRow int) image.Image
- func SaveACT(pal color.Palette, filename string) error
- func SaveGPL(pal color.Palette, filename, paletteName string) error
- func Sort(pal color.Palette)
- type HCLSortablePalette
- type SortablePalette
Constants ¶
This section is empty.
Variables ¶
var BasicPalette16 = [16][3]byte{
{0x0, 0x0, 0x0},
{191, 0x0, 0x0},
{0x0, 191, 0x0},
{191, 191, 0x0},
{0x0, 0x0, 191},
{191, 0x0, 191},
{0x0, 191, 191},
{191, 191, 191},
{0x40, 0x40, 0x40},
{0xff, 0x40, 0x40},
{0x40, 0xff, 0x40},
{0xff, 0xff, 0x40},
{96, 96, 0xff},
{0xff, 0x40, 0xff},
{0x40, 0xff, 0xff},
{0xff, 0xff, 0xff},
}
BasicPalette16 is a basic 16-color palette
var GeneralPalette256 = [256][3]byte{}/* 256 elements not displayed */
GeneralPalette256 is a an OK standard palette
Functions ¶
func ACT ¶ added in v1.0.1
ACT converts a given palette to the Photoshop ACT Palette Format (.act) There is no header, just either 768 or 772 bytes of color data. 256 * 3 = 768. The four extra bytes can be 16-bit color count + 16 bit transparent color index.
func BasicPalette ¶ added in v1.1.0
BasicPalette can return a basic 16 color palette
func Convert ¶ added in v1.0.1
Convert can convert an image from True Color to a 256 color paletted image. The palette is automatically extracted from the image.
func ConvertBasic ¶ added in v1.1.0
ConvertBasic can convert an image from True Color to a 16 color paletted image, using the 16 basic terminal colors
func ConvertBurn ¶ added in v1.3.0
ConvertBurn can convert an image from True Color to a 256 color paletted image, using the Burn palette from github.com/xyproto/burnpal.
func ConvertCustom ¶ added in v1.0.1
ConvertCustom can convert an image from True Color to a <=256 color paletted image, given a custom palette.
func ConvertGeneral ¶ added in v1.0.1
ConvertGeneral can convert an image from True Color to a 256 color paletted image, using a general palette.
func ConvertPlan9 ¶ added in v1.0.1
ConvertPlan9 can convert an image from True Color to a 256 color paletted image, using the Plan9 palette from the Go standard library.
func GPL ¶
GPL converts a given palette to the GIMP Palette Format (.gpl) The given name will be used as the palette name in the header
func GeneralPalette ¶ added in v1.0.1
GeneralPalette can return a pretty general 256 color palette
func GenerateUpTo ¶ added in v1.4.0
GenerateUpTo can generate a palette with up to N colors, given an image
func Median3 ¶ added in v1.0.1
Median3 finds not the average but the median color. Returns three colors if the number of colors is even (average, first and second color in the center).
func Reduce ¶ added in v1.3.0
Reduce can convert an image from True Color to a N color paletted image. The palette is automatically extracted from the image.
func Render ¶ added in v1.0.1
Render a given palette as an image, with blocks of 16x16 pixels and 32 colors per row of blocks.
func RenderWithConfig ¶ added in v1.0.1
RenderWithConfig can render a given palette as an image that shows each color as a square, lined up in rows. blockSize is the size of the color block per color, in pixels (16 is default) colorsPerRow is the number of color blocks per row (32 is default)
func SaveACT ¶ added in v1.0.1
SaveACT can save a palette to file in the Photoship ACT Palette Format (.act)
Types ¶
type HCLSortablePalette ¶ added in v1.0.1
HCLSortablePalette is a slice of color.Color that can be sorted with sort.Sort, by h, c and l values
func (HCLSortablePalette) Len ¶ added in v1.0.1
func (a HCLSortablePalette) Len() int
func (HCLSortablePalette) Less ¶ added in v1.0.1
func (a HCLSortablePalette) Less(i, j int) bool
func (HCLSortablePalette) Swap ¶ added in v1.0.1
func (a HCLSortablePalette) Swap(i, j int)
type SortablePalette ¶
SortablePalette is a slice of color.Color that can be sorted with sort.Sort, by euclidian distance for R, G and B
func (SortablePalette) Len ¶
func (a SortablePalette) Len() int
func (SortablePalette) Less ¶
func (a SortablePalette) Less(i, j int) bool
func (SortablePalette) Swap ¶
func (a SortablePalette) Swap(i, j int)