raster

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package raster provides scanline rasterization for 2D paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveEdge

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

ActiveEdge is an edge being processed by the rasterizer.

type ActiveEdgeTable

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

ActiveEdgeTable represents edges active at a scanline.

func NewActiveEdgeTable

func NewActiveEdgeTable() *ActiveEdgeTable

NewActiveEdgeTable creates a new active edge table.

func (*ActiveEdgeTable) Add

func (aet *ActiveEdgeTable) Add(edge Edge)

Add adds an edge to the active edge table.

func (*ActiveEdgeTable) Clear

func (aet *ActiveEdgeTable) Clear()

Clear clears all edges.

func (*ActiveEdgeTable) Edges

func (aet *ActiveEdgeTable) Edges() []ActiveEdge

Edges returns the active edges.

func (*ActiveEdgeTable) Remove

func (aet *ActiveEdgeTable) Remove(y float64)

Remove removes inactive edges for the given scanline.

func (*ActiveEdgeTable) Sort

func (aet *ActiveEdgeTable) Sort()

Sort sorts edges by x coordinate (insertion sort for small lists).

func (*ActiveEdgeTable) Update

func (aet *ActiveEdgeTable) Update()

Update updates x positions for the next scanline.

type Edge

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

Edge represents a line segment for scanline rasterization.

func NewEdge

func NewEdge(p0, p1 Point) Edge

NewEdge creates a new edge from two points.

func (*Edge) XAtY

func (e *Edge) XAtY(y float64) float64

XAtY calculates the x coordinate at the given y coordinate.

type FillRule

type FillRule int

FillRule specifies how to determine which areas are inside a path.

const (
	// FillRuleNonZero uses the non-zero winding rule.
	FillRuleNonZero FillRule = iota
	// FillRuleEvenOdd uses the even-odd rule.
	FillRuleEvenOdd
)

type Pixmap

type Pixmap interface {
	Width() int
	Height() int
	SetPixel(x, y int, c RGBA)
}

Pixmap is an interface for writing pixels (avoids import cycle).

type Point

type Point struct {
	X, Y float64
}

Point represents a 2D point (internal copy to avoid import cycle).

type RGBA

type RGBA struct {
	R, G, B, A float64
}

RGBA represents a color (internal copy to avoid import cycle).

type Rasterizer

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

Rasterizer performs scanline rasterization.

func NewRasterizer

func NewRasterizer(width, height int) *Rasterizer

NewRasterizer creates a new rasterizer for the given dimensions.

func (*Rasterizer) Fill

func (r *Rasterizer) Fill(pixmap Pixmap, points []Point, fillRule FillRule, color RGBA)

Fill rasterizes a filled path onto a pixmap.

func (*Rasterizer) Stroke

func (r *Rasterizer) Stroke(pixmap Pixmap, points []Point, lineWidth float64, color RGBA)

Stroke rasterizes a stroked path.

type SpanFiller added in v0.5.0

type SpanFiller interface {
	FillSpan(x1, x2, y int, c RGBA)
}

SpanFiller is an optional interface that pixmaps can implement for optimized span filling.

Jump to

Keyboard shortcuts

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