color

package
v0.0.0-...-a0f0792 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: BSD-2-Clause Imports: 7 Imported by: 1

Documentation

Overview

Package color provides a RGB565 color. Sections of this file have been copied from github.com/ev3go/ev3dev/fb/rgb565.go under the following copyright license: Copyright ©2016 The ev3go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

View Source
var (
	Red     = New(255, 0, 0)
	Green   = New(0, 255, 0)
	Blue    = New(0, 0, 255)
	Black   = New(0, 0, 0) // Off
	White   = New(255, 255, 255)
	Magenta = New(209, 13, 62)
)

Predefined colors

View Source
var RGB565Model = color.ModelFunc(rgb565Model)

RGB565Model is the color model for RGB565 images.

Functions

func NewRGB565With

func NewRGB565With(pix []byte, r image.Rectangle, stride int) (draw.Image, error)

NewRGB565With returns a new RGB565 image with the given bounds, backed by the []byte, pix. If stride is zero, a working stride is computed. If the length of pix is less than stride*h, an error is returned.

Types

type Pixel565

type Pixel565 uint16

Pixel565 represents a non-alpha-premultiplied 16-bit color.

func New

func New(red, green, blue uint32) Pixel565

New constructs a new Pixel565 from red, green, blue values.

func RandomPlan9PaletteColor

func RandomPlan9PaletteColor() Pixel565

RandomPlan9PaletteColor returns a random color from the palette.Plan9 slice.

func (Pixel565) RGBA

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

RGBA returns the RGBA values for the receiver. The alpha channel is

type RGB565

type RGB565 struct {
	// Pix holds the image's pixels, as RGB565 values.
	// The Pixel565 at (x, y) is the pair of bytes at
	// Pix[2*(x-Rect.Min.X) + (y-Rect.Min.Y)*Stride].
	// Pixel565 values are encoded little endian in Pix.
	Pix []uint8
	// Stride is the Pix stride (in bytes) between
	// vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

RGB565 is an in-memory image whose At method returns Pixel565 values.

func NewRGB565

func NewRGB565(r image.Rectangle) *RGB565

NewRGB565 returns a new RGB565 image with the given bounds.

func (*RGB565) At

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

At returns the color of the pixel565 at (x, y).

func (*RGB565) Bounds

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

Bounds returns the bounding rectangle for the image.

func (*RGB565) ColorModel

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

ColorModel returns the RGB565 color model.

func (*RGB565) Set

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

Set sets the color of the pixel565 at (x, y) to c.

Jump to

Keyboard shortcuts

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