User Tools

Site Tools


DzFloatColor

A 4-component floating point color value.

More...

Inherits :

Properties

Constructors

DAZ Script
DzFloatColor ()
DzFloatColor ( Number r, Number g, Number b, Number a=1.0 )
DzFloatColor ( Number val, Number alpha=1.0 )
DzFloatColor ( Array color )
DzFloatColor ( Color color )
DzFloatColor ( DzFloatColor color )

Methods

DAZ Script
voidclamp ( Number min, Number max, Boolean includeAlpha=false )
DzFloatColorclamped ( Number min, Number max, Boolean includeAlpha=false )
DzFloatColorclampedMax ( Number max, Boolean includeAlpha=false )
DzFloatColorclampedMin ( Number min, Boolean includeAlpha=false )
voidclampMax ( Number max, Boolean includeAlpha=false )
voidclampMin ( Number min, Boolean includeAlpha=false )
Booleanequals ( DzFloatColor color, Number tolerance=0.000001 )
voidgammaColor ( Number gamma=2.2, Boolean doAlpha=false )
ColorgetColor ()
NumbergetGrayscale ()
ArraygetHsl ()
ArraygetHsv ()
NumbergetMaxRGBValue ()
NumbergetRelativeLuminance ()
ArraygetRgba ()
voidlinearizeColor ( Number gamma=2.2, Boolean doAlpha=false )
DzFloatColormodulate ( Number min, Number max, Boolean includeAlpha=false )
voidmodulo ( Number min, Number max, Boolean includeAlpha=false )
voidsetHsl ( Array list )
voidsetHsl ( Number h, Number s, Number l, Number a=1.0 )
voidsetHsv ( Number h, Number s, Number v, Number a=1.0 )
voidsetHsv ( Array list )
voidsetRgba ( Array list )
voidsetValue ( Number r, Number g, Number b, Number a=1.0 )
voidsetValue ( Color color )

Detailed Description

This class manages 4-component colors (colors that can include an alpha value).

Properties


String : blue

Holds the blue value for the color. Should be in the [0,1] range.


String : green

Holds the green value for the color. Should be in the [0,1] range.


String : red

Holds the red value for the color. Should be in the [0,1] range.

Constructors


DzFloatColor()

Default constructor. Initializes a new color to opaque black.


DzFloatColor( Number r, Number g, Number b, Number a=1.0 )

Constructor that takes individual floating-point RGBA components. Initializes the color to the given values. Values should be in the [0,1] range.

Parameter(s):

  • r - The red value for the color
  • g - The green value for the color
  • b - The blue value for the color
  • a - The alpha value for the color

Example

var oFloatColor4Arg = new DzFloatColor( 1, 0.5, 0.5, 1 );
print( oFloatColor4Arg ); //[1,0.5,0.5,1]

DzFloatColor( Number val, Number alpha=1.0 )

Constructor that creates an achromatic color.

Parameter(s):

  • val - The value to use for each color component.
  • alpha - The value to use for the alpha component.

Example

var oFloatColor1Arg = new DzFloatColor( 0.5 );
print( oFloatColor1Arg ); //[0.5,0.5,0.5,1]
 
var oFloatColor2Arg = new DzFloatColor( 0.5, 1 );
print( oFloatColor2Arg ); //[0.5,0.5,0.5,1]

DzFloatColor( Array color )

Constructor that takes a floating-point array to define RGBA colors. Initializes the color to the given values.

Parameter(s):

  • color - An array of float values for the color. The array can have 1, 2, 3 or 4 float values. The length of the array has meanings that correspond with the other constructors. Values should be in the [0,1] range.

Example

var oFloatColorArray1Arg = new DzFloatColor( [ 1 ] );
print( oFloatColorArray1Arg ); //[1,1,1,1]
 
var oFloatColorArray2Arg = new DzFloatColor( [ 0.5, 1 ] );
print( oFloatColorArray2Arg ); //[0.5,0.5,0.5,1]
 
var oFloatColorArray3Arg = new DzFloatColor( [ 1, 0.5, 0.25 ] );
print( oFloatColorArray3Arg ); //[1,0.5,0.25,1]
 
var oFloatColorArray4Arg = new DzFloatColor( [ 1, 0.5, 0.25, 1 ] );
print( oFloatColorArray4Arg ); //[1,0.5,0.25,1]

DzFloatColor( Color color )

Constructor that takes a QColor. Initializes the color to the given color. The color is assumed to be completely opaque.

Parameter(s):

  • color - The color value to copy into this color.

Example

var oColor = new Color( 255, 128, 0 );
 
var oFloatColorCopyColor = new DzFloatColor( oColor );
print( oFloatColorCopyColor ); //[1,0.501961,0,1]

DzFloatColor( DzFloatColor color )

Copy Constructor.

Parameter(s):

  • color - The color object to copy.

Example

var oColor = new Color( 255, 128, 0 );
 
var oFloatColorCopyColor = new DzFloatColor( oColor );
print( oFloatColorCopyColor ); //[1,0.501961,0,1]
 
var oFloatColorCopyFloatColor = new DzFloatColor( oFloatColorCopyColor );
print( oFloatColorCopyFloatColor ); //[1,0.501961,0,1]

