raster

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: BSD-3-Clause, MIT, Unlicense Imports: 3 Imported by: 0

Documentation

Overview

Package raster provides rasterizers for 2-D vector graphics. Sub-directory vec provides an implementation based on golang.org/x/image/vector.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GradientConfig

type GradientConfig interface {
	// GradientShape returns 0 for a linear gradient and 1 for a radial
	// gradient.
	GradientShape() int
	// SpreadMethod returns 0 for 'none', 1 for 'pad', 2 for 'reflect', 3 for
	// 'repeat'.
	SpreadMethod() int
	// StopColors returns the colors of the gradient stops.
	StopColors() []color.RGBA
	// StopOffsets returns the offsets of the gradient stops.
	StopOffsets() []float64
	// Transform is the pixel space to gradient space affine transformation
	// matrix.
	// | a b c |
	// | d e f |
	Transform() (a, b, c, d, e, f float64)
}

GradientConfig interface could be used in the future to extract the gradient configuration of a source image and have it generated on the GPU.

type Rasterizer

type Rasterizer interface {
	// Reset resets a Rasterizer as if it was just returned by NewRasterizer.
	// This includes setting z.DrawOp to draw.Over.
	Reset(w, h int)
	// Size returns the width and height passed to NewRasterizer or Reset.
	Size() image.Point
	// Bounds returns the rectangle from (0, 0) to the width and height passed to
	// Reset.
	Bounds() image.Rectangle
	// Pen returns the location of the path-drawing pen: the last argument to the
	// most recent XxxTo call.
	Pen() (x, y 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.
	MoveTo(ax, ay 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.
	LineTo(bx, by 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.
	QuadTo(bx, by, cx, cy 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.
	CubeTo(bx, by, cx, cy, dx, dy float32)
	// ClosePath closes the current path.
	ClosePath()
	// Draw aligns r.Min in z with sp in src and then replaces the rectangle r in
	// z with the result of a Porter-Duff composition. The vector paths
	// previously added via the XxxTo calls become the mask for drawing src onto
	// z.
	Draw(r image.Rectangle, src image.Image, sp image.Point)
}

Rasterizer is a 2-D vector graphics rasterizer.

type RasterizerLogger

type RasterizerLogger struct {
	Rasterizer
}

func (*RasterizerLogger) Bounds

func (r *RasterizerLogger) Bounds() image.Rectangle

func (*RasterizerLogger) ClosePath

func (r *RasterizerLogger) ClosePath()

func (*RasterizerLogger) CubeTo

func (r *RasterizerLogger) CubeTo(bx, by, cx, cy, dx, dy float32)

func (*RasterizerLogger) Draw

func (rl *RasterizerLogger) Draw(r image.Rectangle, src image.Image, sp image.Point)

func (*RasterizerLogger) LineTo

func (r *RasterizerLogger) LineTo(bx, by float32)

func (*RasterizerLogger) MoveTo

func (r *RasterizerLogger) MoveTo(ax, ay float32)

func (*RasterizerLogger) Pen

func (r *RasterizerLogger) Pen() (x, y float32)

func (*RasterizerLogger) QuadTo

func (r *RasterizerLogger) QuadTo(bx, by, cx, cy float32)

func (*RasterizerLogger) Reset

func (r *RasterizerLogger) Reset(w, h int)

func (*RasterizerLogger) Size

func (r *RasterizerLogger) Size() image.Point

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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