Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8108565

Interpolator recalculates target on each iteration

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • fx1.2.1
    • javafx
    • None

      It is not only a usablity problem, but rather a performace issue.

      Compile and run the following example.
      Click somewhere inside and you'll see
      that right side color flicks unexpectedly.

      ========== SOURCE ==========
      import javafx.animation.Timeline;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.stage.Stage;
      import javafx.util.Math.random;

      var timer: Timeline on replace old {
        old.stop();
        timer.playFromStart();
      }

      var c1 = Color.BLUE;
      var c2 = Color.BLUE;

      def w: Number = bind stage.scene.width / 2;
      def h: Number = bind stage.scene.height;

      def stage: Stage = Stage {
        title: "JavaFX test"
        scene: Scene {
          width: 640
          height: 480
          content: Group {
            onMouseClicked: function (event) {
              def color = Color.color(random(), random(), random());
              timer = Timeline {
                keyFrames: at (1s) {
                  c1 => color;
                  c2 => Color.color(random(), random(), random());
                }
              }
            }
            content: [
              Rectangle { width: bind w height: bind h fill: bind c1 }
              Rectangle { width: bind w height: bind h fill: bind c2 x: bind w }
            ]
          }
        }
      }

            kcr Kevin Rushforth
            malenkov Sergey Malenkov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: