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

147
Vistas
How to de-normalize numbers (reverse normalize) in javascript?

I have a function thats giving me a number between 0 and 1, for the x and i also have another function thats giving me a number between 0 and 1, for the y coordinate

then i want to visualize it using canvas, so i would want to turn the numbers into pixel values

for example:

i have a a canvas thats 300x400px, if the normalized number is 0.5, for the x and the y

what math would i need to do to make it 150x, 200y?

my code to visualize it (this part works, its just for refrence)

ctx.beginPath()
ctx.arc(xval, yval, 5, 0, 2 * Math.PI)
ctx.fillStyle = "#FF0000";
ctx.fill()

ctx.beginPath();
ctx.moveTo(0, xval);
ctx.lineTo(300, xval);
ctx.stroke();

ctx.beginPath();
ctx.moveTo(yval, 0);
ctx.lineTo(yval, 400);
ctx.stroke();

thanks!

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Simply multiply by the factor you need.

const x = normalized * width;
const y = normalized * height
about 4 years ago · Juan Pablo Isaza Denunciar

0

assuming canvas width =300 and canvas height =400 Just multiply x * wi

about 4 years ago · Juan Pablo Isaza Denunciar
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