final class Color extends AnyRef
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 Colors
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._
.
- Alphabetic
- By Inheritance
- Color
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- val blue: Int
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def darker: Color
Returns a color that is somewhat darker than this one.
- def edit(red: Int = this.red, green: Int = this.green, blue: Int = this.blue, opacity: Int = this.opacity): Color
Returns a color with the specified color components.
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 inmyColor.edit(red = 255, opacity = 100)
. - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(other: Any): Boolean
Determines if this
Color
equals another object. - final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- val green: Int
- lazy val hashCode: Int
Generates a hash code for this
Color
from its four components.Generates a hash code for this
Color
from its four components.- Definition Classes
- Color → AnyRef → Any
- lazy val hsi: (Double, Double, Double)
the HSI (hue--saturation--intensity) equivalents of this RGB color
the HSI (hue--saturation--intensity) equivalents of this RGB color
- returns
the three HSI components as a tuple; cf. hue, saturation, and intensity
- def hue: Double
the hue (“main observable color”) component of this color when viewed in the HSI color scheme, in degrees around the color wheel (0--360)
- def intensity: Double
the intensity (“brightness”) component of this color when viewed in the HSI color scheme, between Color.Min and Color.Max; that is, 0--255
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def lighter: Color
Returns a color that is somewhat lighter than this one.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def negative: Color
Returns the color whose R, G, and B components are the complements of this
Color
object’s respective components (255 minus the value).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. - final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- val opacity: Int
- val red: Int
- def saturation: Double
the saturation (“richness”) component of the color when viewed in the HSI color scheme, between Color.Min and Color.Max; that is, 0--255
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString: String
Returns a string description of this color.
Returns a string description of this color. Examples:
"Red"
,"CornflowerBlue"
(named preset colors)"Color(200, 100, 200)"
(opaque custom color)"Color(200, 100, 200, 50)"
(non-opaque custom color)
- Definition Classes
- Color → AnyRef → Any
- def toSwingColor: java.awt.Color
Returns the java.awt.Color equivalent to this color (which is compatible with Swing GUIs).
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
- Deprecated
(Since version ) see corresponding Javadoc for more information.