Device Pixel Ratio & p5

I use this formula to change the color of a pixel (as indicated in the documentation):

pixels[4*(y*width+x)] = 100;
pixels[4*(y*width+x)+1] = 50;
pixels[4*(y*width+x)+2] = 10;
pixels[4*(y*width+x)+3] = 255;

But what is the correct formula to change the color of a pixel when the device pixel ratio = 2, like Retina IPhones?

ie. if (window.devicePixelRatio === 2){ ??? }

Tagged:

Answers

  • edited December 2014 Answer ✓

    hey @lastnightsparty. very sorry, the pixel stuff is in need of some updating right now to handle retina scaling, as you've discovered. hoping to have a fix soon. in the meantime, you could disable the retina scaling with this function: http://p5js.org/reference/#p5/devicePixelScaling

    (make sure you grab the newest version of the library if you want to use this, it was just added).

Sign In or Register to comment.