
The Day I Saw The Rainbow

Ocean is the ultimate solution

God had spoken to Moses through a burning bush



See: https://openprocessing.org/sketch/1519493



// NOTICE: CODE IS A MESS
void setup(){
size(500,800);
background(255);
translate(width/2-10, height/2-5);
frameRate(5);
}
void draw(){
mouse = true;
background(255, 192, 203);
translate(width/2-10, height/2-180);
generate();
}
public void arm(float c){
float p1x = 0;
float p1y = -100;
float p2x = p1x + random(5,20);
float p2y = p1y + random(10);
float p3x = p2x + random(10);
float p3y = p2y + random(50, 100);
float p4x = p3x + random(-5);
float p4y = p3y + random(10,30);
float p5x = p3x + random(20,200);
float p5y = p3y + random(10,100);
fill(c);
beginShape();
vertex(p1x,p1y);
vertex(p2x,p2y);
vertex(p3x, p3y);
vertex(p3x, p3y);
vertex(p5x, p5y);
vertex(p5x, p5y+ random(5,10));
vertex(-p4x,p4y);
vertex(-p3x,p3y);
vertex(-p2x,p2y);
vertex(p1x,p1y);
endShape();
}
float offset;
public void torso(float c){
float p1x = random(10,20);
float p1y = -100;
float p2x = p1x + random(10);
float p2y = p1y + random(100,150);
float p3x = p2x + random(10);
float p3y = p2y + random(100, 150);
fill(c);
beginShape();
vertex(p1x,p1y);
vertex(p2x,p2y+ random(40));
vertex(p3x, p3y+ random(40) + 20);
vertex(-p3x, p3y+ random(40)+ 20);
vertex(-p2x, p2y + random(40));
vertex(-p1x, p1y);
vertex(p1x, p1y);
endShape();
offset = p3y;
}
public void legs(float c){
float p1x = 0;
float p1y = offset;
float p2x = p1x + random(5,20);
float p2y = p1y + random(10);
float p3x = p2x + random(10);
float p3y = p2y + random(50, 100);
float p4x = p3x + random(-5);
float p4y = p3y + random(10,30);
float p5x = p3x + random(10,150);
float p5y = p3y + random(10,300);
fill(c);
beginShape();
vertex(p1x,p1y);
vertex(-p2x,p2y);
vertex(-p3x, p3y);
vertex(-p3x, p3y);
vertex(-p5x, p5y);
vertex(-p5x, p5y+ random(5,10));
vertex(p4x,p4y);
vertex(p3x,p3y);
vertex(p2x,p2y);
vertex(p1x,p1y);
endShape();
}
public void head(float c){
float p1x = 0;
float p1y = offset+20;
float p2x = p1x + random(5,20);
float p2y = p1y + random(10,20);
float p3x = p2x + random(10);
float p3y = p2x + random(20,25);
fill(c);
beginShape();
vertex(p1x,-p1y);
vertex(-p2x,-p2y);
vertex(-p3x, -p3y+ 20);
vertex(-p3x, -p3y + 20);
vertex(p3x,-p3y);
vertex(p2x,-p2y);
vertex(p1x,-p1y);
endShape();
fill(255);
ellipse(10,-offset + 20,30,30);
fill(0);
ellipse(10,-offset +20,10,10);
}
public void generate(){
arm(200);
legs(200);
torso(220);
head(220);
arm(220);
legs(220);
}
boolean mouse = false;
void mousePressed(){
if(mouse == false){
mouse = true;
background(255, 192, 203);
translate(width/2-10, height/2-180);
generate();
}
}
void mouseReleased(){
mouse = false;
}



