Code generated pattern wrap on 3D

A variation of 2, where you rotate the axes so you can draw in a known safe area, in this case it’s a rectangle located at 0, 0 and with dimensions 100, 100. There you could draw a grid like in your example, knowing that you stick to that safe area if you want to stay within the rectangle.

void setup() {
  size(400, 400, P3D);
  noStroke();
  rectMode(CENTER);
  hint(DISABLE_DEPTH_TEST);
}
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);
  translate(width/2, height/2);
  rotateX(-0.5);
  scale(2.0);

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

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

  // top plane
  fill(140);
  pushMatrix();
  rotateY(PI/4);
  rotateX(PI/2);
  translate(0, 0, 50);
  rect(0, 0, 100, 100);
  drawCircles(0, 0);
  popMatrix();
}

2018-09-10-160408_400x400_scrot

With this approach the result is still vector data. I hope this works with PDF / SVG, I haven’t tried.

The hint I used forces things to be drawn to the screen in the same order as your instructions get executed. Without it I get this unwanted but nice glitch due to z-fighting:
2018-09-10-160832_400x400_scrot

2 Likes