# Handling color in eclipse with processing

**URL:** https://discourse.processing.org/t/handling-color-in-eclipse-with-processing/28497
**Category:** Coding Questions
**Created:** [March 13, 2021, 1:44pm UTC](https://discourse.processing.org/t/handling-color-in-eclipse-with-processing/28497 "2021-03-13T13:44:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [March 13, 2021, 1:44pm UTC](https://discourse.processing.org/t/handling-color-in-eclipse-with-processing/28497/1 "2021-03-13T13:44:26Z")

</div>

Hi guys I’m hoping you can help please I’m a bit stuck.

When trying to convert my code to a library I ran into the following problem, `color is not recognised as a data type`.

I have found the following posts online asking about the same problem and most of them recommend using `int` instead of `color`, which I’m still a bit confused about because when I tried this it did not resolve the problem.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/61f0c1b9cf4066a7643e0efaf047191fdca00e8c.png)

as you can see. Its likely I’m missing something obvious but I simply do not know what I’m looking to do. An int in my understanding is a datatype that only accepts one value not 2, 3 or 4 as color does. So how do I use int to handle the color type.

I have found an alternative which is the `java.awt` library which has a Color class, and has functions such as `getRGB()` etc to extract values, but I’m just wandering if this method has any problems as it means amending my library which at this point has quite a few instances of color.

here is a sketch using awt

```auto
import java.awt.*;

void setup(){
};

void draw(){
  Color c = Color(255, 0, 255);
  background(c.getRGB());
};

```

Many thanks guys

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [March 13, 2021, 3:12pm UTC](https://discourse.processing.org/t/handling-color-in-eclipse-with-processing/28497/2 "2021-03-13T15:12:55Z")

</div>

Hi,

> [@paulgoux](#):
>
> I have found the following posts online asking about the same problem and most of them recommend using `int` instead of `color` , which I’m still a bit confused about because when I tried this it did not resolve the problem.

You were on the right tracks but the error lies when you try to use the `color()` method which is undefined inside your class. It’s accessible from the `PApplet` class, that’s why you need to pass an instance of it in your constructor and store it as a property.

Try this :

```auto
int c = myParent.color(0, 0, 0, 0);

// Note that this is equivalent to myParent.color(0, 0);

```

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [March 13, 2021, 3:20pm UTC](https://discourse.processing.org/t/handling-color-in-eclipse-with-processing/28497/3 "2021-03-13T15:20:22Z")

</div>

oh completely forgot you could do that. Thank-you that was what I was looking for.
