We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
merging shapes? (Read 732 times)
merging shapes?
May 24th, 2006, 10:41pm
 
I want to create a shape that is composed of multiple overlapping circles and I want it to be semitransparent. The problem is that when I make the circles semi-transparent the regions where they overlap become more opaque. Is there anyway  to merge two or more overlapping shapes into a single shape, or change the way overlapping alphas are combined? I'm totally stumped and would appreciate any suggestions.
Re: merging shapes?
Reply #1 - May 24th, 2006, 11:16pm
 
Off the top of my head, one way to do it is to create a mask from the circles and then apply the colour to that.

Check out this for more info about masks: http://processing.org/reference/PImage_mask_.html

hth
steve
Re: merging shapes?
Reply #2 - May 25th, 2006, 4:47pm
 
You could try using the Geomerative library.
Here's the code for merging shapes:

Quote:


import processing.opengl.*;
import geomerative.*;

RPolygon c;

void setup(){
size(800,600,OPENGL);
smooth();

fill(183,20,20,150);
stroke(0);

RPolygon c1 = RPolygon.createCircle(0,-20,30);
RPolygon c2 = RPolygon.createCircle(20,40,45);
RPolygon c3 = RPolygon.createCircle(-40,-20,40);
RPolygon c4 = RPolygon.createCircle(0,0,10);

c = new RPolygon();
c = c.union(c1);
c = c.union(c2);
c = c.union(c3);
c = c.diff(c4);
}

void draw(){
 background(255);
 translate(width/2,height/2);
 
 translate(mouseX-width/2, mouseY-height/2);
 c.draw(g);
 
 translate(mouseX-width/2+10, mouseY-height/2+10);
 c.draw(g);
}



and this is a resulting image:

...

and finally the link to the library:

Geomerative (release 06)

hope it helps
Re: merging shapes?
Reply #3 - May 31st, 2006, 8:03am
 
Geomerative was exactly what I needed. Thanks a lot for the suggestions.
Page Index Toggle Pages: 1