plot

package
v0.0.0-...-8533540 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2019 License: MIT, MIT Imports: 11 Imported by: 0

README

Plot

Overview

This package implements primitives for drawing plots.

Documentation

Overview

Package plot provides plotting primitives that facilitate the construction of simple plots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Canvas

type Canvas struct {
	Width  int
	Height int
	// contains filtered or unexported fields
}

Canvas is the basis for all other drawing primitives. Its only properties are a width, a height and a background color. Canvas is based on `image.RGBA'.

func NewCanvas

func NewCanvas(width, height int, bg *color.RGBA) *Canvas

NewCanvas creates a new canvas for plotting.

func (*Canvas) AddAxis

func (c *Canvas) AddAxis(ticks []int, thick int, position string) error

AddAxis adds an axis to a `Canvas' in either horizontal or vertical position.

func (*Canvas) AddLabel

func (c *Canvas) AddLabel(x, y int, label string, col *color.RGBA)

AddLabel adds a `label' at a certain `x' and `y' position of a `Canvas'. Currently, only a fixed-size font is implemented (`basicfont.Face7x13').

func (*Canvas) At

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

At ensures that `Canvas' implements `image.Image'

func (*Canvas) Bounds

func (c *Canvas) Bounds() image.Rectangle

Bounds ensures that `Canvas' implements `image.Image'

func (*Canvas) ColorModel

func (c *Canvas) ColorModel() color.Model

ColorModel ensures that `Canvas' implements `image.Image'

func (*Canvas) EncodePNG

func (c *Canvas) EncodePNG(w io.Writer) error

EncodePNG encodes a `Canvas' and everything that is drawn on it as a .png using an `io.Writer'.

func (*Canvas) Line

func (c *Canvas) Line(x0, y0, x1, y1, thick int, col *color.RGBA) error

Line draws a straight line on a `Canvas'. The line will be drawn from (`x0', `y0') to (`x1', `y1') with a certain thickness in pixels and a certain color.

func (*Canvas) Rectangle

func (c *Canvas) Rectangle(x0, y0, x1, y1, thick int, out *color.RGBA)

Rectangle creates a rectangle with a certain outline color between points (`x0', `y0') and (`x1', `y1') on a `Canvas'. Thickness `thick' can be specified as well.

func (*Canvas) SaveToFile

func (c *Canvas) SaveToFile(name string) error

SaveToFile saves a `Canvas' to a file at `path'. The file does not need to exist (if it does, it will be overwritten).

func (*Canvas) Set

func (c *Canvas) Set(x, y int, col color.Color)

Set ensures that `Canvas' implements `image.Image'

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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