Animation a = AnimationUtils.loadAnimation(getContext(), R.anim.progress_anim); a.setDuration(duration); a.setInterpolator(new Interpolator() {
final Interpolator colchange = new Interpolator() { ....
Interpolator interpolator = new Interpolator() { @Override protected double curve(double t) { // parabola with zeros at t=0 and t=1 and a maximum of 1 at t=0.5 return 4 * t * (1 - t); } }; KeyValue yKV = new KeyValue(circle.centerYProperty(), hMax, interpolator);
KeyValue xKV = new KeyValue(c.centerXProperty(), 200); KeyValue yKV = new KeyValue(c.centerYProperty(), 0, new Interpolator() {…});
public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ProgressView image = (ProgressView) findViewById(R.id.image); Animation a = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.progress_anim); a.setDuration(1000); image.startAnimation(a); a.setInterpolator(new Interpolator() { private final int frameCount = 8; @Override public float getInterpolation(float input) { return (float) Math.floor(input * frameCount) / frameCount; } }); }
private Circle other = new Circle(100, 100, 10); … else { KeyValue end = new KeyValue(bullet.translateYProperty(), -800, new Interpolator() { @Override protected double curve(double t) { if (!Shape.intersect(bullet, other).getBoundsInLocal().isEmpty()) { System.out.println("Intersection"); } return t; } }); KeyFrame endF = new KeyFrame(Duration.seconds(10), end); timeline.getKeyFrames().addAll(endF); }
Interpolator bugFixInterpolator = new Interpolator() { @Override protected double curve(double t) { Paint fill = scene.getFill(); scene.setFill(Color.RED); scene.setFill(fill); return t; } @Override public String toString() { return "Interpolator.LINEAR"; } }; Timeline t = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(stage.opacityProperty(), 1, bugFixInterpolator)), new KeyFrame(Duration.millis(500), new KeyValue(stage .opacityProperty(), 0, bugFixInterpolator))); t.setAutoReverse(true); t.setCycleCount(Timeline.INDEFINITE); t.playFromStart();
public static Interpolator instance() { if (Contexts.isApplicationContextActive()) { return (Interpolator) Component.getInstance(Interpolator.class, ScopeType.APPLICATION); } else { return new Interpolator(); // for unit testing } }
Animation a = AnimationUtils.loadAnimation(getContext(), R.anim.progress_anim); a.setDuration(duration); a.setInterpolator(new Interpolator() {
Animation a = AnimationUtils.loadAnimation(getContext(), R.anim.progress_anim); a.setDuration(duration); a.setInterpolator(new Interpolator() {
@Override public void start(Stage primaryStage) { Circle circle = new Circle(10); circle.setManaged(false); Pane pane = new Pane(circle); circle.setCenterX(20); circle.setCenterY(800); Timeline timeline = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(circle.centerXProperty(), 20), new KeyValue(circle.centerYProperty(), 800) ), new KeyFrame(Duration.seconds(3), new KeyValue(circle.centerXProperty(), 380), new KeyValue(circle.centerYProperty(), 10, new Interpolator() { @Override protected double curve(double t) { // parabola with zeros at t=0 and t=1 and a maximum of 1 at t=0.5 return 4 * t * (1 - t); } }) ) ); Scene scene = new Scene(pane, 400, 800); scene.setOnMouseClicked(evt -> timeline.playFromStart()); primaryStage.setScene(scene); primaryStage.show(); }
Interpolator i = new Interpolator() { @Override public float getInterpolation(float input) {
timeline.setAutoReverse(false); KeyValue xKV = new KeyValue(c.centerXProperty(), 500); KeyValue yKV = new KeyValue(c.centerYProperty(), 100, new Interpolator() { @Override protected double curve(double t) {