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 Animatable
An interface to call animation methods on animatable objects.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default AnimationBuilder
colorTo(int hex, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.default AnimationBuilder
colorTo(int r, int g, int b, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.default AnimationBuilder
colorTo(int r, int g, int b, int a, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.default AnimationBuilder
colorTo(java.awt.Color color, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.default AnimationBuilder
colorTo(java.lang.String name, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.default AnimationBuilder
colorTo(Hue hue, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.Drawable<?>
drawable()
Get theDrawable
element from thisAnimatable
.default AnimationBuilder
fadeIn(double duration)
Fadethis
in overduration
seconds.default AnimationBuilder
fadeOut(double duration)
Fadethis
out overduration
seconds.default AnimationBuilder
moveBy(int x, int y, double duration)
Movethis
by the specifiedx
andy
overduration
seconds.default AnimationBuilder
moveHorizontalBy(int x, double duration)
Movethis
by the specifiedx
horizontally overduration
seconds.default AnimationBuilder
moveTo(int x, int y, double duration)
Movethis
to the specifiedx
andy
overduration
secondsdefault AnimationBuilder
moveVerticalBy(int y, double duration)
Movethis
by the specifiedy
vertically overduration
seconds.default AnimationBuilder
rotateBy(int angle, double duration)
Rotatethis
byangle
degrees overduration
seconds.default AnimationBuilder
rotateTo(int angle, double duration)
Rotatethis
to the specifiedangle
degrees overduration
seconds.
-
-
-
Method Detail
-
drawable
Drawable<?> drawable()
Get theDrawable
element from thisAnimatable
.- Returns:
- the
Drawable
-
moveTo
default AnimationBuilder moveTo(int x, int y, double duration)
Movethis
to the specifiedx
andy
overduration
secondsCircle 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 ofthis
to the specifiedcolor
overduration
seconds. 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 ofthis
to the specifiedcolor
overduration
seconds. 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 ofthis
to the specifiedcolor
overduration
seconds. 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 ofthis
to the specifiedcolor
overduration
seconds.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 ofthis
to the specifiedcolor
overduration
seconds.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 ofthis
to the specifiedcolor
overduration
seconds. SeeColor
for 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)
Fadethis
out overduration
seconds.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)
Fadethis
in overduration
seconds.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)
Rotatethis
to the specifiedangle
degrees overduration
seconds. If you supply an angle> 360
it 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)
Rotatethis
byangle
degrees overduration
seconds. If you supply an angle> 360
it 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)
Movethis
by the specifiedx
andy
overduration
seconds.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)
Movethis
by the specifiedx
horizontally overduration
seconds. 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)
Movethis
by the specifiedy
vertically overduration
seconds. 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
-
-