pixelDensity()

本参考资料用于Processing 3.0+。 如果你使用的是前一版本,请在使用软件帮助菜单内的参考资料。. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

名称

pixelDensity()

示例
 size(100, 100);

pixelDensity(2);

noStroke();

background(0);

ellipse(30, 48, 36, 36);

ellipse(70, 48, 36, 36);




void setup()
{  
size(100, 100);


pixelDensity(2);


noStroke();


  } 
void draw()
{  
background(0);


ellipse(30, 48, 36, 36);


ellipse(70, 48, 36, 36);


  } 



void setup()
{  
size(100, 100);


// Pulling the display's density dynamically   pixelDensity(displayDensity());


noStroke();


  } 
void draw()
{  
background(0);


ellipse(30, 48, 36, 36);


ellipse(70, 48, 36, 36);


  } 
描述 This function is new with Processing 3.0. It makes it possible for Processing to render using all of the pixels on high resolutions screens like Apple Retina displays and Windows High-DPI displays. This function can only be run once within a program and it must be used right after size() in a program without a setup() and used within setup() when a program has one. The pixelDensity() should only be used with hardcoded numbers (in almost all cases this number will be 2) or in combination with displayDensity() as in the third example above. To use variables as the arguments to pixelDensity() function, place the pixelDensity() function within the settings() function. There is more information about this on the settings() reference page.
语法
pixelDensity(density)
参数
density int: 1 or 2
返回值 void

Updated on October 2, 2018 05:02:04pm EDT

pixelDensity()