dmd

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package dmd implements well-known formats for dot-matrix display (DMD) art.

This dot-matrix display (DMD) image formats are most often used in arcade machines, most notable pinball machines.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHeaderMagic = errors.New("dmd: unexpected header magic")
	ErrSeek        = errors.New("dmd: illegal seek offset")
)
View Source
var (
	Red     = color.RGBA{R: 0xff, A: 0xff}
	Green   = color.RGBA{G: 0xff, A: 0xff}
	Blue    = color.RGBA{B: 0xff, A: 0xff}
	Yellow  = color.RGBA{R: 0xff, G: 0xff, A: 0xff}
	Magenta = color.RGBA{R: 0xff, B: 0xff, A: 0xff}
	Cyan    = color.RGBA{G: 0xff, B: 0xff, A: 0xff}
	Amber   = color.RGBA{R: 0xff, G: 0x7f, A: 0xff}
)

Default colors.

View Source
var (
	Mask = color.Palette{
		color.Alpha{A: 0x00}, color.Alpha{A: 0x11}, color.Alpha{A: 0x22}, color.Alpha{A: 0x33},
		color.Alpha{A: 0x44}, color.Alpha{A: 0x55}, color.Alpha{A: 0x66}, color.Alpha{A: 0x77},
		color.Alpha{A: 0x88}, color.Alpha{A: 0x99}, color.Alpha{A: 0xaa}, color.Alpha{A: 0xbb},
		color.Alpha{A: 0xcc}, color.Alpha{A: 0xdd}, color.Alpha{A: 0xee}, color.Alpha{A: 0xff},
	}
	GrayPalette = color.Palette{
		color.Gray{Y: 0x00}, color.Gray{Y: 0x11}, color.Gray{Y: 0x22}, color.Gray{Y: 0x33},
		color.Gray{Y: 0x44}, color.Gray{Y: 0x55}, color.Gray{Y: 0x66}, color.Gray{Y: 0x77},
		color.Gray{Y: 0x88}, color.Gray{Y: 0x99}, color.Gray{Y: 0xaa}, color.Gray{Y: 0xbb},
		color.Gray{Y: 0xcc}, color.Gray{Y: 0xdd}, color.Gray{Y: 0xee}, color.Gray{Y: 0xff},
	}
	AmberPalette = color.Palette{
		color.RGBA{R: 0x00, G: 0x00, B: 0x00, A: 0xff}, color.RGBA{R: 0x11, G: 0x08, B: 0x00, A: 0xff},
		color.RGBA{R: 0x22, G: 0x11, B: 0x00, A: 0xff}, color.RGBA{R: 0x33, G: 0x19, B: 0x00, A: 0xff},
		color.RGBA{R: 0x44, G: 0x22, B: 0x00, A: 0xff}, color.RGBA{R: 0x55, G: 0x2a, B: 0x00, A: 0xff},
		color.RGBA{R: 0x66, G: 0x33, B: 0x00, A: 0xff}, color.RGBA{R: 0x77, G: 0x3b, B: 0x00, A: 0xff},
		color.RGBA{R: 0x88, G: 0x44, B: 0x00, A: 0xff}, color.RGBA{R: 0x99, G: 0x4c, B: 0x00, A: 0xff},
		color.RGBA{R: 0xaa, G: 0x55, B: 0x00, A: 0xff}, color.RGBA{R: 0xbb, G: 0x5d, B: 0x00, A: 0xff},
		color.RGBA{R: 0xcc, G: 0x66, B: 0x00, A: 0xff}, color.RGBA{R: 0xdd, G: 0x6e, B: 0x00, A: 0xff},
		color.RGBA{R: 0xee, G: 0x77, B: 0x00, A: 0xff}, color.RGBA{R: 0xff, G: 0x7f, B: 0x00, A: 0xff},
	}
)

Default palettes.

Functions

func EncodeToGIF

func EncodeToGIF(w io.Writer, a Animation, c color.Color) error

Types

type Animation

type Animation interface {
	// Name of the animation.
	Name() string

	// IsMask indicates the animation contains masks.
	IsMask() bool

	// size of the animation.
	Size() (width, height int)

	// ClockInFront checks if the clock should be over the image.
	ClockInFront() bool

	// ClockOffset is the offset of the clock.
	ClockOffset() image.Point

	// Duration of the animation.
	Duration() time.Duration

	// Len is the length of the animation in number of frames.
	Len() int

	// Next frame, will return EOF when end of animation is reached.
	NextFrame() (image.Image, time.Duration, error)

	// Seek to frame.
	SeekFrame(pos int) error
}

func Colorize

func Colorize(a Animation, p color.Palette) Animation

func DecodeDMD1

func DecodeDMD1(r io.Reader) (Animation, error)

DecodeDMD1 decodes one DMD1 animation (as used in RPI2DMD).

func DecodeGIF

func DecodeGIF(r io.Reader) (Animation, error)

type Animations

type Animations []Animation

Animations is 0 or more Animation.

func DecodeRunDMD

func DecodeRunDMD(r io.ReadSeeker) (Animations, error)

DecodeRunDMD can decode animations in a (raw) Run-DMD SD card image.

func DecodeVPIN

func DecodeVPIN(r io.ReadSeeker) (Animations, error)

DecodeVPIN calls DecodeVPINWithColoring.

func DecodeVPINWithColoring

func DecodeVPINWithColoring(r io.ReadSeeker, c *Pin2DMDColoring) (Animations, error)

DecodeVPINWithColoring can decode animations from a Virtual Pinball animation file.

Typically, these animation file are called "pin2dmd.vni" or "pin2dmd.ani". If you have a machine palette file ("pin2dmd.pal"), you can load the coloring definitions with LoadPin2DMDColoring / DecodePin2DMDColoring.

type Pin2DMDColoring

type Pin2DMDColoring struct {
	Version  uint8
	Palette  *Pin2DMDPalette
	Palettes []*Pin2DMDPalette
	Default  int
	Mappings map[uint32]*Pin2DMDMapping
	Masks    [][]byte
}

Pin2DMDColoring contains a coloring description.

func DecodePin2DMDColoring

func DecodePin2DMDColoring(r io.Reader) (c *Pin2DMDColoring, err error)

DecodePin2DMDColoring decodes palette mappings from the supplied Reader.

func LoadPin2DMDColoring

func LoadPin2DMDColoring(name string) (*Pin2DMDColoring, error)

LoadPin2DMDColoring loads *.pal Pin2DMD colorization files.

func (*Pin2DMDColoring) GetPalette

func (c *Pin2DMDColoring) GetPalette(i int) *Pin2DMDPalette

type Pin2DMDMapping

type Pin2DMDMapping struct {
	Checksum     uint32
	Mode         SwitchMode
	PaletteIndex uint16
	Duration     uint32
	Offset       uint32
}

func (Pin2DMDMapping) IsAnimation

func (m Pin2DMDMapping) IsAnimation() bool

type Pin2DMDPalette

type Pin2DMDPalette struct {
	Index        uint16
	Type         uint8
	IsDefault    bool
	IsPersistent bool
	Colors       color.Palette
}

type SwitchMode

type SwitchMode byte
const (
	SwitchModePalette SwitchMode = iota
	SwitchModeReplace
	SwitchModeColorMask
	SwitchModeEvent
	SwitchModeFollow
)

Directories

Path Synopsis
cmd
Package container contains helpers for animation(set) containers.
Package container contains helpers for animation(set) containers.
internal

Jump to

Keyboard shortcuts

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