#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# How can i replace a pixel color?

edited June 2016

I have a sketch, in wich I overlay some shapes with opacity. Is there a way to tell the program to replace the pixel color generated from the overlay, with a new color?

Tagged:

## Answers

• edited June 2016

How can I make the intersection area, red?

Here's an example sketch:

``````int x = 0;

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

void draw () {
background (0);
fill (255,200);
ellipse (200,200, 100,100);
ellipse (x,200, 100,100);
x = x + 2;
if (x == width+50) {
x = -50;
}
}
``````
• edited June 2016

But what i need is to:

Make the intersection of two objects, an X color, and the intersection of three objects, a Y color.

Here's another example sketch:

``````int x = 0;
int y = 50;

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

void draw () {
background (0);
fill (255,200);
ellipse (200,200, 100,100);
ellipse (x,200, 100,100);
ellipse (200, y, 50,50);

x = x + 2;
if (x == width+50) {
x = -50;
}

y = y + 2;
if (y == 350) {
y = 50;
}
}
``````
• There's no automatic way to do this in Processing that I can think of. You could possibly be very clever with color choice and alpha to get the desired results. . but you could use arc() to draw just the intersection part! Look at OPEN!

https://processing.org/reference/arc_.html

Sign In or Register to comment.