Documentation ¶
Index ¶
- func Abs(a int32) int32
- func Add(c1, c2 uint32) uint32
- func Alpha(cv uint32) uint8
- func Blend(c1, c2 uint32) uint32
- func BlitImage(pixels []uint32, pitch int32, img *image.RGBA) error
- func BlitImageOnTop(pixels []uint32, pitch int32, img *image.RGBA) error
- func Blue(cv uint32) uint8
- func Clamp(x, a, b int32) int32
- func ClampByte(x, a, b uint8) uint8
- func Clear(pixels []uint32, c color.RGBA)
- func ColorToColorValue(c color.RGBA) uint32
- func ColorValueToRGBA(cv uint32) (uint8, uint8, uint8, uint8)
- func FastClear(pixels []uint32, colorValue uint32)
- func FastPixel(pixels []uint32, x, y int32, colorValue uint32, pitch int32)
- func GetWrap(pixels []uint32, pos, size int32) uint32
- func GetXYWrap(pixels []uint32, x, y, w, h, pitch int32) uint32
- func GlitchyStretchContrast(cores int, pixels []uint32, pitch int32, discardRatio float32)
- func Green(cv uint32) uint8
- func HorizontalLine(pixels []uint32, y, x1, x2 int32, c color.RGBA, pitch int32)
- func HorizontalLineFast(pixels []uint32, y, x1, x2 int32, c color.RGBA, pitch int32)
- func Lengths(p1, p2 *Pos) (int32, int32)
- func Line(pixels []uint32, x1, y1, x2, y2 int32, c color.RGBA, pitch int32)
- func Max2(a, b int32) int32
- func Max3(a, b, c int32) int32
- func Min2(a, b int32) int32
- func Min3(a, b, c int32) int32
- func MinMax(a, b int32) (int32, int32)
- func MinMax3(a, b, c int32) (int32, int32)
- func MinMax3Byte(a, b, c uint8) (uint8, uint8)
- func OrAlpha(cores int, pixels []uint32)
- func Pixel(pixels []uint32, x, y int32, c color.RGBA, pitch int32)
- func PixelRGB(pixels []uint32, x, y int32, r, g, b uint8, pitch int32)
- func PixelsToImage(pixels []uint32, pitch int32) *image.RGBA
- func RGBAToColorValue(r, g, b, a uint8) uint32
- func Red(cv uint32) uint8
- func RemoveBlue(cores int, pixels []uint32)
- func RemoveGreen(cores int, pixels []uint32)
- func RemoveRed(cores int, pixels []uint32)
- func SaveImageToPNG(img *image.RGBA, filename string, overwrite bool) error
- func SavePixelsToPNG(pixels []uint32, pitch int32, filename string, overwrite bool) error
- func Scale(x, fromA, toA, fromB, toB int32) int32
- func ScaleByte(x, fromA, toA, fromB, toB uint8) uint8
- func SetBlueBits(cores int, pixels []uint32)
- func SetGreenBits(cores int, pixels []uint32)
- func SetRedBits(cores int, pixels []uint32)
- func SetWrap(pixels []uint32, pos, size int32, colorValue uint32)
- func SetXYWrap(pixels []uint32, x, y, w, h int32, colorValue uint32, pitch int32)
- func Sort2(a, b int32) (int32, int32)
- func Sort3(a, b, c int32) (int32, int32, int32)
- func StretchContrast(cores int, pixels []uint32, pitch int32, discardRatio float32)
- func Triangle(cores int, pixels []uint32, x1, y1, x2, y2, x3, y3 int32, c color.RGBA, ...)
- func Value(cv uint32) uint8
- func ValueWithAlpha(cv uint32) uint8
- func VerticalLine(pixels []uint32, x, y1, y2 int32, c color.RGBA, pitch int32)
- func VerticalLineFast(pixels []uint32, x, y1, y2 int32, c color.RGBA, pitch int32)
- func WireTriangle(cores int, pixels []uint32, x1, y1, x2, y2, x3, y3 int32, c color.RGBA, ...)
- type Pair
- type PairList
- type Pos
- type Vec3
- type Vertex
- func (v *Vertex) A() uint8
- func (v *Vertex) B() uint8
- func (v *Vertex) G() uint8
- func (v *Vertex) Get() (float32, float32, float32)
- func (v *Vertex) GetColor() color.RGBA
- func (v *Vertex) GetRGBA() (uint8, uint8, uint8, uint8)
- func (v *Vertex) GetVec3() *Vec3
- func (v *Vertex) Normalize() error
- func (v *Vertex) R() uint8
- func (v *Vertex) Set(x, y, z float32)
- func (v *Vertex) SetColor(c color.RGBA)
- func (v *Vertex) SetRGBA(r, g, b, a uint8)
- func (v *Vertex) String() string
- func (v *Vertex) X() float32
- func (v *Vertex) Y() float32
- func (v *Vertex) Z() float32
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add adds one color value on top of another. Only considers the alpha value of the second color value. Returns an opaque color.
func BlitImageOnTop ¶
BlitImageOnTop blits an image on top of a pixel buffer, disregarding any previous pixels. The resulting pixels are opaque.
func ColorToColorValue ¶
ColorToColorValue converts from color.RGBA to an ARGB uint32 color value
func ColorValueToRGBA ¶
ColorValueToRGBA converts from an ARGB uint32 color value to four bytes
func FastClear ¶
FastClear changes all pixels to the given uint32 color value, like 0xff0000ff for: 0xff red, 0x00 green, 0x00 blue and 0xff alpha.
func GlitchyStretchContrast ¶
GlitchyStretchContrast stretches the contrast of the pixels in the given "pixels" slice (of width "pitch"), discarding the discardRatio ratio of the most unpopular pixel values, then scaling the remaining pixels to cover the full 0..255 range.
func HorizontalLine ¶
HorizontalLine draws a line from (x1, y) to (x2, y)
func HorizontalLineFast ¶
HorizontalLineFast draws a line from (x1, y) to (x2, y), but x1 must be smaller than x2!
func Line ¶
Line draws a line in a completely wrong way to the pixel buffer. pixels are the pixels, pitch is the width of the pixel buffer.
func MinMax3Byte ¶
MinMax3Byte finds the smallest and largest of three bytes
func PixelsToImage ¶
PixelsToImage converts a pixel buffer to an image.RGBA image
func RGBAToColorValue ¶
RGBAToColorValue converts from four bytes to an ARGB uint32 color value
func RemoveGreen ¶
RemoveGreen removes all green color.
func SaveImageToPNG ¶
SaveImageToPNG saves an image.RGBA image to a PNG file. Set overwrite to true to allow overwriting files.
func SavePixelsToPNG ¶
Save pixels in uint32 ARGB format to PNG with alpha. pitch is the width of the pixel buffer. Set overwrite to true to allow overwriting files.
func Scale ¶
Scale an int on the scale from fromA to toA, to a scale from fromB to toB.
Example ¶
fmt.Println(ScaleByte(0, 0, 255, 0, 255)) fmt.Println(ScaleByte(20, 20, 80, 0, 255)) fmt.Println(ScaleByte(80, 20, 80, 0, 255)) fmt.Println(ScaleByte(255, 255, 255, 0, 255)) fmt.Println(ScaleByte(0, 0, 0, 0, 255))
Output: 0 0 255 255 0
func ScaleByte ¶
ScaleByte scales a byte on the scale from fromA to toA, to a scale from fromB to toB.
func StretchContrast ¶
StretchContrast uses "cores" CPU cores to concurrently stretch the contrast of the pixels in the given "pixels" slice (of width "pitch"), discarding the discardRatio ratio of the most unpopular pixel values, then scaling the remaining pixels to cover the full 0..255 range.
func Triangle ¶
Triangle draws a triangle, concurrently. Core is the number of goroutines that will be used. pitch is the "width" of the pixel buffer.
func ValueWithAlpha ¶
Extract the color value / intensity from a ARGB uint32 color value
func VerticalLine ¶
VerticalLine draws a line from (x, y1) to (x, y2)
func VerticalLineFast ¶
VerticalLineFast draws a line from (x, y1) to (x, y2), but y1 must be smaller than y2!
Types ¶
type PairList ¶
type PairList []Pair
A slice of pairs that implements sort.Interface to sort by values
type Pos ¶
type Pos struct {
// contains filtered or unexported fields
}
Pos represents a position in 2D space
func Interpolate ¶
Interpolate interpolates between two points, with the number of steps equal to the length of the longest stretch