Comments (5)
Hi @alfongj! Could you add some more detail why you opened this issue, are you missing some features or documentation?
Assuming the latter, parametric L-Systems are in fact supported. As a starting point you may refer to the docs which have some details and examples regarding parametric L-System usage.
from lindenmayer.
Really? That's exciting. I couldn't make it work and saw:
- on README.md "Most stuff should work. I am currently working on parametric L-System support.".
- that the getting started guide for parametric isn't written
So I thought it wasnt :)
I'm going to give it another try and resort back; maybe there's a bug on my code or I found a bug in the library
from lindenmayer.
Good find! Both the broken link and that statement are outdated. Changed them. ;)
Parametric L-Systems as described in the docs and readme should work. You can also take a look at the unit tests to see some more working examples. Since the tests are run before a version is released, you can be sure that the test examles will work.
However note, that the classic syntax for parametric L-Systems as defined by Prusinkiewicz and Lindenmayer in 1990 will not work. This library does not try to replicate the exact functionality as described in the book, but offers a different, more JS-idiomatic approach to parametric L-Systems. So if you were looking to 1:1 reproduce the examples from the book, this won't be possible I am afraid.
Symbols in L-Systems axioms and productions in this library are defined exclusively via JS objects (see docs + readme).
However, I wouldn't see it as a disadvantages, since it gives you a lot flexibility and interoparabilty with your own code.
from lindenmayer.
I found the issue.
If you define a parametric's system axiom as a simple string (e.g. "X") and then have parametric productions, then it doesn't work -- "axiom" moving forward will always be a string and never store objects for parts produced on parametric productions.
I think the bug is on the function applyProductions()
The way to fix this is to pass an axiom with objects from the get go
from lindenmayer.
if (typeof newAxiom === 'string') {
newAxiom += result;
} else if (result instanceof Array) {
// If result is an array, merge result into new axiom instead of pushing.
newAxiom.push(...result);
} else {
newAxiom.push(result);
}
Here you may want to either throw an error if typeof newAxiom === 'string' but results are objects, or add a branch that transforms the existing axiom into an object based representation and merge with the new results
from lindenmayer.
Related Issues (20)
- Should we have built-in support for conditional productions, stochastic productions? HOT 16
- better setProduction docs
- How to have a production with multiple parameterised inputs HOT 3
- Make LSystem an overrideable ES6 class HOT 8
- benchmark L-Systems that are functional equal but differ in data types
- auto-conversion strings/list
- improve documentation HOT 1
- multiple productions on same symbol: object order not preserved
- transformClassicCSProduction being passed two arguments but only accepting one HOT 3
- help wanted: audit/improve CS-matching function
- use multi-element push instead
- context sensitive productions with contexts for left and right are only checked for left side
- How to make this library work in Internet Explorer? HOT 13
- FR: Pseudorandom number generators for stochastic functions
- More diverse examples
- a-frame component
- How to render tree leaves on a second pass, so they overlay branches? HOT 5
- multiple classic context sensitive productions
- add option to treat all production lists stochastically HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lindenmayer.