raster

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package raster converts geometric shapes and map images into grid cost data.

Index

Constants

This section is empty.

Variables

View Source
var FromPoint = domain.FromPoint

FromPoint converts orb points to the raster vector type.

Functions

func ApplyBorderPenalty

func ApplyBorderPenalty(r domain.GridData, penaltyRadius int, floorThreshold Cost)

ApplyBorderPenalty increases traversable cell costs near wall cells.

func RasterLine

func RasterLine(p0, p1 Vec2, width float64, cost Cost, scale float64, r domain.GridData)

RasterLine draws a thick line by expanding it to a rectangle before rasterizing.

func RasterPNG

func RasterPNG(path string, pixelsPerCell float64, r domain.GridData) error

RasterPNG rasterizes a PNG image onto a RegionGrid.

pixelsPerCell is the number of source-image pixels that correspond to one grid cell side. The function box-samples every pixel whose centre falls inside each cell's footprint and writes the normalised redness [0,255] into the matching cell.

Pixel (px, py) belongs to cell (cx, cy) when:

cx = floor(px / pixelsPerCell)
cy = floor(py / pixelsPerCell)

Only cells that fall within both the image bounds and the grid bounds are written; out-of-range areas are silently skipped.

func RasterPNG2

func RasterPNG2(path string, pixelsPerCell float64, r domain.GridData, penaltyRadius int, floorThreshold Cost) error

RasterPNG2 rasterizes a PNG and applies a distance-based border penalty.

func RasterPNG3

func RasterPNG3(path string, pixelsPerCell float64, r domain.GridData, traversableCost Cost) error

RasterPNG3 rasterizes a generic image without wall aura.

func RasterPNG3WithAura

func RasterPNG3WithAura(path string, pixelsPerCell float64, r domain.GridData, traversableCost Cost, auraRadius int) error

RasterPNG3WithAura is the generic-image version of the map rasterizer.

func RasterPNG3_v2

func RasterPNG3_v2(path string, pixelsPerCell float64, r domain.GridData, traversableCost Cost) error

RasterPNG3_v2 rasterizes a simple paletted image without wall aura.

func RasterPNG3_v2WithAura

func RasterPNG3_v2WithAura(path string, pixelsPerCell float64, r domain.GridData, traversableCost Cost, auraRadius int) error

RasterPNG3_v2WithAura rasterizes a simple paletted image and applies wall aura.

func RasterPNG4

func RasterPNG4(path string, pixelsPerCell float64, r domain.GridData, traversableCost Cost) error

RasterPNG4 rasterizes a PNG using the production selector without wall aura.

func RasterPNG4WithAura

func RasterPNG4WithAura(path string, pixelsPerCell float64, r domain.GridData, traversableCost Cost, auraRadius int) error

RasterPNG4WithAura is the production map-image rasterizer used by grid.FromImg. It selects the paletted fast path when possible and falls back to generic PNG handling.

func RasterRectangle

func RasterRectangle(pv0, pv1, pv2, pv3 Vec2, cost Cost, canvasScale float64, r domain.GridData)

RasterRectangle maps world-space rectangle corners to grid cells and draws them as two triangles.

func RasterTriangle

func RasterTriangle(t *Triangle, cost Cost, r domain.GridData)

RasterTriangle adds cost to every grid cell covered by the triangle using cell-center sampling and clipping to the target region bounds.

func ValidTriangle

func ValidTriangle(polygon *orb.Polygon) bool

ValidTriangle accepts one closed ring with three non-collinear points.

Types

type Cost

type Cost = pubdomain.Cost

Cost is the traversal-cost type written by rasterizers.

type Triangle

type Triangle struct {
	A, B, C Vec2
}

Triangle is the raster primitive used after polygons or rectangles are split into three-point shapes.

func NewTriangle

func NewTriangle(polygon *orb.Polygon) Triangle

NewTriangle converts a valid three-point polygon into a raster triangle.

type Vec2

type Vec2 = domain.Vec2

Vec2 is the 2D vector type used by raster geometry.

Jump to

Keyboard shortcuts

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