scanFT

package module
v0.0.0-...-3672f1d Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

README

scanFT

scanFT is an antialiaser derived from the golang freetype translation.

scanFT encodes the ScannerFT struct that satisfies the Scanner interface of the rasterx rasterizer package which implements full SVG2.0 path functions, including the newer 'arc' join-mode.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlphaOverPainter

type AlphaOverPainter struct {
	Image *image.Alpha
}

An AlphaOverPainter is a Painter that paints Spans onto a *image.Alpha using the Over Porter-Duff composition operator.

func NewAlphaOverPainter

func NewAlphaOverPainter(m *image.Alpha) AlphaOverPainter

NewAlphaOverPainter creates a new AlphaOverPainter for the given image.

func (AlphaOverPainter) Paint

func (r AlphaOverPainter) Paint(ss []Span, done bool, clip image.Rectangle)

Paint satisfies the Painter interface.

type AlphaSrcPainter

type AlphaSrcPainter struct {
	Image *image.Alpha
}

An AlphaSrcPainter is a Painter that paints Spans onto a *image.Alpha using the Src Porter-Duff composition operator.

func NewAlphaSrcPainter

func NewAlphaSrcPainter(m *image.Alpha) AlphaSrcPainter

NewAlphaSrcPainter creates a new AlphaSrcPainter for the given image.

func (AlphaSrcPainter) Paint

func (r AlphaSrcPainter) Paint(ss []Span, done bool, clip image.Rectangle)

Paint satisfies the Painter interface.

type ClipRectPainter

type ClipRectPainter struct {
	// Painter is the wrapped Painter.
	Painter Painter
	// a is the precomputed alpha values for linear interpolation, with fully
	// opaque == 0xffff.
	ClipRect image.Rectangle
}

A ClipRectPainter wraps another Painter, but restricts painting to within the ClipRect

type GammaCorrectionPainter

type GammaCorrectionPainter struct {
	// Painter is the wrapped Painter.
	Painter Painter
	// contains filtered or unexported fields
}

A GammaCorrectionPainter wraps another Painter, performing gamma-correction on each Span's alpha value.

func NewGammaCorrectionPainter

func NewGammaCorrectionPainter(p Painter, gamma float64) *GammaCorrectionPainter

NewGammaCorrectionPainter creates a new GammaCorrectionPainter that wraps the given Painter.

func (*GammaCorrectionPainter) Paint

func (g *GammaCorrectionPainter) Paint(ss []Span, done bool, clip image.Rectangle)

Paint delegates to the wrapped Painter after performing gamma-correction on each Span.

func (*GammaCorrectionPainter) SetGamma

func (g *GammaCorrectionPainter) SetGamma(gamma float64)

SetGamma sets the gamma value.

type MonochromePainter

type MonochromePainter struct {
	Painter Painter
	// contains filtered or unexported fields
}

A MonochromePainter wraps another Painter, quantizing each Span's alpha to be either fully opaque or fully transparent.

func NewMonochromePainter

func NewMonochromePainter(p Painter) *MonochromePainter

NewMonochromePainter creates a new MonochromePainter that wraps the given Painter.

func (*MonochromePainter) Paint

func (m *MonochromePainter) Paint(ss []Span, done bool, clip image.Rectangle)

Paint delegates to the wrapped Painter after quantizing each Span's alpha value and merging adjacent fully opaque Spans.

type Painter

type Painter interface {
	Paint(ss []Span, done bool, clip image.Rectangle)
}

A Painter knows how to paint a batch of Spans. Rasterization may involve Painting multiple batches, and done will be true for the final batch. The Spans' Y values are monotonically increasing during a rasterization. Paint may use all of ss as scratch space during the call.

type PainterFunc

type PainterFunc func(ss []Span, done bool, clip image.Rectangle)

The PainterFunc type adapts an ordinary function to the Painter interface.

func (PainterFunc) Paint

func (f PainterFunc) Paint(ss []Span, done bool, clip image.Rectangle)

Paint just delegates the call to f.

type RGBAColFuncPainter

type RGBAColFuncPainter struct {
	RGBAPainter
	// contains filtered or unexported fields
}

RGBAColFuncPainter is a Painter that paints Spans onto a *image.RGBA, and uses a color function as a the color source, or the composed RGBA paint func for a solid color

func (*RGBAColFuncPainter) Paint

func (r *RGBAColFuncPainter) Paint(ss []Span, done bool, clip image.Rectangle)

Paint satisfies the Painter interface.

type RGBAPainter

type RGBAPainter struct {
	// Image is the image to compose onto.
	Image *image.RGBA
	// Op is the Porter-Duff composition operator.
	Op draw.Op
	// contains filtered or unexported fields
}

An RGBAPainter is a Painter that paints Spans onto a *image.RGBA.

func NewRGBAPainter

func NewRGBAPainter(m *image.RGBA) *RGBAPainter

NewRGBAPainter creates a new RGBAPainter for the given image.

func (*RGBAPainter) Paint

func (r *RGBAPainter) Paint(ss []Span, done bool, clip image.Rectangle)

Paint satisfies the Painter interface.

func (*RGBAPainter) SetColor

func (r *RGBAPainter) SetColor(c color.Color)

SetColor sets the color to paint the spans.

type ScannerFT

type ScannerFT struct {
	// If false, the behavior is to use the even-odd winding fill
	// rule during Rasterize.
	UseNonZeroWinding bool
	// An offset (in pixels) to the painted spans.
	Dx, Dy int

	Pntr *RGBAColFuncPainter
	// contains filtered or unexported fields
}

Rasterizer converts a path to a raster using the grainless algorithm.

func NewScannerFT

func NewScannerFT(width, height int, p *RGBAPainter) *ScannerFT

NewScanner creates a new Scanner with the given bounds.

func (*ScannerFT) Clear

func (s *ScannerFT) Clear()

Clear cancels any previous accumulated scans

func (*ScannerFT) Draw

func (s *ScannerFT) Draw()

Draw converts r's accumulated curves into Spans for p. The Spans passed to the painter are non-overlapping, and sorted by Y and then X. They all have non-zero width (and 0 <= X0 < X1 <= r.width) and non-zero A, except for the final Span, which has Y, X0, X1 and A all equal to zero.

func (*ScannerFT) GetPathExtent

func (s *ScannerFT) GetPathExtent() fixed.Rectangle26_6

func (*ScannerFT) Line

func (s *ScannerFT) Line(b fixed.Point26_6)

Line adds a linear segment to the current curve.

func (*ScannerFT) SetBounds

func (s *ScannerFT) SetBounds(width, height int)

SetBounds sets the maximum width and height of the rasterized image and calls Clear. The width and height are in pixels, not fixed.Int26_6 units.

func (*ScannerFT) SetClip

func (s *ScannerFT) SetClip(rect image.Rectangle)

SetClip sets an optional clipping rectangle to restrict rendering only to that region -- if size is 0 then ignored (set to image.ZR to clear)

func (*ScannerFT) SetColor

func (s *ScannerFT) SetColor(clr interface{})

func (*ScannerFT) SetWinding

func (s *ScannerFT) SetWinding(useNonZeroWinding bool)

func (*ScannerFT) Start

func (s *ScannerFT) Start(a fixed.Point26_6)

Start starts a new path at the given point.

type Span

type Span struct {
	Y, X0, X1 int
	Alpha     uint32
}

A Span is a horizontal segment of pixels with constant alpha. X0 is an inclusive bound and X1 is exclusive, the same as for slices. A fully opaque Span has Alpha == 0xffff.

Jump to

Keyboard shortcuts

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