Java Reference
In-Depth Information
fill: Color.BLACK
}
transforms: Transform.rotate(i/60.0 * 360.0, 0, 0);
}
insert dot into clock.content;
}
for (i in [0..11]){
var bigDot = Group{
content: Circle{
translateX: 200
radius: 3
fill: Color.BLACK
}
transforms: Transform.rotate(i/12.0 * 360.0, 0, 0);
}
insert bigDot into clock.content;
}
var rotation = 0.0;
var hand = Rectangle{
width: 190
height: 1
fill: Color.RED
transforms: bind Transform.rotate(rotation, 0, 0);
}
insert hand into clock.content;
var anim = Timeline{
repeatCount: Timeline.INDEFINITE
keyFrames: KeyFrame{
time: 60s
values: rotation => 360.0 tween StepInterpolator{steps: 61}
}
}
anim.play();
Stage {
title: "Chapter 5 - Clock Example"
width: 640
height: 480
scene: Scene {
fill: Color.WHITE
content: [clock]
}
}
}
In the code, a number of dots are drawn in a circular pattern, like the tick marks for seconds on an
analog clock. A rectangle called hand is rotated 360 degrees over 60 seconds. A StepInterpolator is used
make the second hand snap from tick to tick. The StepInterpolator uses 61 steps, since in this case we
Search WWH ::




Custom Search