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

package vgimg

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

Package vgimg implements the vg.Canvas interface using draw2d (github.com/sksullivan/draw2d) as a backend to output raster images.

Index

Package Files

vgimg.go

Constants

const (
    // DefaultDPI is the default number of dots per inch.
    DefaultDPI = 96

    // DefaultWidth and DefaultHeight are the default canvas
    // dimensions.
    DefaultWidth  = 4 * vg.Inch
    DefaultHeight = 4 * vg.Inch
)

func UseDPI Uses

func UseDPI(dpi int) option

UseDPI sets the dots per inch of a canvas. It should only be used as an option argument when initializing a new canvas.

func UseImage Uses

func UseImage(img draw.Image) option

UseImage specifies an image to create the canvas from. The minimum point of the given image should probably be 0,0.

func UseImageWithContext Uses

func UseImageWithContext(img draw.Image, gc draw2d.GraphicContext) option

UseImageWithContext specifies both an image and a graphic context to create the canvas from. The minimum point of the given image should probably be 0,0.

func UseWH Uses

func UseWH(w, h vg.Length) option

UseWH specifies the width and height of the canvas. The size is rounded up to the nearest pixel.

type Canvas Uses

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

Canvas implements the vg.Canvas interface, drawing to an image.Image using draw2d.

func New Uses

func New(w, h vg.Length) *Canvas

New returns a new image canvas.

func NewWith Uses

func NewWith(o ...option) *Canvas

NewWith returns a new image canvas created according to the specified options. The currently accepted options are UseWH, UseDPI, UseImage, and UseImageWithContext. Each of the options specifies the size of the canvas (UseWH, UseImage), the resolution of the canvas (UseDPI), or both (useImageWithContext). If size or resolution are not specified, defaults are used. It panics if size and resolution are overspecified (i.e., too many options are passed).

func (*Canvas) DPI Uses

func (c *Canvas) DPI() float64

func (*Canvas) Fill Uses

func (c *Canvas) Fill(p vg.Path)

func (*Canvas) FillString Uses

func (c *Canvas) FillString(font vg.Font, x, y vg.Length, str string)

func (*Canvas) Pop Uses

func (c *Canvas) Pop()

func (*Canvas) Push Uses

func (c *Canvas) Push()

func (*Canvas) Rotate Uses

func (c *Canvas) Rotate(t float64)

func (*Canvas) Scale Uses

func (c *Canvas) Scale(x, y float64)

func (*Canvas) SetColor Uses

func (c *Canvas) SetColor(clr color.Color)

func (*Canvas) SetLineDash Uses

func (c *Canvas) SetLineDash(ds []vg.Length, offs vg.Length)

func (*Canvas) SetLineWidth Uses

func (c *Canvas) SetLineWidth(w vg.Length)

func (*Canvas) Size Uses

func (c *Canvas) Size() (w, h vg.Length)

func (*Canvas) Stroke Uses

func (c *Canvas) Stroke(p vg.Path)

func (*Canvas) Translate Uses

func (c *Canvas) Translate(x, y vg.Length)

type JpegCanvas Uses

type JpegCanvas struct {
    *Canvas
}

A JpegCanvas is an image canvas with a WriteTo method that writes a jpeg image.

func (JpegCanvas) WriteTo Uses

func (c JpegCanvas) WriteTo(w io.Writer) (int64, error)

WriteTo implements the io.WriterTo interface, writing a jpeg image.

type PngCanvas Uses

type PngCanvas struct {
    *Canvas
}

A PngCanvas is an image canvas with a WriteTo method that writes a png image.

func (PngCanvas) WriteTo Uses

func (c PngCanvas) WriteTo(w io.Writer) (int64, error)

WriteTo implements the io.WriterTo interface, writing a png image.

type TiffCanvas Uses

type TiffCanvas struct {
    *Canvas
}

A TiffCanvas is an image canvas with a WriteTo method that writes a tiff image.

func (TiffCanvas) WriteTo Uses

func (c TiffCanvas) WriteTo(w io.Writer) (int64, error)

WriteTo implements the io.WriterTo interface, writing a tiff image.

Package vgimg imports 12 packages (graph) and is imported by 2 packages. Updated 2016-08-04. Refresh now. Tools for package owners.