Package paintingcanvas.drawable
Interface Colorable<T extends Drawable<T>>
-
- Type Parameters:
T
- the type of the object
- All Superinterfaces:
Animatable
,Drawable<T>
- All Known Implementing Classes:
Circle
,DrawableBase
,DrawableBase.InteractableShape
,DrawableBase.OutlineableDrawableBase
,DrawableBase.Shape
,Ellipse
,Image
,Line
,Path
,Polygon
,Rectangle
,Square
,Text
,Triangle
public interface Colorable<T extends Drawable<T>> extends Drawable<T>
Elements that can be colored in with a
Color
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.awt.Color
getColor()
Get the current color of an element as aColor
void
internalSetColor(java.awt.Color color)
default T
setColor(int hex)
Set the color ofthis
to the specifiedcolor
.default T
setColor(int r, int g, int b)
Set the color ofthis
to the specifiedcolor
.default T
setColor(int r, int g, int b, int a)
default T
setColor(java.awt.Color color)
Set the color of the object with aColor
object.default T
setColor(java.lang.String name)
Set the color of the object with a hue name or hex code.default T
setColor(Hue hue)
Set the color of the object with aHue
object.-
Methods inherited from interface paintingcanvas.animation.Animatable
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.
-
Methods inherited from interface paintingcanvas.drawable.Drawable
Modifier and Type Method Description default AnimationBuilder
animate()
Start animating this object.default T
bringToFront()
Brings the object in front of all other objects.java.awt.Point
center(java.awt.Graphics2D g)
Get the object's centerpointdefault Drawable<?>
drawable()
Get theDrawable
element from thisAnimatable
.default void
erase()
Erase this object from the canvas.int
getLayer()
Gets the current layer of the object.T
getThis()
T
hide()
Hide the Object.void
internalSetLayer(int layer)
void
render(java.awt.Graphics2D g)
Actually render the object itselfdefault T
sendToBack()
Puts the object behind all other objects.default T
setLayer(int layer)
Puts the object on a specific layer.T
show()
Show the Object
-
-
-
-
Method Detail
-
internalSetColor
void internalSetColor(java.awt.Color color)
-
getColor
java.awt.Color getColor()
Get the current color of an element as aColor
- Returns:
- the
Color
of the element
-
setColor
default T setColor(java.awt.Color color)
Set the color of the object with aColor
object.Circle o = new Circle(100, 100, 20); o.setColor(Color.RED); // Set color to red
- Parameters:
color
- color.- Returns:
- the original object to allow method chaining
-
setColor
default T setColor(int hex)
Set the color ofthis
to the specifiedcolor
. See Wikipedia for how this works.Circle o = new Circle(100, 100, 20); // 0xFF0000 is hex for (255, 0, 0), which is red o.setColor(0xFF0000);
- Parameters:
hex
- the number describing the RGB color- Returns:
- the original object to allow method chaining
-
setColor
default T setColor(Hue hue)
Set the color of the object with aHue
object.Circle o = new Circle(100, 100, 20); o.setColor(Hue.GREEN); // Set color to red
- Parameters:
hue
- the hue- Returns:
- the original object to allow method chaining
-
setColor
default T setColor(java.lang.String name)
Set the color of the object with a hue name or hex code.- Parameters:
name
- the string describing the hue or the hex code- Returns:
- the original object to allow method chaining
- See Also:
Misc.stringToColor(String)
-
setColor
default T setColor(int r, int g, int b)
Set the color ofthis
to the specifiedcolor
. See Wikipedia for how this works.Circle o = new Circle(100, 100, 20); o.setColor(255, 0, 0); // Set color to red
- Parameters:
r
- red (0-255)g
- green (0-255)b
- blue (0-255)- Returns:
- the original object to allow method chaining
-
setColor
default T setColor(int r, int g, int b, int a)
Set the color ofthis
to the specifiedcolor
See Wikipedia for how this works.Circle o = new Circle(100, 100, 20); o.setColor(255, 0, 0); // Set color to red
- Parameters:
r
- red (0-255)g
- green (0-255)b
- blue (0-255)a
- alpha (0-255)- Returns:
- the original object to allow method chaining
-
-