Keep Calm and Carry On

Global Warming is every time going to worse consequently, producing the climate change. Everyday we are polluting each time more and more. The human being is contaminating the planet which is the only one we have! Non-renewable energies are actually the most used energies in out daily life. Renewable energies should be used the most In our daily life and non-renewable should be the least. Plastic is the main cause why we are burning fossil fuels everyday, like coal, gas and oil every minute to make plastic. We are destroying the nature, throwing away tons and tons of plastic and rubbish into the sea killing hundreds or even thousands or animals. If the temperature in the planet increases by a few degrees during the next few years, we will be in to a serious problem,. When fossil fuels are being burned everyday, we are contaminating the Earth’s atmosphere with carbon dioxide producing the greenhouse effect over the Planet which is the only cause which Global Warming is being produced.

We shouldn’t carry on like this. #stopwar

Made in Processing & P5
PeasyCam & minim libraries used

You can reach code from below;

https://github.com/bestesaylar/stopwar


script CODE

float angle = 0;

ArrayList<PVector> vectors = new ArrayList<PVector>();

import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.geometry.*;
import processing.video.*;
//music
import ddf.minim.*;

float beta = 0;

PShader shift;
Minim minim;
AudioPlayer sample;

Planet sun;
PeasyCam cam;
Movie mMovie;
Movie bgMovie;
PImage mS;
int vScale=4;
int mW;
int mH;


PImage bg;
PImage img;
float i;
float a=0.0; 
Capture video;

PImage starfield;
PImage sunTexture;
PImage[] textures= new PImage[8];


float x=(width/2)-200;
float y=(height/2)-100;
int z=0;

IntDict counts;
void setup(){
  //background(0);
  //bg=loadImage("pic2.png");
  //bg.resize(width,height);

  //size(1280,720,P3D);
  size(1440,900,P3D);
 
  //
  
  mMovie = new Movie(this, "mov2.mov");
  mMovie.loop();
  
  bgMovie = new Movie(this, "bg_movie2.mov");
  bgMovie.play();
  
   //music
  //frameRate(50);
  //frameRate(30);
  frameRate(28.5);
  smooth();
  minim = new Minim(this);
  sample = minim.loadFile("pxp_music.mp3", 1024);
  sample.play();
 
//WORD COUNTING
//   counts=new IntDict();
//   String[]lines=loadStrings("environment.txt");
//   String allwords=join(lines,"\n");
//   String[] tokens  = splitTokens(allwords,"\n\" /)(.,:?!}{");
   
//   for(int i=0;i<tokens.length;i++){
//     String word=tokens[i].toLowerCase();
//     if(counts.hasKey(word)){
//       counts.increment(word);
//   }else{
//     counts.set(word,1);
//   }
// }
//String[] keys=counts.keyArray();
//for(String k:keys){
//  int count =counts.get(k);
//  textSize(count);
//  float x=random(width);
//  float y=random(height);
//  text(k,x,y);
//}
  
  String videoList[] = Capture.list();
  video = new Capture(this, width, height, videoList[0]);
  video.start();

  sunTexture=loadImage("sun.jpg");
  textures[0]=loadImage("mars.jpg");
  textures[1]=loadImage("earth.jpg");
  textures[2]=loadImage("venus.jpg");
  textures[3]=loadImage("neptune.jpg");
  textures[4]=loadImage("pluto.jpg");
  textures[5]=loadImage("mercury.jpg");
  textures[6]=loadImage("jupiter.jpg");
  
  cam = new PeasyCam(this,500);
  sun = new Planet(50,0,0,sunTexture);
  sun.spawnMoons(4,1);
  
}

void movieEvent(Movie mMovie){
  mMovie.read();
  bgMovie.read();
}

void draw(){
  //background(mMovie);
  //image(mMovie,0,0);

  if (mMovie.available()){
    mMovie.read();
  }
  
  if (video.available() == true){
    video.read();
  }
  
  backgroundVid();
  knot();
  music();

  
  //tvscreen 
   lights();
   noStroke();
   fill(127);
   pushMatrix();
   lights();
   translate(x,y,z);
   rotate(a);  
   rotateY(i);
   beginShape();
   box(120,80,2);
   texture(video);
   texture(bgMovie);
   endShape(CLOSE);
   popMatrix();
   i+=.0121;
   a+=.01;

  directionalLight(255,255,255,-1,0,0);
  pointLight(255,255,255,0,0,0);
  sun.show();
  sun.orbit();
}     

void backgroundVid() {
   cam.beginHUD();
   pushMatrix();
   beginShape();
   translate(width/2,height/2,-1000);
   //fill(255,0,0);
   box(width,height,1);
   //rect(-width,-height,width * 2,height *2);
   texture(mMovie);
   endShape(CLOSE);

   popMatrix();
   cam.endHUD();
}

void music(){
  cam.beginHUD();
  stroke(128);
  strokeWeight(1);
  //WITH GRID
  //for ( int i=0; i<height/60; i++) {
  //  line(0, i*60, width, i*60);
  //}
  //for ( int i=0; i<width/60; i++) {
  //  line(i*60, 0, i*60, height);
  //}
  
  translate(width/2, height/2);
  scale(1, 2);
  rotate(-PI/4);
  strokeWeight(2);
  stroke(255, 120);
  noFill();
  beginShape();
  float f = 400;
  float left[] = sample.left.toArray();

  for ( int i =0; i<sample.bufferSize() -10; i++) {
        float x1 = left[i];
    float x2 = left[i+10];
    curveVertex( (x1)*f, (x2)*f);
  }
  endShape();
  cam.endHUD();
}

void knot(){
  cam.beginHUD();
  pushMatrix();
  translate(width/2, height/2);
  rotateY(angle);
  angle += 0.03;

//knot pattern formula
  float r = 100*(0.8 + 1.6 * sin(6 * beta));
  float theta = 2 * beta;
  float phi = 0.6 * PI * sin(12 * beta);
  
  float x = r * cos(phi) * cos(theta);
  float y = r * cos(phi) * sin(theta);
  float z = r * sin(phi);
  stroke(255, r, 255);

  //draw it
  vectors.add(new PVector(x,y,z));

  beta += 0.01;

  noFill();
  stroke(255,255,204);
  //stroke(255);
  strokeWeight(1);
  beginShape();
  for (PVector v : vectors) {

    //float d=v.mag();
    //stroke(255,d,0);
    vertex(v.x, v.y, v.z);
  }
  endShape();
  popMatrix();
  cam.endHUD();
}

Geometric Transformation

I have some global variables, for the arc circle I’m going to draw each time I pressed the button.

In the setup I’m loading the image, giving a size and draw the image to the canvas. In draw function, I’ve a if function and in that if function, I’m using a mouseButton which I need to define whether if its, right left or center. So, If you press left , I’m calling the arc Circle function where the mouse is and incrementally increasing the diameter as you hold the mouse down. If you press right, it clears the canvas.

I’ve two features in key pressed function, which w’ll allow you to save the image when you pressed ’s’ key. Or if you press ‘r’ it draws random circles number of 5-15 on to the sketch. Sizewise, minium width divided by 5 to half of the width. 

Arc Circle function

This is the function that’s being called each time we hold down the mouse. Each time this is called, diamRadius is increasing by speed grow.  This is what makes the circle start off small but grow larger. This is the function responsible of creating one size circle at a time. 

Draw function

arcCircle((int)mouseX, (int)mouseY, diam+=speedGrow, arcStep);

And than, we are doing this while loop. This while loop goes through the whole range of angles, from 0-360. This allows us to create full circle.  The x and y values corresponds to some point along the outline of the circle. 

This condition is pretty much asking if we are trying to draw a circle on a new point. OR first circle we draw at a point. Find the color in the image that corresponds to that point

color clr = img.get(x, y);

Set that color from the arcClr list, based off of the angle that corresponds to that point

arcClr[angle] = clr;

This runs in the condition where x and y (the edge of the circle) are NOT outside of the image itself.

fill to the color from the arc Color array

fill(arcClr[angle]);

We are determining the arc, that we are working with, which is given by our current angle and the arc step

This creates a filled arc that is the fill color, and goes according to the angle where this arc starts and ends.

We increase the angle by the speed interval. This will let the while loop work from the next angle when it runs again.

DEMO

Made by Processing3

Data: Pablo Picasso, 1921, Three Musicians, oil on canvas, 200.7 × 222.9 cm, Museum of Modern Art, New York. Acquired through the Lillie P. Bliss Bequest


CODE


// Controls:
// leftClick   - draw arcCircle
// rightClick  - clear
// centerClick - set start diameter for arcCircle
// 
// keys:
// s - save image
// r - add random 5-15 arcCircles

int startDiam = 3;
int diam = startDiam;
int arcStep = 1;
int speedGrow = 5;
int maxAngle = 360;
int cx;
int cy;
color [] arcClr = new color[maxAngle]; 
PImage img;

void setup() {
  img = loadImage("three-musicians.jpg");
//  size(img.width, img.height);
  size(845, 827);
  image(img, 0, 0);
  //frameRate(300);
}


void draw() {
  if (mousePressed && mouseButton == LEFT) {
     //print("setting mouseX:"+(int)mouseX+"\n");
    arcCircle((int)mouseX, (int)mouseY, diam+=speedGrow, arcStep);
    cx = (int)mouseX;
    cy =(int)mouseY;
    //print("cx initially set to:"+cx+"\n");
  } else if (mousePressed && mouseButton == RIGHT ) {
    image(img, 0, 0);
  } else {
    diam = startDiam;
  }
}

void keyPressed() {
  if (key == 's') {
    saveFrame("img-###"+".jpg");
  } else if (key == 'r') {
    for (int i = (int)random(5, 15); i >= 0; --i) {        
      int x = (int)random(0, img.width);
      int y = (int)random(0, img.height-1);
      int size = (int)random(img.width/5, img.width/2);

      for (int j = 0; j < 1; j++) {
        arcCircle(x, y, size, 1);
      }
    }
  }
}


void arcCircle(int cirlX, int cirlY, int diamRaduis, int arcStep) {
  int angle = 0;
  int speed = arcStep;
  int arcRadius = diamRaduis/2;
  int x, y;

  noStroke();
  fill(255);

  while (angle< maxAngle) {
    
    x = int(cirlX + cos(radians(angle)) * arcRadius);
    y = int(cirlY + sin(radians(angle)) * arcRadius);
    
    if ( cx != cirlX || cy != cirlY) {
      x = min(max(x, 1), img.width-1);    
      y = min(max(y, 1), img.height-1);
    
      color clr = img.get(x, y);
  
      arcClr[angle] = clr;
    } 
 
    else if (!(   x < 1 || y < 1 || y < 1 || x < 1 
      || x > img.width-1  || x > img.width-1 
      || y > img.height-1 || y > img.height-1 ))
    {
      x = min(max(x, 1), img.width-1);    
      y = min(max(y, 1), img.height-1); 
      color clr = img.get(x, y);
      arcClr[angle] = clr;
    }
  
    fill(arcClr[angle]);

    float radSrt = radians(angle);
    float radEnd = radians(angle+arcStep);

    arc(cirlX, cirlY, diamRaduis, diamRaduis, radSrt, radEnd);
 
    angle += speed;
  }
}

Image Processing, Color Manipulation

CODE

import processing.video.*;

float pixelBrightness;
float pixelR;
float pixelG;
float pixelB;
float newPixelR;
float newPixelG;
float newPixelB;
Capture video;
void setup() {
size(displayWidth, displayHeight);
video= new Capture(this, width, height );
video.start();
}

void draw() {
if (video.available ()) {
video.read();
video.loadPixels();
loadPixels();
for (int x=max(mouseX-100, 0); x<min(mouseX+100, video.width); x++) {
for (int y=max (mouseY-100, 0); y<min(mouseY+100, video.height); y++) {
int thisPixel= (x+ y*video.width);
color ColorFromImage= video.pixels[thisPixel];

pixelBrightness= brightness(ColorFromImage);

if (pixelBrightness<60) {
pixelR= 255;
pixelG= 255;
pixelB= 255;
} else {

pixelR= newPixelR;
pixelG= newPixelG;
pixelB= newPixelB;
}

color newColor= color(pixelR, pixelG, pixelB);
pixels[thisPixel]= newColor;
pixels[thisPixel/2]= newColor;

}
}
updatePixels();

}
}

void mousePressed(){
newPixelR=random(0,200);
newPixelG=random(0,200);
newPixelB=random(0,200);
}