/* * Main.fx * * Created on 2009/11/26, 2:34:19 */ package parabora; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.animation.Timeline; import javafx.animation.KeyFrame; import javafx.scene.shape.Line; import javafx.scene.paint.Color; import javafx.animation.Interpolator; import javafx.scene.shape.Circle; import javafx.scene.paint.RadialGradient; import javafx.scene.paint.Stop; import javafx.scene.control.Slider; /** * @author arton */ def Width = 280.0; def Height = 280.0; var x = 0.0; var y = 0.0; Timeline { repeatCount: Timeline.INDEFINITE keyFrames : [ KeyFrame { time : 10s canSkip : true values : [ x => Width tween Interpolator.LINEAR ] } ] }.play(); function adjustValue(x: Slider) : Number { return x.value - x.max / 2; } function fun(ax) : Number { var rx = ax - Width / 2; return adjustValue(vala) * rx * rx + adjustValue(valb) * rx + adjustValue(valc) + Height / 2; } var vala = Slider { width: Width layoutX: 5, layoutY: Height blockIncrement: 0.001 min: 0 max: 0.2 value: 0.11 vertical: false } var valb = Slider { width: Width layoutX: 5, layoutY: Height + 10 blockIncrement: 0.1 min: 0 max: 20 value: 10 vertical: false } var valc = Slider { width: Width layoutX: 5, layoutY: Height + 20 blockIncrement: 0.1 min: 0 max: 400 value: 200 vertical: false } Stage { title: "parabola" width: 300 height: 360 scene: Scene { fill: RadialGradient { centerX: 50, centerY: 60 radius: 90 proportional: false stops: [ Stop { offset: 0.0 color: Color.web("#3B8DED") }, Stop { offset: 1.0 color: Color.web("#044EA4") } ] } content: [ Line { startX: 0, startY: Height / 2 endX: Width, endY: Height / 2 strokeWidth: 1 stroke: Color.BLACK } Line { startX: Width / 2, startY: 0 endX: Width / 2, endY: Height strokeWidth: 1 stroke: Color.BLACK } Circle { centerX: bind x, centerY: bind fun(x); radius: 4 fill: Color.YELLOW } vala, valb, valc ] } }