A beginners guide...?

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
boork
Posts: 14
Joined: Fri May 06, 2005 9:14 am
Location: london
Contact:

A beginners guide...?

Post 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!
when everything is connected, for better or for worse, everything matters.

User avatar
mtnviewmark
Site Admin
Posts: 81
Joined: Wed May 04, 2005 12:46 pm
Location: Mountain View, CA
Contact:

Post 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
I'm the "m" in "mtree.cfdg"

boork
Posts: 14
Joined: Fri May 06, 2005 9:14 am
Location: london
Contact:

Post 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...
when everything is connected, for better or for worse, everything matters.

Pornboy

Post 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.

Pornboy

Post 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.'

Pornboy

One final note

Post 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.

shevegen
Posts: 57
Joined: Wed Jul 06, 2005 5:38 am

Post 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. :>

Post Reply