a port of the Processing Visualization Language
Class PImage
Name

set()

Examples
example pic
// @pjs preload must be used to preload the image
/* @pjs preload="tower.jpg"; */
PImage img = loadImage("tower.jpg");
background(img);
noStroke(); 
color c = img.get(60, 90); 
fill(c); 
rect(25, 25, 50, 50);
Description

Changes the color of any pixel or writes an image directly into the image. The x and y parameter specify the pixel or the upper-left corner of the image. The color parameter specifies the color value.

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". Processing requires calling loadPixels() to load the display window data into the pixels[] array before getting the values and calling updatePixels() to update the window.

This function ignores imageMode().

Syntax
img.set(x,y,color)

Parameters
img PImage: any variable of type PImage
x int: x-coordinate of the pixel
y int: y-coordinate of the pixel
color color: any value of the color datatype
Returns None
Usage Web & Application
Related get()
pixels[]
copy()

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub