genmarchingsquares

package
v0.0.0-...-ce97658 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

README

genmarchingsquares

This package provides a simple implementation of the marching squares algorithm for illustrative purposes for now.

Be warned... Right now I am implementing this blindly without looking anything up, so who knows if what I am doing is correct.

Scope

Create a package that takes a pixel field and outputs a 2d grid of tiles representing the contours of said field.

alt text

Done
  • 2d boolean input field
  • 2d output grid of tiles encoded as 4 bit values
  • Simple export to PNG in garish colors
  • Rotate the tile templates for different orientations
  • Draw the pixel states on the exported PNG
TODO
  • Scalar input field
    • Threshold value for contour detection
    • Interpolation of output grid based on scalar values
  • Fix x/y coordinate handling (the array indices are flipped)
  • Simplify tile drawing
  • Documentation
  • Make code nicer

Reference

Documentation

Overview

Package genmarchingsquares implements the marching squares algorithm. See: https://en.wikipedia.org/wiki/Marching_squares

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportToPNG

func ExportToPNG(squares [][]byte, dimX, dimY, tileSize int, filename string) error

ExportToPNG exports the given encoded tiles to PNG.

func MarchSquares

func MarchSquares(pixels [][]bool, dimX, dimY int) [][]byte

MarchSquares returns a grid of tiles encoded as 4 bit values that are generated from the given pixel grid.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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