Package paintingcanvas.animation
Interface Animatable
-
- All Known Subinterfaces:
Anchorable<T>,Colorable<T>,Drawable<T>,Outlineable<T>,Positionable<T>
- All Known Implementing Classes:
Circle,DrawableBase,DrawableBase.InteractableShape,DrawableBase.OutlineableDrawableBase,DrawableBase.Shape,Ellipse,Image,Line,Path,Polygon,Rectangle,Square,Text,Triangle
public interface AnimatableAn interface to call animation methods on animatable objects.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default AnimationBuildercolorTo(int hex, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.default AnimationBuildercolorTo(int r, int g, int b, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.default AnimationBuildercolorTo(int r, int g, int b, int a, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.default AnimationBuildercolorTo(java.awt.Color color, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.default AnimationBuildercolorTo(java.lang.String name, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.default AnimationBuildercolorTo(Hue hue, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.Drawable<?>drawable()Get theDrawableelement from thisAnimatable.default AnimationBuilderfadeIn(double duration)Fadethisin overdurationseconds.default AnimationBuilderfadeOut(double duration)Fadethisout overdurationseconds.default AnimationBuildermoveBy(int x, int y, double duration)Movethisby the specifiedxandyoverdurationseconds.default AnimationBuildermoveHorizontalBy(int x, double duration)Movethisby the specifiedxhorizontally overdurationseconds.default AnimationBuildermoveTo(int x, int y, double duration)Movethisto the specifiedxandyoverdurationsecondsdefault AnimationBuildermoveVerticalBy(int y, double duration)Movethisby the specifiedyvertically overdurationseconds.default AnimationBuilderrotateBy(int angle, double duration)Rotatethisbyangledegrees overdurationseconds.default AnimationBuilderrotateTo(int angle, double duration)Rotatethisto the specifiedangledegrees overdurationseconds.
-
-
-
Method Detail
-
drawable
Drawable<?> drawable()
Get theDrawableelement from thisAnimatable.- Returns:
- the
Drawable
-
moveTo
default AnimationBuilder moveTo(int x, int y, double duration)
Movethisto the specifiedxandyoverdurationsecondsCircle c = new Circle(200, 200, 50); // the circle will slowly move to (100, 100) over 3 seconds c.moveTo(100, 100, 3);- Parameters:
x- the x position to move toy- the y position to move toduration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
colorTo
default AnimationBuilder colorTo(int r, int g, int b, double duration)
Change the color ofthisto the specifiedcoloroverdurationseconds. See Wikipedia for how this works.Circle c = new Circle(200, 200, 50); // the circle will slowly turn red over 3 seconds c.colorTo(255, 0, 0, 3);- Parameters:
r- red (0-255)g- green (0-255)b- blue (0-255)duration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
colorTo
default AnimationBuilder colorTo(int r, int g, int b, int a, double duration)
Change the color ofthisto the specifiedcoloroverdurationseconds. See Wikipedia for how this works.Circle c = new Circle(200, 200, 50); // the circle will slowly turn red with with 100/255 opacity over three seconds c.colorTo(255, 0, 0, 100, 3);- Parameters:
r- red (0-255)g- green (0-255)b- blue (0-255)a- alpha (0-255)duration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
colorTo
default AnimationBuilder colorTo(int hex, double duration)
Change the color ofthisto the specifiedcoloroverdurationseconds. See Wikipedia for how this works.Circle c = new Circle(200, 200, 50); // the circle will slowly turn red over three seconds c.colorTo(0xFF0000, 3);- Parameters:
hex- the number describing the RGB colorduration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
colorTo
default AnimationBuilder colorTo(Hue hue, double duration)
Change the color ofthisto the specifiedcoloroverdurationseconds.Circle c = new Circle(200, 200, 50); // the circle will slowly turn red over 3 seconds c.colorTo(0xFF0000, 3);- Parameters:
hue- the hueduration- the number of seconds it lasts- Returns:
- a
ColorAnimation
-
colorTo
default AnimationBuilder colorTo(java.lang.String name, double duration)
Change the color ofthisto the specifiedcoloroverdurationseconds.Circle c = new Circle(200, 200, 50); // the circle will slowly turn red over 3 seconds // then, the circle will slowly turn blue over 3 seconds c.colorTo("red", 3).colorTo("#0000FF", 3);- Parameters:
name- the hue name or the hex codeduration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
colorTo
default AnimationBuilder colorTo(java.awt.Color color, double duration)
Change the color ofthisto the specifiedcoloroverdurationseconds. SeeColorfor the full list of colors, and constructors for this classCircle c = new Circle(200, 200, 50); // the circle will turn slowly red over 3 seconds c.colorTo(Color.RED, 3);- Parameters:
color- the color to fade toduration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
fadeOut
default AnimationBuilder fadeOut(double duration)
Fadethisout overdurationseconds.Circle c = new Circle(200, 200, 50); // the circle will slowly fade out over 3 seconds c.fadeOut(3);- Parameters:
duration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
fadeIn
default AnimationBuilder fadeIn(double duration)
Fadethisin overdurationseconds.Circle c = new Circle(200, 200, 50); // the circle will slowly fade out over 3 seconds // then, fade back in over 3 seconds c.fadeOut(3).fadeIn(3);- Parameters:
duration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
rotateTo
default AnimationBuilder rotateTo(int angle, double duration)
Rotatethisto the specifiedangledegrees overdurationseconds. If you supply an angle> 360it will make more than one full rotation.Square s = new Square(200, 200, 50); // the square will slowly rotate one turn counter-clockwise over 3 seconds // then, slowly rotate two turns clockwise over 3 seconds c.rotateTo(360, 3).rotateTo(-360, 3);- Parameters:
angle- the absolute angle to rotate to in degrees.duration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
rotateBy
default AnimationBuilder rotateBy(int angle, double duration)
Rotatethisbyangledegrees overdurationseconds. If you supply an angle> 360it will make more than one full rotation.Square s = new Square(200, 200, 50); // the square will slowly rotate one turn counter-clockwise over 3 seconds // then, slowly rotate one turn clockwise over 3 seconds c.rotateBy(360, 3).rotateBy(-360, 3);- Parameters:
angle- the relative angle to rotate to in degrees.duration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
moveBy
default AnimationBuilder moveBy(int x, int y, double duration)
Movethisby the specifiedxandyoverdurationseconds.Circle c = new Circle(200, 200, 50); // the circle will slowly move down 100 over 3 seconds // then, slowly move right over 3 seconds c.moveBy(0, 100, 3).moveBy(200, 0, 3);- Parameters:
x- the x to move byy- the y to move byduration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
moveHorizontalBy
default AnimationBuilder moveHorizontalBy(int x, double duration)
Movethisby the specifiedxhorizontally overdurationseconds. Positive values move right, negative values move left. This method is equivalent tomoveBy(x, 0, duration)Circle c = new Circle(200, 200, 50); // the circle will move slowly right 300 pixels over 3 seconds c.moveHorizontalBy(100, 3);- Parameters:
x- the x to move byduration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
moveVerticalBy
default AnimationBuilder moveVerticalBy(int y, double duration)
Movethisby the specifiedyvertically overdurationseconds. Positive values move down, negative values move up. This method is equivalent tomoveBy(0, y, duration)Circle c = new Circle(200, 200, 50); // the circle will move right 300 pixels over 3 seconds c.moveVerticalBy(100, 3);- Parameters:
y- the y to move byduration- the number of seconds it lasts- Returns:
- an
AnimationBuilder
-
-