Skip to content

Instantly share code, notes, and snippets.

@Hacksore
Created July 1, 2024 15:17
Show Gist options
  • Save Hacksore/5632920d3139cd7113170b2a16417964 to your computer and use it in GitHub Desktop.
Save Hacksore/5632920d3139cd7113170b2a16417964 to your computer and use it in GitHub Desktop.
FULL TURBO
$$\textsf{\color[rgb]{0.0, 0, 1.0}F\color[rgb]{0.1, 0, 0.9}U\color[rgb]{0.2, 0, 0.8}L\color[rgb]{0.3, 0, 0.7}L\color[rgb]{0.4, 0, 0.6} \color[rgb]{0.6, 0, 0.4}T\color[rgb]{0.7, 0, 0.3}U\color[rgb]{0.8, 0, 0.2}R\color[rgb]{0.9, 0, 0.1}B\color[rgb]{1.0, 0, 0.0}O}$$
function generateGradientText(input) {
  let result = "\\textsf{";
  const length = input.length;
  
  for (let i = 0; i < length; i++) {
    const r = (i / (length - 1)).toFixed(1); // Red value
    const g = 0; // Green value (fixed)
    const b = (1 - i / (length - 1)).toFixed(1); // Blue value
    result += `\\color[rgb]{${r}, ${g}, ${b}}${input[i]}`;
  }
  
  result += '}';
  return result;
}

// Example usage:
const inputString = "FULL TURBO";
const gradientText = generateGradientText(inputString);
console.log(gradientText);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment