Hi,
As a begginer to context free grammer, i am still finding it hard to write the code properly, i have read through the lesson example, which has helped, but am still a bit stuck...
First, what are all the possible start shapes cfdg is programmed to recognise? Is there a list of possible startshapes, or am i misunderstanding this?
At the moment, i am basically trying to look at other peoples code, modify, and see what happens, but if someone can start posting tips for beginners, i would be very gratefull!
A beginners guide...?
Moderators: MtnViewJohn, chris, mtnviewmark
A beginners guide...?
when everything is connected, for better or for worse, everything matters.
- mtnviewmark
- Site Admin
- Posts: 81
- Joined: Wed May 04, 2005 12:46 pm
- Location: Mountain View, CA
- Contact:
The startshape statement can name any shape you like. You generally name one of your own shapes. You define your shapes with rile statements. The only two pre-progeammed shapes are CIRCLE and SQUARE.
So:
just draws a circle
Whereas:
draws the two shapes in your rule
So:
Code: Select all
startshape CIRCLE
Whereas:
Code: Select all
startshape Any_Shape_Name_You_Care_To_Invent
rule Any_Shape_Name_You_Care_To_Invent {
CIRCLE { }
SQUARE { x 1.5 }
}
I'm the "m" in "mtree.cfdg"
ahh, yes!
o.k, that makes sense, you name a shape, then state what that shape is.
startshape boork
rule boork {
CIRCLE { }
SQUARE { x 0.1 }
}
Then you call on this shape, with another rule, and tell it to rotate, or change brightness etc...
Thanks, this is a very helpfull tip...
o.k, that makes sense, you name a shape, then state what that shape is.
startshape boork
rule boork {
CIRCLE { }
SQUARE { x 0.1 }
}
Then you call on this shape, with another rule, and tell it to rotate, or change brightness etc...
Thanks, this is a very helpfull tip...
when everything is connected, for better or for worse, everything matters.
Besides the CIRCLE and SQUARE commands, there are four (maybe more, I'm just experimenting m'self) instructions you can pass to a rule: x, y, r, and s. x & y are relative distance, r is rotation in degrees, and s is scale. Distances with x & y scale with the s instruction. Example:
startshape TENDRIL
rule TENDRIL{
SQUARE{}
TENDRIL{x 1 r 1 s .99}
}
There's more, like the unusual 'RULENAME integer {}' seen in the second rule SPIKE in the snowflake program. I'm hoping that there's some instruction manual online and I've just missed it, because as fun as it is toying with the examples, I'm simply baffled at times.
startshape TENDRIL
rule TENDRIL{
SQUARE{}
TENDRIL{x 1 r 1 s .99}
}
There's more, like the unusual 'RULENAME integer {}' seen in the second rule SPIKE in the snowflake program. I'm hoping that there's some instruction manual online and I've just missed it, because as fun as it is toying with the examples, I'm simply baffled at times.
I just got the use of an integer between the rule name and its brackets. It's a randomizer - if you have a rule named SPIKE and define
rule SPIKE 0.1 {}
then roughly one out of every ten times SPIKE{} is called, it will trigger SPIKE 0.1{} instead. I think the three letters next to the Save Image button are the seed value for randomizations. Multiple renderings with automatic advancement of said seed indicate that the number is only a likelihood and not a genuine 'one of every x.'
rule SPIKE 0.1 {}
then roughly one out of every ten times SPIKE{} is called, it will trigger SPIKE 0.1{} instead. I think the three letters next to the Save Image button are the seed value for randomizations. Multiple renderings with automatic advancement of said seed indicate that the number is only a likelihood and not a genuine 'one of every x.'
One final note
The author has been kind enough to include an example program with very nice explanations. The program is named Lesson, it's available under the Exmples drop-down menu, and I feel a bit foolish for missing it.
Someone can explain how to properly use the different values ?
x 0.91
y 0.91
Ok i can figure out what rotate is doing, about the others and the values I am not so sure.
Also, what happens when I have recursive functions that call themselves - i assume the values they generate becomes less and less (infinite down) ?
Yes, /me confused newbie. :>
x 0.91
y 0.91
Ok i can figure out what rotate is doing, about the others and the values I am not so sure.
Also, what happens when I have recursive functions that call themselves - i assume the values they generate becomes less and less (infinite down) ?
Yes, /me confused newbie. :>