作者 主题: [ Processing 作品开源 ] feb21a_2012_rgbDaze  (阅读 3786 次)

RavenKwok

  • Sr. Member
  • ****
  • 帖子: 277
  • Artist/ Animator/ Coder/ Cynical Asshole
[ Processing 作品开源 ] feb21a_2012_rgbDaze
« 于: 二月 22, 2012, 03:58:03 下午 »
俺昨儿写的一个简单的基于正弦波以及余弦波的晕眩影像生成程序。




程序代码
//Raven Kwok | 郭锐文
//Email: raystain@gmail.com
//Blog: the-moor.blogbus.com
//Vimeo: vimeo.com/ravenkwok
//Weibo: weibo.com/ravenkwok
//Inspired by Pete Hipwell's Sine Dive via http://openprocessing.org/visuals/?visualID=4324
 
float base;
float baseDegree;
float range;
float incre;
 
void setup() {
  size(400, 400, P2D);
  range = 1000;
  incre = 0.01;
}
void draw() {
  base = sin(radians(baseDegree))*range;
  background(0);
  loadPixels();
  for (int i=0;i< width/2;i++) {
    for (int j=0;j< height/2;j++) {
      int index1 = i+j*width;
      int index2 = width-1-i+j*width;
      int index3 = i+(height-1-j)*width;
      int index4 = width-1-i+(height-1-j)*width;
      float r = 255*sin(radians(base*dist(i,j,width/2,height/2)));
      float g = 255*cos(radians(base*dist(i,j,0,0)));
      float b = 255*sin(radians(base*dist(i,j,width,height)));
      pixels[index1] = color(r,g,b);
      pixels[index2] = color(r,g,b);
      pixels[index3] = color(r,g,b);
      pixels[index4] = color(r,g,b);
    }
  }
  baseDegree +=incre;
  updatePixels();
}

via openProcessing

代码方面受Pete Hipwell 的Sine Dive 启发,改进了可读性。并使用绘制像素来加快渲染速度。欢迎交流,拍砖。

Ting

  • Newbie
  • *
  • 帖子: 8
Re: [ Processing 作品开源 ] feb21a_2012_rgbDaze
« 回复 #1 于: 二月 24, 2012, 07:25:16 下午 »
Cool ! 催眠效果极佳~

Tags: