We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I am currently trying to figure out the best way to tackle this and if you have any suggestions it would be most appreciated. I have an array of JSON objects retturned from an HTTP request that contain numerical values. These values can range from 100 to 100,000,000. Do you know of possible ways of scaling these particular values as points to a window? Would I have to get the highest possible value first to map it to the pixels of the window or are there other options? How would this be accomplished?
Thanks in advance for any help.
Answers
Use map() if you can guess the range
If you don't know what the highest and/or lowest number will will be, you can always iterate through all the numbers to determine which is the highest and/or lowest. In a for loop:
if(nr[i] >highestNr) hihgestNr = nr[i];
Then in another loop:
map (nr[i, lowestNr,highestNr, 0,width);
That helped immensely. Thank you.
https://forum.Processing.org/two/discussion/16600/script-won-t-load-in-browser-but-no-error-message-in-console
http://p5js.SketchPad.cc/sp/pad/view/ro.90xVTuJFcVi/latest