gomjau-hogg
v0.1.1
Published
Gomjau-hogg notation tessellations of regular polygons
Downloads
900
Maintainers
Readme
This is a FORK of the original Antwerp.
The original Antwerp can be found on Github.
The major differences are:
- the original Antwerp has a better demo
- runs optimally in
O(n)
; original runs inO(n^3)
(wheren
is the number of tiles) - 🔥blazingly fast🔥 - under a micro-second per tiled shape
Demo
Installation
npm install gomjau-hogg
Usage
import { toShapes } from 'gomjau-hogg';
// Any tesselation in GomJau-Hogg notation
const configuration = '6-4-3,3/m30/r(h1)';
// transformation repetition count ~ c*sqrt of number of shapes tiled,
// e.g. `15` results in `1099` tiles for the above configuration
const repeatCount = 15;
// size of sidelength of shapes
const shapeSize = 25;
const data = toShapes(configuration, repeatCount, shapeSize);
// `data` will be:
{
maxStage: 9,
maxStagePlacement: 4,
shapes: [
{
"sides": 6, // number of sides of shape -> hexagon in this case
"stage": 0, // transformation stage -> 0 means seed placement
"stagePlacement": 1, // stage within each transformation - can be used for coloring
"θm": -6, // the rotation angle of the shape in 𝜋/12 increments
"c": [0,0] // shape centroid
},
{ "sides": 4, "stage": 0, "stagePlacement": 2, "θm": 16, "c": [ 13.660254037844375, 23.660254037844393 ] },
...
],
transformPointsMaps: [Map(...)] // map of transform points
}
To get the actual vertices of a shape just call:
const { c, θm, sides } = shape;
fromCentroidAndAngle(c, θm, sides, shapeSize); //=> array of points, i.e. `points: number[][]`
Demo Notes
The demo has been hacked from the original and for the purpose of testing the library so lots of functionality has been removed mostly because I struggled (and didn't have the time) getting things (mostly the newest version of React Router and preshape) working but it's relatively easy to fix all the shortcomings.
Most notably:
- no web workers
repeatCount
replacesmaxRepeat
in the web address search params- cannot directly edit notation - must use the library
- options can only be set in the addess bar, an example being
- https://florissteenkamp.github.io/gomjau-hogg/?configuration=6-4-3%2C3%2Fm30%2Fr(h1)&repeatCount=20&shapeSize=20
- several minor omissions, e.g. only one way of coloring, doesn't display transforms, etc.