Need help with converting Robot's getPixelColor to use it in Processing
in
Programming Questions
•
8 months ago
I'm trying to readh the RGB from where my mouse is on the screen and this is my code so far.
I know that initializing a class in Ddraw() can't be good but its the only way im not getting errors.
My println(col) is saying "java.awt.Color[r=13,g=12,b=13]"
But dont know how to convert it to an int or something to use in processing?
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Color;
Robot robot;
Color col;
void setup() {
size(400, 400);
try {
robot = new Robot();
col = new Color();
}
catch (AWTException e) {
e.printStackTrace();
}
robot.mouseMove(displayWidth/2, displayHeight/2);
}
void draw() {
col = robot.getPixelColor(20, 20); //println(frameCount);
println(col.getRed());
background(col.getRed(),col.getGreen(),col.getBlue());
}
1