Code generated pattern wrap on 3D

It almost worked in achieving the vector output, but unfortunately it is rendering pdf/svg in triangles. I’m looking for vectors with clean paths. I would be using the vector output on a xy plotter. Im assuming there should be another way of rendering the pdf/svg output.

import processing.pdf.*;
import processing.svg.*;
float rotx = PI/4;
float roty = PI/4;
boolean record;

void setup() {
  size(400, 400, OPENGL);
  noStroke();
  rectMode(CENTER);
  hint(DISABLE_DEPTH_TEST);
  pixelDensity(2);
  ortho();
  smooth();
}
void drawCircles(float x, float y) {
  for (int sz=80; sz>0; sz-=10) {
    fill(random(255));
    ellipse(x, y, sz, sz);
  }
}
void draw() {
  background(255);

  if (record) {
    beginRaw(PDF, "output.pdf");
    //beginRaw(SVG, "output.svg");
  }

  translate(width/2, height/2);
  rotateX(rotx);
  rotateY(roty);  
  scale(2.0);

  // right plane
  fill(255, 0, 0);
  pushMatrix();
  rotateY(PI/4);
  translate(0, 0, 50);
  rect(0, 0, 100, 100);
  drawCircles(0, 0);
  popMatrix();

  // left plane
  fill(0, 100, 255);
  pushMatrix();
  rotateY(-PI/4);
  translate(0, 0, 50);
  rect(0, 0, 100, 100);
  drawCircles(0, 0);
  popMatrix();

  // top plane
  fill(255, 200, 0);
  pushMatrix();
  rotateY(PI/4);
  rotateX(PI/2);
  translate(0, 0, 50);
  rect(0, 0, 100, 100);
  drawCircles(0, 0);
  popMatrix();
  if (record) {
    endRaw();
    record = false;
  }
}

void keyPressed() {
  // Use a key press so that it doesn't make a million files
  if (key == 's') {
    record = true;
  }
}

void mouseDragged() {
  float rate = 0.01;
  rotx += (pmouseY-mouseY) * rate;
  roty += (mouseX-pmouseX) * rate;
}

1 Like