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.ColorgetColor()Get the current color of an element as aColorvoidinternalSetColor(java.awt.Color color)default TsetColor(int hex)Set the color ofthisto the specifiedcolor.default TsetColor(int r, int g, int b)Set the color ofthisto the specifiedcolor.default TsetColor(int r, int g, int b, int a)default TsetColor(java.awt.Color color)Set the color of the object with aColorobject.default TsetColor(java.lang.String name)Set the color of the object with a hue name or hex code.default TsetColor(Hue hue)Set the color of the object with aHueobject.-
Methods inherited from interface paintingcanvas.animation.Animatable
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.
-
Methods inherited from interface paintingcanvas.drawable.Drawable
Modifier and Type Method Description default AnimationBuilderanimate()Start animating this object.default TbringToFront()Brings the object in front of all other objects.java.awt.Pointcenter(java.awt.Graphics2D g)Get the object's centerpointdefault Drawable<?>drawable()Get theDrawableelement from thisAnimatable.default voiderase()Erase this object from the canvas.intgetLayer()Gets the current layer of the object.TgetThis()Thide()Hide the Object.voidinternalSetLayer(int layer)voidrender(java.awt.Graphics2D g)Actually render the object itselfdefault TsendToBack()Puts the object behind all other objects.default TsetLayer(int layer)Puts the object on a specific layer.Tshow()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
Colorof the element
-
setColor
default T setColor(java.awt.Color color)
Set the color of the object with aColorobject.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 ofthisto 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 aHueobject.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 ofthisto 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 ofthisto the specifiedcolorSee 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
-
-