Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
How can I get rgb values from a string like "red"?

How would I get an rgb value from color strings like "red" and "green" programmatically? I wanted to make the opacity of things on an html canvas 25%, and I found out you can set the alpha value with ctx.fillStyle = "rgba(...)". However I don't know the rgb values. How can I get it? I tried googling it but the reusults were hex to rgb and rgb to hex.

My current code

let ctx = canvas.getContext("2d");
ctx.fillStyle = this.color; //"red" or "green"
if (condition) ctx.fillStyle = `rgba()` //how to get the values?
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda