StrToRgb


The StrToRgb function extracts R, G, and B numbers from a triplet string. For example, passing "100,20.5,300.25" returns the numbers 100, 20.5 and 300.25. The string does not actually have to contain true R, G and B components but must contain just 3 numbers separated by commas.

Syntax

nR, nG, nB = StrToRgb( string )

where

    string is the string comtaining 3 comma-separated numbers.

    nR, nG, nB are numeric values.

Example

The example below extracts 3 numbers from a string:

 

str = "100,20.5,300.25"

-- data type "float"

r, g, b = StrToRgb( str )

-- get the 3 numbers

Printf("R=%lg, G=%lf, B=%lf", r, g, b )

-- result: R=100, G=20.5, B=300.25

Related Topics

CImage:Getr

Data Types

CColorRef class