Skip to content

Commit eecc9cd

Browse files
committed
feat: color
1 parent 1a771dd commit eecc9cd

File tree

4 files changed

+72
-57
lines changed

4 files changed

+72
-57
lines changed

Assets/JCSUnity/Editor/JCSUnity_EditorWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ private static void CreateSlidePanel()
647647

648648
if (panelImage != null)
649649
{
650-
panelImage.color = JCS_Random.PickColor();
650+
panelImage.color = JCS_Random.Color();
651651
}
652652

653653
// assign to slide panel holder.

Assets/JCSUnity/Scripts/Util/JCS_Random.cs

Lines changed: 64 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,75 @@ public static float RangeInclude(float min, float max)
6262
return Range(min, max + include);
6363
}
6464

65+
/// <summary>
66+
/// Return a random vector 2 int.
67+
/// </summary>
68+
public static Vector2Int Vector2Int(int min, int max)
69+
{
70+
int x = Range(min, max);
71+
int y = Range(min, max);
72+
return new Vector2Int(x, y);
73+
}
74+
75+
/// <summary>
76+
/// Return a random vector 2.
77+
/// </summary>
78+
public static Vector2 Vector2(float min, float max)
79+
{
80+
float x = Range(min, max);
81+
float y = Range(min, max);
82+
return new Vector2(x, y);
83+
}
84+
85+
/// <summary>
86+
/// Return a random vector 3 int.
87+
/// </summary>
88+
public static Vector3Int Vector3Int(int min, int max)
89+
{
90+
int x = Range(min, max);
91+
int y = Range(min, max);
92+
int z = Range(min, max);
93+
return new Vector3Int(x, y, z);
94+
}
95+
96+
/// <summary>
97+
/// Return a random vector 3.
98+
/// </summary>
99+
public static Vector3 Vector3(float min, float max)
100+
{
101+
float x = Range(min, max);
102+
float y = Range(min, max);
103+
float z = Range(min, max);
104+
return new Vector3(x, y, z);
105+
}
106+
107+
/// <summary>
108+
/// Return a random Quaternion.
109+
/// </summary>
110+
public static Quaternion Quaternion(float min, float max)
111+
{
112+
float x = Range(min, max);
113+
float y = Range(min, max);
114+
float z = Range(min, max);
115+
return UnityEngine.Quaternion.Euler(x, y, z);
116+
}
117+
65118
/// <summary>
66119
/// Return a random color.
67120
/// </summary>
68121
/// <returns> random color object. </returns>
69-
public static Color PickColor(float a = 1.0f)
122+
public static Color Color()
70123
{
71-
return new Color(Range(0.0f, 1.0f), Range(0.0f, 1.0f), Range(0.0f, 1.0f), a);
124+
float a = Range(0.0f, 1.0f);
125+
return Color(a);
126+
}
127+
public static Color Color(float a = 1.0f)
128+
{
129+
float x = Range(0.0f, 1.0f);
130+
float y = Range(0.0f, 1.0f);
131+
float z = Range(0.0f, 1.0f);
132+
133+
return new Color(x, y, z, a);
72134
}
73135

74136
/// <summary>
@@ -138,58 +200,5 @@ public static Vector3 PointInSphere(Vector3 centerPosition, float radius)
138200
Vector3 randomPoint = Random.insideUnitSphere * radius;
139201
return centerPosition + randomPoint;
140202
}
141-
142-
/// <summary>
143-
/// Return a random vector 2 int.
144-
/// </summary>
145-
public static Vector2Int Vector2Int(int min, int max)
146-
{
147-
int x = Range(min, max);
148-
int y = Range(min, max);
149-
return new Vector2Int(x, y);
150-
}
151-
152-
/// <summary>
153-
/// Return a random vector 2.
154-
/// </summary>
155-
public static Vector2 Vector2(float min, float max)
156-
{
157-
float x = Range(min, max);
158-
float y = Range(min, max);
159-
return new Vector2(x, y);
160-
}
161-
162-
/// <summary>
163-
/// Return a random vector 3 int.
164-
/// </summary>
165-
public static Vector3Int Vector3Int(int min, int max)
166-
{
167-
int x = Range(min, max);
168-
int y = Range(min, max);
169-
int z = Range(min, max);
170-
return new Vector3Int(x, y, z);
171-
}
172-
173-
/// <summary>
174-
/// Return a random vector 3.
175-
/// </summary>
176-
public static Vector3 Vector3(float min, float max)
177-
{
178-
float x = Range(min, max);
179-
float y = Range(min, max);
180-
float z = Range(min, max);
181-
return new Vector3(x, y, z);
182-
}
183-
184-
/// <summary>
185-
/// Return a random Quaternion.
186-
/// </summary>
187-
public static Quaternion Quaternion(float min, float max)
188-
{
189-
float x = Range(min, max);
190-
float y = Range(min, max);
191-
float z = Range(min, max);
192-
return UnityEngine.Quaternion.Euler(x, y, z);
193-
}
194203
}
195204
}

docs/ScriptReference/Util/JCS_Mathf.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Math library class.
3737
| Cos | Cosine in degree. |
3838
| Sin | Sine in degree. |
3939
| Tan | Tangent in degree. |
40+
| AngleOnAxis | Return angle on axis. |
4041
| Truncate | Truncate a decimal number. |
4142
| GCD | Find the greatest common factor. |
4243
| GetSign | Return the positive/negative 1 sign from VAL. |

docs/ScriptReference/Util/JCS_Random.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ Random library class.
88
|:--------------|:--------------------------------------------|
99
| Range | Default random range wrapper. |
1010
| RaneeInclude | Include the maxinum number. |
11-
| PickColor | Returns a random color. |
11+
| Vector2Int | Return a random `Vector2Int`. |
12+
| Vector2 | Return a random `Vector2`. |
13+
| Vector3Int | Return a random `Vector3Int`. |
14+
| Vector3 | Return a random `Vector3`. |
15+
| Quaternion | Return a random `Quaternion`. |
16+
| Color | Returns a random color. |
1217
| ChooseOne | Choose one object from the list. |
1318
| ChooseOneE | Choose one object from the list. (Ellipsis) |
1419
| EnumValue | Return a random enum value. |

0 commit comments

Comments
 (0)