draw

package module
v0.0.0-...-08c86e0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2018 License: MIT Imports: 9 Imported by: 2

README

draw

Basic library for drawing of common shapes (eg. line, rectangle) and text over an image

Credits

  • IsInPolygon() method adapted from C implementation by W. Randolph Franklin, published at his article "PNPOLY - Point Inclusion in Polygon Test - W. Randolph Franklin (WRF)"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

Context provides simple methods for drawing over an image.

func NewContext

func NewContext(rgba *image.RGBA) *Context

NewContext creates a new context for drawing over image.

func (*Context) Cross

func (c *Context) Cross(x, y, size int)

Cross draws a cross centered at x,y.

func (*Context) Dot

func (c *Context) Dot(x, y int)

Dot draw a single dot at x,y coordinates.

func (*Context) Dots

func (c *Context) Dots(points []image.Point)

Dots draws a sequence of dots.

func (*Context) FillPixel

func (c *Context) FillPixel(x, y int)

FillPixel fills the pixel at x,y with the current fill color.

func (*Context) IsInPolygon

func (c *Context) IsInPolygon(x, y int, points []image.Point) bool

IsInPolygon tests if the point at X and Y lies inside the polygon defined by the given points.

func (*Context) Line

func (c *Context) Line(x0, y0, x1, y1 int)

Line draws an approximation of a straight line between two points using Bresenham's algorithm.

func (*Context) Parabola

func (c *Context) Parabola(a1, b1, c1 float64)

Parabola draws a parabola with the specified coefficients a, b and c.

func (*Context) ParabolaArc

func (c *Context) ParabolaArc(a1, b1, c1 float64, x1, x2 int)

ParabolaArc draws the arc of parabola between x1 and x2 with the specified coefficients a, b and c.

func (*Context) Path

func (c *Context) Path(points []image.Point)

Path draws a sequence of points, connected by lines.

func (*Context) Polygon

func (c *Context) Polygon(points []image.Point)

Polygon outlines and fills a polygon defined by the given points.

func (*Context) Rect

func (c *Context) Rect(x0, y0, x1, y1 int)

Rect draws a rectangle with pen's color.

func (*Context) SetFill

func (c *Context) SetFill(clr color.Color)

SetFill changes the fill color.

func (*Context) SetFontFace

func (c *Context) SetFontFace(font *truetype.Font, options *truetype.Options)

SetFontFace changes the font face and font options.

func (*Context) SetFontSize

func (c *Context) SetFontSize(size float64)

SetFontSize changes the font size only.

func (*Context) SetPen

func (c *Context) SetPen(clr color.Color)

SetPen changes the pen color (outline color).

func (*Context) SetTextColor

func (c *Context) SetTextColor(clr color.Color)

SetTextColor changes the text color.

func (*Context) Text

func (c *Context) Text(x, y int, text string)

Text draws the given text at x,y with the font chosen in context. The default font is golang.org/x/image/font/basicfont.

Jump to

Keyboard shortcuts

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