« Java 3D meets JavaFX - Thanks to InteractiveMesh.org | Main | And the "Major Award" goes to... (JavaFX Puzzler #1) »

March 23, 2009

Comments

acw1668 from HK

/* JavaFX with Passion! Puzzler #1 */

import javafx.stage.*;
import javafx.scene.Scene;
import javafx.scene.text.*;
import javafx.scene.paint.Color;
import javafx.scene.layout.VBox;
import javafx.ext.swing.SwingSlider;

var width: Number = 320;
var height: Number = 320;

var slider: SwingSlider = SwingSlider {
minimum: 0
maximum: 360
value: 0
vertical: false
translateX: bind (width - slider.boundsInLocal.width) / 2
}

var text: Text = Text {
font: Font { name: "Arial Bold", size: 32 }
content: bind "Angle: {slider.value}"
rotate: bind slider.value
fill: Color.BLUE
translateX: bind (width - text.boundsInLocal.width) / 2
translateY: bind height / 2
}

Stage {
width: bind width with inverse
height: bind height with inverse
title: "Rotate Puzzler"
scene: Scene {
content: VBox {
content: [ slider, text ]
}
}
}

hakim

it's look like my previous post reformatted by your blog engine, so "== 10 and num < 100)
return "Angle: 0{num}"
else
return "Angle: {num}";
}

def text:Text = Text {
font: font
fill: Color.BLUE
translateX: bind tx
translateY: bind ty
style: "font-weight:bold"
rotate: bind angle
content: bind formatString(angle)
}

def scene:Scene = Scene {
content: [ slider, text ] }

Stage {
title: "RotSlider"
width: bind width with inverse
height: bind height with inverse
scene: scene
}

hakim

import javafx.ext.swing.SwingSlider;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.transform.Rotate;

/**
* @author Hakim
*/


def font = Font{name:"Arial", size: 40, embolden:true}
def angle = bind slider.value;
var width:Number = 350;
var height:Number = 300;
var pivoty:Number = bind text.boundsInParent.height/2;
var tx = bind (width - text.boundsInLocal.width)/2;
var ty = bind (height - text.boundsInLocal.height)/2;

def slider = SwingSlider {
width: bind width*2/3
translateX: bind width/6
minimum: 0
maximum: 360
value: 0
vertical: false
}

function formatString(num:Integer):String{
if (num = 10 and num < 100)
return "Angle: 0{num}"
else
return "Angle: {num}";
}

def text:Text = Text {
font: font
fill: Color.BLUE
translateX: bind tx
translateY: bind ty
style: "font-weight:bold"
rotate: bind angle
content: bind formatString(angle)
}

def scene:Scene = Scene {
content: [ slider, text ] }

Stage {
title: "RotSlider"
width: bind width with inverse
height: bind height with inverse
scene: scene
}

Luis Henrique M. Carvalho

/*
* Main.fx
*
* Created on 23/03/2009, 21:18:42 (BRAZIL TIME) on Ubuntu :D
*/
package anglefx;

import javafx.ext.swing.SwingSlider;
import javafx.scene.paint.Color;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
* @author bulinha
*/
var angle = 0;

Stage {
title: "Rotate Puzzler"
width: 250
height: 250
scene: Scene {
content: [
SwingSlider {
minimum: 0
maximum: 360
value: bind angle with inverse
vertical: false
width: 200;
translateX: 25
},
Text {
font: Font {
size: 30
embolden: true

}
fill: Color.BLUE;
translateX: 50,
translateY: 120,
rotate: bind angle

content: bind "angle: {angle}"
}
]
}

}

The comments to this entry are closed.

Categories