forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandom.cs
More file actions
39 lines (34 loc) · 1.5 KB
/
Copy pathRandom.cs
File metadata and controls
39 lines (34 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
namespace UnityEngine
{
public static partial class Random
{
public static Color ColorHSV()
{
return ColorHSV(0f, 1f, 0f, 1f, 0f, 1f, 1f, 1f);
}
public static Color ColorHSV(float hueMin, float hueMax)
{
return ColorHSV(hueMin, hueMax, 0f, 1f, 0f, 1f, 1f, 1f);
}
public static Color ColorHSV(float hueMin, float hueMax, float saturationMin, float saturationMax)
{
return ColorHSV(hueMin, hueMax, saturationMin, saturationMax, 0f, 1f, 1f, 1f);
}
public static Color ColorHSV(float hueMin, float hueMax, float saturationMin, float saturationMax, float valueMin, float valueMax)
{
return ColorHSV(hueMin, hueMax, saturationMin, saturationMax, valueMin, valueMax, 1f, 1f);
}
public static Color ColorHSV(float hueMin, float hueMax, float saturationMin, float saturationMax, float valueMin, float valueMax, float alphaMin, float alphaMax)
{
var h = Mathf.Lerp(hueMin, hueMax, Random.value);
var s = Mathf.Lerp(saturationMin, saturationMax, Random.value);
var v = Mathf.Lerp(valueMin, valueMax, Random.value);
var color = Color.HSVToRGB(h, s, v, true);
color.a = Mathf.Lerp(alphaMin, alphaMax, Random.value);
return color;
}
}
}