From Processing to Gif Series 03

Trying To Break Free By Jerome Herr

I went on checking this generous and gifted author's openProcessing page, trying to dig out more about his talents of creating digital loop motion. Then this piece of work enlightened my eyes.

Code:

int sz = 400, num=20;
float theta, angle, rad = 60;
 
void setup() {
  size(500, 500);
  fill(0);
  stroke(255);
  strokeWeight(8);
}
 
void draw() {
  background(255);
  angle=0;
  for (int i=0; i<num; i++) {
    float x = width/2-rad/2 + cos(angle)*rad;
    float y = height/2 + sin(angle)*rad;
    float s = map(sin(theta+TWO_PI/num*i),-1,1,1,.6);
    float scal = 1-0.045*i;
    int f=i==num-1 ? 255 : 0;
    fill(f);
    ellipse(x-20, y, sz*scal*s, sz*scal*s);
    angle -= (PI/num);
  }
  theta +=0.0523;
}

Code with My Comments :

int sz = 400, num=20;
float theta, angle, rad = 60;

void setup() {
  size(500, 500);
  fill(0);
  stroke(255);
  strokeWeight(8);
}

void draw() {
  background(255);
  angle=0;
  for (int i=0; i<num; i++) {
    float x = width/2-rad/2 + cos(angle)*rad;
    float y = height/2 + sin(angle)*rad;
    //any sin or cos is a valu which pingPongs from -1 to 1
    //map this changes as from 1 to 0.6
    float s = map(sin(theta+(TWO_PI/num)*i), -1, 1, 1, .6);
    float scal = 1-0.045*i;
    int f = 0;
    //this means if i equals num-1, f is 255, else, f is 0
    int f=i==num-1 ? 255 : 0;
    fill(f);
    ellipse(x-20, y, sz*scal*s, sz*scal*s);
    // angele = angle - (PI/num);
    angle -= (PI/num);
  }
  //sin value changes as theta changes
  theta +=0.0523;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,997评论 0 23
  • 周末双十一,小勇来杭州,昨天一偷懒,有三天没有写东西了,有点荒废。 双十一刷爆信用卡,一入淘宝深似海,会变得疯狂,...
    terrence_zhan阅读 213评论 0 0
  • 为了改变儿子的现状,我一直在努力学习,一边修炼提升自己,一边四处寻求帮助,希望能尽快找到灵丹妙药,让儿子幡然醒悟,...
    小瓶盖Q日记阅读 614评论 2 3
  • 昨天下午从外面回来的时候,看到一只流浪小狗停留在一家宠物店的门口,呆呆地向里面张望。天接近黄昏,虽然他的另一个同伴...
    大白和小呆阅读 289评论 0 3
  • 灰色与红色搅拌成了我们。 而用量的不同造成我们的独特性与多样性。 每天,我们向外界汲取黑色,黄色,白色…… 我们就...
    林逸凡Aaron阅读 230评论 0 1