# 2D lineart - culling hidden lines for SVG output / Plotting

**URL:** <https://discourse.processing.org/t/2d-lineart-culling-hidden-lines-for-svg-output-plotting/30031>\
**Category:** Libraries\
**Created:** [May 11, 2021, 5:18am UTC](https://discourse.processing.org/t/2d-lineart-culling-hidden-lines-for-svg-output-plotting/30031 "2021-05-11T05:18:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mrWoodo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mrwoodo/32/13153_2.png) [@mrWoodo](https://discourse.processing.org/u/mrWoodo)\
**Post date:** [May 11, 2021, 8:45am UTC](https://discourse.processing.org/t/2d-lineart-culling-hidden-lines-for-svg-output-plotting/30031/2 "2021-05-11T08:45:54Z")

</div>

Ok, I think [GitHub - micycle1/PGS: Processing Geometry Suite](https://github.com/micycle1/PGS) 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 :

1. The foreground box (green), and
2. 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!

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/85e6261f012278253243836a58813584fe02a588.png)

```auto
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);
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/2d-lineart-culling-hidden-lines-for-svg-output-plotting/30031)._
