plot: github.com/sksullivan/plot/vg/draw Index | Files

package draw

import "github.com/sksullivan/plot/vg/draw"

Index

Package Files

canvas.go

type BoxGlyph Uses

type BoxGlyph struct{}

BoxGlyph is a glyph that draws a filled square.

func (BoxGlyph) DrawGlyph Uses

func (BoxGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point)

DrawGlyph implements the Glyph interface.

type Canvas Uses

type Canvas struct {
    vg.Canvas
    Rectangle
}

A Canvas is a vector graphics canvas along with an associated Rectangle defining a section of the canvas to which drawing should take place.

func New Uses

func New(c vg.CanvasSizer) Canvas

New returns a new (bounded) draw.Canvas.

func NewCanvas Uses

func NewCanvas(c vg.Canvas, w, h vg.Length) Canvas

NewCanvas returns a new (bounded) draw.Canvas of the given size.

func (*Canvas) Center Uses

func (c *Canvas) Center() Point

Center returns the center point of the area

func (*Canvas) ClipLinesX Uses

func (c *Canvas) ClipLinesX(lines ...[]Point) (clipped [][]Point)

ClipLineX returns a slice of lines that represent the given line clipped in the X direction.

func (*Canvas) ClipLinesXY Uses

func (c *Canvas) ClipLinesXY(lines ...[]Point) [][]Point

ClipLineXY returns a slice of lines that represent the given line clipped in both X and Y directions.

func (*Canvas) ClipLinesY Uses

func (c *Canvas) ClipLinesY(lines ...[]Point) (clipped [][]Point)

ClipLineY returns a slice of lines that represent the given line clipped in the Y direction.

func (*Canvas) ClipPolygonX Uses

func (c *Canvas) ClipPolygonX(pts []Point) []Point

ClipPolygonX returns a slice of lines that represent the given polygon clipped in the X direction.

func (*Canvas) ClipPolygonXY Uses

func (c *Canvas) ClipPolygonXY(pts []Point) []Point

ClipPolygonXY returns a slice of lines that represent the given polygon clipped in both X and Y directions.

func (*Canvas) ClipPolygonY Uses

func (c *Canvas) ClipPolygonY(pts []Point) []Point

ClipPolygonY returns a slice of lines that represent the given polygon clipped in the Y direction.

func (*Canvas) Contains Uses

func (c *Canvas) Contains(p Point) bool

Contains returns true if the Canvas contains the point.

func (*Canvas) ContainsX Uses

func (c *Canvas) ContainsX(x vg.Length) bool

Contains returns true if the Canvas contains the x coordinate.

func (*Canvas) ContainsY Uses

func (c *Canvas) ContainsY(y vg.Length) bool

ContainsY returns true if the Canvas contains the y coordinate.

func (Canvas) Crop Uses

func (c Canvas) Crop(minx, miny, maxx, maxy vg.Length) Canvas

Crop returns a new Canvas corresponding to the receiver area with the given number of inches added to the minimum and maximum x and y values of the Canvas's Rectangle.

func (*Canvas) DrawGlyph Uses

func (c *Canvas) DrawGlyph(sty GlyphStyle, pt Point)

DrawGlyph draws the given glyph to the draw area. If the point is not within the Canvas or the sty.Shape is nil then nothing is drawn.

func (*Canvas) DrawGlyphNoClip Uses

func (c *Canvas) DrawGlyphNoClip(sty GlyphStyle, pt Point)

DrawGlyphNoClip draws the given glyph to the draw area. If the sty.Shape is nil then nothing is drawn.

func (*Canvas) FillPolygon Uses

func (c *Canvas) FillPolygon(clr color.Color, pts []Point)

FillPolygon fills a polygon with the given color.

func (*Canvas) FillText Uses

func (c *Canvas) FillText(sty TextStyle, x, y vg.Length, xalign, yalign float64, txt string)

FillText fills lines of text in the draw area. The text is offset by its width times xalign and its height times yalign. x and y give the bottom left corner of the text befor e it is offset.

func (*Canvas) SetLineStyle Uses

func (c *Canvas) SetLineStyle(sty LineStyle)

SetLineStyle sets the current line style

func (*Canvas) StrokeLine2 Uses

func (c *Canvas) StrokeLine2(sty LineStyle, x0, y0, x1, y1 vg.Length)

StrokeLine2 draws a line between two points in the given Canvas.

func (*Canvas) StrokeLines Uses

func (c *Canvas) StrokeLines(sty LineStyle, lines ...[]Point)

StrokeLines draws a line connecting a set of points in the given Canvas.

func (*Canvas) X Uses

