-
Notifications
You must be signed in to change notification settings - Fork 1
/
tab-animation.html
188 lines (173 loc) · 8.02 KB
/
tab-animation.html
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html>
<head>
<title>TAB Animated Gradient Generator</title>
<style type="text/css">
@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');
:root {
--primary-color: #9A97F3;
--secondary-color: #818cab;
--font-color: #e1e1ff;
--bg-color: #161625;
--heading-color: #818cab;
}
* {
font-family: 'Poppins', Helvetica, arial, sans-serif;
}
body {
background-color: var(--bg-color);
color: var(--font-color);
transition: 0.3s all ease-in;
padding: 25px;
}
code {
font-family: 'consolas';
background-color: #5f5f5f;
}
.light-mode {
background-color: white;
color: black;
transition: 0.3s all ease-in;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
background-color: #dddddd;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
transition: 0.3s all ease-in;
}
li a:hover {
background-color: #111;
transition: 0.3s all ease-in;
}
</style>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/2.1.0/chroma.min.js"></script>
<link rel="stylesheet" href="./default.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
<script type="text/javascript">
function toggleLightMode() {
var element = document.body;
element.classList.toggle("light-mode");
}
function trim(s) { return (s.charAt(0) == '#') ? s.substring(1, 7) : s }
function convertToHex(rgb) {
return hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
}
function convertToRGB(hex) {
var color = [];
color[0] = parseInt ((trim(hex)).substring (0, 2), 16);
color[1] = parseInt ((trim(hex)).substring (2, 4), 16);
color[2] = parseInt ((trim(hex)).substring (4, 6), 16);
return color;
}
function createYaml() {
const name = document.getElementById("animation-name").value || "name";
let text = document.getElementById("text").value || "Text";
const from = document.getElementById("color1").value || "#771177";
const to = document.getElementById("color2").value || "#7a0000";
const changeInterval = document.getElementById("changeInterval").value || "100";
const placeholder = "%animation:" + name + "%"
const bold = document.getElementById("bold").checked || false;
const italic = document.getElementById("italic").checked || false;
const underlined = document.getElementById("underlined").checked || false;
const strikethrough = document.getElementById("strikethrough").checked || false;
const obfuscated = document.getElementById("obfuscated").checked || false;
if (bold) text = "&l" + text;
if (italic) text = "&o" + text;
if (underlined) text = "&n" + text;
if (strikethrough) text = "&m" + text;
if (obfuscated) text = "&k" + text;
let scale = chroma.scale([from, to]);
let length = parseInt(text.split("").length);
let obj = [];
for (let i = 1; i < length + 1; i++) {
let ts = 1 / length * i;
obj.push(scale(ts).hex());
}
let nickCmd = [];
for (let x = 0; x < length; x++) { nickCmd.push(obj[x] + text.charAt(x)); }
let h = 0;
let desc = " " + name + ":<br> change-interval: " + changeInterval + "<br> texts:<br> ";
desc += (" - \"{" + from + ">}" + text + "{" + obj[0] + "<}\"<br>");
for (let i = 1; i<length; i++) {
h = i - 1;
desc += (" - \"{" + obj[h] + ">}" + text + "{" + obj[i] + "<}\"<br>");
}
h = 0;
j = 0;
for (var i = length - 1; i >= 0; i--) {
if (i == 0) {
desc += (" - \"{" + obj[i] + ">}" + text + "{" + from + "<}\"<br>");
continue;
}
h = i - 1;
desc += (" - \"{" + obj[i] + ">}" + text + "{" + obj[h] + "<}\"<br>");
}
document.getElementById("code").innerHTML = desc;
document.getElementById("placeholder").innerHTML = placeholder;
hljs.highlightBlock(document.getElementById("code"));
hljs.highlightBlock(document.getElementById("placeholder"));
}
</script>
</head>
<body>
<ul>
<li><a href="./">Home</a></li>
<li><a href="./tab-animation">Tab Animated Gradient Generator</a></li>
<li><a href="./gradient-text">Gradient Text Generator</a></li>
<li><a href="./cosmonaut">Cosmonaut</a></li>
<li><a href="./projects">Projects</a></li>
<li><a onclick="toggleLightMode()">Toggle light mode</a></li>
</ul>
<center>
<h1>TAB Animated Gradient Generator</h1>
<h2>by <a href="https://github.com/starve-l">reliances</a></h2>
<label for="animation-name">Animation name</label><br>
<input id="animation-name" type="text" placeholder="Animation name" value="" onkeyup="this.value = this.value.toLowerCase().replace(' ', '-').replace(/[^a-z0-9_-]/g, '');"><br><br>
<label for="text">Text</label><br>
<input id="text" type="text" placeholder="Text"><br><br>
<label for="changeInterval">Change Interval in ms</label><br>
<input id="changeInterval" type="number" placeholder="100"><br><br>
<label for="color1">First color</label><br>
<input id="color1" type="color" value="#771177"><br><br>
<label for="color2">Last color</label><br>
<input id="color2" type="color" value="#710000"><br><br>
<input type="checkbox" id="bold">
<label for="bold"><b>bold</b></label><br>
<input type="checkbox" id="italic">
<label for="italic"><i>italic</i></label><br>
<input type="checkbox" id="underlined">
<label for="underlined"><u>underlined</u></label><br>
<input type="checkbox" id="strikethrough">
<label for="strikethrough"><s>strikethrough</s></label><br>
<input type="checkbox" id="obfuscated">
<label for="obfuscated">obfuscated</label><br><br>
<button id="create" onclick="createYaml()" lang="yaml">Generate YAML</button><br><br><br><br><br><br><br><br><br><br>
</center>
<div style="padding:2cm; align-items:left;">
<label for="code">Paste this in your <code>animations.yml</code> file:</label><br>
<code class="language-yaml" id="code" style="align-content: left"></code><br>
<label for="placeholder">Use this as a placeholder:</label><br>
<code class="language-yaml" class="style-atom-one-dark" id="placeholder" style="align-content: left"></code>
</div>
</body>
</html>