Page 1 of 1

Barren tree

Posted: Tue Jul 12, 2005 1:50 pm
by romulusnr
Somewhat more realistic than your traditional "tree fractal". I took my "intestine" code, took advantage of the 2-argument size function (upgrade to 1.1 needed I guess!) and changed it around to make this believable tree shape. Looks somewhat like sagebrush or a tumbleweed branch.

Code: Select all

startshape REALTREE

rule REALTREE {
  MOVE {}
}  

//tweak sizes for length

rule MOVE {
  STRIPE {}
  MOVE { r 20  y .9 x -.15  s .9}
}

rule MOVE {
  STRIPE {}
  MOVE { r -20 y .9 x .15 s .9}
}

//tweak weight for density

rule MOVE 2 {
  STRIPE {}
  MOVE { r 20  y .9 x -.15 s .8}
  MOVE { r -20  y .9 x .15 s .8}
}

rule STRIPE {
SQUARE {s .1 1}
CIRCLE { s .1 y .5 }
CIRCLE { s .1 y -.5 }
}

Posted: Tue Jul 12, 2005 6:38 pm
by odinsdream
Beautiful!

Can someone explain the two-argument size thing? Where is this documented?

Posted: Tue Jul 12, 2005 6:57 pm
by chris
It's separate scaling along the (relative) x and y axes.

Posted: Tue Jul 12, 2005 7:06 pm
by odinsdream
Where is it documented? I'm interested in learning all I can about the CFDG syntax as possible, and while it's nice to pick up things here and there on the forums, a formal reference would be great.

Posted: Tue Jul 12, 2005 7:57 pm
by chris
there's no official documentation yet, other than the examples and lesson that come with Context Free.

The reason is that we're expanding the language and about to finalize it with colors, blending, etc.

I've been working on a more extensive tutorial, but it's not done yet and I'm waiting for the language to be completed.

In the meantime, people here can answer questions of any kind. There are only a few commands in the language.

-cc

Posted: Wed Jul 13, 2005 7:17 am
by odinsdream
Well, I'm probably over-estimating the amount of things there are to learn about, but, for example, I recently came across code that involved a "skew" adjustment. I hadn't heard of this one before. So, right now, I know about:

size (one or two arguments, x and y scaling?)
brightness
skew (not exactly sure what it does)
rotation
x
y

I also know that rules can be in the form of:

rule NAME chance {
}

Where chance is an optional numerical argument from 0 to 100 that specifies the chance that this rule, as opposed to another identically-named, will be chosen. Is there more to the "rule" declaration than this, for instance?

Posted: Wed Jul 13, 2005 7:27 am
by chris
I think that's it. skew and relative sizing were just added this week, which is why they aren't in the examples yet. As soon as colors and blending are added, we'll come up with good examples and I'll finalize a tutorial.

A couple other things:

1. you can include files with the include directive.
2. putting a replacement in square brackets performs the transformations in order you list them instead of the "natural" order.

Example:

rule shape1 {
SQUARE {r 20 x 1 y 1}
}

puts a square at spot 1,1 rotated 20 degrees counter-clockwise

whereas

rule shape1 {
SQUARE [r 20 x 1 y 1]
}

rotates first, so the actual 1,1 placement is on a rotated coordinate plane. (relatively, of course!) A good example of where you wuold use this is drawing the face of a clock. It lets you avoid doing the trigonometry yourself or creating a separate rule to force the rotation first.

Posted: Wed Jul 13, 2005 7:38 am
by odinsdream
Wow, neat stuff. Very powerful! Thanks!