pixel

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pixel implements a color and image library suitable for OLED and LCD pixel displays.

This module provides additional color models, compatible with Go's native color.Color and image.Image / draw.Image interfaces.

Index

Constants

This section is empty.

Variables

View Source
var (
	MonoModel   color.Model = color.ModelFunc(monoModel)
	Gray2Model  color.Model = color.ModelFunc(gray2Model)
	Gray4Model  color.Model = color.ModelFunc(gray4Model)
	CBGR15Model color.Model = color.ModelFunc(cbgr15Model)
	CRGB15Model color.Model = color.ModelFunc(crgb15Model)
	CBGR16Model color.Model = color.ModelFunc(cbgr16Model)
	CRGB16Model color.Model = color.ModelFunc(crgb16Model)
)

Models for the standard color types.

View Source
var (
	Off = Mono{false}
	On  = Mono{true}
)

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	// Rect is the image bounding box.
	Rect image.Rectangle

	// Pix are the image pixels.
	Pix []byte

	// Stride is the Pix stride (in bytes) between vertically adjacent pixels.
	Stride int
}

Buffer holds the pixel values and is a container that is used by most image formats in this package.

func (*Buffer) Bounds

func (p *Buffer) Bounds() image.Rectangle

func (*Buffer) Clear added in v0.0.10

func (p *Buffer) Clear()

type CBGR15 added in v1.1.0

type CBGR15 struct {
	V uint16
}

CBGR15 represents a 15-bit 5-5-5 BGR color.

func (CBGR15) RGBA added in v1.1.0

func (c CBGR15) RGBA() (r, g, b, a uint32)

type CBGR15Image added in v1.1.0

type CBGR15Image struct {
	Buffer
	Order binary.ByteOrder
}

CBGR15Image is a 15-bits per pixel 5-5-5-bit BGR image.

func NewCBGR15Image added in v1.1.0

func NewCBGR15Image(w, h int) *CBGR15Image

func (*CBGR15Image) At added in v1.1.0

func (p *CBGR15Image) At(x, y int) color.Color

func (*CBGR15Image) ColorModel added in v1.1.0

func (p *CBGR15Image) ColorModel() color.Model

func (*CBGR15Image) Fill added in v1.1.0

func (p *CBGR15Image) Fill(c color.Color)

func (*CBGR15Image) Set added in v1.1.0

func (p *CBGR15Image) Set(x, y int, c color.Color)

type CBGR16 added in v1.1.0

type CBGR16 struct {
	V uint16
}

CBGR16 represents a 16-bit 5-6-5 BGR color.

func (CBGR16) RGBA added in v1.1.0

func (c CBGR16) RGBA() (r, g, b, a uint32)

type CBGR16Image added in v1.1.0

type CBGR16Image struct {
	Buffer
	Order binary.ByteOrder
}

CBGR16Image is a 16-bits per pixel 5-6-5-bit BGR image.

func NewCBGR16Image added in v1.1.0

func NewCBGR16Image(w, h int) *CBGR16Image

func (*CBGR16Image) At added in v1.1.0

func (p *CBGR16Image) At(x, y int) color.Color

func (*CBGR16Image) ColorModel added in v1.1.0

func (p *CBGR16Image) ColorModel() color.Model

func (*CBGR16Image) Fill added in v1.1.0

func (p *CBGR16Image) Fill(c color.Color)

func (*CBGR16Image) Set added in v1.1.0

func (p *CBGR16Image) Set(x, y int, c color.Color)

type CRGB15

type CRGB15 struct {
	V uint16
}

CRGB15 represents a 15-bit 5-5-5 RGB color.

func (CRGB15) RGBA

func (c CRGB15) RGBA() (r, g, b, a uint32)

type CRGB15Image

type CRGB15Image struct {
	Buffer
	Order binary.ByteOrder
}

CRGB15Image is a 15-bits per pixel 5-5-5-bit RGB image.

func NewCRGB15Image

func NewCRGB15Image(w, h int) *CRGB15Image

func (*CRGB15Image) At

func (p *CRGB15Image) At(x, y int) color.Color

func (*CRGB15Image) ColorModel

func (p *CRGB15Image) ColorModel() color.Model

func (*CRGB15Image) Fill added in v0.0.10

func (p *CRGB15Image) Fill(c color.Color)

func (*CRGB15Image) Set

func (p *CRGB15Image) Set(x, y int, c color.Color)

type CRGB16

