canvas

package
v0.0.0-...-1b60a0e Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package canvas represents a rectangular grid of Pixels.

Index

Constants

View Source
const PixelMapTemplate = `{{ .PPMIdentifier }}
{{ .Width }} {{ .Height }}
{{ .MaxColorValue }}
{{ pixels .Pixels }}`

PixelMapTemplate is a template used for rendering a Canvas to a portable pixmap (PPM) file.

Variables

This section is empty.

Functions

This section is empty.

Types

type Canvas

type Canvas struct {
	Width         int
	Height        int
	Pixels        [][]color.Color
	PPMIdentifier string
	MaxColorValue uint8
	MinColorValue uint8
}

Canvas represents a rectangular grid of Pixels.

func NewCanvas

func NewCanvas(width, height int) *Canvas

NewCanvas returns a new Canvas with the passed Width and Height.

func (*Canvas) PixelAt

func (c *Canvas) PixelAt(x, y int) (color.Color, error)

PixelAt returns the Color at the pixel located at the passed x and y values.

func (*Canvas) ToPPM

func (c *Canvas) ToPPM(writer io.Writer, goTemplate string) error

ToPPM writes the current canvas to a file in the portable pixmap (PPM) format.

func (*Canvas) ValidateInCanvasBounds

func (c *Canvas) ValidateInCanvasBounds(x, y int) error

ValidateInCanvasBounds validates that the passed x and y values fit into the pixel bounds of the canvas.

func (*Canvas) WritePixel

func (c *Canvas) WritePixel(x, y int, color color.Color) error

WritePixel writes the passed Color to the Canvas at the pixel located at the passed x and y values.

Jump to

Keyboard shortcuts

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