Moiré patterns – rainbow sphere

Experimenting with moiré patterns, light and color in processing. Based on code from OpenProcessing. Full code here and below.

//adapted from - Open Processing: https://www.openprocessing.org/sketch/28755#

// thanks to this weird guy with the projector: https://www.youtube.com/watch?v=W8Jf9SVsT38

float _detail = 50;
float _moire = 2;
int _ballRadius = 200;
float fillVal = 0;

void setup() {
 size(800, 800, P3D);
 colorMode(HSB, 100);
 background(0);
 rectMode(CENTER);
 smooth();
}

void draw() {
 background(0);
 if (keyPressed == true) {fillVal = fillVal + 1;} 
  else {fillVal = fillVal - 1;}
 
 float silk= map(fillVal, 0 , 800, 0, _detail);
 noFill();

 for (int x = 0; x<width; x+=_detail) {
   for (int y = 0; y<height; y+=_detail) {
     stroke(65, 70, 100);
     float w = _detail/_moire;
     float h = _detail/TWO_PI;
     stroke(x%100, 70, 100);
     rect(x,y,w+silk,h);
     rect(x,y, 0 ,h);
     ellipse(x,y, w+silk, w+silk);
     ellipse(x,y, h, h);}}
}

Leave a Reply

Your email address will not be published. Required fields are marked *