Barren tree

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
romulusnr
Posts: 13
Joined: Wed Jul 06, 2005 2:50 pm
Location: Seattle

Barren tree

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

odinsdream
Posts: 12
Joined: Sat Jul 09, 2005 2:18 pm

Post by odinsdream »

Beautiful!

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

User avatar
chris
Site Admin
Posts: 72
Joined: Wed May 04, 2005 10:57 am
Location: New York, NY
Contact:

Post by chris »

It's separate scaling along the (relative) x and y axes.
Current Project: I'm creative director of OKCUPID at http://www.okcupid.com

odinsdream
Posts: 12
Joined: Sat Jul 09, 2005 2:18 pm

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

User avatar
chris
Site Admin
Posts: 72
Joined: Wed May 04, 2005 10:57 am
Location: New York, NY
Contact:

Post 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
Current Project: I'm creative director of OKCUPID at http://www.okcupid.com

odinsdream
Posts: 12
Joined: Sat Jul 09, 2005 2:18 pm

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

User avatar
chris
Site Admin
Posts: 72
Joined: Wed May 04, 2005 10:57 am
Location: New York, NY
Contact:

Post 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.
Current Project: I'm creative director of OKCUPID at http://www.okcupid.com

odinsdream
Posts: 12
Joined: Sat Jul 09, 2005 2:18 pm

Post by odinsdream »

Wow, neat stuff. Very powerful! Thanks!

Post Reply