You are here: Home Tech Create a Code Swarm Animation

Create a Code Swarm Animation

by Chris Shenton last modified Oct 29, 2008 03:20 PM
Code Swarm could use a bit o' luvin' in the docs but this was pretty easy on OS X.

Code Swarm analyzes SVN (or other repo) checkins to visualize checkins by date, author, color-coded by file name.  

It's Java, so check it out, build it, then run it with the defaults:

svn export http://codeswarm.googlecode.com/svn/trunk codeswarm
cd codeswarm
ant
ant run

It will pop up a window for your repo URL (e.g., http://svn.example.com/project), username, and password (creds seem required). It examines the repo and logs verbosely, eventually showing an animation.

I tweaked the log config to not be so verbose:

--- log.properties	(revision 247)
+++ log.properties	(working copy)
@@ -1,5 +1,6 @@
 #see http://java.sun.com/j2se/1.4.2/docs/api/java/util/logging/LogManager.html

 .level=SEVERE
-org.codeswarm.level=FINEST
+#org.codeswarm.level=FINEST
+org.codeswarm.level=WARNING
 handlers=java.util.logging.ConsoleHandler
 java.util.logging.ConsoleHandler.level = ALL

Then tweaked the config to add an event timeline and save image frames to disk, and used some "svn log -v" and awk, uniq, sort commands to come up with the most interesting file extensions to color-code it:

Index: sample.config
===================================================================
--- sample.config       (revision 247)
+++ sample.config       (working copy)
@@ -7,7 +7,8 @@
 Height=480
 
 # Input file
-InputFile=data/sample-repevents.xml
+#InputFile=data/sample-repevents.xml
+InputFile=realtime_sample1961992439.xml
 
 # Particle sprite file
 ParticleSpriteFile=src/particle.png
@@ -36,23 +37,23 @@
 # Pattern:  "Label", "regex", R,G,B, R,G,B
 # Label is optional.  If it is omitted, the regex
 # will be used.
-#
-ColorAssign1="Docs",".*doc.*", 0,0,255, 0,0,255
-ColorAssign2="Code1",".*src1.*", 0,255,255, 0,255,255
-ColorAssign3="Code2",".*src2.*", 102,0,255, 102,0,255
-ColorAssign4="Code3",".*src3.*", 255,0,0, 255,0,0
-ColorAssign5="Code4",".*src4.*", 255,255,0, 255,255,0
-ColorAssign6="Code5",".*src5.*", 119,68,119, 119,68,119
-ColorAssign7="Code6",".*src6.*", 136,51,17, 136,51,17
-ColorAssign8="Code7",".*src7.*", 250,110,110, 250,110,130
-ColorAssign9="Code8",".*src8.*", 238,102,68, 238,102,68
-ColorAssign10=".*src9.*", 238,68,119, 238,68,119
+ColorAssign1="doc",".*doc.*", 0,0,255, 0,0,255
+ColorAssign2="py",".*py.*", 0,255,255, 0,255,255
+ColorAssign3="xml|zcml|tpl",".*xml|zcml|tpl.*", 102,0,255, 102,0,255
+ColorAssign4="pt|zpt|dtml|html",".*pt|zpt|dtml|html.*", 255,0,0, 255,0,0
+ColorAssign5="cfg|conf",".*cfg|conf.*", 255,255,0, 255,255,0
+ColorAssign6="zcml",".*xml|zcml.*", 119,68,119, 119,68,119
+ColorAssign7="css",".*css.*", 136,51,17, 136,51,17
+ColorAssign8="js",".*js.*", 250,110,110, 250,110,130
+ColorAssign9="gif|png|jpg|jpeg",".*gif|png|jpg|jpeg.*", 238,102,68, 238,102,68
+ColorAssign10="txt|rst", ".*txt|rst.*", 238,68,119, 238,68,119
 
 # Save each frame to an image?
-TakeSnapshots=false
+#TakeSnapshots=false
+TakeSnapshots=true
 
 # Where to save each frame
-SnapshotLocation=frames/code_swarm-#####.png
+SnapshotLocation=frames/schwa_code_swarm-#####.png
 
 # Draw names (combinatory) :
 # Draw sharp names?
@@ -72,7 +73,8 @@
 ShowLegend=true
 
 # Show the History at start
-ShowHistory=false
+#ShowHistory=false
+ShowHistory=true
 
 # Show the Date at start
 ShowDate=true

Then re-do the "ant run" command and it should be much less chatty, and save frames to disk. 

On OS X, you can then use QuickTime Player to create an animation from these frames.  Use File -> Open Image Sequence and pick one of the files in your folder of frames.  Then save the resulting .mov file and declare victory. The result of converting codeswarm's 2351 800x600 frames was 66MB and rand about 70 seconds.

 

I tried using "convert" from ImageMagick

convert schwa_code_swarm*.png schwa_code_swarm.mov

but it took forever then ran out of memory.

A 3rd party app called "Framed" finally completed but its .mov file for the same frames was 1.3GB so I bailed on it.

 

Share this: