# RGB::fromHSV

Convert HSV colors to RGB

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```RGB::fromHSV(`[h, s, v, <a>]`)
```

## Description

`RGB::fromHSV(HSVcolor)` converts color coordinates in HSV to the corresponding RGB color.

`RGB::fromHSV(HSVcolor)` is the inverse of `RGB::toHSV`.

## 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. For example, see `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, for example, 1. To plot this scheme in MuPAD, 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, choose a larger rectangle because the sine is too similar to the identity in small neighborhoods of the 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

 `a` The translucency (alpha) value: a numerical value between 0 and 1. `h` The "hue" in an HSV specification: a numerical value between 0 and 360 `s` The "saturation" in an HSV specification: a numerical value between 0 and 1 `v` The "value" in an HSV specification: a numerical value between 0 and 1

## Return Values

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

## See Also

### MuPAD Functions

Was this topic helpful?

Get trial now