Learn creative coding writing simple programs

81. How to read the color of a pixel

With the get() function we can read the color of any pixel in our program window. We can specify which pixel we are interested in by using x and y coordinates as parameters. For example, color mycolor = get(100, 200); would grab the color of pixel 100, 200 and put that color into the mycolor variable. You can use this on many different ways. For instance you could grab the color of the pixel under the mouse pointer and use it for drawing something. Or if you wanted to draw a shape at a certain place, you could observe the color of pixels near that place. Now you will be able to draw things that depend on things which were previously drawn in the screen.

Tags: get, read, pixel

Code editor

You can make changes to the code below. Then
Below you can ask and answer questions related to this video. If your question is unrelated to the video, please post it at the Processing Forum as I'm unable to help with all of your programs and still have enough free time to eat and sleep :)
comments powered by Disqus