Ok, I think GitHub - micycle1/PGS: Processing Geometry Suite is a way forward - Here’s my quick check
The boxes on the left have fills which wouldn’t work on the plotter.
The boxes on the right are made of :
- The foreground box (green), and
- the subtraction of the foreground box from the background box (red)
No fill() used on the right hand side - So a bit of playing around to progressively add one house at a time to a resulting shape. Still would be keen to hear how anyone else would approach this one, Cheers!
import processing.svg.*;
import micycle.pgs.*;
boolean plotter = false;
void setup()
{
//size(10680, 6240); //a4
size(1068, 624);
if (plotter)
{
beginRecord(SVG, "test.svg");
}
background(255);
noFill();
stroke(0);
strokeWeight(1.0);
smooth();
}
void draw()
{
//rect(10, 10, width - 20, height - 20);
//The original houses on the left side (with fills to hide any background houses)
House backgroundHouse = new House(100, 100);
House foregroundHouse = new House(140, 200);
backgroundHouse.Draw();
foregroundHouse.Draw();
//Houses put through Processing Geometry Suite on the right side
int destX = 500;
int destY = 100;
PShape bground = PGS_Transformation.translateTo(backgroundHouse.s, backgroundHouse.x, backgroundHouse.y);
PShape fground = PGS_Transformation.translateTo(foregroundHouse.s, foregroundHouse.x, foregroundHouse.y);
//Show the subtraction of the foreground house from the background
PShape subtract = PGS_ShapeBoolean.subtract(bground, fground);
PGS_Conversion.disableAllFill(subtract);
PGS_Conversion.setAllStrokeColor(subtract, color(100, 0, 0), 2);
shape(subtract, destX, destY);
//Show the foreground house
PGS_Conversion.disableAllFill(fground);
PGS_Conversion.setAllStrokeColor(fground, color(0, 100, 0), 2);
shape(fground, destX, destY);
if (plotter)
{
endRecord();
}
noLoop();
}
class House //ok it's not much of a house, it's a box :)
{
PShape s;
int x;
int y;
House(int xPos, int yPos)
{
x = xPos;
y = yPos;
s = createShape();
s.beginShape();
s.fill(230);
s.vertex(0, 0);
s.vertex(0, 200);
s.vertex(200, 200);
s.vertex(200, 0);
s.endShape(CLOSE);
}
void Draw()
{
shape(s, x, y);
}
}