Color

o1.gui.Color$
See theColor companion class
object Color

This companion object of class Color provides methods for creating new Color objects. There is also a small selection of related utility methods and constants.

For many constants of type Color that represent different preset colors, see o1.gui.colors.

This object has an alias in the top-level package o1, so it’s accessible to students simply via import o1.*.

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Color.type

Members list

Value members

Concrete methods

Creates a new fully opaque Color with the given RGB components.

Creates a new fully opaque Color with the given RGB components.

Parameters

blue

the amount of blue in the color; values outside the 0–255 range are clamped to fit it

green

the amount of green in the color; values outside the 0–255 range are clamped to fit it

red

the amount of red in the color; values outside the 0–255 range are clamped to fit it

Attributes

Returns

the color

Creates a new Color with the given RGB components and opacity.

Creates a new Color with the given RGB components and opacity.

Parameters

blue

the amount of blue in the color; values outside the 0–255 range are clamped to fit it

green

the amount of green in the color; values outside the 0–255 range are clamped to fit it

opacity

the opacity of the color; values outside the 0–255 range are clamped to fit it

red

the amount of red in the color; values outside the 0–255 range are clamped to fit it

Attributes

Returns

the color

Creates a Color specified in terms of the HSI (hue—saturation—intensity) color scheme.

Creates a Color specified in terms of the HSI (hue—saturation—intensity) color scheme.

Parameters

hue

the hue (“main observable color”) component of color, in degrees around the color wheel (0–360)

intensity

the intensity (“brightness”) component of the color; values outside the 0–255 range are clamped to fit it

opacity

the color’s opacity; if unspecified, defaults to fully opaque (Color.Max)

saturation

the saturation (“richness”) component of the color; values outside the 0–255 range are clamped to fit it

Attributes

Returns

the color (represented internally as RGB nonetheless)

Deconstructs a Color to its components and returns them as a tuple. Its presence here in the companion object enables us to write things like:

Deconstructs a Color to its components and returns them as a tuple. Its presence here in the companion object enables us to write things like:

myColor match
 case Color(r, g, b, 255)          => "opaque color: " + r + "," + g + "," + b
 case Color(r, _, _, _) if r > 200 => "high in red"
 case _                            => "other color"

Parameters

color

any color

Attributes

Returns

a Some that contains a tuple with all the RGB components of the given color and its opacity

Concrete fields

val Max: Int

The maximum value of a Color’s RGB and opacity components. (They range between 0 and 255, so this equals 255.)

The maximum value of a Color’s RGB and opacity components. (They range between 0 and 255, so this equals 255.)

Attributes

val Min: Int

The minimum value of a Color’s RGB and opacity components. (They range between 0 and 255, so this equals zero.)

The minimum value of a Color’s RGB and opacity components. (They range between 0 and 255, so this equals zero.)

Attributes

Givens