IC Python API:RLPy RColor

From Reallusion Wiki!
Jump to: navigation, search
Main article: Modules.
Last modified: 04/12/2020

Description

Primary color class that stores data for red (R), green (G), and blue (B). The value stored in RColor ranges from 0 to 1, which represents 0 to 255 in color value. You can swtich between these two representations in different ways; For example, the range of values retrieved by R is 0 to 1, and the range of values retrieved by Red is 0 to 255. In addition, preset colors are provided for direct usage:

Constant Value
RLPy.RColor.BLACK RLPy.RColor(0, 0, 0)
RLPy.RColor.WHITE RLPy.RColor(1, 1, 1)
RLPy.RColor.RED RLPy.RColor(1, 0, 0)
RLPy.RColor.GREEN RLPy.RColor(0, 1, 0)
RLPy.RColor.BLUE RLPy.RColor(0, 0, 1)
RLPy.RColor.YELLOW RLPy.RColor(1, 1, 0)
RLPy.RColor.CYAN RLPy.RColor(0, 1, 1)
RLPy.RColor.MAGENTA RLPy.RColor(1, 0, 1)

This class also provides conversions to other color formats:

 1 # create color
 2 color_red1 = RLPy.RColor(1,0,0,1)
 3 color_red2 = RLPy.RColor()
 4 color_red2.From(255,0,0,255)
 5 color_red3 = RLPy.RColor.RED_ALPHA
 6  
 7 # print color
 8 print( color_red1.R() )		# 1
 9 print( color_red1.Red() )	# 255
10  
11 # convert different format
12 print(hex(color1.ToXRGB()))	# 0xff0000
13 print(hex(color1.ToCOLORREF()))# 0xff

See Also: RRgb

Member Functions

A ( self, args )

Get the alpha value of this color (0-1).

See Also: Alpha

Returns

Value for the alpha channel - float [0,1]
1 color1 = RLPy.RColor(0,0,1,1)
2 print( color1.A() )		# 1

AdjustHSBC ( self, fHue, fSaturate, fBrightness, fContrast, bInvert )

Use HSBC to adjust this color. H stands for hue, S stands for saturation, B for brightness, and C for contrast. The HSBC values range from 0 to 1. If the invert option is true, then the output RGB color will be inverted (1-R, 1-G, 1-B), otherwise known as complementary color.

See Also: B

Parameters

fHue [IN] Hue - float [0,1]
fSaturate [IN] Saturate - float [0,1]
fBrightness [IN] Brightness - float [0,1]
fContrast [IN] Contrast - float [0,1]
bInvert [IN] Whether to invert - bool
1 color1 = RLPy.RColor()
2 color1.AdjustHSBC(0.5, 0.5, 0.5, 0.5, False)

AdjustRGBA ( self, fRed, fGreen, fBlue, fAlpha, bInvert )

Use RGBA (red, Green, Blue, alpha) to adjust this color. The RGBA values range from 0 to 1. When the invert option is true, then the output RGB color will be inverted (1-R, 1-G, 1-B), otherwise known as complementary color.

Parameters

fRed [IN] Red - float [0,1]
fGreen [IN] Green - float [0,1]
fBlue [IN] Blue - float [0,1]
fAlpha [IN] Alpha - float [0,1]
bInvert [IN] Whether to invert - bool
1 color1 = RLPy.RColor()
2 color1.AdjustRGBA(0.5, 0.5, 0.5, 1.0, False)

Alpha ( self )

Get the alpha value of this color (0-255).

See Also: A

Returns

Value of the alpha channel - int [0,255]
1 color1 = RLPy.RColor(0,0,1,1)
2 print( color1.Alpha() )		# 255

B ( self, args )

Get the blue value of this color (0-1).

See Also: Blue

Returns

Value for the blue channel - float [0,1]
1 color1 = RLPy.RColor(0,0,1,1)
2 print( color1.B() )		# 1

Blue ( self, args )

Get the blue value of this color (0-255).

See Also: B

Returns

Value for the blue channel - float [0,255]
1 color1 = RLPy.RColor(0,0,1,1)
2 print( color1.Blue() )		# 255

