JFXStudio: sketch, hack, share

JFXStudio Challenge: Small is the New Big

Posted by: Josh Marinacci on: August 31, 2009

shape explosion.png

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:

  • starts on September 8th. secret theme will be announced then.
  • entries due by September 30th
  • must not be more than 30 lines of code or 3000 characters (your choice).
  • no 3rd party libs, but media from the internet is okay
  • email your submission to joshua.marinacci@sun.com

Example


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();

Run the example

21 Responses to "JFXStudio Challenge: Small is the New Big"

“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

very nice demo

d’oh! I meant the full 30 lines. :)

I made this the lead topic of my java.net Daily Editor’s Blog:

http://weblogs.java.net/blog/editor/archive/2009/09/02/starting-soon-new-jfxstudio-challenge-javafx-developers

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?

It’s my contest, so I’ll say no. We won’t count imports and package statements. Just lines of real code. (maybe in the future i’ll count’em to make it harder).

Just to clarify, can you have more than 3000 characters, but less then 30 lines?

You can have 30 lines or 3000 characters, whichever you choose.

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???

30 lines total or 3000 chars total. (for an average of 100 chars per line).

Seriously guys, we aren’t going to be that strict. This should be fun. :)

I posted in portuguese for brazilians readers:

http://javafree.uol.com.br/noticia/4258/Criatividade-e-30-linhas-de-codigo-Novo-concurso-de-JavaFX.html

Waiting for the theme!

hi,
will a line like this:

i++;c++; void main(){dszdsda}

be assumed as only one line? :)

thanks for the challenge and answer

Yep, that would be only one line. Rock out!

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

Leave a Reply

Challenge: Small is the New Big

This month's challenge: code something cool in only 30 lines, using the theme of Five

Tags

Archives