<div class="meta" robots="noindex">

</div>

Method

# HSV

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

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `Color.HSV<color.hsv>` as a replacement.

</div>

## Description

Returns a `Color</api/data_types/color>` object based on the <span class="title-ref">HSV</span> (hue, saturation, value) color model with the passed level of transparency. Use the new form of the `Picture</api/graphics/picture>` constructor to create pictures that support the alpha channel or convert existing pictures to the new format using the code described in `HasAlphaChannel<picture.hasalphachannel>`.

## Usage

*result*=**HSV**(*hue*, *saturation*, *value* \[, *alpha* = 0\])

| Part       | Type                               | Description                                                                                                                           |
|------------|------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| result     | `Color</api/data_types/color>`     | An object that represents the color based on the *hue*, *saturation*, *value*, and transparency values.                               |
| hue        | `Double</api/data_types/double>`   | The value of Hue in the color (0-1).                                                                                                  |
| saturation | `Double</api/data_types/double>`   | The value of Saturation in the color (0-1).                                                                                           |
| value      | `Double</api/data_types/double>`   | The value of Value (brightness or lightness) in the color (0-1).                                                                      |
| alpha      | `Integer</api/data_types/integer>` | The value of transparency in the color (0-255). Zero is completely opaque and 255 is fully transparent. If omitted, the default is 0. |

## Notes

The <span class="title-ref">HSV</span> function returns a color object based on the amounts of Hue, Saturation, Value and Transparency (alpha channel) passed. The colors are amounts are represented by doubles between 0 and 1. *Alpha* is an `Integer</api/data_types/integer>` from 0-255.

Colors can also be created using the `Color.RGB<color.rgb>` or `Color.CMY<color.cmy>` models. You can also use the `&c</api/language/literals/c>` literal to specify a color using the RGB model. All alternatives support the optional transparency parameter.

## Sample code

This example uses the <span class="title-ref">HSV</span> function to assign a `Color</api/data_types/color>` to the FillColor property. This code is in the Paint event of a `Canvas</api/deprecated/canvas>` or a `Window</api/deprecated/window>`.

``` xojo
g.FillColor = HSV(0.8, 0.5, 0.75)
```

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

The following example draws sample color patches in a `Canvas</api/deprecated/canvas>` with varying levels of transparency. With the <span class="title-ref">HSV</span> function, the range is from 0 to 255. Zero is completely opaque and 255 is completely transparent. The code is in the `Paint<canvas.paint>` event.

``` xojo
g.ForeColor = HSV(1.0, 1.0, 1.0) ' red, no transparency
g.DrawRect(0, 0, 200, 50)

g.FillRect(0, 0, 200, 50)
g.ForeColor = HSV(0, 0, 0)
g.DrawString("Translucent = 0", 210, 10)

g.ForeColor = HSV(1.0, 1.0, 1.0, 76) ' transparency = 0.3

g.FillRect(0, 70, 200, 50)
g.ForeColor = HSV(0, 0, 0)
g.DrawString("Translucent = 30%", 210, 80)

g.ForeColor = HSV(1.0, 1.0, 1.0, 127) ' transparency = 0.5

g.FillRect(0, 140, 200, 50)
g.ForeColor = HSV(0, 0, 0, 0)
g.DrawString("Translucent = 50%", 210, 150)

g.ForeColor = HSV(1.0, 1.0, 1.0, 178) ' transparency = 0.7

g.FillRect(0, 210, 200, 50)
g.ForeColor = HSV(0, 0, 0, 0)
g.DrawString("Translucent = 70%", 210, 220)

g.ForeColor = HSV(1.0, 1.0, 1.0, 229) ' transparency = 0.9

g.FillRect(0, 280, 200, 50)
g.ForeColor = HSV(0, 0, 0, 0)
g.DrawString("Translucent = 90%", 210, 290)
```

## Compatibility

All project types on all supported operating systems.

## See also

`Color</api/data_types/color>` data type, `Color.CMY<color.cmy>`, `Color.RGB<color.rgb>`, `Color.SelectedFromDialog<color.selectedfromdialog>` functions; `&c</api/language/literals/c>` literal.
