Boolean Difference on Vertexes?

Hi all, I’m trying to get this ‘Unknown Pleasures’ cover to generate an SVG without the full vertex paths.

This is the code I’m using, written by someone else:

As you can see it generates full overlapping paths. When I generate an SVG for use with a Pen Plotter, it won’t work. The line output I need has to be like this:

Now I have been looking like crazy everywhere. I don’t own Illustrator, and InkScape is not letting me do what I want. I’m now manually removing line segments in Rhino3D but it’s giving me an intense headache. There must be a way to have the overlapping paths cut each other off. I believe that each next vertex should perform a boolean difference on every previously generated vertex.

I have found that the Geomerative library allows such a thing but have been unsuccessful in finding out exactly how. If this is a lot of work, let me know, I will accept the Rhino3D headache way, but imagine if there is a simple way of getting the result I want, it would’ve been dumb to not at least ask here.

This is the code I edited:

  Unknown Pleasures
  Curves constructed from the actual data from the first
  recorded radio pulsar, PSR B1919+21. Artist Peter Saville
  saw the image in The Cambridge Encyclopaedia of Astronomy,
  and presented a few options to the band. Bernard Sumner
  chose PSR B1919+21, and the rest is history.
  CSV file contains 80 lines, each containing 300 data points.

import processing.svg.*;
PImage img;

void setup() {
    String outfile = "Unknown_Pleasures.svg";
  beginRecord(SVG, outfile);
  println("press key [r] to save to "+outfile);

void draw() {
  String[] data = loadStrings("pulsar.csv");
  for (int i = 0; i < data.length; i++) {
    float[] points = float(split(data[i],','));
    for (int j = 0; j < 300; j++) {
      vertex(100 + 2 * j, -80 + height - (8 * (79 - i) + 2 * points[j]));
void keyPressed() {
  if (key == 'r') { 
    endRecord();                   //press the 'r' key to save SVG

Original source by Michael Kennan for the code is here:


Hi @Marinus,

Have you tried with the createGraphics method ? (see bottom of that page)

It seems to work on my side (example in Python mode)

def setup():

    data = loadStrings("pulsar.csv")

    svg = createGraphics(800, 800, SVG, "output.svg");
    svg.translate(100, 80)
    for i in xrange(len(data)):
        vals = map(float, split(data[i], ","))
        for j, val in enumerate(vals):
            svg.vertex(j*2, i*8 - val*2)



Use endShape(CLOSE) to fill each layer with a color given by fill().

You’ll need to draw back to front if you aren’t already. Importantly, closing the shape will draw a line segment from the last point to the first which you probably don’t want to see in your project. A work around is for each layer, to turn stroke off (noStroke()), draw the shape as you did before, turn stroke on, and finally draw the outline for the layer using line().

Drawing the stroke and fill separately is something I’ve done for one of my projects – an FPS plotter (I didn’t want to see the stroke outline at the right and bottom sides):


Thanks for your reply! The issue is not that I can’t get it ti have a fill, setting a fill works fine But I want the lines to cut each other off so that when I load the vector lines up in a vector based software, the lines don’t all just appear on top of each other. So what the infill is normally covering up, the other lines are still behind it ‘hidden’ by the infill. And I want the lines that aren’t visible behind the infill to completely disappear so that when I plot the lines with a pen plotter, they don’t appear.

I hope my explanation is clear :grinning:

ps I could get your method to work, but it was not what I was looking for, maybe my question was unclear? Sorry.

Thanks micycle, I will try it out when I’m back at the computer where I work from :slight_smile: I’m going to check out how the booleans work, it’s something new to me :slight_smile:

Btw, I’m working with a physical pen plotter, so no digital plotter.

Here is a video:

1 Like