Hello everyone,
I have a question about using the Processing Geometry Suite (PGS) library.
I’m working on a code that subtracts a ‘circleShape’ from a collection of lines called ‘lines’.
When generating the ‘lines’, I assign a randomly chosen stroke color.
I’m trying to apply ‘PGS_ShapeBoolean.subtractMesh(lines, circleShape)’ to subtract the ‘circleShape’, but the stroke color assigned during the creation of ‘lines’ gets lost.
I’ve looked into various solutions, but I haven’t found any way to resolve this issue. Is there any way to maintain the stroke color?
import micycle.pgs.*;
int nLines = 7;
int nColors = 20;
color[] strokeColors = new color[nColors];
void setup() {
size(800, 800);
background(255);
for (int i = 0; i < nColors; i++) {
strokeColors[i] = color(random(255), random(255), random(255));
}
}
void draw() {
PShape lines = createShape(GROUP);
float step = width / float(nLines);
for (int i = 0; i < nLines; i++) {
float x = i * step;
PShape lineShape = createShape();
lineShape.beginShape();
lineShape.stroke(color(strokeColors[i]));
lineShape.vertex(x, 0);
lineShape.vertex(x, height);
lineShape.endShape();
lines.addChild(lineShape);
}
PShape circleShape = createShape();
circleShape = createShape(ELLIPSE, 300, 300, 400, 400);
circleShape.setFill(255);
circleShape.setStroke(strokeColors[int(random(nColors))]);
PShape subtructedLines = createShape();
subtructedLines = PGS_ShapeBoolean.subtractMesh(lines, circleShape);
shape(circleShape);
shape(subtructedLines);
//shape(lines);
noLoop();
}