# hsva method

Color hsva(
1. dynamic h,
2. dynamic s,
3. dynamic v,
4. dynamic a
)

Creates a transparent color object from hue, saturation, value and alpha (HSVA) values. Note that this is not the same as hsla, and is a color space available in Photoshop.

Parameters: hue: An integer 0-360 representing degrees. saturation: A percentage 0-100% or number 0-1. value: A percentage 0-100% or number 0-1. alpha: A percentage 0-100% or number 0-1. Returns: color Example: hsva(90, 100%, 50%, 0.5) Output: rgba(64, 128, 0, 0.5)

## Implementation

``````Color hsva(dynamic h, dynamic s, dynamic v, dynamic a) {
final dynamic _h = ((number(h) % 360) / 360) * 360;
final dynamic _s = number(s);
final dynamic _v = number(v);
final dynamic _a = number(a);

final int i = ((_h / 60) % 6).floor();
final double f = (_h / 60) - i;

final vs = <num>[
_v,
_v * (1 - _s),
_v * (1 - f * _s),
_v * (1 - (1 - f) * _s)
];

final perm = <List<int>>[
<int>[0, 3, 1],
<int>[2, 0, 1],
<int>[1, 0, 3],
<int>[1, 2, 0],
<int>[3, 1, 0],
<int>[0, 1, 2]
];

return rgba(
vs[perm[i][0]] * 255, vs[perm[i][1]] * 255, vs[perm[i][2]] * 255, _a);

//    hsva: function(h, s, v, a) {
//        h = ((number(h) % 360) / 360) * 360;
//        s = number(s); v = number(v); a = number(a);
//
//        var i, f;
//        i = Math.floor((h / 60) % 6);
//        f = (h / 60) - i;
//
//        var vs = [v,
//            v * (1 - s),
//            v * (1 - f * s),
//            v * (1 - (1 - f) * s)];
//        var perm = [[0, 3, 1],
//            [2, 0, 1],
//            [1, 0, 3],
//            [1, 2, 0],
//            [3, 1, 0],
//            [0, 1, 2]];
//
//        return colorFunctions.rgba(vs[perm[i][0]] * 255,
//            vs[perm[i][1]] * 255,
//            vs[perm[i][2]] * 255,
//            a);
//    }
}``````