Literal

# &c

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to represent a color literal.

## Usage

``` xojo
&cRRGGBBAA
```

| Part | Type                             | Description                                                                                                                       |
|------|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| RR   | `String</api/data_types/string>` | The amount of Red in the color, in hexadecimal. The range is from 00 to FF.                                                       |
| GG   | `String</api/data_types/string>` | The amount of Green in the color, in hexadecimal. The range is from 00 to FF.                                                     |
| BB   | `String</api/data_types/string>` | The amount of Blue in the color, in hexadecimal. The range is from 00 to FF.                                                      |
| AA   | `String</api/data_types/string>` | The amount of transparency (alpha channel) in the color, in hexadecimal. The range is from 00 (opaque) to FF (fully transparent). |

## Notes

&c is an alternative to the `Color<color.rgb>` function for specifying a `Color</api/data_types/color>` using the `Color.RGB<color.rgb>` model. It provides the same functionality as the `Color.RGB<color.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 `Color.HSV<color.hsv>` and `Color.CMY<color.cmy>` models.

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

## Sample code

``` xojo
Var red As Color = &cFF000000
Var blue As Color = &c0000FF10 ' mostly opaque
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This example fills a `Canvas</api/user_interface/desktop/desktopcanvas>` with a 50% transparent color:

``` xojo
g.DrawingColor = &cff00007f
g.FillRectangle(0,0,me.width,me.height)
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The following example draws sample color patches in a `Canvas</api/user_interface/desktop/desktopcanvas>`. The code is in the `Paint<desktopcanvas.paint>` event.

``` xojo
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.

> ![image](images/c_translucentpatches.jpg)

The following example allows the user to select a color that will be used as the fillcolor in a `DesktopRectangle</api/user_interface/desktop/desktoprectangle>` control.

``` xojo
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
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`Color.CMY<color.cmy>`, `Color.HSV<color.hsv>`, `Color.RGB<color.rgb>` functions; `Color</api/data_types/color>`, `Graphics</api/graphics/graphics>`, `Picture</api/graphics/picture>` classes.

</div>
