Posted by: Josh Marinacci on: August 31, 2009

With JavaFX 1.2 out the door and the summer almost over we thought it was high time to have another coding challenge. This time we are going to try something different. Harkening back to the demo scene of old, this month’s challenge is to build something interesting with a very small amount of code: 30 lines in a single file! I bet with liberal use of bind and recursion you’ll create something fantastic.
Here’s how it will work. We are announcing the contest today. On the 8th we will announce the secret theme so you can begin coding. This will give you a week to play around with different ways of building compact code. The deadline for entries is the 30th of September, and we will announce the winners a week later. The prize will again be a 20$ gift certificate to Amazon and a badge to put on your website.
The 30 lines will be counted by actual lines or by 3000 characters, you’re choice (please try not to have lines a 1000 columns wide
You can have as many classes as you want but only one file. You can’t use any 3rd party libraries, but you can load resources (images, videos, music) from the internet. You must submit your code by pasting the 30 lines of code in an email to joshua.marinacci@sun.com with the subject: JFXStudio Challenge: Small is the New Big
That’s it. We’ll see you again on the 8th when we reveal the secret theme.
Summary:
package shapeexplosion;
import javafx.stage.Stage;
import javafx.scene.*;
import javafx.scene.shape.Rectangle;
import javafx.animation.Timeline;
import javafx.scene.paint.Color;
import javafx.util.Math;
var t = 0.0; var tr = bind Math.toRadians(t);
function recurse(depth:Integer,index:Integer):Node {
if(depth == 0) {
return Rectangle {
width: bind (Math.sin(tr*5)+1)*100 height: bind (Math.sin(tr*3)+2)*100
fill: bind Color.hsb(t/3*index,1.0,1.0,0.7)
rotate: bind -t*5
}
}
return Group {
rotate: bind t
content: for(i in [0..2]) {
var node = recurse(depth-1,i);
node.translateX= 60*i;
node.translateY= 60*i;
node;
} }
}
Stage { width: 500 height: 500 scene: Scene { content: recurse(3,0) fill: Color.BLACK} };
Timeline { repeatCount: Timeline.INDEFINITE
keyFrames: [ at(0s) { t => 0.0 } at(12s) { t => 360.0*3 } ] }.play();
very nice demo
I made this the lead topic of my java.net Daily Editor’s Blog:
Hopefully you’ll get a lot of interesting submissions for the contest!
Regards,
Kevin Farnham
Hopefully you’ll get a lot of interesting submissions for the contest!
–
Why you think so?
I know this is going to sound totally nit-picky, but are the package, and import statements counted?
Just to clarify, can you have more than 3000 characters, but less then 30 lines?
I am waiting for the theme
Fancy! This is even working under Linux (Fedora 11)
Ooh I just love demo effects this one was not even crippled but rather fast
Nice idea, looking forward to seeing the submissions.
The rules arent very clear.
Is it 30 lines or more as long as you dont have more than 3000 characters in the whole file ??
or 30 lines with less than 1000 chars of length each ??
I guess you men the first one right ?
Or is it 3000 chars max with max 30 lines of any length???
hi,
will a line like this:
i++;c++; void main(){dszdsda}
be assumed as only one line?
thanks for the challenge and answer
This looks like a fun challenge indeed! I think I’ll join in.
Hypnotic demmmmmmo. Must…code….must….code
i++;c++; void main(){dszdsda}
I assume then no style points?
It slowed the whole system when I started it. I can’t open a txt file even.
My laptop
Intel Core 2 T7200
ATI X1400
2GB RAM
vista 32bit
1 | Jim Weaver
September 1, 2009 at 5:55 pm
“You must submit your code by pasting the 20 lines of code in an email to joshua.marinacci@sun.com with the subject: JFXStudio Challenge: Small is the New Big”
How should we submit the other 10 lines?
Thanks,
Jim Weaver