Hi everyone,
I don't think this should be difficult, but I can't get it to work. I want do draw Bezier shapes like this:
Code:
stroke(#FFFFFF,100);
noFill();
beginShape(POLYGON);
for (int i=0; i<x2s.length-1; i++)
{
vertex(x2s[i], y2s[i]);
bezierVertex(x1, y1, x1, y1, x2s[i+1], y2s[i+1]);
}
vertex(x2s[x2s.length-1], y2s[x2s.length-1]);
bezierVertex(x1, y1, x1, y1, x2s[0], y2s[0]);
endShape(CLOSE);
Now, that works. But because I have many such shapes that I would like to use over and over again, I tried to create a function like this one:
Code:
PGraphics2D create_cell_shape(int x1, int y1, int[] x2s, int[] y2s, color bg, color st) {
smooth();
stroke(#AAAAAA);
fill(#FFFFFF);
PGraphics2D cell = new PGraphics2D();
cell.beginDraw();
cell.beginShape(POLYGON);
for (int i=0; i<x2s.length-1; i++)
{
cell.vertex(x2s[i], y2s[i]);
cell.bezierVertex(x1, y1, x1, y1, x2s[i+1], y2s[i+1]);
}
cell.vertex(x2s[x2s.length-1], y2s[x2s.length-1]);
cell.bezierVertex(x1, y1, x1, y1, x2s[0], y2s[0]);
cell.endShape(CLOSE);
cell.endDraw();
image(cell);
return cell;
}
I played around a little with the type of object that 'cell' is, so at least it compiles now, but I can't get it do display in the draw() function, as in shape() or image() and so forth.
Any ideas about this would be very much appreciated. Thanks!