# Beginner Color Help

**URL:** <https://discourse.processing.org/t/beginner-color-help/14873>\
**Category:** Beginners\
**Created:** [October 22, 2019, 3:02pm UTC](https://discourse.processing.org/t/beginner-color-help/14873 "2019-10-22T15:02:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![FilDomInteractive](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/fildominteractive/32/6678_2.png) [@FilDomInteractive](https://discourse.processing.org/u/FilDomInteractive)\
**Post date:** [October 22, 2019, 3:02pm UTC](https://discourse.processing.org/t/beginner-color-help/14873/1 "2019-10-22T15:02:35Z")

</div>

How do I make something happen when like a line is on a specific colour?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 22, 2019, 3:06pm UTC](https://discourse.processing.org/t/beginner-color-help/14873/2 "2019-10-22T15:06:17Z")

</div>

it would help to see your code.

Generically speaking, you could check the color of the end-point of the line by using color cComp=get(x,y);

When myColor is your color you want to check against:

Then say

```auto
if(myColor==cComp) { 
     println("Hello");   
}

```

Here is an example:

```auto

color cComp=0; 
color myColor=0;
String text1="Is the color you clicked on RED ? ";
//
// ---------------------------------------------------------------
//
void setup() {
  // init
  size(800, 600);
  myColor=color (255, 0, 0);
} // func 

void draw() { 
  background(255);

  fill(255, 0, 0); // RED  
  triangle(30, 75, 
    58, 20, 
    300, 75);
  if (myColor==cComp) { 
    text( text1+"Yes "+colorAsString(), 400, 400);
  } else {
    text( text1+"NO "+colorAsString(), 400, 400);
  }

  fill(0, 0, 255);
  rect(400, 200, 44, 44); 
  //
} // func 
//

void mousePressed() {
  cComp=get(mouseX, mouseY);
}//func

String colorAsString() {
  return 
    str(int(red(cComp))) 
    + "," +
    str(int(green(cComp))) 
    + "," +
    str(int(blue(cComp))) ;
}
//

```

It is the question if the ENTIRE line is placed on the same color:

- Then you need to check the whole line pixel by pixel prior to drawing it

---

<div class="post-metadata">

**Author:** ![FilDomInteractive](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/fildominteractive/32/6678_2.png) [@FilDomInteractive](https://discourse.processing.org/u/FilDomInteractive)\
**Post date:** [October 22, 2019, 3:14pm UTC](https://discourse.processing.org/t/beginner-color-help/14873/3 "2019-10-22T15:14:18Z")

</div>

# I just realized how to do it but thanks.
