-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.luau
141 lines (122 loc) · 4.6 KB
/
init.luau
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
--!strict
--- ### Color3.luau
---
--- extension of Color3 library
local Color3K = {
white = Color3.fromRGB(255, 255, 255);
lightgray = Color3.fromRGB(222, 222, 222);
gray = Color3.fromRGB(148, 148, 148);
darkgray = Color3.fromRGB(74, 74, 74);
black = Color3.fromRGB(0, 0, 0);
red = Color3.fromRGB(255, 85, 85);
orange = Color3.fromRGB(255, 170, 85);
yellow = Color3.fromRGB(255, 255, 85);
lime = Color3.fromRGB(170, 255, 85);
green = Color3.fromRGB(85, 255, 85);
turquoise = Color3.fromRGB(85, 255, 170);
cyan = Color3.fromRGB(85, 255, 255);
blue = Color3.fromRGB(85, 170, 255);
royal = Color3.fromRGB(85, 85, 255);
violet = Color3.fromRGB(170, 85, 255);
pink = Color3.fromRGB(255, 85, 255);
hotpink = Color3.fromRGB(255, 85, 170);
glow300 = Color3.fromRGB(300, 300, 300);
glow400 = Color3.fromRGB(400, 400, 400);
glow500 = Color3.fromRGB(500, 500, 500);
glow750 = Color3.fromRGB(750, 750, 750);
glow1000 = Color3.fromRGB(1000, 1000, 1000);
PlayerColors = table.freeze{
[1] = Color3.fromRGB(253, 41, 67); --- Color3.new(253/255, 41/255, 67/255);
[2] = Color3.fromRGB(1, 162, 255); --- Color3.new(1/255, 162/255, 255/255);
[3] = Color3.fromRGB(2, 184, 87); --- Color3.new(2/255, 184/255, 87/255);
[4] = Color3.fromRGB(180, 128, 255); --- BrickColor.new("Alder").Color; Color3.fromRGB(107, 50, 124); BrickColor.new("Bright violet").Color;
[5] = Color3.fromRGB(218, 133, 65); --- BrickColor.new("Bright orange").Color;
[6] = Color3.fromRGB(245, 205, 48); --- BrickColor.new("Bright yellow").Color;
[7] = Color3.fromRGB(232, 186, 200); --- BrickColor.new("Light reddish violet").Color;
[8] = Color3.fromRGB(215, 197, 154); --- BrickColor.new("Brick yellow").Color;
};
--- ### Color3K.ColorSequence
---
--- extension of ColorSequence library
ColorSequence = table.freeze{
white = ColorSequence.new(Color3.fromRGB(255, 255, 255));
gray = ColorSequence.new(Color3.fromRGB(148, 148, 148));
black = ColorSequence.new(Color3.fromRGB(0, 0, 0));
red = ColorSequence.new(Color3.fromRGB(255, 85, 85));
orange = ColorSequence.new(Color3.fromRGB(255, 170, 85));
yellow = ColorSequence.new(Color3.fromRGB(255, 255, 85));
lime = ColorSequence.new(Color3.fromRGB(170, 255, 85));
green = ColorSequence.new(Color3.fromRGB(85, 255, 85));
turquoise = ColorSequence.new(Color3.fromRGB(85, 255, 170));
cyan = ColorSequence.new(Color3.fromRGB(85, 255, 255));
blue = ColorSequence.new(Color3.fromRGB(85, 170, 255));
royal = ColorSequence.new(Color3.fromRGB(85, 85, 255));
violet = ColorSequence.new(Color3.fromRGB(170, 85, 255));
pink = ColorSequence.new(Color3.fromRGB(255, 85, 255));
hotpink = ColorSequence.new(Color3.fromRGB(255, 85, 170));
--- returns `ColorSequence.new(Color3.fromRGB(w, w, w))`
fromconstant = function(w: number)
return ColorSequence.new(Color3.fromRGB(w, w, w))
end;
--- returns color3 in colorsequence at interpolant `a`
colorat = function(sequence: ColorSequence, a: number)
local lastkeypoint = nil
for _, Keypoint in ipairs(sequence.Keypoints) do
if a < Keypoint.Time then
local time = lastkeypoint.Time
return lastkeypoint.Value:Lerp(Keypoint.Value, (a - time) / (Keypoint.Time - time))
end
lastkeypoint = Keypoint
end
return lastkeypoint and lastkeypoint.Value or Color3.fromRGB(255, 255, 255)
end;
};
}
--- returns `Color3.fromRGB(w, w, w)`
function Color3K.fromconstant(w: number)
return Color3.fromRGB(w, w, w)
end
--- adjusts color3 saturation
function Color3K.saturation(c: Color3, value: number)
local H, S, V = c:ToHSV()
return Color3.fromHSV(H, math.clamp(S + (value / 100), 0, 1), V)
end
--- returns approximate sort value of color3 \
--- equivalent to `(c:ToHSV()) * 100`
function Color3K.sortvalue(c: Color3)
return (c:ToHSV()) * 100
end
--- returns an inversion of color3
function Color3K.invert(c: Color3)
return Color3.new(1 - c.R, 1 - c.G, 1 - c.B)
end
--- returns vertexcolor from color3
function Color3K.tovertexcolor(c: Color3)
return Vector3.new(c.R, c.G, c.B)
end
--- returns color3 from vertexcolor
function Color3K.fromvertexcolor(v: Vector3)
return Color3.new(v.X, v.Y, v.Z)
end
--- returns `color3 * x`
function Color3K.scale(c: Color3, x: number)
return Color3.new(c.R * x, c.G * x, c.B * x)
end
--- returns color3 with respect to player name
function Color3K.fromplayername(name: string)
local value, len = 0, #name
for i = 1, len do
local byte = string.byte(string.sub(name, i, i))
local reverseidx = len - i + 1
if len % 2 == 1 then
reverseidx -= 1
end
if reverseidx % 4 >= 2 then
byte = -byte
end
value += byte
end
value %= #Color3K.PlayerColors
return Color3K.PlayerColors[1 + value]
end
return Color3K