CF rocks! check it, made a "leaf"

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
Redi_jedi
Posts: 3
Joined: Mon Aug 14, 2006 8:20 pm

CF rocks! check it, made a "leaf"

Post by Redi_jedi »

Code: Select all

startshape FOO

rule FOO{
	LEAF[]
	STEM[s .1 .3 hue 0 saturation .4 b .5]
	//FOO2[x 5 s .99 r 10]
}
rule FOO2 .01 {
	FOO[flip 15]
}
rule FOO2 .01 {
	FOO[flip -15]
}
rule LEAF{
 REDI[z 1 s .8 r -90 h 90 b .6 saturation 1]
 REDI[z 1 s 1.2 r -45 h 90 b .6 saturation 1]
 REDI[z 1 s 1.3 r 0 h 90 b .6 saturation 1]
 REDI[z 1 s 1.5 r 45 h 90 b .6 saturation 1]
 REDI[z 1 s 1.3 r 90 h 90 b .6 saturation 1]
 REDI[z 1 s 1.2 r 135 h 90 b .6 saturation 1]
 REDI[z 1 s .8 r 180 h 90 b .6 saturation 1]

}
rule REDI{
	TRIANGLE[ r 20 s .7]
	RED[]
}

rule RED{
	REDI[x .2 y .2 s .91  r 3]
	
}
rule RED{
	REDI[x .2 y .2 s .91  r -3]
	
}
rule STEM{
	CIRCLE[s 2]
   CIRCLE[y -1 s 2]
	CIRCLE[y -2 s 2]
   CIRCLE[y -3 s 2]
	CIRCLE[y -4 s 2]
   CIRCLE[y -5 s 2]
	CIRCLE[y -6 s 2]
   CIRCLE[y -7 s 2]
}

nice little pot leaf, came out farily well i guess, for my first one anyway

theres some worthless code in there, cause i was trying to make a whole plant, but havent figured out how to place the leaves yet... and its time to leave work so...

Redi_jedi
Posts: 3
Joined: Mon Aug 14, 2006 8:20 pm

Post by Redi_jedi »

wow this program is pretty cool!
heres the whole plant
looks good on NIM

Code: Select all

startshape MAIN

rule MAIN{
s0[x -20]
//MAIN[ x 25 s .6]
//MAIN[ x -25 s .6]
//bud[x 50]
}
// no branches yet
rule s0{
SQUARE[hue 0 saturation .7 b .3]
s0[y 1.5 s .99]
}

rule s0 .5 {
s0[r 2]
}
rule s0 .5 {
s0[r -2]
}
rule s0 .1 {
s1[]
}

/////// main stalk
rule s1{
SQUARE[hue 0 saturation .7 b .3]
s1[y 1.5 s .99]
}

rule s1 .5 {
s1[r 2]
}
rule s1 .5 {
s1[r -2]

}

rule s1 .05 {
s2[r 45 s .9]
s1[]
s2[r 135 s .9]
}


//////// branches
rule s2 {
SQUARE[hue 0 saturation .4 b .5]
s2[x 1.5 s .99]
}
rule s2 .2 {
s2[r 3]
}
rule s2 .2 {
s2[r -3]
}
rule s2 .01{
s3[r -45]
s3[]
s3[r -130]
}

///////  shoots
rule s3{
SQUARE[hue 0 saturation .4 b .5]
s3[y 1.5 s .99]
}
rule s3 .5 {
s3[r 3]
}
rule s3 .5 {
s3[r -3]
}
rule s3 .015 {
FOO[s 5 x -1 a -.6 r 90 hue 40 saturation .5 b 0]
s3[]
}
rule s3 .015 {
FOO[s 5 x 1  a -.6 r -90 hue 20 saturation 1 b .3]
s3[]
}
rule s3 .1{
bud[z 2 s .9 a -.4]
s3[]
}
////// leaves

rule FOO{
   LEAF[s 1 r -45 r 45 hue 10 saturation .4 b .5]
 STEM[z 1 s 0.1618  r 0 hue 0 saturation .4 b .5]
}

rule LEAF{
 REDI[z 1 s .8 r -90 h 90 b .5 saturation 1]
 REDI[z 2 s 1.2 r -45 h 90 b .55 saturation 1]
 REDI[z 2 s 1.3 r 0 h 90 b .6 saturation 1]
 REDI[z 2 s 1.5 r 45 h 90 b .6 saturation 1]
 REDI[z 2 s 1.3 r 90 h 90 b .6 saturation 1]
 REDI[z 2 s 1.2 r 135 h 90 b .55 saturation 1]
 REDI[z 1 s .8 r 180 h 90 b .5 saturation 1]

}
rule REDI{
   TRIANGLE[ r 20 s .7]
   RED[]
}
rule RED  {
	REDI[h 4 b .04 saturation 0]
}
rule RED  {
	REDI[h -4 b -.02 saturation 0]
}

