I participated in the original one back at the were-here forums, and couldn't resist giving it a shot this time around as well
If you don't know, this is what I'm talking about.
In the spirit of my upcoming FITC Talk, I naturally went for a text effect! Click the image to see it in action :

I started with a good 50 lines of code... I'm just getting my head around the tricks involved with using Graphics.drawTriangles(). Took a bit of effort to a) get it to work, b) get it down to 25 lines. Basically the code:
- Creates a textfield
- Grabs a bitmapData of it, this is the "material"
- Creates a cylinder with a loop (vertices, triangles and uv data)
- In an enterframe it:
- Rotates a matrix in y and z
- Transforms that rotation to the "mesh" and it to the perspective projection
- Draws the triangles using the material as a bitmap fill
At the end, I got the line count down to the point where I could even add some glow and z rotation
oh: The screenshot looks a bit "pixely", and it is, because the font is not embedded.
The 25lines website proclaims : "You probably don't want to share your code prematurely, but that's up to you", well.... Last time I was probably 60th out of 61 entries so I doubt this is gonna kill my chances
I'll never match up to the math gurus out there, but hey, mine has a joke in it!
The code:
Actionscript:
-
// 3 free lines! Alter the parameters of the following lines or remove them.
-
// Do not substitute other code for the three lines in this section
-
[SWF(width=800, height=380, backgroundColor=0x000044, frameRate=31)]
-
stage.align = StageAlign.TOP_LEFT;
-
stage.scaleMode = StageScaleMode.NO_SCALE;
-
// 25 lines begins here!
-
-
var tf:TextField=new TextField();
-
tf.defaultTextFormat=new TextFormat("Helvetica",120,0xFFFFFF,true);//Hopefully all machines have Helvetica...
-
tf.text="Circular Logic Works Because ";
-
tf.autoSize=TextFieldAutoSize.LEFT;
-
tf.filters=[new GlowFilter(0x2222BB,.7,12,12,4,3)]
-
var material:BitmapData=new BitmapData(tf.width+10,tf.height+10,false,0x000044);
-
material.draw(tf,null,null,null,null,true);
-
var vertices:Vector.<Number>=new Vector.<Number>(),t_vertices:Vector.<Number>=new Vector.<Number>(),points:Vector.<Number>=new Vector.<Number>(),triangles:Vector.<int>=new Vector.<int>(),uv:Vector.<Number>=new Vector.<Number>(),angle:Number=0,radius:Number=material.width/Math.PI/2,slices:uint=20,x_rot:Number=0,x_rot_speed:Number=1,y_rot:Number=-150,z_rot:Number=0,z_rot_dir:Number=-.1;
-
for(var i:int=0;i<=slices;i++){
-
vertices.push(radius*Math.cos(angle*(Math.PI/180)),0,radius*Math.sin(angle*(Math.PI/180)),radius*Math.cos(angle*(Math.PI/180)),material.height,radius*Math.sin(angle*(Math.PI/180)));
-
uv.push(1-angle/360,0,0,1-angle/360,1,0);
-
angle+=(360/slices);
-
if(i>1)triangles.push(i*2-4, i*2-2, i*2-3,i*2-3, i*2-2, i*2-1);
-
}
-
triangles.push(i*2-4, i*2-2, i*2-3,i*2-3, i*2-2, i*2-1);
-
addEventListener("enterFrame",function handleEnterFrame(e:Event=null) {
-
var transform_matrix:Matrix3D=new Matrix3D();
-
transform_matrix.prependTranslation(stage.stageWidth/2,stage.stageHeight/2-material.height/2,0);//maybe better to use a container?
-
transform_matrix.prependRotation(y_rot--, Vector3D.Y_AXIS);
-
transform_matrix.prependRotation((z_rot+=z_rot_dir), Vector3D.Z_AXIS);
-
if(z_rot>20 || z_rot<-20)z_rot_dir*=-1;
-
transform_matrix.transformVectors(vertices, t_vertices);
-
Utils3D.projectVectors(new Matrix3D(), t_vertices, points, uv);
-
graphics.clear();
-
graphics.beginBitmapFill(material);
-
graphics.drawTriangles(points, triangles, uv, TriangleCulling.POSITIVE);
-
});
-
// 25 lines ends here!
The source in an easier "cut and paste" format : circular_logic.txt
Again, the html page with the compiled swf in it : 25Lines.html
anyway, fingers crossed! Looking forwards to seeing the other entries