Methods


void : clamp( Number min, Number max, Boolean includeAlpha=false )

Modifies the color such that the value of no component is less than min and no more than max.

Parameter(s):

  • min - The minimum value to allow in each component of the color.
  • max - The maximum value to allow in each component of the color.
  • includeAlpha - If true, the alpha component is also clamped.

DzFloatColor : clamped( Number min, Number max, Boolean includeAlpha=false )

Parameter(s):

  • min - The minimum value to allow in each component of the color.
  • max - The maximum value to allow in each component of the color.
  • includeAlpha - If true, the alpha component is also clamped.

Return Value:

  • A copy of this color where the value of no component is less than min and no more than max.

DzFloatColor : clampedMax( Number max, Boolean includeAlpha=false )

Parameter(s):

  • max - The maximum value to allow in each component of the color.
  • includeAlpha - If true, the alpha component is also clamped.

Return Value:

  • A copy of this color where the value of no component is more than max.

DzFloatColor : clampedMin( Number min, Boolean includeAlpha=false )

Parameter(s):

  • min - The minimum value to allow in each component of the color.
  • includeAlpha - If true, the alpha component is also clamped.

Return Value:

  • A copy of this color where the value of no component is less than min.

void : clampMax( Number max, Boolean includeAlpha=false )

Modifies the color such that the value of no component is more than max.

Parameter(s):

  • max - The maximum value to allow in each component of the color.
  • includeAlpha - If true, the alpha component is also clamped.

void : clampMin( Number min, Boolean includeAlpha=false )

Modifies the color such that the value of no component is less than min.

Parameter(s):

  • min - The minimum value to allow in each component of the color.
  • includeAlpha - If true, the alpha component is also clamped.

Boolean : equals( DzFloatColor color, Number tolerance=0.000001 )

Parameter(s):

  • color - The color to test this color against.
  • tolerance - The amount of deviation to allow in each component of the color.

Return Value:

  • true if this color is within tolerance of color, otherwise false.

void : gammaColor( Number gamma=2.2, Boolean doAlpha=false )

Applies a gamma value to the color.

Parameter(s):

  • gamma - The gamma value to apply.
  • doAlpha - If true, applies gamma to the alpha channel of the color.

Color : getColor()

Holds the alpha value for the color. Should be in the [0,1] range.


Number : getGrayscale()

Return Value:

  • A suitable grayscale equivalent of this color.

Array : getHsl()

Return Value:

  • An array consisting of the hue, saturation, lightness and alpha component values.

Array : getHsv()

Return Value:

  • An array consisting of the hue, saturation, value and alpha component values.

Number : getMaxRGBValue()

Return Value:

  • The maximum value for this color.

Number : getRelativeLuminance()

Return Value:

  • The relative luminance for this color, calculated as: Y = 0.212671*R + 0.715160*G + 0.072169*B

Array : getRgba()

Return Value:

  • An array consisting of the red, green, blue and alpha component values.

void : linearizeColor( Number gamma=2.2, Boolean doAlpha=false )

Linerizes the color based on a gamma value.

Parameter(s):

  • gamma - The gamma value to linearize by.
  • doAlpha - If true, linearizes the alpha channel of the color by gamma.

DzFloatColor : modulate( Number min, Number max, Boolean includeAlpha=false )

Parameter(s):

  • min - The minimum value to allow in each component of the color.
  • max - The maximum value to allow in each component of the color.
  • includeAlpha - If true, the alpha component is also clamped.

Return Value:

  • A copy of this color where the value of each component is modulated between min and max.

void : modulo( Number min, Number max, Boolean includeAlpha=false )

Modifies the color such that the value of each component is modulated between min and max.

Parameter(s):

  • min - The minimum value to allow in each component of the color.
  • max - The maximum value to allow in each component of the color.
  • includeAlpha - If true, the alpha component is also modulated.

void : setHsl( Array list )

Sets the color according to an array of the hue, saturation, lightness and (optionally) alpha component values.


void : setHsl( Number h, Number s, Number l, Number a=1.0 )

Sets a HSL value on the color.

Parameter(s):

  • h - The value to set on the hue component.
  • s - The value to set on the saturation component.
  • l - The value to set on the lightness component.
  • a - The value to set on the alpha component.

void : setHsv( Number h, Number s, Number v, Number a=1.0 )

Sets a HSV value on the color.

Parameter(s):

  • h - The value to set on the hue component.
  • s - The value to set on the saturation component.
  • v - The value to set on the value component.
  • a - The value to set on the alpha component.

void : setHsv( Array list )

Sets the color according to an array of the hue, saturation, value and alpha component values.


void : setRgba( Array list )

Sets the color according to an array of the red, green, blue and alpha component values.


void : setValue( Number r, Number g, Number b, Number a=1.0 )

Sets the color values. Values should be in the [0,1] range.

Parameter(s):

  • r - The red value for the color
  • g - The green value for the color
  • b - The blue value for the color
  • a - The alpha value for the color

See Also:

  • getValue()

void : setValue( Color color )

TODO: Add description.