set()

本参考资料用于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.

名称

set()

示例
 color black = color(0);

set(30, 20, black);

set(85, 20, black);

set(85, 75, black);

set(30, 75, black);


for (int i = 30;

i < width-15;

i++)
{  
for (int j = 20;

j < height-25;

j++)
{
color c = color(204-j, 153-i, 0);


set(i, j, c);


   }
  } 
 size(100, 100);

PImage myImage = loadImage("apples.jpg");

set(0, 0, myImage);

line(0, 0, width, height);

line(0, height, width, 0);

描述 Changes the color of any pixel, or writes an image directly to the display window.

The x and y parameters specify the pixel to change and the c parameter specifies the color value. The c parameter is interpreted according to the current color mode. (The default color mode is RGB values from 0 to 255.) When setting an image, the x and y parameters define the coordinates for the upper-left corner of the image, regardless of the current imageMode().

Setting the color of a single pixel with set(x, y) is easy, but not as fast as putting the data directly into pixels[]. The equivalent statement to set(x, y, #000000) using pixels[] is pixels[y*width+x] = #000000. See the reference for pixels[] for more information.

语法
set(x, y, c) set(x, y, img)
参数
x int: x-coordinate of the pixel
y int: y-coordinate of the pixel
c int: any value of the color datatype
img PImage: image to copy into the original image
返回值 void
相关 get()
pixels[]
copy()

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

set()