• fullscreen
  • FruitsExplode.pde
  • PImage img;
    int cellsize =8;
    int columns, rows;
    PFont myfont;
    
    void keyPressed() {
      save("sample.png");
    }
    
    void setup() {
      size(900, 600, P3D);
      img = loadImage("fruits.jpg");
      myfont = createFont("Futura", 160);
      columns = img.width / cellsize;
      rows = img.height / cellsize;
    }
    
    void draw() {
      background(255);
      rotateY(0.0);
      rotateX(0.0);
        
      if (mousePressed) {
        stroke(255, 160, 160);
        noFill();
        line(0, 570, 900, 570);
        line(900, 570, 880, 550);
        line(900, 570, 880, 590);
        ellipse(mouseX, 570, 30, 30);
        for ( int i = 0; i < columns; i++) {
          for ( int j = 0; j < rows; j++) {
            int x = i*cellsize + cellsize/2; 
            int y = j*cellsize + cellsize/2; 
            int loc = x + y*img.width;
            color c = img.pixels[loc];
            float z = (mouseX / float(width)) * blue(img.pixels[loc])/5 - 14.0;
            pushMatrix();
            translate(x + 245, y + 100, z * 90);
            
            fill(c, 190);
            noStroke();
            //rotateX(cos(i + 1.0) * (millis() / 1000.0) * PI);
            rotateY(cos(i + 1.0) * (millis() / 1000.0) * PI);
            textFont(myfont, 12.0);
            
            text("fruits", cellsize, cellsize, z*10);
          
            popMatrix();
          }
        }
      }
    
    
      else {
        stroke(255, 160, 160);
        line(0, 570, 900, 570);
        line(900, 570, 880, 550);
        line(900, 570, 880, 590);
        fill(255, 160, 160, 190);
        ellipse(15, 570, 30, 30);
        for ( int i = 0; i < columns; i++) {
          for ( int j = 0; j < rows; j++) {
            int x = i*cellsize + cellsize/2;  
            int y = j*cellsize + cellsize/2;
            int loc = x + y*img.width; 
            color c = img.pixels[loc]; 
            float z = -14;
            pushMatrix();
            translate(x + 245, y + 100, z * 90);
    
            fill(c, 190);
            noStroke();
            textFont(myfont, 12.0);
            text("fruits", cellsize, cellsize, z*10);
            popMatrix();
          }
        }
      }
    }
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement


    Shohei Shirai

    FruitsExplode

    Add to Faves Me Likey@! 3
    You must login/register to add this sketch to your favorites.

    You need to login/register to comment.