Each instance of this class represents a color. The class uses the RGB color scheme: each color is a combination of a red, green, and blue components; there’s also a fourth component of opacity. Color
objects are immutable.
You don’t instantiate Color
directly; instead, you create Color
s with the methods on the Color
companion object (e.g. Color(200, 150, 255)
) or use one of the named color constants in o1.gui.colors. There are also a few methods in this class that returns new Color objects defined in terms of existing ones (e.g., lighter, edit).
This class has an alias in the top-level package o1, so it’s accessible to students simply via import o1.*
.
Parameters
- blue
-
the amount of blue in the color, between Color.Min and Color.Max; that is, 0–255
- green
-
the amount of green in the color, between Color.Min and Color.Max; that is, 0–255
- opacity
-
the opacity of the color, between Color.Min and Color.Max; that is, 0–255
- red
-
the amount of red in the color, between Color.Min and Color.Max; that is, 0–255
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Returns a color that is somewhat darker than this one.
Returns a color that is somewhat darker than this one.
Attributes
Returns a string description of this color, using preset color names where possible. This description reflects the color’s RGB values and opacity. Examples:
Returns a string description of this color, using preset color names where possible. This description reflects the color’s RGB values and opacity. Examples:
"Color(200, 100, 200)"
(opaque custom color)"transparent Color(200, 100, 200, 0)"
(fully transparent custom color)"translucent Color(200, 100, 200, 50)"
(non-opaque, non-transparent custom color)"opaque Brown"
(opaque color with RGB values 165, 42, and 42 — whether the constant LightGreen or an identical custom color)"opaque Brown"
(non-opaque color with RGB values 165, 42, and 42)"transparent Brown"
(fully transparent custom color with RGB values 165, 42, and 42)"translucent Brown"
(non-opaque, non-transparent custom color with RGB values 165, 42, and 42)
Attributes
- See also
Returns a color with the specified color components. The parameters default to this Color
object’s component values, so you can specify just the ones you want to change, as in myColor.edit(red = 255, opacity = 100)
.
Returns a color with the specified color components. The parameters default to this Color
object’s component values, so you can specify just the ones you want to change, as in myColor.edit(red = 255, opacity = 100)
.
Attributes
the hue (“main observable color”) component of this color when viewed in the HSI color scheme, in degrees around the color wheel (0–360)
the hue (“main observable color”) component of this color when viewed in the HSI color scheme, in degrees around the color wheel (0–360)
Attributes
Returns a color that is somewhat lighter than this one.
Returns a color that is somewhat lighter than this one.
Attributes
If this color matches one of the named preset colors, returns that name; None
otherwise. In case this color matches multiple preset colors, uses one of those names.
If this color matches one of the named preset colors, returns that name; None
otherwise. In case this color matches multiple preset colors, uses one of those names.
Attributes
- See also
Returns the color whose R, G, and B components are the complements of this Color
object’s respective components (255 minus the value). Opacity is retained.
Returns the color whose R, G, and B components are the complements of this Color
object’s respective components (255 minus the value). Opacity is retained.
Attributes
Returns a string description of this color. This description reflects how the color was created. Examples:
Returns a string description of this color. This description reflects how the color was created. Examples:
"Red"
,"CornflowerBlue"
(named preset colors)"Color(200, 100, 200)"
(opaque custom color)"Color(200, 100, 200, 50)"
(non-opaque custom color)
Attributes
- See also
- Definition Classes
Returns the java.awt.Color equivalent to this color (which is compatible with Swing GUIs).
Returns the java.awt.Color equivalent to this color (which is compatible with Swing GUIs).
Attributes
Concrete fields
A hash code generated for this Color
from its four components.
A hash code generated for this Color
from its four components.
Attributes
the HSI (hue—saturation—intensity) equivalents of this RGB color
the HSI (hue—saturation—intensity) equivalents of this RGB color
Attributes
- Returns
-
the three HSI components as a tuple; cf. hue, saturation, and intensity