Rotate Sample

 

スクリプト

rotateNode.fx

mport java.lang.Math;
import javafx.animation.Interpolator;
import javafx.animation.transition.RotateTransition;
import javafx.scene.effect.BlendMode;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
 
def radian = Math.PI / 180.0;
 
var node: Node = Group {
    translateX: 100
    translateY: 100
 
    // 6個の円
    content: [
        for (angle in [0..300 step 60]) {
            Circle {
                centerX: 50.0 * Math.cos(angle * radian);
                centerY: -50.0 * Math.sin(angle* radian);
                radius: 35
                fill: Color.PINK
                stroke: Color.RED
            }
        },
        // 重ね順を調節するための半円
        Arc {
            centerX: 50,
            centerY: 0
            radiusX: 35,
            radiusY: 35
            startAngle: 180,
            length: 180
            type: ArcType.OPEN
            fill: Color.PINK
            stroke: Color.RED
        }
    ]
};
 
var rotateTransition = RotateTransition {
    // 回転の対象ノード
    node: node
     
    // 回転角度の設定
    // 0度から720度回転させる
    fromAngle: 0
    byAngle: 720
 
    // これらのアトリビュートは Timeline クラスに準ずる
    duration: 5s
    repeatCount:4
    interpolate: Interpolator.EASEBOTH
    autoReverse: true
};
 
// 回転の開始
rotateTransition.play();
 
Stage {
    title: "Rotate Sample"
    scene: Scene {
        width: 200
        height: 200
        content: node
    }
}