package carbadges;

import javafx.animation.Timeline;
import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Rectangle;

public class Mitsubishi extends CustomNode {

	def stageSize = 250.0;
	def centerStage = stageSize / 2;

	def points : Number[] = [125,125,92,67,125,10,158,67,125,125,58,125,25,183,92,183,125,125,192,125,225,183,158,183];

	public override function create(): Node {
		return Group {
			content: [
				Rectangle {
					width: stageSize
					height: stageSize
					fill: Color.BLACK
				}
				Group {
					rotate: bind rotAngle
					scaleY: bind sy
					scaleX: bind sx
					content: [
						Rectangle {
							width: stageSize
							height: stageSize
							fill: Color.BLACK
							opacity: 0.0
						}
						Polygon {
							points: points
							fill: bind color
						}
					]
				} // group
			] // return group content
		}; // return group

	} // create

	var rotAngle = 0.0;
	var sx=1.0;
	var sy=1.0;
	var color = Color.RED;

	public var timeline:Timeline = Timeline {
		keyFrames: [
		at (0s) {sx => 0.0;sy => 0.0;}
		at (4s) {sx=>1.0; sy=>1.0; color=>Color.RED}
		at (7s) {sx => -1.0;  sy=>1.0; color=>Color.CYAN}
		at (10s) { sy=>-1.0; color=>Color.RED;rotAngle=>0.0;}
		at (12s) {rotAngle => 60.0;}
		]
	}
}