From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!


Used to represent a color literal.



Part Type Description
RR String The amount of Red in the color, in hexadecimal. The range is from 00 to FF.
GG String The amount of Green in the color, in hexadecimal. The range is from 00 to FF.
BB String The amount of Blue in the color, in hexadecimal. The range is from 00 to FF.
AA String The amount of transparency (alpha channel) in the color, in hexadecimal. The range is from 00 (opaque) to FF (fully transparent).


&c is an alternative to the RGB function for specifying a Color using the RGB model. It provides the same functionality as the RGB function, except that you specify the amount of each primary color and the level of transparency in hexadecimal (00-FF) rather than decimal (0-255).

In the Code Editor, the parameters RR, GG, and BB appear in the color that they represent. The amount of transparency appears in the default color for text in the Code Editor. A color can also be specified using the HSV and CMY models.

To create a picture that supports the alpha channel, use the new form of the Picture constructor to create pictures or convert existing pictures to the new format using the code described in HasAlphaChannel.


Var red As Color = &cFF000000
Var blue As Color = &c0000FF10 // mostly transparent

This example fills a Canvas with a 50% transparent color:

g.DrawingColor = &cff00007f


The following example draws sample color patches in a Canvas. The code is in the Paint event.

g.DrawingColor = &cff000000 // red color patch, no transparency
g.DrawRectangle(0, 0, 200, 50)
g.FillRectangle(0, 0, 200, 50)
g.DrawingColor = &c000000 // black text
g.DrawText("Translucent = 0", 210, 10)

g.DrawingColor = &cff00004d // transparency = 30%
g.FillRect(0, 70, 200, 50)
g.DrawingColor = &c000000
g.DrawText("Translucent = 30%", 210, 80)

g.DrawingColor = &cff00007f // transparency = 50%
g.FillRectangle(0, 140, 200, 50)
g.DrawingColor = &c000000
g.DrawText("Translucent = 50%", 210, 150)

g.DrawingColor = &cff000083 // transparency = 70%
g.FillRectangle(0, 210, 200, 50)
g.DrawingColor = &c000000
g.DrawText("Translucent = 70%", 210, 220)

g.DrawingColor = &cff0000e5 // transparency = 90%
g.FillRectangle(0, 280, 200, 50)
g.DrawingColor = &c000000
g.DrawText("Translucent = 90%", 210, 290)

The result is shown here.

Sample red color patches illustrating transparency.

Color Picker Example

The following example allows the user to select a color that will be used as the fillcolor in a Rectangle control.

Var c As Color
Var b As Boolean
c = &cFFFFFF // set the default color shown in color picker (white in this case)
b = Color.SelectedFromDialog(c, "Select a Color:")
Rectangle1.FillColor = c

See Also

CMY, HSV, RGB functions; Color, Graphics, Picture classes.