rule RED{
   REDI[x .2 y .2 s .91  r 3]
   
}
rule RED{
   REDI[x .2 y .2 s .91  r -3]
   
}
rule STEM{
   CIRCLE[s 2]
   CIRCLE[y -1 s 2]
   CIRCLE[y -2 s 2]
   CIRCLE[y -3 s 2]
   CIRCLE[y -4 s 2]
   CIRCLE[y -5 s 2]
   CIRCLE[y -6 s 2]
   CIRCLE[y -7 s 2]
}


rule bud{
s4[]
nug[]
} 
rule s4{
SQUARE[h 20 b .4 saturation .8]
s4[y 1.5 s .99]
}
rule s4 .3 {
s4[r 10]

}
rule s4 .3 {
s4[r -10]
}
rule s4 .5 {
nug[]
s4[]
}
rule nug{
CIRCLE[h 110 b .6 saturation 1]
nug[y 1 s .98 h 0 b 0 saturation 0]
}
rule nug .02 {
nug[r 60 ]
nug2[r -60 ]
}

rule nug2 {
CIRCLE[h 0 b .9 saturation 1]
nug2[y 1 s .98 h 0 b 0 saturation 0]
}
rule nug2 .02 {
nug[r 60 ]
nug2[r -60 ]
}
rule nug3 {
CIRCLE[h 110 b 1 saturation .1]
nug3[y 1 s .98 h 0 b 0 saturation 0]
}
rule nug3 .02 {
nug[r 60 ]
nug3[r -60 ]
}

Redi_jedi
Posts: 3
Joined: Mon Aug 14, 2006 8:20 pm

Post by Redi_jedi »

Q-bert anyone?

Code: Select all

startshape MAIN
rule MAIN {
 col{ y 0 x 0 z 0 s 1}
 col{ y 3 x -2 z -.1 s 1}
 col{ y 6 x -4 z -.1 s 1}
 col{ y 9 x -6 z -.1 s 1}
 col{ y 12 x -8 z -.1 s 1}
 col{ y 15 x -10 z -.1 s 1}
 col{ y 18 x -12 z -.1 s 1}
 col{ y 21 x -14 z -.1 s 1}
 col{ y 24 x -16 z -.1 s 1}
 col{ y 27 x -18 z -.1 s 1}
 col{ y 30 x -20 z -.1 s 1}
 col{ y 33 x -22 z -.1 s 1}
 col{ y 36 x -24 z -.1 s 1}
 col{ y 39 x -26 z -.1 s 1}
 col{ y 42 x -28 z -.1 s 1}

}





rule col {
 row{}
 row{ y 3 x 2 z -.1 s 1}
 row{ y 6 x 4 z -.1 s 1}
 row{ y 9 x 6 z -.1 s 1}
 row{ y 12 x 8 z -.1 s 1}
 row{ y 15 x 10 z -.1 s 1}
 row{ y 18 x 12 z -.1 s 1}
 row{ y 21 x 14 z -.1 s 1}
 row{ y 24 x 16 z -.1 s 1}
 row{ y 27 x 18 z -.1 s 1}
 row{ y 30 x 20 z -.1 s 1}
 row{ y 33 x 22 z -.1 s 1}
 row{ y 36 x 24 z -.1 s 1}
 row{ y 39 x 26 z -.1 s 1}
 row{ y 42 x 28 z -.1 s 1}


 //col{ y 3 x -2 z -.1 s 1}
}
//rule col .1 {
//}

rule row {
 box{}
 ///row{ y 3 x 2 z -.1 s 1}
}
//rule row .1 {
//box{}
//}

rule box {
 SQUARE{x 1 s 2 1 r 0 skew 0 45 b 1 sat .9 h 250 a 1 z 1}
 SQUARE{x -1 s 2 1 r 0 skew 0 -45 b 1 sat .9 h 350 a 1 z 1}
 SQUARE{y 1 x 1 s 2 1 r 0 skew 0 45 b 1 sat .9 h 250 a 1 z 1}
 SQUARE{y 1 x -1 s 2 1 r 0 skew 0 -45 b 1 sat .9 h 350 a 1 z 1}
 TOP{ y 2 }
}

rule TOP{
 SQUARE{y 0 s 2 1 r 0 skew 45 -45 b 1 sat .9 h 150 a 1 z .99}

}

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

Hi Redi_jedi,

There are some Context Free features that can save you a lot of work: loops and order-dependent adjustments. Your Q-bert design can be shrunk down to this:

Code: Select all

startshape MAIN 
rule MAIN { 
	15* {y -1.555 x 1 z -0.1 } col { } 
} 

rule col { 
	15* {y 1.555 x 1 z -0.1 } box {s 1.111 1} 
} 

rule box {
	SQUARE [r  15 skew 15 15 x 0.5 y -0.5 sat 0.9 b 1 h 250]
	SQUARE [r 135 skew 15 15 x 0.5 y -0.5 sat 0.9 b 1 h 150]
	SQUARE [r 255 skew 15 15 x 0.5 y -0.5 sat 0.9 b 1 h 350]
}
The loop syntax replaces your 15 col and row shapes with one 15x loop. The SQUARE shapes in the box rule use square brackets instead of curly brackets. This allows you to control the order of the shape adjustments. This lets you make the three diamond shapes without having to do a lot of trig. Read more about it here.

Post Reply