vray.Color

class vray.Color

Bases: object

A 3-component floating point color value. It supports mathematical operations, indexing and equality checking. In most contexts the component values are in the range (0; 1), but in lighting calculations HDR values above 1.0 are possible. This object is immutable.

  • Color() -> new Color with value (0, 0, 0)

  • Color(red, green, blue) -> new Color full constructor

Attributes

COLOR_SPACE_ACEScg

COLOR_SPACE_CIE

COLOR_SPACE_SRGB

b

Color blue component

g

Color green component

r

Color red component

Methods

__init__()

fromSRGB(self)

Creates a color with R, G and B values converted from sRGB to linear values.

fromTemperature(self, temperature, rgbColorSpace)

Creates a color with components equal to the normalized RGB color of a black body with the given temperature in Kelvin.

getClosestTemperature(self, rgbColorSpace)

Finds the black body color that is closest to the given color and returns its temperature in Kelvin.

getClosestTemperatureAndColor(self, …)

Finds the black body color that is closest to the given color and returns it and its temperature in Kelvin.

getIntensity(self)

Returns the intensity of the color (also called chroma or saturation) which is the brightness or dullness of a color.

getLength(self)

Returns the length of the color.

getLengthSquared(self)

Returns the squared length of the color.

getLuminance(self)

Returns the luminance of the color which is a measure of the intensity of light that reaches the eye.

getPower(self)

Returns the sum of all color components.

getRGBToRGBMatrix(self, srcColorSpace, …)

Compute the rgb to rgb transformation matrix between two linear color spaces This is an expensive operation and you should cache the matrix if possible

getWhiteComplement(self)

Returns the white complement of the Color.

setContrast(self, k, middle)

Applies a contrast correction to the color and returns the new color.

setSaturation(self, k)

(De)saturates the given color and returns the new color.

toSRGB(self)

Creates a color with R, G and B values converted from (presumably) linear to sRGB values.

fromSRGB(self) → Color

Creates a color with R, G and B values converted from sRGB to linear values. Returns the created Color.

static fromTemperature(self, temperature: float, rgbColorSpace: int) → Color

Creates a color with components equal to the normalized RGB color of a black body with the given temperature in Kelvin.

  • temperature The color temperature in Kelvin.

  • rgbColorSpace The color space to use from [vray.Color.COLOR_SPACE_CIE, vray.Color.COLOR_SPACE_SRGB, vray.Color.COLOR_SPACE_ACEScg]

Returns the created Color.

getClosestTemperature(self, rgbColorSpace: int) → float

Finds the black body color that is closest to the given color and returns its temperature in Kelvin.

  • rgbColorSpace The color space to use from [vray.Color.COLOR_SPACE_CIE, vray.Color.COLOR_SPACE_SRGB, vray.Color.COLOR_SPACE_ACEScg]

Returns a number.

getClosestTemperatureAndColor(self, rgbColorSpace: int) → tuple[float, Color]

Finds the black body color that is closest to the given color and returns it and its temperature in Kelvin.

  • rgbColorSpace The color space to use from [vray.Color.COLOR_SPACE_CIE, vray.Color.COLOR_SPACE_SRGB, vray.Color.COLOR_SPACE_ACEScg]

Returns a tuple with two elements.

getIntensity(self) → float

Returns the intensity of the color (also called chroma or saturation) which is the brightness or dullness of a color.

Returns the intensity of the color.

getLength(self) → float

Returns the length of the color.

getLengthSquared(self) → float

Returns the squared length of the color.

getLuminance(self) → float

Returns the luminance of the color which is a measure of the intensity of light that reaches the eye.

Returns the luminance of the color.

getPower(self) → float

Returns the sum of all color components.

static getRGBToRGBMatrix(self, srcColorSpace: int, dstColorSpace: int) → Matrix

Compute the rgb to rgb transformation matrix between two linear color spaces This is an expensive operation and you should cache the matrix if possible

  • srcColorSpace Source RGB color space from [vray.Color.COLOR_SPACE_CIE, vray.Color.COLOR_SPACE_SRGB, vray.Color.COLOR_SPACE_ACEScg]

  • dstColorSpace Destination RGB color space from [vray.Color.COLOR_SPACE_CIE, vray.Color.COLOR_SPACE_SRGB, vray.Color.COLOR_SPACE_ACEScg]

Returns Matrix that converts from source to destination.

getWhiteComplement(self) → Color

Returns the white complement of the Color.

Note that this will clamp (restrict a number between two other numbers) the color from below (e.g. no component will be below zero).

setContrast(self, k: float, middle: float = 0.5) → Color

Applies a contrast correction to the color and returns the new color.

  • k double number: the contrast scale - 1.0 leaves the color unchanged and 0.0 makes the color equal to the middle

  • middle double number: an optional argument the contrast base - the level that remains unchanged (default value set to 0.5)

setSaturation(self, k: float) → Color

(De)saturates the given color and returns the new color.

  • k double number: for k=0.0 means color is greyed; for k=1.0 means the color is unchanged; for k>1.0 adds more color

toSRGB(self) → Color

Creates a color with R, G and B values converted from (presumably) linear to sRGB values. Returns the created Color.

COLOR_SPACE_ACEScg = 2
COLOR_SPACE_CIE = 0
COLOR_SPACE_SRGB = 1
b

Color blue component

g

Color green component

r

Color red component