JavaFX/AnimatedIcon のバックアップの現在との差分(No.2)
TITLE:JavaFX Script でアイコンのアニメーション
JavaFX Script でアイコンのアニメーション
編集者:Terai Atsuhiro~
作成日:2006-05-18
更新日:2018-07-09 (月) 17:16:44
- title: JavaFX Script でアイコンのアニメーション author: aterai pubdate: 2006-05-18 noindex: true
- 古くなったのですべて削除しました。
概要
JavaFX ScriptでFireFox風のAnimated Icon を作成します。サンプルコード
#spanend
#spandel
import javafx.ui.*;
#spanend
#spandel
import javafx.ui.canvas.*;
#spanend
#spandel
#spanend
#spandel
public class Timer {
#spanend
private attribute rotationValue: Number;
public attribute running: Boolean;
#spandel
}
#spanend
#spandel
attribute Timer.rotationValue = bind if running
#spanend
#spandel
then [0,45..360] dur 1040 linear
#spanend
#spandel
while running
#spanend
#spandel
continue if true
#spanend
#spandel
else 0;
#spanend
#spandel
#spanend
#spandel
class CircleRtation extends CompositeNode {
#spanend
public attribute animating: Boolean;
attribute radius: Number;
attribute fill: Color;
#spandel
}
#spanend
#spandel
attribute CircleRtation.radius = 6;
#spanend
#spandel
attribute CircleRtation.fill = green;
#spanend
#spandel
#spanend
#spandel
operation CircleRtation.composeNode() {
#spanend
var r = 2*radius;
var c = 2*r+5; //2>(sqrt(2)+0.5), margin=5+r*(1.5-sqrt(2))
var t = Timer {running: bind animating};
return Group {
transform: bind [rotate(t.rotationValue, c, c), translate(c, c)]
content: [foreach (i in [1..8]) Circle {
radius: this.radius,
fill: bind fill,
opacity: 0.1*i,
transform: [translate(-r, -r), rotate(i*45, r, r)]
}, Circle {
fill: Color{ opacity: 0 }
radius: r
onMousePressed: operation(e:CanvasMouseEvent) { t.running = false; }
onMouseReleased: operation(e:CanvasMouseEvent) { t.running = true; }
onMouseEntered: operation(e:CanvasMouseEvent) { fill = red; }
onMouseExited : operation(e:CanvasMouseEvent) { fill = green; }
}]
};
#spandel
}
#spanend
#spandel
var cr = CircleRtation{ animating: true };
#spanend
#spandel
Frame {
#spanend
title : "JavaFX - Icon Animation"
width : 320
height : 120
content: Canvas { content: cr }
centerOnScreen: true
visible: true
onClose: operation() {
//System.exit(0);
cr.animating = false;
}
#spandel
};
#spanend
#spandel