CColorRef:new


The new method constructs a new instance of a CColorRef object. The CColorRef class includes 3 properties for R, G, and B color intensities. Three different constructor overloads are available to create a new CColorRef and initialize the properties.

Syntax

C = CColorRef:new()

C = CColorRef:new( CColorRef2 )

C = CColorRef:new( R, G, B )

where

    If no arguments are passed, a new CColorRef object is created with properties initialized to (0,0,0).

    CColorRef2 is an existing CColorRef object whose properties are copied to the new CColorRef object.

    R, G, B are 3 color values used to initialize the new CColorRef object.

    C is the new CColorRef object.

Example

The following script computes the equivalent gray intensity using 2 different constructors:

 

A = CColorRef(255,140,5)

-- create CColorRef A with values

B = CColorRef:new( A )

-- copy A to a new CColorRef B

n = A:ToGray(B)

-- complement the color

Printf("%d,%d,%d -> %.2lf", A.R,A.G,A.B,n)

-- result: 255,140,5 -> 158.19

Printf("%d,%d,%d -> %.2lf", B.R,B.G,B.B,n)

-- result: 255,140,5 -> 158.19

Related Topics

delete

CColorRef class