void mousePressed() {
if (mouseX >= 0 && mouseX < img.width && mouseY >= 0 && mouseY < img.height) {
if (mouseButton == LEFT) {
String coord = mouseX + ", " + mouseY;
println("Coordinates: " + coord);
copyToClipboard(coord);
}
else if (mouseButton == RIGHT) {
color c = img.get(mouseX, mouseY);
String rgb = int(red(c)) + ", " + int(green(c)) + ", " + int(blue(c));
println("Color: " + rgb);
copyToClipboard(rgb);
}
}
}
void copyToClipboard(String s) {
java.awt.datatransfer.StringSelection selection = new java.awt.datatransfer.StringSelection(s);
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, null);
}