Skip to content

[work in progress] – Use Lindenmayer systems as SVG patterns.

License

Notifications You must be signed in to change notification settings

derhuerst/svg-patterns-lindenmayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

svg-patterns-lindenmayer

Use Lindenmayer systems as SVG patterns. Work in progess. In particular, the following is missing:

  • tests
  • helpful example code that yields a nice-looking pattern
  • publishing to npm
  • compatibility with svg-patterns

npm version build status ISC-licensed chat on gitter

Installing

npm install svg-patterns-lindenmayer

Usage

const generate = require('svg-patterns-lindenmayer')

const svg = generate(5, 'A', {
	A: 'B',
	B: 'F++OB'
})

console.log(svg)

API

generate(iterations, axiom, rules, [opt])

iterations should be an integer >0. It determines how often rule identifiers in axiom will be evaluated.

axiom must be a string of multiple rule identifiers (e.g. 'AA[B+]') or an array of individual identifiers (e.g. ['A'. 'A', '[', 'B', '+', ']']).

rules must be an object. Each key is a rule identifier, each value must be a string of rule identifiers (e.g. AB) or an array of rule identifiers (e.g. ['A', 'B']), which will be used during evaluation.

opt is optional and must be an object. It may have the following keys:

  • colors: An array of colors to be used.
  • distance: The distance to move forward. Used by e.g. F, M.
  • atoms: An object of atoms. Each key is the identifier of the atom. Each value must be a function which executes a rendering operation. See the source code for details.

Contributing

If you have a question or have difficulties using svg-patterns-lindenmayer, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

About

[work in progress] – Use Lindenmayer systems as SVG patterns.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages