Showing posts with label drawing. Show all posts
Showing posts with label drawing. Show all posts

Monday, 28 May 2018

Processing drawing using Math.





Code for the final dragrams.

float t=0;

void setup() {
  size(1200, 500);
  background(0);
  //Usingg same formula three time with different constant in tis case 7 and 11
  translate(200,200);
  for(t=0;t<Math.PI*2;t+=0.001){
    float x=cos(t) + cos(7 * t)/2 + sin(11 * t)/3;
    float y=sin(t) + sin(7 * t)/2 + cos(11 * t)/3;
    noStroke();
    color c=color(38,191,250);
    fill(c);
    ellipse(100*x,100*y,3,3);
  }
  
  //here 6 and 14
  resetMatrix();
  translate(600,200);
  
  for(t=0;t<Math.PI*2;t+=0.001){
      float x=cos(t) + cos(6 * t)/2 + sin(14 * t)/3;
      float y=sin(t) + sin(6 * t)/2 + cos(14 * t)/3;
      noStroke();
      color c=color(38,191,250);
      fill(c);
      ellipse(100*x,100*y,3,3);
  }
  // in las one 5 and 15
  resetMatrix();
  translate(1000,200);
  
  for(t=0;t<Math.PI*2;t+=0.001){
      float x=cos(t) + cos(5 * t)/2 + sin(15 * t)/3;
      float y=sin(t) + sin(5 * t)/2 + cos(15 * t)/3;
      noStroke();
      color c=color(38,191,250);
      fill(c);
      ellipse(100*x,100*y,3,3);
  }
}

Friday, 25 May 2018

Simple processing Generative Art/Drawing 4

 




Below is the code to generate the above shown drawing..

float r=0;

void setup() {
  size(400, 400);
  background(0);
  smooth();
  noStroke();
}

void draw() {
  
  if (r>300) {     // To reset the drawing
    fill(0);
    r=0;
    rect(0, 0, width, height);
  }
  rotate(r);
  translate(width/2, height/2); //to bring it to center
  fill(0, random(r, 255), random(r, 255));
  float circle_size= random(5, 15);
  ellipse(100+r, 10, circle_size, circle_size);
  r=r+0.2;
}

Tuesday, 8 May 2018

Cafe Wall Illusion using processing




Cafe Wall Illusion

int s=89;
color black=color(0);
color white=color(255);
Line l[];
float update=0;

void setup() {
  size(810, 680);
  stroke(89, 89, 89);
  strokeWeight(2);
  l=new Line[8];

  for (int i=0; i<8; i++) {
    l[i]=new Line(i*90);
  }
}

void draw() {

  for (int i=0; i<8; i++) {
    if (i%2==0)
      l[i].drawL(-270+update);
    else
      l[i].drawL(-270-update);
  }
  update=update+0.5;
  //println(update+"");
  if (update==180)
    update=0;
}

class Line {

  int n=20;
  float posY;

  Line(float posY) {
    this.posY=posY;
  }

  void drawL(float diff) {

    for (int i=0; i<16; i++) {
      float posX=i*90 +diff;
      if (i%2==0) {
        fill(0);
        rect(posX, posY, s, s);
      } else {
        fill(255);
        rect(posX, posY, s, s);
      }
    }
  }
}

Monday, 30 April 2018

Simple Clock Animation Using Processing(with Code)





Find the code for above video below.

void setup(){

  size(800,800);
  background(0);
  strokeCap(SQUARE);
}

void draw(){

  fill(0);
  rect(0,0,800,800);

  int s=second();
  int h=hour();
  int m=minute();

  String time;

  if(h>=10)
    time=h+"";
  else
    time="0"+h;
  if(m<10)
    time=time+":0"+m;
  else
    time=time+":"+m;
  if(s<10)
    time=time+":0"+s;
  else
    time=time+":"+s;

  if(h>12)
    h=h-12;

  translate(400,400);
  rotate(radians(-90));

  noFill();
  strokeWeight(24);
  stroke(255);//Set your Color
  arc(0,0,400,400,0,((2*PI)/60)*s);

  stroke(255);//Set your Color
  arc(0,0,350,350,0,((2*PI)/60)*m);

  stroke(255);//Set your Color
  arc(0,0,300,300,0,((2*PI)/12)*h);

  rotate(radians(90));
  PFont font = createFont("Comic Sans MS", 40);
  textFont(font);
  fill(255);
  text(time, -80, 0);
} 

Sunday, 23 July 2017

Simple Processing Generative Art/Drawing 3







To Generate Above drawing
Note : Play with fill to get different color

float r = 0;

void setup() {
  size(400,400);
  background(10);
  smooth();
  noStroke();
}
void draw() {
  translate(width/2, height/2);
  fill(255);
  rotate(r);
  float circle_size = random(5, 15);
  fill(0,random(r,255),random(r,255));
  ellipse(100 + r, 10, circle_size, circle_size);
  r = r + 0.2;
  println(r);
  if(r>150)
    r=0;
}

Simple Processing Generative Art/Drawing 2





Code to generate above patten

1. For rectangle

void setup(){
size(600,600);
}

void draw(){
noStroke();
fill(random(255),random(255),random(255),random(255));
rect(random(255),random(255),random(255),random(255));
}

2. For Ellipse

void setup(){
size(600,600);
}

void draw(){
noStroke();
fill(random(255),random(255),random(255),random(255));
ellipse(random(255),random(255),random(255),random(255));
}

Simple Processing Generative Art/Drawing 1





Code to generate above pttern

void setup(){
    size(255,255);
}

void draw(){
    float r=random(255);
    float b=random(255);
    float g=random(255);
    stroke(r,b,g);
    line(0,0,r,b);
}