func (c *Canvas) X(x float64) vg.Length

X returns the value of x, given in the unit range, in the drawing coordinates of this draw area. A value of 0, for example, will return the minimum x value of the draw area and a value of 1 will return the maximum.

func (*Canvas) Y Uses

func (c *Canvas) Y(y float64) vg.Length

Y returns the value of x, given in the unit range, in the drawing coordinates of this draw area. A value of 0, for example, will return the minimum y value of the draw area and a value of 1 will return the maximum.

type CircleGlyph Uses

type CircleGlyph struct{}

CircleGlyph is a glyph that draws a solid circle.

func (CircleGlyph) DrawGlyph Uses

func (CircleGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point)

DrawGlyph implements the GlyphDrawer interface.

type CrossGlyph Uses

type CrossGlyph struct{}

CrossGlyph is a glyph that draws a big X.

func (CrossGlyph) DrawGlyph Uses

func (CrossGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point)

DrawGlyph implements the Glyph interface.

type GlyphDrawer Uses

type GlyphDrawer interface {
    // DrawGlyph draws the glyph at the given
    // point, with the given color and radius.
    DrawGlyph(*Canvas, GlyphStyle, Point)
}

A GlyphDrawer wraps the DrawGlyph function.

type GlyphStyle Uses

type GlyphStyle struct {
    // Color is the color used to draw the glyph.
    color.Color

    // Radius specifies the size of the glyph's radius.
    Radius vg.Length

    // Shape draws the shape of the glyph.
    Shape GlyphDrawer
}

A GlyphStyle specifies the look of a glyph used to draw a point on a plot.

func (GlyphStyle) Rectangle Uses

func (g GlyphStyle) Rectangle() Rectangle

Rectangle returns the rectangle surrounding this glyph, assuming that it is drawn centered at 0,0

type LineStyle Uses

type LineStyle struct {
    // Color is the color of the line.
    Color color.Color

    // Width is the width of the line.
    Width vg.Length

    Dashes   []vg.Length
    DashOffs vg.Length
}

LineStyle describes what a line will look like.

type PlusGlyph Uses

type PlusGlyph struct{}

PlusGlyph is a glyph that draws a plus sign

func (PlusGlyph) DrawGlyph Uses

func (PlusGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point)

DrawGlyph implements the Glyph interface.

type Point Uses

type Point struct {
    X, Y vg.Length
}

A Point is a location in 2d space.

Points are used for drawing, not for data. For data, see the XYer interface.

type PyramidGlyph Uses

type PyramidGlyph struct{}

PyramidGlyph is a glyph that draws a filled triangle.

func (PyramidGlyph) DrawGlyph Uses

func (PyramidGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point)

DrawGlyph implements the Glyph interface.

type Rectangle Uses

type Rectangle struct {
    Min Point
    Max Point
}

A Rectangle represents a rectangular region of 2d space.

func (Rectangle) Path Uses

func (r Rectangle) Path() (p vg.Path)

Path returns the path of a Rect specified by its upper left corner, width and height.

func (Rectangle) Size Uses

func (r Rectangle) Size() Point

Size returns the width and height of a Rectangle.

type RingGlyph Uses

type RingGlyph struct{}

RingGlyph is a glyph that draws the outline of a circle.

func (RingGlyph) DrawGlyph Uses

func (RingGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point)

DrawGlyph implements the Glyph interface.

type SquareGlyph Uses

type SquareGlyph struct{}

SquareGlyph is a glyph that draws the outline of a square.

func (SquareGlyph) DrawGlyph Uses

func (SquareGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point)

DrawGlyph implements the Glyph interface.

type TextStyle Uses

type TextStyle struct {
    // Color is the text color.
    Color color.Color

    // Font is the font description.
    Font vg.Font
}

TextStyle describes what text will look like.

func (TextStyle) Height Uses

func (sty TextStyle) Height(txt string) vg.Length

Height returns the height of the text when using the given font.

func (TextStyle) Rectangle Uses

func (sty TextStyle) Rectangle(txt string) Rectangle

Rectangle returns a rectangle giving the bounds of this text assuming that it is drawn at 0, 0

func (TextStyle) Width Uses

func (sty TextStyle) Width(txt string) (max vg.Length)

Width returns the width of lines of text when using the given font.

type TriangleGlyph Uses

type TriangleGlyph struct{}

TriangleGlyph is a glyph that draws the outline of a triangle.

func (TriangleGlyph) DrawGlyph Uses

func (TriangleGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point)

DrawGlyph implements the Glyph interface.

Package draw imports 4 packages (graph) and is imported by 3 packages. Updated 2016-08-04. Refresh now. Tools for package owners.