Page 1 of 1

A beginners guide...?

Posted: Sat May 07, 2005 8:42 am
by boork
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!

Posted: Sat May 07, 2005 9:05 am
by mtnviewmark
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:

Code: Select all

startshape CIRCLE
just draws a 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 }
}
draws the two shapes in your rule

Posted: Sat May 07, 2005 9:17 am
by boork
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...

Posted: Tue Jul 05, 2005 4:11 pm
by Pornboy
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.

Posted: Tue Jul 05, 2005 5:04 pm
by Pornboy
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.'

One final note

Posted: Tue Jul 05, 2005 9:38 pm
by Pornboy
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.

Posted: Wed Jul 06, 2005 5:07 pm
by shevegen
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. :>