All Projects β†’ nhartland β†’ forma

nhartland / forma

Licence: MIT license
A Lua toolkit for computational geometry on a grid

Programming Languages

lua
6591 projects
shell
77523 projects

Projects that are alternatives of or similar to forma

AsLib
🎨: RPG map maker (paint tool)
Stars: ✭ 82 (+141.18%)
Mutual labels:  procedural-generation
sandbox
2D Pixel Physics Simulator
Stars: ✭ 76 (+123.53%)
Mutual labels:  cellular-automata
martinez-src
Mirrored implementations of polygon clipping/CSG/operations algorithm, in C (original, by MartΓ­nez et al) and ActionScript3 (port, by Mahir Iqbal)
Stars: ✭ 34 (+0%)
Mutual labels:  geometry2d
Procedural-Terrain-Generator-OpenGL
Procedural terrain generator with tessellation | C++ OpenGL 4.1
Stars: ✭ 98 (+188.24%)
Mutual labels:  procedural-generation
sprite-gen
🎨 Procedurally generate 2D sprites
Stars: ✭ 68 (+100%)
Mutual labels:  procedural-generation
civarium
isometric software vivarium that simulates a mini civilization
Stars: ✭ 18 (-47.06%)
Mutual labels:  procedural-generation
pixel-sprite-generator
html5 random pixel sprite generator
Stars: ✭ 22 (-35.29%)
Mutual labels:  procedural-generation
poisson-disk-sampling
Poisson disk sampling in arbitrary dimensions
Stars: ✭ 147 (+332.35%)
Mutual labels:  procedural-generation
LifeBrush
A toolkit for painting agent-based mesoscale molecular simulations and illustrations.
Stars: ✭ 38 (+11.76%)
Mutual labels:  procedural-generation
caves
2D Cave Exploration Game with Procedurally Generated Levels
Stars: ✭ 29 (-14.71%)
Mutual labels:  procedural-generation
GraphTerm
GraphTerm: An aspirational DevOps and Container IDE Concept
Stars: ✭ 25 (-26.47%)
Mutual labels:  procedural-generation
Procedural-Terrain-Generation
3D computer graphics program in C++ OpenFrameworks of a procedural terrain generator based on simplex noise with camera movement and real-time adjustable parameters from the GUI
Stars: ✭ 18 (-47.06%)
Mutual labels:  procedural-generation
DrawSpace
Space-game oriented rendering engine
Stars: ✭ 20 (-41.18%)
Mutual labels:  procedural-generation
artistoo
CPM implementation in pure JavaScript
Stars: ✭ 25 (-26.47%)
Mutual labels:  cellular-automata
namegen
A library and CLI program for generating random names, written in Go.
Stars: ✭ 24 (-29.41%)
Mutual labels:  procedural-generation
DungeonGenerator
Procedural Dungeon Generation with Python and Pygame
Stars: ✭ 57 (+67.65%)
Mutual labels:  procedural-generation
lua-namegen
Lua Name Generator
Stars: ✭ 48 (+41.18%)
Mutual labels:  procedural-generation
cellular-automata-explorer
(WIP) An interactive web app for exploring cellular automata.
Stars: ✭ 18 (-47.06%)
Mutual labels:  cellular-automata
voxigen
Voxel handling library for game development, threaded generation/io/meshing with openGL rendering.
Stars: ✭ 47 (+38.24%)
Mutual labels:  procedural-generation
nutshell
[alpha!] [on hiatus] An advanced cellular-automaton-specification language that transpiles to Golly's.
Stars: ✭ 16 (-52.94%)
Mutual labels:  cellular-automata

Build Status Coverage Status License

forma

2D grid shape generation in Lua

forma is a utility library for the procedural generation and manipulation of shapes on a two dimensional grid or lattice. It came about as part of experiments in making roguelike games. forma is therefore particularly suited (but not limited) to the generation of roguelike environments.

Features

  • A spatial-hashing pattern class for fast lookup of active cells.
  • Pattern manipulators such as the addition, subtraction, rotation and reflection of patterns.
  • Rasterisation algorithms for 2D primitives, e.g lines, circles, squares and Bezier curves.
  • A very flexible cellular automata implementation with
    • Synchronous and asynchronous updates
    • Combination of multiple rule sets
  • Pattern sampling algorithms including
    • Random (white noise) sampling
    • Perlin noise sampling
    • Poisson-disc sampling
    • Mitchell's best-candidate sampling
  • Algorithms for subpattern finding including
    • Flood-fill contiguous segment finding
    • Convex hull finding
    • Pattern edge and surface finding
    • Binary space partitioning
    • Voronoi tessellation / Lloyd's algorithm

Results can be nested to produce complex patterns, and all of these methods are able to use custom distance measures and definitions of the cellular neighbourhood (e.g Moore, von Neumann).

Examples

-- Generate a square box to run the CA inside
local domain = primitives.square(80,20)

-- CA initial condition: 800-point random sample of the domain
local ca = subpattern.random(domain, 800)

-- Moore (8-cell) neighbourhood 4-5 rule
local moore = automata.rule(neighbourhood.moore(), "B5678/S45678")

-- Run the CA until converged or 1000 iterations
local ite, converged = 0, false
while converged == false and ite < 1000 do
    ca, converged = automata.iterate(ca, domain, {moore})
    ite = ite+1
end

-- Access a subpattern's cell coordinates for external use
for icell in ca:cells() do
    -- local foo = bar(icell)
    -- or
    -- local foo = bar(icell.x, icell.y)
end

-- Find all 4-contiguous segments of the CA pattern
-- Uses the von-neumann neighbourhood to determine 'connectedness'
-- but any custom neighbourhood can be used.
local segments = subpattern.segments(ca, neighbourhood.von_neumann())

-- Print a representation to io.output
subpattern.print_patterns(domain, segments)

Installation

forma is compatible with Lua 5.1, 5.2, 5.3 and LuaJIT 2.0, 2.1. The library is written in pure Lua, no compilation is required. Including the project is as simple as including the forma directory in your project or Lua path.

The easiest way to do this is via LuaRocks. To install the latest stable version use:

    luarocks install forma

Alternatively you can try the dev branch with:

    luarocks install --server=http://luarocks.org/dev forma

Documentation

Documentation is hosted here.

Generating the documentation requires

Simply running

ldoc --output contents --dir docs .

in the root directory should generate all the required pages.

Testing

Unit tests and coverage reports are provided. The test suite requires

To run the tests use

./run_tests.sh
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].