Color
From Real Software Documentation
A Color is an intrinsic data type that consists of three bytes that define the color. A color can be set using the RGB, HSV, or CMY models or the &c literal. Each set of properties is used with the appropriate function to specify a color. The values of any of the nine properties can then be read. The default value of a Color is &c000000 (black).
| Properties | ||||||||||||
|
Notes
Colors are often used to assign colors to properties of type Color. Use the RGB, HSV, or CMY functions to assign a color to an object or use the format:
where RR is the RGB value of Red in hexadecimal, GG is the value Green in hexadecimal, and BB is the value of Blue in hexadecimal. You can choose the color that you want to assign to a property by clicking on the existing color in the Properties pane to open the Color picker. Choose the color via the Color picker and Real Studio will figure out the hexadecimal values that represent that color.
You can use the VarType function to determine whether a property or a variable is a Color. If it is, VarType returns 16.
You can use the Str function to obtain the string form of the value of the color in hexadecimal, i.e.,
Alpha Channel Support
Real Studio 2011r4 introduces support for Colors and Pictures with alpha channels and the ability to set the transparency used when drawing to a Graphics object.
The Color type now has a read-only "Alpha" property. The alpha channel is the transparency of the color represented as an integer between 0 (opaque) and 255 (transparent).
The Color literal syntax has been updated to optionally have two more hexadecimal digits at the end representing the alpha channel (for example, "&cFF00007F"). If the color literal has only 3 channels of information, the alpha component defaults to 0.
The RGB, HSV, and CMY functions have also been updated to take an optional integer parameter, which specifies the alpha channel for the Color.
Examples
The following example uses the RGB model to set the forecolor property of a Canvas control and draw a square using the current forecolor. The code is placed in the Canvas control's Paint event.
Canvas1.Graphics.DrawRect(0, 0, 50, 50)
The following example assigns a color directly using the RGB color model. The RGB values must be specified in hexadecimal:
Canvas1.Graphics.DrawRect(0, 0, 50, 50)
The following example uses the CMY model to set the fillcolor of a Rectangle control, r.
The following example inverts the fillcolor:
See Also
CMY, DarkTingeColor, FillColor, FrameColor, HighlightColor, HSV, LightBevelColor, LightTingeColor, RGB, SelectColor, TextColor, VarType functions; &c literal; Dim, Static, Declare statements; -, +, *, /, <, <=, =, >=, >, <> VarType functions; Boolean, Byte, CFStringRef, Color, CString, Currency, Delegate, Double, Int16, Int32, Int64, Int8, Integer, OSType, PString, Ptr, Short, Single, String, UInt16, UInt32, UInt64,UInt8, UShort, Variant, WindowPtr, WString data types. IsNumeric, Mod, Str, Val, Vartype, functions.
