CColorRef:ToGray


The ToGray method returns the gray equivalent luminance of a color triplet. The conversion is computed using the standard visual response weights (see Visual Response Equivalent Gray).

Syntax

nGray = CColorRef:ToGray()

bullet.gif    Returns the gray equivalent of the class member colors.

nGray = CColorRef:ToGray( CColorRef )

bullet.gif    Returns the gray equivalent of the CColorRef passed as the argument.

nGray = CColorRef:ToGray( R, G, B )

bullet.gif    Returns the gray equivalent of the specified R, G, and B values.

Remarks

Three overloads are provided for this method; they compute the gray equivalent for the class members, a CColorRef object, or for 3 explicit color values. If you pass something other than a CColorRef or R, G, B values, such as a string or a number, this method defaults to using the class members.

Example

The following script computes the equivalent gray intensity using all 3 of the overloads:

A = new_colorref(255,140,5)

-- create a CColorRef with values

Printf("Gray = %.2lf", A:ToGray())

-- result: Gray = 158.19

B = new_colorref(A)

-- create a new copy of A

B:Invert()

-- invert the colors of B

Printf("Gray = %.2lf", A:ToGray(B))

-- result: Gray = 96.81

Printf("Gray = %.2lf", B:ToGray(0,115,250))

-- result: Gray = 96.81

Related Topics

CColorRef, Visual Response Equivalent Gray


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.