Package paintingcanvas.animation
Interface Animatable
-
-
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(java.awt.Color color, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.Drawable<?>
drawable()
Get theDrawable
element from thisAnimatable
.default AnimationBuilder
fadeIn(double duration)
Fadesthis
in over @{code duration} seconds.default AnimationBuilder
fadeOut(double duration)
Fadesthis
out over @{code duration} seconds.default AnimationBuilder
moveBy(int x, int y, double duration)
This method movesthis
by the specifiedx
andy
default AnimationBuilder
moveHorizontalBy(int x, double duration)
This method movesthis
by the specifiedx
horizontally.default AnimationBuilder
moveTo(int x, int y, double duration)
Movethis
to the specifiedx
andy
overduration
secondsdefault AnimationBuilder
moveVerticalBy(int y, double duration)
This method movesthis
by the specifiedx
horizontally.default AnimationBuilder
rotateBy(int angle, double duration)
Rotatesthis
byangle°
.default AnimationBuilder
rotateTo(int angle, double duration)
Rotatesthis
to the specifiedangle°
.
-
-
-
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 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 toy
- the y-position to move toduration
- the number of seconds it lasts- Returns:
- an
this
-
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 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 ofthis
to the specifiedcolor
overduration
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 colorduration
- the number of seconds it lasts- Returns:
- an
this
-
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 red, and then blue c.colorTo(Color.RED, 3).colorTo(Color.BLUE, 3);
- Parameters:
color
- The color to fade toduration
- the number of seconds it lasts- Returns:
- an
this
-
fadeOut
default AnimationBuilder fadeOut(double duration)
Fadesthis
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)
Fadesthis
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)
Rotatesthis
to the specifiedangle°
. 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)
Rotatesthis
byangle°
.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 movesthis
by the specifiedx
andy
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 byy
- the y to move byduration
- the number of seconds it lasts- Returns:
- an
this
-
moveHorizontalBy
default AnimationBuilder moveHorizontalBy(int x, double duration)
This method moves
this
by the specifiedx
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 byduration
- the number of seconds it lasts- Returns:
- an
this
-
moveVerticalBy
default AnimationBuilder moveVerticalBy(int y, double duration)
This method moves
this
by the specifiedx
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 byduration
- the number of seconds it lasts- Returns:
- an
this
-
-