type CRGB16 struct {
	// CRed, 5, CGreen, 6, CBlue, 5
	V uint16
}

CRGB16 represents a 16-bit 5-6-5 RGB color.

func (CRGB16) RGBA

func (c CRGB16) RGBA() (r, g, b, a uint32)

type CRGB16Image

type CRGB16Image struct {
	Buffer
	Order binary.ByteOrder
}

CRGB16Image is a 16-bits per pixel 5-6-5-bit RGB image.

func NewCRGB16Image

func NewCRGB16Image(w, h int) *CRGB16Image

func (*CRGB16Image) At

func (p *CRGB16Image) At(x, y int) color.Color

func (*CRGB16Image) ColorModel

func (p *CRGB16Image) ColorModel() color.Model

func (*CRGB16Image) Fill added in v0.0.10

func (p *CRGB16Image) Fill(c color.Color)

func (*CRGB16Image) Set

func (p *CRGB16Image) Set(x, y int, c color.Color)

type Gray2

type Gray2 struct {
	Y uint8
}

Gray2 represents a 2-bit grayscale color.

func (Gray2) RGBA

func (c Gray2) RGBA() (r, g, b, a uint32)

type Gray2Image

type Gray2Image struct {
	Buffer
}

Gray2Image is a 2-bits per pixel gray scale image.

func NewGray2Image

func NewGray2Image(w, h int) *Gray2Image

func (*Gray2Image) At

func (p *Gray2Image) At(x, y int) color.Color

func (*Gray2Image) ColorModel

func (p *Gray2Image) ColorModel() color.Model

func (*Gray2Image) Fill added in v0.0.10

func (p *Gray2Image) Fill(c color.Color)

func (*Gray2Image) Set

func (p *Gray2Image) Set(x, y int, c color.Color)

type Gray4

type Gray4 struct {
	Y uint8
}

Gray4 represents a 4-bit grayscale color.

func (Gray4) RGBA

func (c Gray4) RGBA() (r, g, b, a uint32)

type Gray4Image

type Gray4Image struct {
	Buffer
}

Gray4Image is a 4-bits per pixel gray scale image.

func NewGray4Image

func NewGray4Image(w, h int) *Gray4Image

func (*Gray4Image) At

func (p *Gray4Image) At(x, y int) color.Color

func (*Gray4Image) ColorModel

func (p *Gray4Image) ColorModel() color.Model

func (*Gray4Image) Fill added in v0.0.10

func (p *Gray4Image) Fill(c color.Color)

func (*Gray4Image) Set

func (p *Gray4Image) Set(x, y int, c color.Color)

type Image added in v1.0.0

type Image interface {
	draw.Image

	// Clear the image.
	Clear()

	// Fill the image with a single color.
	Fill(color.Color)
}

type Mono

type Mono struct {
	On bool
}

Mono represents a 1-bit monochrome color.

func (Mono) RGBA

func (c Mono) RGBA() (r, g, b, a uint32)

type MonoImage

type MonoImage struct {
	Buffer
}

MonoImage is a 1-bit per pixel monochrome image.

func NewMonoImage

func NewMonoImage(w, h int) *MonoImage

func (*MonoImage) At

func (p *MonoImage) At(x, y int) color.Color

func (*MonoImage) ColorModel

func (p *MonoImage) ColorModel() color.Model

func (*MonoImage) Fill added in v0.0.10

func (p *MonoImage) Fill(c color.Color)

func (*MonoImage) PixOffset

func (p *MonoImage) PixOffset(x, y int) int

func (*MonoImage) Set

func (p *MonoImage) Set(x, y int, c color.Color)

type MonoVerticalLSBImage

type MonoVerticalLSBImage struct {
	Buffer
}

MonoVerticalLSBImage is a 1-bit per pixel monochrome image.

This is mostly used by SSD1xxx OLED displays.

func NewMonoVerticalLSBImage

func NewMonoVerticalLSBImage(w, h int) *MonoVerticalLSBImage

func (*MonoVerticalLSBImage) At

func (p *MonoVerticalLSBImage) At(x, y int) color.Color

func (*MonoVerticalLSBImage) ColorModel

func (p *MonoVerticalLSBImage) ColorModel() color.Model

func (*MonoVerticalLSBImage) Fill added in v0.0.10

func (p *MonoVerticalLSBImage) Fill(c color.Color)

func (*MonoVerticalLSBImage) Set

func (p *MonoVerticalLSBImage) Set(x, y int, c color.Color)

Jump to

Keyboard shortcuts

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