vector - ActiveState ActiveGo 1.8
...

Package vector

import "golang.org/x/image/vector"
Overview
Index

Overview ▾

Package vector provides a rasterizer for 2-D vector graphics.

type Rasterizer

Raster is a 2-D vector graphics rasterizer.

The zero value is usable, in that it is a Rasterizer whose rendered mask image has zero width and zero height. Call Reset to change its bounds.

type Rasterizer struct {

    // DrawOp is the operator used for the Draw method.
    //
    // The zero value is draw.Over.
    DrawOp draw.Op
    // contains filtered or unexported fields
}

func NewRasterizer

func NewRasterizer(w, h int) *Rasterizer

NewRasterizer returns a new Rasterizer whose rendered mask image is bounded by the given width and height.

func (*Rasterizer) Bounds

func (z *Rasterizer) Bounds() image.Rectangle

Bounds returns the rectangle from (0, 0) to the width and height passed to NewRasterizer or Reset.

func (*Rasterizer) ClosePath

func (z *Rasterizer) ClosePath()

ClosePath closes the current path.

func (*Rasterizer) CubeTo

func (z *Rasterizer) CubeTo(bx, by, cx, cy, dx, dy float32)

CubeTo adds a cubic Bézier segment, from the pen via (bx, by) and (cx, cy) to (dx, dy), and moves the pen to (dx, dy).

The coordinates are allowed to be out of the Rasterizer's bounds.

func (*Rasterizer) Draw

func (z *Rasterizer) Draw(dst draw.Image, r image.Rectangle, src image.Image, sp image.Point)

Draw implements the Drawer interface from the standard library's image/draw package.

The vector paths previously added via the XxxTo calls become the mask for drawing src onto dst.

func (*Rasterizer) LineTo

func (z *Rasterizer) LineTo(bx, by float32)

LineTo adds a line segment, from the pen to (bx, by), and moves the pen to (bx, by).

The coordinates are allowed to be out of the Rasterizer's bounds.

func (*Rasterizer) MoveTo

func (z *Rasterizer) MoveTo(ax, ay float32)

MoveTo starts a new path and moves the pen to (ax, ay).

The coordinates are allowed to be out of the Rasterizer's bounds.

func (*Rasterizer) Pen

func (z *Rasterizer) Pen() (x, y float32)

Pen returns the location of the path-drawing pen: the last argument to the most recent XxxTo call.

func (*Rasterizer) QuadTo

func (z *Rasterizer) QuadTo(bx, by, cx, cy float32)

QuadTo adds a quadratic Bézier segment, from the pen via (bx, by) to (cx, cy), and moves the pen to (cx, cy).

The coordinates are allowed to be out of the Rasterizer's bounds.

func (*Rasterizer) Reset

func (z *Rasterizer) Reset(w, h int)

Reset resets a Rasterizer as if it was just returned by NewRasterizer.

This includes setting z.DrawOp to draw.Over.

func (*Rasterizer) Size

func (z *Rasterizer) Size() image.Point

Size returns the width and height passed to NewRasterizer or Reset.