I have a problem with the alpha on my code. I made 2 circles with stripes, but the area between stripes wasn't tranparent. Here goes the code:
PGraphics circ, line, line2, circ2;
void setup(){
size(600,600,P2D);
circ = createGraphics(600,600,P2D);
circ2 = createGraphics(600,600,P2D);
line = createGraphics(600,600,P2D);
line2 = createGraphics(600,600,P2D);
makeCircle(line,circ,300,300,100,#00ff00);
makeCircle(line2,circ2,350,350,100,#ff0000);
}
void draw(){
}
void makeCircle(PGraphics stripes, PGraphics mask, int x, int y, int r,
color c){
mask.smooth();
mask.beginDraw();
mask.background(0,0);
mask.ellipse(x,y,r*2,r*2);
mask.endDraw();
stripes.beginDraw();
stripes.noStroke();
stripes.fill(c,200);
for(int i=0;i<11;i++){
stripes.rectMode(CENTER);
stripes.rect(x+(i*20)-r,y,10,r*2);
}
stripes.mask(mask);
stripes.endDraw();
image(stripes,0,0);
}
I want to make this shape, if you guys know another way, please tell me.
You can obtain this easily with Geomerative library.
import geomerative.*;
void setup()
{
size(600,600,P2D);
RG.init(this);
}
void draw()
{
background(255);
makeCircle(300, 300, 100, #00ff00);
makeCircle(mouseX, mouseY, 100, #ff0000);
}
void makeCircle(int x, int y, int r, color c) {
fill(c);
RShape mask = RShape.createEllipse(x, y, r*2, r*2);
for (int i=0; i<11; i++) {
RShape strip = RShape.createRectangle(x+(i*20)-r, y-r, 10, r*2);
RShape masked = strip.intersection(mask);
masked.setStroke(false);
RG.shape(masked);
}
}