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