# RGB::toHSV

Convert RGB colors to HSV

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```RGB::toHSV(`[r, g, b, <a>]`)
```

## Description

`RGB::toHSV(RGBcolor)` returns `RGBcolor` expressed in HSV values, with hue in the range (i.e., in degrees) and saturation and value in the range .

## Examples

### Example 1

With the `RGB::fromHSV` utility, all colors in a MuPAD® graphics can be specified easily as HSV colors. For example, the color "violet" is given by the HSV values ```[290, 0.4, 0.6]```, whereas "dark green" is given by the HSV specification `[120, 1, 0.4]`. Hence, a semi-transparent violet sphere intersected by an opaque dark green plain may be specified as follows:

```plot(plot::Sphere(1, [0, 0, 0], Color = RGB::fromHSV([290, 0.4, 0.6]).[0.5]), plot::Surface([x, y, 0.5], x = -1 .. 1, y = -1 .. 1, Mesh = [2, 2], Color = RGB::fromHSV([120, 1, 0.4])) ):```

### Example 2

There are numerous ways of displaying complex-valued functions of a complex argument, see for example `plot::Conformal`. One of these is to use a color scheme that interprets the complex plane as a section through HSV color space at a fixed value, say, 1. To plot this scheme in MuPAD, we use `plot::Density`, providing the following color function:

```f_color := (x, y, fz, a) -> RGB::fromHSV([180/float(PI)*arg(fz), abs(fz), 1]):```

The identity function is thus shown as follows:

```plot(plot::Density((x, y) -> x + I*y, x = -1..1, y = -1..1, XMesh = 50, YMesh = 50, FillColorFunction = f_color))```

doubles the argument of a complex function, resulting in the following picture:

```plot(plot::Density((x, y) -> (x + I*y)^2, x = -1..1, y = -1..1, XMesh = 50, YMesh = 50, FillColorFunction = f_color))```

To plot the complex sine function, we choose a larger rectangle, since the sine is too similar to the identity in small neighborhoods of th origin to be of interest:

```plot(plot::Density((x, y) -> sin(x + I*y), x = -2..2, y = -2..2, XMesh = 50, YMesh = 50, FillColorFunction = f_color))```

is clearly discontinuous along the negative real axis:

```plot(plot::Density((x, y) -> (x + I*y)^(4/3), x = -1..1, y = -1..1, XMesh = 50, YMesh = 50, FillColorFunction = f_color))```

## Parameters

 `r`, `g`, `b` The red, green, and blue contributions of an RGB color: numerical values between 0 and 1. `a` The translucency (alpha) value: a numerical value between 0 and 1.

## Return Values

a list with three or four floating-point values, depending on whether `a` was given in the input.