Animated binary 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
Xhargh
Posts: 1
Joined: Wed Jul 06, 2005 12:44 pm

Animated binary tree

Post by Xhargh »

I have now played with CFDG for a couple of hours and I created a small animation of a sort of binary tree :D
Image
Click the image for an animated version


I started with the lesson.cfdg and worked my way from that one...

Code: Select all

startshape TOC

rule TOC {

	LINES { x 0 y 0 rotate 90}

}

rule LINES { 
	LINE {x 0 y 0}
}

rule LINE {
	BIT {  }
	LINE_L { x 1 size 0.999 rotate 3}
}

rule LINE {
	BIT {  }
	LINE_R { x 1 size 0.999 rotate -3}
}

rule LINE_L 7 {
	LINE_L {x 1 size 0.999 rotate 3 }
	BIT { }
}

rule LINE_R 7 {
	BIT { }
	LINE_R {x 1 size 0.999 rotate -3}
}

rule LINE_L 1 {
	LINE_SPLIT {}
}

rule LINE_R 1 {
	LINE_SPLIT {}
}

rule LINE_SPLIT 1 {
	LINE {x 0.8 y -0.5 size 0.75 rotate -30 b 0.05}
	BIT { }
	LINE {x 0.8 y 0.5 size 0.75 rotate 30 b 0.03}
}


rule BIT {
	One {x 0}
}

rule BIT {
	Zero {x 0}
}

rule BOX 10 {
	SQUARE { size 0.8 }
}

rule BOX 1 {
	CIRCLE { size 0.8 b 0.3}
}

rule One {
	BOX { x 0 y 0.4  size 0.2 }
	BOX { x 0 y 0.2  size 0.2 }
	BOX { x 0 y 0    size 0.2 }
	BOX { x 0 y -0.2 size 0.2 }
	BOX { x 0 y -0.4 size 0.2 }
	
	BOX { x -0.2 y 0.2 size 0.2 }
}

rule Zero {
	BOX { x 0.4 y 0.2  size 0.2 }
	BOX { x 0.4 y 0    size 0.2 }
	BOX { x 0.4 y -0.2 size 0.2 }

	BOX { x -0.4 y 0.2  size 0.2 }
	BOX { x -0.4 y 0    size 0.2 }
	BOX { x -0.4 y -0.2 size 0.2 }

	BOX { x  0.2  y  0.4  size 0.2 }
	BOX { x  0.0  y  0.4  size 0.2 }
	BOX { x -0.2 y  0.4    size 0.2 }

	BOX { x  0.2  y -0.4  size 0.2 }
	BOX { x  0.0  y -0.4  size 0.2 }
	BOX { x -0.2  y -0.4  size 0.2 }

}
Then I did something like this in bash:

Code: Select all

$ for ((a=0;a<=25000;a+=500)) ; do cfdg -m $a -s 500 anim.cfdg -v AAA anim$a.png ; convert anim$a.png anim$a.gif; done
$ gifsicle --delay=5 --optimize --colors 8 --loop `ls -tr anim*gif` `ls -t anim*gif` > binary_tree_anim.gif

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

Post by chris »

sweeeeeet.
Current Project: I'm creative director of OKCUPID at http://www.okcupid.com

Post Reply