plot

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package plot provides library code to for rendering hex coordinates grids

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	Coord coord.Coord
	Style *CellStyle
	Text  string
}

Cell represents a hexagon to be drawn

type CellStyle

type CellStyle struct {
	Color    color.RGBA
	FontSize int
}

CellStyle represents style for a cell

type CellStyleFunc

type CellStyleFunc func(coord coord.Coord) (string, *CellStyle)

CellStyleFunc is a function for styling a cell in the figure

type Figure

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

Figure represents a collection of hex coordinates to be plotted

func NewFigure

func NewFigure() *Figure

NewFigure returns a new Figure instance

func (*Figure) AddCoord

func (f *Figure) AddCoord(coord coord.Coord)

AddCoord adds an un-styled hex cell at the given coordinate

func (*Figure) AddCoords

func (f *Figure) AddCoords(coords coord.Coords)

AddCoords adds un-styled hex cells at the given coordinates

func (*Figure) AddStyledCoord

func (f *Figure) AddStyledCoord(coord coord.Coord, style Style)

AddStyledCoord adds a styled hex cell at the given coordinate, using the given style

func (*Figure) AddStyledCoords

func (f *Figure) AddStyledCoords(coords coord.Coords, style Style)

AddStyledCoords adds a styled hex cells at the given coordinates, using the given style

func (*Figure) Render

func (f *Figure) Render(writer io.Writer) error

Render renders the figure as an SVG to the specified writer

func (*Figure) RenderFile

func (f *Figure) RenderFile(name string) error

RenderFile renders the figure to the specified SVG file

func (*Figure) SetCoordType

func (f *Figure) SetCoordType(coordType consts.CoordType)

SetCoordType sets the coordinate system type to use for rendering coordinate values

func (*Figure) SetOrientation added in v0.1.1

func (f *Figure) SetOrientation(orientation consts.Orientation)

SetOrientation sets the orientation of the hexagons rendered by the figure

func (*Figure) SetTheme added in v0.1.1

func (f *Figure) SetTheme(theme *Theme)

SetTheme sets the theme for the figure

type Style

type Style func(coord.Coord) (string, *CellStyle)

Style represents text and cell style

func (Style) Color

func (s Style) Color(color color.RGBA) Style

Color sets the color of the cell style

func (Style) FontSize

func (s Style) FontSize(size int) Style

FontSize sets the font size of the cell style

func (Style) Name

func (s Style) Name(name string) Style

Name sets the name of the cell style

type Theme

type Theme struct {
	BackgroundColor color.RGBA
	BorderColor     color.RGBA
	CellColor       color.RGBA
	CoordQColor     color.RGBA
	CoordRColor     color.RGBA
	CoordSColor     color.RGBA
	TextColor       color.RGBA
}

Theme represents a theme for coloring a figure and its cells

func DefaultTheme

func DefaultTheme() *Theme

DefaultTheme returns the default theme for styling figures

Directories

Path Synopsis
Package style provides helper functions for styling plot.Figure cells
Package style provides helper functions for styling plot.Figure cells

Jump to

Keyboard shortcuts

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