IC8 Python API:RLPy RColor

From Reallusion Wiki!
Jump to: navigation, search

Contents

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: {| class="wikitable" !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: See Also: RRgb

Constructor & Destructor

__init__ (self, *args)

Initializes a new color value instance.

Parameters

  • args

Member Functions

A (self, *args)

Get the alpha value of this color (0-1). See Also: Alpha

Parameters

  • args

Sample code

Demonstrates calls to `RLPy.RColor.__itruediv__` and `RLPy.RColor.__truediv__` using the example's inputs.

import RLPy

def run_script():
    source = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    divided = source / 2.0
    inplace = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    inplace /= 2.0
    return {
        "divided": (divided.R(), divided.G(), divided.B(), divided.A()),
        "inplace_divided": (inplace.R(), inplace.G(), inplace.B(), inplace.A()),
    }

Sample code

Calls `RLPy.RColor.A` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0,0,1,1)
    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
  • fSaturate
  • fBrightness
  • fContrast
  • bInvert

Sample code

Calls `RLPy.RColor.AdjustHSBC` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor()
    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
  • fGreen
  • fBlue
  • fAlpha
  • bInvert

Sample code

Calls `RLPy.RColor.AdjustRGBA` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor()
    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

Sample code

Calls `RLPy.RColor.Alpha` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0,0,1,1)
    print( color1.Alpha() )		# 255

B (self, *args)

Get the blue value of this color (0-1). See Also: Blue

Parameters

  • args

Sample code

Demonstrates calls to `RLPy.RColor.__itruediv__` and `RLPy.RColor.__truediv__` using the example's inputs.

import RLPy

def run_script():
    source = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    divided = source / 2.0
    inplace = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    inplace /= 2.0
    return {
        "divided": (divided.R(), divided.G(), divided.B(), divided.A()),
        "inplace_divided": (inplace.R(), inplace.G(), inplace.B(), inplace.A()),
    }

Sample code

Calls `RLPy.RColor.FromCOLORREF` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor()
    color1.FromCOLORREF(0x0000ff)
    print((color1.R(), color1.G(), color1.B()))  # (1.0, 0.0, 0.0)

Sample code

Calls `RLPy.RColor.B` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0,0,1,1)
    print( color1.B() )		# 1

Blue (self)

Get the blue value of this color (0-255). See Also: B

Sample code

Calls `RLPy.RColor.Blue` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0,0,1,1)
    print( color1.Blue() )		# 255

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

Adjust color using 32 bit (0-255).

Parameters

  • r
  • g
  • b
  • a

Sample code

Calls `RLPy.RColor.From` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor()
    color1.From(255,0,0,255)

FromARGB (self, arg2)

Adjust color using ARGB (0xaarrggbb).

Parameters

  • arg2

Sample code

Calls `RLPy.RColor.FromARGB` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor()
    color = color1.FromARGB(0xff0000ff)
    print((color.R(), color.G(), color.B(), color.A()))

FromCOLORREF (self, arg2)

Adjust color using COLORREF (0xbbggrr).

Parameters

  • arg2

Sample code

Calls `RLPy.RColor.FromCOLORREF` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor()
    color1.FromCOLORREF(0x0000ff)
    print((color1.R(), color1.G(), color1.B()))  # (1.0, 0.0, 0.0)

FromHSL (self, fHue, fSaturate, fLevel)

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

Parameters

  • fHue
  • fSaturate
  • fLevel

Sample code

Calls `RLPy.RColor.FromHSL` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor()
    color1.FromHSL(0.5,0.5,0.5)

G (self, *args)

Get the green value of this color (0-1). See Also: Green

Parameters

  • args

Sample code

Demonstrates calls to `RLPy.RColor.__itruediv__` and `RLPy.RColor.__truediv__` using the example's inputs.

import RLPy

def run_script():
    source = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    divided = source / 2.0
    inplace = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    inplace /= 2.0
    return {
        "divided": (divided.R(), divided.G(), divided.B(), divided.A()),
        "inplace_divided": (inplace.R(), inplace.G(), inplace.B(), inplace.A()),
    }

Sample code

Calls `RLPy.RColor.FromCOLORREF` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor()
    color1.FromCOLORREF(0x0000ff)
    print((color1.R(), color1.G(), color1.B()))  # (1.0, 0.0, 0.0)

Sample code

Calls `RLPy.RColor.G` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0,1,0,1)
    print( color1.G() )		# 1

GammaCorrect (self, fGamma)

Output this color with gamma correction.

Parameters

  • fGamma

Sample code

Calls `RLPy.RColor.GammaCorrect` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0.5, 0, 0, 1)
    corrected = color1.GammaCorrect(1.0 / 2.2)
    print((corrected.R(), corrected.G(), corrected.B(), corrected.A()))
    # (0.7297400236, 0.0, 0.0, 1.0)

Green (self)

Get the green value of this color (0-255). See Also: G

Sample code

Calls `RLPy.RColor.Green` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0,1,0,1)
    print( color1.Green() )		# 1

