pixel

package
v0.0.0-...-7a819e8 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package pixel provides a virtual screen designed to display pixel art.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearPalette

func ClearPalette()

func ColorCount

func ColorCount() int

ColorCount returns the number of colors in the palette.

func Err

func Err() error

Err returns the first unchecked error of package pixel, and considers it checked.

func PaletteCPC

func PaletteCPC()

func PaletteMSX

func PaletteMSX()

func PaletteMSX2

func PaletteMSX2()

func PixelSize

func PixelSize() int32

func SetBackground

func SetBackground(c colour.Colour)

Types

type Color

type Color uint8

A Color identifies a color inside the palette.

func FindColor

func FindColor(v colour.Colour) (c Color, ok bool)

FindColor searches for a color by its colour.RGBA values. If this exact color isn't in the palette, the first color is returned, and ok is set to false.

func GetColor

func GetColor(name string) Color

GetColor returns the color associated with a name. If there isn't any, the first color is returned, and a sticky error is set.

func NewColor

func NewColor(name string, v colour.Colour) Color

NewColor adds a color to the palette and returns its index. The name must be either unique or empty.

Note: The palette contains a maximum of 256 colors.

func (Color) RGBA

func (c Color) RGBA() colour.RGBA

RGBA returns the color corresponding to a palette index.

func (Color) SetRGBA

func (c Color) SetRGBA(v colour.Colour)

SetRGBA changes the colour.RGBA values of a color.

type Coord

type Coord struct {
	X, Y int16
}

Coord represents a pair of coordinates on the virtual screen, in (virtual) pixels.

func Mouse

func Mouse() Coord

Mouse returns the mouse position on the virtual screen.

func ScreenSize

func ScreenSize() Coord

func (Coord) Minus

func (p Coord) Minus(o Coord) Coord

Minus returns the difference with another pair of coordinates.

func (Coord) Mod

func (p Coord) Mod(s int16) Coord

Mod returns the remainder (modulus) of the division by a scalar (which must be non-zero).

func (Coord) ModCW

func (p Coord) ModCW(o Coord) Coord

ModCW returns the remainder (modulus) of the component-wise division by another pair of coordinates (of which both X and Y must be non-zero).

func (Coord) Opposite

func (p Coord) Opposite() Coord

Opposite returns the opposite pair of coordinates.

func (Coord) Plus

func (p Coord) Plus(o Coord) Coord

Plus returns the sum with another pair of coordinates.

func (Coord) Slash

func (p Coord) Slash(s int16) Coord

Slash returns the integer quotient of the division by a scalar (which must be non-zero).

func (Coord) SlashCW

func (p Coord) SlashCW(o Coord) Coord

SlashCW returns the integer quotients of the component-wise division by another pair of coordinates (of which both X and Y must be non-zero).

func (Coord) Times

func (p Coord) Times(s int16) Coord

Times returns the product with a scalar.

func (Coord) TimesCW

func (p Coord) TimesCW(o Coord) Coord

TimesCW returns the component-wise product with another pair of coordinates.

func (Coord) XY

func (p Coord) XY() (x, y float32)

XY returns the cartesian coordinates of the vector.

This function implements the plane.Vector interface.

type Mode

type Mode uint8

Mode describes the way a picture is stored in memory.

const (
	Indexed   Mode = 1
	FullColor Mode = 2
	GrayScale Mode = 3
)

The three modes supported for pictures.

type Picture

type Picture struct {
	// contains filtered or unexported fields
}

func GetPicture

func GetPicture(name string) *Picture

GetPicture returns the picture associated with a name. If there isn't any, an empty picture is returned, and a sticky error is set.

func (*Picture) Paint

func (p *Picture) Paint(x, y int16)

func (*Picture) Size

func (p *Picture) Size() Coord

Size returns the width and height of the picture.

Jump to

Keyboard shortcuts

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