function pad(num, size) {
num = num.toString();
while (num.length < size) num = "0" + num;
return num;
}
const msg:string = "Das mit dem Farbverlauf geht so:";
let r = 0;
let g = 0;
let b = 0;
let s = "";
for (let i = 0; i < msg.length; i++) {
if (i < msg.length / 4) {
r = Math.round(1.0 / (msg.length / 4 - i) * 255);
} else if (i < msg.length / 4 * 3) {
g = Math.round(1.0 / (msg.length / 4 * 3 - i) * 255);
}
s += `[COLOR=#${pad(r.toString(16), 2)}${pad(g.toString(16), 2)}${pad(b.toString(16), 2)}]${msg.charAt(i)}[/COLOR]`
}
console.log(s);
To embed this program on your website, copy the following code and paste it into your website's HTML: