simpledraw

package
v0.0.0-...-8efb767 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2017 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Black = color.RGBA{0, 0, 0, 255}

Black is a sensible default RGB color choice

View Source
var Blue = color.RGBA{51, 147, 204, 255}

Blue is a sensible default RGB color choice

View Source
var DefaultBasicProperties = BasicProperties{
	Color:  White,
	Stroke: Black,
	Weight: 1,
}

DefaultBasicProperties provides sensible defaults for shape properties

View Source
var Green = color.RGBA{62, 214, 89, 255}

Green is a sensible default RGB color choice

View Source
var Orange = color.RGBA{234, 133, 44, 255}

Orange is a sensible default RGB color choice

Pallate is a collection of preset colors for easy cycling through in list iterations

View Source
var Purple = color.RGBA{175, 102, 209, 255}

Purple is a sensible default RGB color choice

View Source
var Red = color.RGBA{244, 86, 66, 255}

Red is a sensible default RGB color choice

View Source
var White = color.RGBA{255, 255, 255, 255}

White is a sensible default RGB color choice

View Source
var Yellow = color.RGBA{239, 235, 117, 255}

Yellow is a sensible default RGB color choice

Functions

func Rad2Deg

func Rad2Deg(rad float64) float64

Rad2Deg is a simple helper for converting from Radians to Degrees, usually used for printing

Types

type BasicProperties

type BasicProperties struct {
	Color, Stroke color.RGBA
	Weight        float64
}

BasicProperties contains the basic properties that all shapes need

type Circle

type Circle struct {
	Props        BasicProperties
	X, Y, Radius float64
}

Circle is a simple struct with circle's properties

func NewCircle

func NewCircle(x, y, radius float64) Circle

NewCircle returns a circle with sensible defaults

func (Circle) PointAtAngle

func (c Circle) PointAtAngle(radian float64) (float64, float64)

PointAtAngle returns the x, y pair along a circle's circumference at the given angle in radians

type Draw

type Draw struct {
	*draw2dimg.GraphicContext
}

Draw embeds draw2dimg.GraphicContext and gives us some handy simple drawing tools

func (*Draw) DrawCircle

func (d *Draw) DrawCircle(c Circle)

DrawCircle draws the given circle

func (*Draw) DrawLegend

func (d *Draw) DrawLegend(l *Legend)

DrawLegend draws out the legend and all its registered elements

func (*Draw) DrawOnEdge

func (d *Draw) DrawOnEdge(c Circle, angle float64, sides int, radius float64, props BasicProperties)

DrawOnEdge will draw a regular poloygon on the circumference of a given circle

func (*Draw) DrawRegularPolygon

func (d *Draw) DrawRegularPolygon(sides int, x, y, radius float64, props BasicProperties)

DrawRegularPolygon draws a regular polygon, but handles special case of also drawing a circle if sides <= 1. Could add wrappers for DrawSquare or DrawTriangle if warrented. Not needed currently.

func (*Draw) WriteBoldStringAt

func (d *Draw) WriteBoldStringAt(text string, x, y float64) (width float64)

WriteBoldStringAt writes bold black text at the given location

func (*Draw) WriteStringAt

func (d *Draw) WriteStringAt(text string, x, y float64) (width float64)

WriteStringAt writes black text at the given location

type Legend

type Legend struct {
	Title    string
	Caption  string
	Elements []LegendElement
}

Legend is used for displaying a legend, as for a chart

func (*Legend) AppendElement

func (l *Legend) AppendElement(polygonSides int, name string, props BasicProperties)

AppendElement is a helper to cut down on visual clutter when developing. Not async.

func (*Legend) ContentHeight

func (l *Legend) ContentHeight() float64

ContentHeight returns the height of the computed legend

func (*Legend) ContentWidth

func (l *Legend) ContentWidth() float64

ContentWidth returns the width of the computed legend

func (*Legend) PrependElement

func (l *Legend) PrependElement(polygonSides int, name string, props BasicProperties)

PrependElement is a helper to cut down on visual clutter when developing. Not async.

type LegendElement

type LegendElement struct {
	Name          string
	PolygonSides  int
	Width, Height float64
	Props         BasicProperties
}

LegendElement is used in the Legend struct and is not likely to be used outside the package. It is exported just in case it it needed.

Jump to

Keyboard shortcuts

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