Skip to content

Commit

Permalink
Merge pull request #12 from nhartland/dev
Browse files Browse the repository at this point in the history
Version 0.4
  • Loading branch information
nhartland committed Jan 7, 2019
2 parents 50305ec + 50f76d8 commit ce9ef8c
Show file tree
Hide file tree
Showing 46 changed files with 646 additions and 85 deletions.
12 changes: 12 additions & 0 deletions .ldoctest
@@ -0,0 +1,12 @@
-- Environment for `forma` ldoctests
return {
math = math,
assert = assert,
print = function() end,
cell = require('forma.cell'),
pattern = require('forma.pattern'),
automata = require('forma.automata'),
primitives = require('forma.primitives'),
subpattern = require('forma.subpattern'),
neighbourhood = require('forma.neighbourhood'),
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Expand Up @@ -60,3 +60,16 @@
- Slightly faster convergence check for `automata.iterate`
- Harmonised coordinate handling between pattern prototype and tostring


0.4
---------

# Features
- Perlin noise sampling
- Quadratic Bezier curve drawing.

# Misc
- Check that CA rule sets don't have neighbourhoods that are too large for
the rule signature format (>10 neighbours)
- Fixed some typos in usage examples
- Setup forma documentation example checking with `ldoctest`
14 changes: 11 additions & 3 deletions README.md
Expand Up @@ -21,12 +21,13 @@ suited (but not limited) to the generation of roguelike environments.

- **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.
- **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
Expand Down Expand Up @@ -69,7 +70,7 @@ 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)
-- but any custom neighbourhood can be used.
local segments = subpattern.segments(ca, neighbourhood.von_neumann())

-- Print a representation to io.output
Expand All @@ -82,12 +83,19 @@ subpattern.print_patterns(domain, segments)
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:
The easiest way to do this is via LuaRocks. To install the latest stable version
use:

```Shell
luarocks install forma
```

Alternatively you can try the dev branch with:

```Shell
luarocks install --server=http://luarocks.org/dev golflike
```

## Documentation

