forma: a toolkit for the manipulation of shapes on a 2D grid

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
Posts: 1
Joined: Fri Jun 08, 2018 8:40 pm

forma: a toolkit for the manipulation of shapes on a 2D grid

Post by alphabetr » Fri Jun 08, 2018 9:05 pm

Hi all,

Long time lurker here but this is my first post.

I've been working for a while on a little toolkit, something I've mainly been using for roguelike map generation.
It's a library in pure lua 5.1 for the manipulation of shapes and patterns on a 2D grid.

You can see it on github:
With documentation at:

It's a bit niche, but provides some handy stuff with (I hope) a reasonably natural API. Some examples of what it includes:

Basic features
  • A 'cell' class with normal (integer) vector operations
  • A 'pattern' class which holds a set of cells
  • A bunch of pattern primitives, for drawing circles, lines, squares etc
  • A bunch of basic manipulating functions, for shifting, enlarging, reflecting patterns.
A basic but flexible Cellular Automata implementation
  • Custom CA neighbourhoods and update rules
  • Synchronous and asynchronous updates
  • CA patterns can be 'nested' or generating inside the results of previous patterns
Helpers for generating 'subpatterns'
  • Flood-filling to determine contiguous areas (according to custom definitions of contiguous)
  • Voronoi tessellation
  • Binary space partitioning
  • Finding the largest contiguous rectangle in a pattern
  • Finding points on the inner/outer surface of patterns
I hope this can be useful for somebody, and please let me know if you have any feedback! There are examples on the github page, but here are some game specific applications where I have used forma for map/level design and generation.
  • [ASCII/Terminal] Golf course layout generation using nested CA.
  • [ASCII/Terminal] Building layout generation.
  • [Tiles/Love2D]] Building layout generation.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests