-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Before I explain my suggestion, allow me to copy/paste the current .cfdg I am working on; it was
written by someone else for a grass-pattern.
startshape field
tile {s 150 }
background { hue 83.1 sat 0.4664 b -0.1255}
rule field
{
grass{hue 97.6 sat 0.7282 b 0.7647}
}
# Add a chance to add a seedling.
rule grass 5
{
seedling{}
grass{}
}
rule grass
{
grass{b 0.2}
}
rule grass
{
grass{b -0.1}
}
rule grass
{
grass{hue 0.1}
}
rule grass
{
grass{hue -.1}
}
rule grass
{
grass{sat 0.01}
}
rule grass
{
grass{sat -.01}
}
rule grass 10
{
grass{r 5}
}
rule grass 10
{
grass{r -5}
}
rule grass
{
grass{r 180}
}
rule grass
{
grass{x 10}
}
rule grass
{
grass{x -10}
}
rule grass
{
grass{y 10}
}
rule grass
{
grass{y -10}
}
rule grass 0.01
{
// end
}
rule seedling
{
SQUARE{}
seedling{y 1 r -2 s 0.991}
}
rule seedling
{
SQUARE{}
seedling{y 1 r 2 s 0.991}
}
I have been thinking about that. The rule {} entries actually look like method
calls in a programming language.
We also have things such as:
rule grass 5
which I think is ultimately a probability value, right?
So what if we could actually turn that into a programming-language or programming-like
language?
Say we have a common entry point which we call "main". That way we can remove the
startshape-clause. Each individual rule could be constructed like a method.
For example:
rule grass 5
{
seedling{}
grass{}
}
Could perhaps become:
def grass(probability: 5)
seedling()
grass()
We could use python-like syntax based on indent, or ruby-like syntax where
each "def" ends with "end". (I don't like the python requirement for a ":" after
the def, though. Indent alone should be enough.)
So why do I make this suggestion at all? Well, I think that the existing way to
build up such a context-free generated image, could also be done in a
programming-centric fashion. Perhaps this may be simpler for some folks.
We could also use aliases so that things such as "b -1.0" could be more
verbose, if the user wants to.
For example:
{y 1 r -2 s 0.991}
I think many new users have no idea what these single letters mean. They
can look at the wiki, yes, but I wonder whether it may not be better to simply
allow for a style such as:
y_axis: 1
radius: -2
scale: 0.991
(I made up the names here, but you get the idea.)
Anyway - not sure how likely it is to add alternative set of rules or grammar
but I wanted to suggest it. Note that I do NOT mean to obsolete the old
rules! These should be kept for many reasons, including compatibility,
but also because many other users will probably prefer the old way. Thus
my suggestion is for an ADDITIONAL way. (And perhaps we can cross-translate
it once it exists, so people can always adjust to what they prefer to use.)
Please feel free to close this issue - it is mostly meant as a suggestion for
future changes.