Normalize (self)

Normalize RGB values so that their sum equals 1.

Sample code

Calls `RLPy.RColor.Normalize` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0, 1, 0, 1)
    normalized = color1.Normalize()
    print((normalized.R(), normalized.G(), normalized.B(), normalized.A()))
    # (0.0, 0.707106769..., 0.0, 0.707106769...)

R (self, *args)

Get the red value of this color (0-1). See Also: Red

Parameters

  • args

Sample code

Demonstrates calls to `RLPy.RColor.__itruediv__` and `RLPy.RColor.__truediv__` using the example's inputs.

import RLPy

def run_script():
    source = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    divided = source / 2.0
    inplace = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    inplace /= 2.0
    return {
        "divided": (divided.R(), divided.G(), divided.B(), divided.A()),
        "inplace_divided": (inplace.R(), inplace.G(), inplace.B(), inplace.A()),
    }

Sample code

Calls `RLPy.RColor.R` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(1,0,0,1)
    print( color1.R() )		# 1

Sample code

Calls `RLPy.RColor.FromCOLORREF` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor()
    color1.FromCOLORREF(0x0000ff)
    print((color1.R(), color1.G(), color1.B()))  # (1.0, 0.0, 0.0)

Red (self)

Get the red value of this color (0-255). See Also: R

Sample code

Calls `RLPy.RColor.Red` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(1,0,0,1)
    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.

Sample code

Calls `RLPy.RColor.Saturate` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(1.2,-0.3,0.5, 1.0)
    color1.Saturate()		# (1, 0, 0.5, 1.0)

ToARGB (self)

Output ARGB data from this color (0xaarrggbb). See Also: FromARGB

Sample code

Calls `RLPy.RColor.ToARGB` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0, 0, 1, 1)
    print(hex(int(color1.ToARGB())))  # 0xff0000ff

ToCOLORREF (self)

Output COLORREF data from this color (0xbbggrr). See Also: FromCOLORREF

Sample code

Calls `RLPy.RColor.ToCOLORREF` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0, 0, 1, 1)
    print( int(color1.ToCOLORREF()) )		# 0xff0000

ToGrayScale (self)

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

Sample code

Calls `RLPy.RColor.ToGrayScale` with the inputs shown in the example.

def run_script():
    import RLPy
    color1 = RLPy.RColor(0, 0, 1, 1)
    print( color1.ToGrayScale() )		# 0.11400000005960464

ToHSL (self, fHue, fSaturate, fLevel)

Converts the rgba data to HSL data.

Parameters

  • fHue
  • fSaturate
  • fLevel

__add__ (self, arg2)

Adds another value to this value and returns the result.

Parameters

  • arg2

__eq__ (self, arg2)

Reports whether this value equals another value.

Parameters

  • arg2

__iadd__ (self, arg2)

Adds another value to this value in place.

Parameters

  • arg2

__imul__ (self, *args)

Multiplies this value by another value in place.

Parameters

  • args

__isub__ (self, arg2)

Subtracts another value from this value in place.

Parameters

  • arg2

__itruediv__ (self, *args)

Divides this value by another value in place.

Parameters

  • args

Sample code

Demonstrates calls to `RLPy.RColor.__itruediv__` and `RLPy.RColor.__truediv__` using the example's inputs.

import RLPy

def run_script():
    source = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    divided = source / 2.0
    inplace = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    inplace /= 2.0
    return {
        "divided": (divided.R(), divided.G(), divided.B(), divided.A()),
        "inplace_divided": (inplace.R(), inplace.G(), inplace.B(), inplace.A()),
    }

__lt__ (self, arg2)

Reports whether this value is less than another value.

Parameters

  • arg2

__mul__ (self, *args)

Multiplies this value by another value and returns the result.

Parameters

  • args

__ne__ (self, arg2)

Reports whether this value differs from another value.

Parameters

  • arg2

__neg__ (self)

Returns the negated value.

__sub__ (self, arg2)

Subtracts another value from this value and returns the result.

Parameters

  • arg2

__truediv__ (self, *args)

Divides this value by another value and returns the result.

Parameters

  • args

Sample code

Demonstrates calls to `RLPy.RColor.__itruediv__` and `RLPy.RColor.__truediv__` using the example's inputs.

import RLPy

def run_script():
    source = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    divided = source / 2.0
    inplace = RLPy.RColor(0.2, 0.4, 0.6, 0.8)
    inplace /= 2.0
    return {
        "divided": (divided.R(), divided.G(), divided.B(), divided.A()),
        "inplace_divided": (inplace.R(), inplace.G(), inplace.B(), inplace.A()),
    }

Properties

thisown

Indicates whether this SWIG proxy owns the underlying C++ object.

Constants

BLACK

BLACK_ALPHA

BLUE

BLUE_ALPHA

CYAN

CYAN_ALPHA

GREEN

GREEN_ALPHA

MAGENTA

MAGENTA_ALPHA

RED

RED_ALPHA

WHITE

WHITE_ALPHA

YELLOW

YELLOW_ALPHA