From ( self, r, g, b, a )

Adjust color using 32 bit (0-255).

Parameters

r [IN] Red value - int [0,255]
g [IN] Green value - int [0,255]
b [IN] Blue value - int [0,255]

Returns

Changed color - RColor
1 color1 = RLPy.RColor()
2 color1.From(255,0,0,255)

FromARGB ( self, arg2 )

Adjust color using ARGB (0xaarrggbb).

Parameters

arg2 [IN] ARGB value.

Returns

Changed color - RColor
1 color1 = RLPy.RColor()
2 color1.FromARGB(int('ff0000ff',16))

FromCOLORREF ( self, arg2 )

Adjust color using COLORREF (0xbbggrr).

Parameters

arg2 [IN] COLORREF data

Returns

Changed color - RColor
1 color1 = RLPy.RColor()
2 color1.FromCOLORREF(int('ff0000',16))

FromHSL( self, fHue, fStaurate, fLevel )

Adjust color using HSL (Hue, Saturation, Lightness).

Parameters

fHue [IN] Hue - float [0,1]
fSaturate [IN] Saturation - float [0,1]
fLevel [IN] Lightness - float [0,1]
1 color1 = RLPy.RColor()
2 color1.FromHSL(0.5,0.5,0.5)

G ( self, args )

Get the green value of this color (0-1).

See Also: Green

Returns

Green value of this color - float [0,1]
1 color1 = RLPy.RColor(0,1,0,1)
2 print( color1.G() )		# 1

GammaCorrect ( self, fGamma )

Output this color with gamma correction.

Returns

Gamma corrected color - RColor
1 color1 = RLPy.RColor(0.5,0,0,1)
2 print( color1.GammaCorrect() )	# RGBA(0.73,0,0,1)

Green ( self )

Get the green value of this color (0-255).

See Also: G

Returns

Green value of this color (0-255) - int
1 color1 = RLPy.RColor(0,1,0,1)
2 print( color1.Green() )		# 1

Normalize( self )

Normalize RGB values so that their sum equals 1.

Returns

Normalized color - RColor
1 color1 = RLPy.RColor(0,1,0,1)
2 color1.Normalize()		# (0, 0.5, 0, 0.5)

R ( self, args )

Get the red value of this color (0-1).

See Also: Red

Returns

Red value of this color - float [0,1]
1 color1 = RLPy.RColor(1,0,0,1)
2 print( color1.R() )		# 1

Red ( self )

Get the red value of this color (0-255).

See Also: R

Returns

Red value of this color - int [0,255]
1 color1 = RLPy.RColor(1,0,0,1)
2 print( color1.Red() )		# 255

Saturate ( self )

Clamp the RGB values to a range of 0 and 1. Values under 0 will become 0, and values over 1 will become 1.

Returns

This color saturated - RColor
1 color1 = RLPy.RColor(1.2,-0.3,0.5, 1.0)
2 color1.Saturate()		# (1, 0, 0.5, 1.0)

ToARGB ( self )

Output ARGB data from this color (0xaarrggbb).

See Also: FromARGB

Returns

ARGB color data - int
1 color1 = RLPy.RColor(0, 0, 1, 1)
2 print( int(color1.ToARGB()) )		# 0xffff0000

ToARGB ( self )

Output ARGB data from this color (0xaarrggbb).

Returns

ARGB color data - int

See Also: FromARGB

1 color1 = RLPy.RColor(0, 0, 1, 1)
2 print( int(color1.ToARGB()) )		# 0xffff0000

ToCOLORREF ( self )

Output COLORREF data from this color (0xbbggrr).

See Also: FromCOLORREF

Returns

COLORREF color data - int
1 color1 = RLPy.RColor(0, 0, 1, 1)
2 print( int(color1.ToCOLORREF()) )		# 0xff0000

ToGrayScale ( self )

Output grayscale data from this color (0-1).

Returns

Grayscale data - float [0,1]
1 color1 = RLPy.RColor(0, 0, 1, 1)
2 print( color1.ToGrayScale() )		# 0.11400000005960464