読者です 読者をやめる 読者になる 読者になる

atelier:mitsuba

i love UI/UX, Blend, XAML, Behavior, P5, oF, Web, Tangible Bits and Physical computing. なにかあればお気軽にご連絡ください。atelier@c-mitsuba.com

Rainy

Proccessing for Androidで遊んでみました。
特に何でもないアプリだけど、雨模様に見えませんか?
一応マルチタッチで青い円が描けますが、動画だと見にくいですね。

PImage bg;

int an = 50;
float[] ax = new float[an];
float[] ay = new float[an];
float[] ix = new float[an];
float[] iy = new float[an];
float[] is = new float[an];
float[] ellipseSize = new float[an];
float[] ellipseAxis = new float[an];

void setup(){
  background(0);
  size(720,1280);
  
  bg = loadImage("rainy.png");
  
  frameRate(30);
  for(int i=0;i<ax.length;i++){
    ax[i] = random(width);
    ay[i] = random(height);
    ellipseSize[i] = random(width/10);
    ellipseAxis[i] = random(1.02,1.07);
    
    ix[i] = 0;
    iy[i] = 0;
    is[i] = 0;
  }  
}

void draw(){
  background(0);
  image(bg, 0, 0);
  noFill(); 
  
  for(int i=0;i<ax.length;i++){
    if(ellipseSize[i]>width){
        ax[i] = random(width);
        ay[i] = random(height);
        ellipseSize[i] =  random(20,width/10);
    }else{
      ellipseSize[i] *= ellipseAxis[i];
    }
    
    stroke(255,255,255,255-((ellipseSize[i]/width)*255));
    ellipse(ax[i],ay[i],ellipseSize[i],ellipseSize[i]);
  }

  for(int i=0;i<ix.length;i++){
    if(is[i] != 0){
      if(is[i]<width){
        is[i] *= ellipseAxis[i];
      }else{
        is[i] = 0;
      }
      
      stroke(0,0,255,255-((is[i]/width)*255));
      ellipse(ix[i],iy[i],is[i],is[i]);
    }
  }
}

void mousePressed(){
  noFill();
  
  for(int i=0;i<ix.length;i++){
    if(is[i] == 0){
      ix[i] = mouseX;
      iy[i] = mouseY;   
      is[i] = random(width/10);
      break;
    }
  }
}