rect

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

rect is a subpackage for generating labyrinth walls of type []image.Rectangle

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawWallsToImage

func DrawWallsToImage(walls []image.Rectangle, img *image.RGBA)

DrawWallsToImage draws the wall rectangles onto an RGBA image

func FillRectangle

func FillRectangle(img *image.RGBA, rect image.Rectangle, fillColor color.Color)

FillRectangle is a utility function to fill a single rectangle on an RGBA image

Types

type Cell

type Cell struct {
	X, Y    int
	Visited bool
	Walls   [4]bool // North, East, South, West
}

Cell represents a single cell in the maze grid

type Direction

type Direction int

Direction represents the four cardinal directions

const (
	North Direction = iota
	East
	South
	West
)

type MazeGenerator

type MazeGenerator struct {
	WallThickness int
	Width, Height int
	CellSize      int
	Grid          [][]Cell
	// contains filtered or unexported fields
}

MazeGenerator holds the maze state

func NewMazeGenerator

func NewMazeGenerator(width, height, cellSize, wallThickness int) *MazeGenerator

NewMazeGenerator creates a new maze generator

func (*MazeGenerator) GenerateMaze

func (mg *MazeGenerator) GenerateMaze() []image.Rectangle

GenerateMaze creates a maze using depth-first search algorithm

func (*MazeGenerator) Size added in v1.1.0

func (mg *MazeGenerator) Size() image.Point

Size returns the size of the maze in pixels.

The size is calculated as the number of cells multiplied by the cell size, plus the wall thickness to account for the walls around the maze.

Jump to

Keyboard shortcuts

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