Documentation is hosted [here](https://nhartland.github.io/forma/).
Expand Down
7 changes: 6 additions & 1 deletion docs/contents.html
Expand Up @@ -51,6 +51,7 @@ <h2>Examples</h2>
<li><a href="examples/corridors.lua.html">corridors.lua</a></li>
<li><a href="examples/isolines.lua.html">isolines.lua</a></li>
<li><a href="examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><a href="examples/perlin.lua.html">perlin.lua</a></li>
<li><a href="examples/readme.lua.html">readme.lua</a></li>
<li><a href="examples/sampling.lua.html">sampling.lua</a></li>
<li><a href="examples/voronoi.lua.html">voronoi.lua</a></li>
Expand Down Expand Up @@ -127,6 +128,10 @@ <h2>Examples</h2>
<td class="name" nowrap><a href="examples/maxrectangle.lua.html">maxrectangle.lua</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="examples/perlin.lua.html">perlin.lua</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="examples/readme.lua.html">readme.lua</a></td>
<td class="summary"></td>
Expand All @@ -145,7 +150,7 @@ <h2>Examples</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/async_automata.lua.html
Expand Up @@ -41,6 +41,7 @@ <h2>Examples</h2>
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li>
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li>
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><a href="../examples/perlin.lua.html">perlin.lua</a></li>
<li><a href="../examples/readme.lua.html">readme.lua</a></li>
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li>
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li>
Expand Down Expand Up @@ -107,7 +108,7 @@ <h2>async_automata.lua</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/binary_space_partition.lua.html
Expand Up @@ -41,6 +41,7 @@ <h2>Examples</h2>
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li>
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li>
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><a href="../examples/perlin.lua.html">perlin.lua</a></li>
<li><a href="../examples/readme.lua.html">readme.lua</a></li>
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li>
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li>
Expand Down Expand Up @@ -81,7 +82,7 @@ <h2>binary_space_partition.lua</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/bubbles.lua.html
Expand Up @@ -41,6 +41,7 @@ <h2>Examples</h2>
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li>
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li>
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><a href="../examples/perlin.lua.html">perlin.lua</a></li>
<li><a href="../examples/readme.lua.html">readme.lua</a></li>
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li>
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li>
Expand Down Expand Up @@ -91,7 +92,7 @@ <h2>bubbles.lua</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/cellular_automata.lua.html
Expand Up @@ -41,6 +41,7 @@ <h2>Examples</h2>
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li>
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li>
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><a href="../examples/perlin.lua.html">perlin.lua</a></li>
<li><a href="../examples/readme.lua.html">readme.lua</a></li>
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li>
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li>
Expand Down Expand Up @@ -94,7 +95,7 @@ <h2>cellular_automata.lua</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/corridors.lua.html
Expand Up @@ -41,6 +41,7 @@ <h2>Examples</h2>
<li><strong>corridors.lua</strong></li>
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li>
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><a href="../examples/perlin.lua.html">perlin.lua</a></li>
<li><a href="../examples/readme.lua.html">readme.lua</a></li>
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li>
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li>
Expand Down Expand Up @@ -99,7 +100,7 @@ <h2>corridors.lua</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/isolines.lua.html
Expand Up @@ -41,6 +41,7 @@ <h2>Examples</h2>
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li>
<li><strong>isolines.lua</strong></li>
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><a href="../examples/perlin.lua.html">perlin.lua</a></li>
<li><a href="../examples/readme.lua.html">readme.lua</a></li>
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li>
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li>
Expand Down Expand Up @@ -102,7 +103,7 @@ <h2>isolines.lua</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/maxrectangle.lua.html
Expand Up @@ -41,6 +41,7 @@ <h2>Examples</h2>
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li>
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li>
<li><strong>maxrectangle.lua</strong></li>
<li><a href="../examples/perlin.lua.html">perlin.lua</a></li>
<li><a href="../examples/readme.lua.html">readme.lua</a></li>
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li>
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li>
Expand Down Expand Up @@ -85,7 +86,7 @@ <h2>maxrectangle.lua</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
94 changes: 94 additions & 0 deletions docs/examples/perlin.lua.html
@@ -0,0 +1,94 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>forma Reference</title>
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>forma</h1>

<ul>
<li><a href="../contents.html">Index</a></li>
</ul>



<h2>Examples</h2>
<ul class="nowrap">
<li><a href="../examples/async_automata.lua.html">async_automata.lua</a></li>
<li><a href="../examples/binary_space_partition.lua.html">binary_space_partition.lua</a></li>
<li><a href="../examples/bubbles.lua.html">bubbles.lua</a></li>
<li><a href="../examples/cellular_automata.lua.html">cellular_automata.lua</a></li>
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li>
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li>
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><strong>perlin.lua</strong></li>
<li><a href="../examples/readme.lua.html">readme.lua</a></li>
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li>
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/forma.cell.html">forma.cell</a></li>
<li><a href="../modules/forma.pattern.html">forma.pattern</a></li>
<li><a href="../modules/forma.primitives.html">forma.primitives</a></li>
<li><a href="../modules/forma.subpattern.html">forma.subpattern</a></li>
<li><a href="../modules/forma.automata.html">forma.automata</a></li>
<li><a href="../modules/forma.neighbourhood.html">forma.neighbourhood</a></li>
</ul>
<h2>Readme</h2>
<ul class="nowrap">
<li><a href="../readme/README.md.html">README</a></li>
</ul>

</div>

<div id="content">

<h2>perlin.lua</h2>
<pre>
<span class="comment">-- Perlin noise sampling
</span><span class="comment">-- Here we sample a square domain pattern according to perlin noise,
</span><span class="comment">-- generating three new patterns consisting of the noise thresholded at
</span><span class="comment">-- values of 0, 0.5 and 0.7.
</span>
<span class="keyword">local</span> subpattern = <span class="global">require</span>(<span class="string">'forma.subpattern'</span>)
<span class="keyword">local</span> primitives = <span class="global">require</span>(<span class="string">'forma.primitives'</span>)

<span class="keyword">local</span> domain = primitives.square(<span class="number">80</span>,<span class="number">20</span>)
<span class="keyword">local</span> frequency, depth = <span class="number">0.2</span>, <span class="number">1</span>
<span class="keyword">local</span> thresholds = {<span class="number">0</span>, <span class="number">0.5</span>, <span class="number">0.7</span>}
<span class="keyword">local</span> noise = subpattern.perlin(domain, frequency, depth, thresholds)

<span class="comment">-- Print resulting pattern segments
</span>subpattern.print_patterns(domain, noise, {<span class="string">'.'</span>, <span class="string">'+'</span>, <span class="string">'o'</span>})</pre>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
3 changes: 2 additions & 1 deletion docs/examples/readme.lua.html
Expand Up @@ -41,6 +41,7 @@ <h2>Examples</h2>
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li>
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li>
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><a href="../examples/perlin.lua.html">perlin.lua</a></li>
<li><strong>readme.lua</strong></li>
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li>
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li>
Expand Down Expand Up @@ -112,7 +113,7 @@ <h2>readme.lua</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/sampling.lua.html
Expand Up @@ -41,6 +41,7 @@ <h2>Examples</h2>
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li>
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li>
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><a href="../examples/perlin.lua.html">perlin.lua</a></li>
<li><a href="../examples/readme.lua.html">readme.lua</a></li>
<li><strong>sampling.lua</strong></li>
<li><a href="../examples/voronoi.lua.html">voronoi.lua</a></li>
Expand Down Expand Up @@ -93,7 +94,7 @@ <h2>sampling.lua</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/voronoi.lua.html
Expand Up @@ -41,6 +41,7 @@ <h2>Examples</h2>
<li><a href="../examples/corridors.lua.html">corridors.lua</a></li>
<li><a href="../examples/isolines.lua.html">isolines.lua</a></li>
<li><a href="../examples/maxrectangle.lua.html">maxrectangle.lua</a></li>
<li><a href="../examples/perlin.lua.html">perlin.lua</a></li>
<li><a href="../examples/readme.lua.html">readme.lua</a></li>
<li><a href="../examples/sampling.lua.html">sampling.lua</a></li>
<li><strong>voronoi.lua</strong></li>
Expand Down Expand Up @@ -85,7 +86,7 @@ <h2>voronoi.lua</h2>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2018-08-08 18:12:10 </i>
<i style="float:right;">Last updated 2019-01-07 21:10:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
Expand Down

0 comments on commit ce9ef8c

Please sign in to comment.