Interface Animatable

    • Method Detail

      • moveTo

        default AnimationBuilder moveTo​(int x,
                                        int y,
                                        double duration)
        Move this to the specified x and y over duration seconds
        
         Circle c = new Circle(200, 200, 50);
         // the circle will move to (100, 100), and then to (200, 200)
         c.moveTo(100, 100, 3).moveTo(200, 200, 3);
         
        Parameters:
        x - the x-position to move to
        y - the y-position to move to
        duration - the number of seconds it lasts
        Returns:
        an this
      • colorTo

        default AnimationBuilder colorTo​(int r,
                                         int g,
                                         int b,
                                         double duration)
        Change the color of this to the specified color over duration seconds. See Wikipedia for how this works.
        
         Circle c = new Circle(200, 200, 50);
         // the circle will turn red, and then blue
         c.colorTo(255, 0, 0, 3).colorTo(0, 0, 255, 3);
         
        Parameters:
        r - red (0-255)
        g - green (0-255)
        b - blue (0-255)
        duration - the number of seconds it lasts
        Returns:
        an this
      • colorTo

        default AnimationBuilder colorTo​(int hex,
                                         double duration)
        Change the color of this to the specified color over duration seconds. See Wikipedia for how this works.
        
         Circle c = new Circle(200, 200, 50);
         // the circle will turn red, and then blue
         c.colorTo(0xFF0000, 3).colorTo(0x0000FF, 3);
         
        Parameters:
        hex - The number describing the RGB color
        duration - the number of seconds it lasts
        Returns:
        an this
      • colorTo

        default AnimationBuilder colorTo​(java.awt.Color color,
                                         double duration)
        Change the color of this to the specified color over duration seconds. See Color for the full list of colors, and constructors for this class
        
         Circle c = new Circle(200, 200, 50);
         // the circle will turn red, and then blue
         c.colorTo(Color.RED, 3).colorTo(Color.BLUE, 3);
         
        Parameters:
        color - The color to fade to
        duration - the number of seconds it lasts
        Returns:
        an this
      • fadeOut

        default AnimationBuilder fadeOut​(double duration)
        Fades this out over @{code duration} seconds.
        
         Circle c = new Circle(200, 200, 50);
         // the circle will fade out, then in
         c.fadeOut(3).fadeIn(3);
         
        Parameters:
        duration - the amount of time it takes to fade out
        Returns:
        an this
        See Also:
        fadeIn(double)
      • fadeIn

        default AnimationBuilder fadeIn​(double duration)
        Fades this in over @{code duration} seconds.
        
         Circle c = new Circle(200, 200, 50);
         // the circle will fade out, then in
         c.fadeOut(3).fadeIn(3);
         
        Parameters:
        duration - the amount of time it takes to fade out
        Returns:
        an this
        See Also:
        fadeOut(double)
      • rotateTo

        default AnimationBuilder rotateTo​(int angle,
                                          double duration)
        Rotates this to the specified angle°. If you supply an angle > 360 it will make more than one full rotation.
        
         Square s = new Square(200, 200, 50);
         // the square will rotate one turn counter-clockwise, then 2 turns clockwise
         c.rotateTo(360, 3).colorTo(-360, 3);
         
        Parameters:
        angle - The absolute angle to rotate to in degrees.
        duration - the number of seconds it lasts
        Returns:
        an this
      • rotateBy

        default AnimationBuilder rotateBy​(int angle,
                                          double duration)
        Rotates this by angle°.
        
         Square s = new Square(200, 200, 50);
         // the square will rotate one turn counter-clockwise, then one turns clockwise
         c.rotateTo(360, 3).colorTo(-360, 3);
         
        Parameters:
        angle - The relative angle to rotate to in degrees.
        duration - the number of seconds it lasts
        Returns:
        an this
      • moveBy

        default AnimationBuilder moveBy​(int x,
                                        int y,
                                        double duration)
        This method moves this by the specified x and y
        
         Circle c = new Circle(200, 200, 50);
         // the circle will move down 100, and then right 200
         c.moveBy(0, 100, 3).moveBy(200, 0, 3);
         
        Parameters:
        x - the x to move by
        y - the y to move by
        duration - the number of seconds it lasts
        Returns:
        an this
      • moveHorizontalBy

        default AnimationBuilder moveHorizontalBy​(int x,
                                                  double duration)

        This method moves this by the specified x horizontally. Positive values move right, negative values move left.

        This method is equivalent to moveBy(x, 0, duration)

        
         Circle c = new Circle(200, 200, 50);
         // the circle will move right 300 pixels over 3 seconds
         c.moveHorizontalBy(0, 100, 3);
         
        Parameters:
        x - the x to move by
        duration - the number of seconds it lasts
        Returns:
        an this
      • moveVerticalBy

        default AnimationBuilder moveVerticalBy​(int y,
                                                double duration)

        This method moves this by the specified x horizontally. Positive values move right, negative values move left.

        This method is equivalent to moveBy(0, y, duration)

        
         Circle c = new Circle(200, 200, 50);
         // the circle will move right 300 pixels over 3 seconds
         c.moveHorizontalBy(0, 100, 3);
         
        Parameters:
        y - the y to move by
        duration - the number of seconds it lasts
        Returns:
        an this