Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
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 answers
Answer question

0

Simply multiply by the factor you need.

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

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!