How to find a colour on the screen?

i have a colour value (11, 96, 133) and i want the program to tell me if there is any colour that is really similar or exactly the same. here is the rest of my code if its useful:

PImage screenshot;
import java.awt.Robot;

void setup() {
 size(400,300);
}

void draw() {
     try {
       Robot robot = new Robot();
       screenshot = new PImage(robot.createScreenCapture(new java.awt.Rectangle()(0,0,screen.width,screen.height)));
     
     } catch (AWTException e) {
     }
 image(screenshot, 0, 0, width, height);
screenshot(0,0,width, height);
}

`

`

*** 1. > * Blockquote**

`

`

[quote="MoonAlien822, post:1, topic:30405, full:true"]
i have a colour value (11, 96, 133) and i want the program to tell me if there is any colour that is really similar or exactly the same. here is the rest of my code if its useful: 

PImage screenshot;
import java.awt.Robot;

void setup() {
 size(400,300);
}

void draw() {
     try {
       Robot robot = new Robot();
       screenshot = new PImage(robot.createScreenCapture(new java.awt.Rectangle()(0,0,screen.width,screen.height)));
     
     } catch (AWTException e) {
     }
 image(screenshot, 0, 0, width, height);
screenshot(0,0,width, height);
}

Hello,

Please format your code as per:
https://discourse.processing.org/faq#format-your-code

This is the same code as you provided here:
https://discourse.processing.org/t/help-with-error-in-robot-class-and-createscreencapture-method/30396/1

I provided you with a link in the topic above to a working example that you can modify to get a PImage of the screen.

Please correct your code and then take the next step.

Once you get a PImage you can use get():
https://processing.org/reference/get_.html

See tutorial:
https://processing.org/tutorials/pixels/ Intro To Image Processing section has a good example to work with!
https://processing.org/tutorials/color/

:)

i think i fixed it. if i need to change anything else, just say so and i will change it.

Hello,

You formatted your code but did not do it correctly.
Take a look at it and you will see duplicate code… you can edit this.

That code does not work as is.
Take a look at your code and examples for some insight.

I was able to find an exact color on the screen and display x,y co-ordinates with the tips that I provided you:

This will require some work on your part to complete.

:)

Hello,

You can get the desktop screen resolution with this to integrate with the other code:
https://www.geeksforgeeks.org/java-program-to-print-screen-resolution/

The solution above was me doing some research.
There may be other ways to do it.

Example:

// https://www.geeksforgeeks.org/java-program-to-print-screen-resolution/

import java.awt.*;

Dimension screenSize;
int scrWidth;
int scrHeight;
 
void setup() 
  {
  size(640, 480, P3D);
  
  // This does not work!
  //println(screen.width,screen.height);
  
  //Another solution
  screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  scrWidth = (int)(screenSize.getWidth());
  scrHeight = (int)(screenSize.getHeight());
  println("1: ", scrWidth, scrHeight);
  noLoop();
  }
 
void draw() 
  {
  println("2: ", scrWidth, scrHeight);
  }

And an easier way:
https://processing.org/reference/size_.html

makes reference to:

As of Processing 3, to run a sketch at the full dimensions of a screen, use the fullScreen() function, rather than the older way of using size(displayWidth, displayHeight) .

You can use:

  // This does not work!
  //println(screen.width,screen.height);
  
  println(displayWidth, displayHeight);

I came across this looking here in some of the Processing source files:
https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java
Careful! You can get lost in there.

:)

This post is continued here by @MoonAlien822 :

thank you, do you know how you, insead of finding the exact colour, can find something extremely simelar?

Hello,

I made some suggestions in your topic here:

I had success comparing to a range of hues.

:)