import org.gicentre.handy.*; // For Handy rendering.
HandyRenderer h; // This does all the hard work of rendering.
void setup()
{
size(1000,700);
h = new HandyRenderer(this);
}
float d1x, d1y,d2x, d2y,d3x, d3y;
int sX = 1000;
int sY = 700;
float cropfactor = 0.75;
float[] Q = { random(100, 500.0), random(-200, -400.0), random(100, 500.0), random(-1000, 1000.0)};
float[][] initial_positions = { {random((1-cropfactor)*sX, sX*cropfactor), random((1-cropfactor)*sY, sY*cropfactor)},
{random((1-cropfactor)*sX, sX*cropfactor), random((1-cropfactor)*sY, sY*cropfactor)},
{random((1-cropfactor)*sX, sX*cropfactor), random((1-cropfactor)*sY, sY*cropfactor)},
{random((1-cropfactor)*sX, sX*cropfactor), random((1-cropfactor)*sY, sY*cropfactor)}
};
void draw()
{
background(240);
float maxincrement = 5;
float EE,ll,deltax,deltay;
for(int k = 0; k<Q.length; k++){
fill(random(120)); h.ellipse(initial_positions[k][0],initial_positions[k][1],10,10);
initial_positions[k][0] += random(-maxincrement,maxincrement);
initial_positions[k][1] += random(-maxincrement,maxincrement);
}
ll=40; // grains of semolina dimension (try ll=10, ll=20)
int ns=3000; // number of grains (try ns=10000, ns=30000)
float dx,dy;
float[] distance = new float[Q.length];
float[] Field = new float[Q.length];
for(int i=0; i<ns; i++)
{
float sumX = 0;
float sumY = 0;
float x=int(random(1000));
float y=int(random(700));
for(int k = 0; k<Q.length; k++){
dx= x - initial_positions[k][0]; dy=y-initial_positions[k][1];
distance[k] = sqrt(dx*dx+dy*dy);
Field[k]=Q[k]/(distance[k]*distance[k]);
sumX += Field[k]*dx;
sumY += Field[k]*dy;
}
EE=sqrt(sumX*sumX+sumY*sumY);
deltax=ll*sumX/EE;
deltay=ll*sumY/EE;
stroke(color(random(50,200)));
h.line(x,y,x+deltax,y+deltay);
}
loop();
}

Processing 3.5.4 java:
A code to plot the Earth
int rows, cols;
int w = 1600;
int h = 2200;
int scl;
float[][] land;
float forward = 0;
void setup(){
size(600, 800, P3D);
frameRate(30);
scl = 20;
rows = h/scl;
cols = w/scl;
}
void draw(){
forward -= 0.1;
float y_ = forward;
land = new float[cols][rows];
for (int y = 0; y < rows; y++){
float x_ = 0;
for (int x = 0; x < cols; x++){
land[x][y] = map(noise(x_,y_), 0, 1, -80, 170);
x_ += 0.1;
}
y_ += 0.1;
}
background(0);
translate(width/2, height/2 + 100);
rotateX(PI/3.2);
translate(-w/2, -h/2);
for (int y = 0; y < rows-1; y++){
beginShape(TRIANGLE_STRIP);
for (int x = 0; x < cols; x++){
if (land[x][y] > 80) {
fill(255);
}
else if (land[x][y] > 50) {
fill(#567d46);
}else if (land[x][y] > 30) {
fill(#FFFF00);
}
else{
fill(0, 0, 190);
}
vertex(x*scl, y*scl, land[x][y]);
vertex(x*scl, (y+1)*scl, land[x][y+1]);
}
endShape();
}
saveFrame();
}



void setup(){
size(800, 800);
background(#eeeeee);
noLoop();
}
void draw(){
background(#eeeeee);
translate(width/2, height/2);
for (int a = 0; a<360; a +=1){
float x = random(130, 150);
float xx = random(100, 350);
pushMatrix();
rotate(radians(a));
strokeCap(ROUND);
if (abs(x - xx)<20){
strokeWeight(5);
stroke(50);
line(x, 0, xx, 0);
}else{
strokeWeight(2);
stroke(300, 100, random(20, 200));
line(x, 0, xx, 0);
stroke(100);
circle(x, 200, 100);
stroke(50);
circle(x*2, 200, 100);
stroke(50);
circle(x*3, 200, 100);
}
popMatrix();
}
}
void keyPressed(){
redraw();
}