On this page:
Color
Color.red
Color.green
Color.blue
Color.alpha
Color.scale
Color.blend
Color.handle
Color.from_  handle
8.12

2 Color🔗ℹ

class

class Color():

  constructor

  | (name :: String)

  | (red :: Byte, green :: Byte, blue :: Byte)

  | (red :: Byte, green :: Byte, blue :: Byte,

     alpha :: Real.in(0.0, 1.0))

When name is given, it must be one of the predefined names listed with #{color-database<%>}.

When alpha is not supplied, 1.0 is used.

Color like an existing one can be constructed using with and the field names red, green, blue, and/or alpha.

property

property (col :: Color).red :: Byte

 

property

property (col :: Color).green :: Byte

 

property

property (col :: Color).blue :: Byte

 

property

property (col :: Color).alpha :: Real.in(0, 1)

Properties to access color components.

method

method (col :: Color).scale(factor :: NonnegReal) :: Color

Scales a color, making it brighter or darker. If factor is less than 1, the color is darkened by multiplying the red, green, and blue components by factor. If factor is greater than 1, the color is lightened by dividing the gap between the red, green, and blue components and 255 by factor.

method

method (col :: Color).blend(other :: Color) :: Color

Blends two colors to produce a new one. Each red, green, and blue component contibutes to the corresponding blended component by its weighted average, where each color’s alpha is is weight. The result color’s alpha is the average of the two color’s alphas.

property

property (col :: Color).handle :: Any

 

function

fun Color.from_handle(hand :: Any) :: Color

The Color.handle property returns a Racket object that corresponds to the drawing context for use directly with racket/draw. The Color.from_handle function creates a Color from such a Racket object.