Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
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 Respostas
Responde à pergunta

0

Simply multiply by the factor you need.

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

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda