美文网首页
From Processing to Gif Series 0

From Processing to Gif Series 0

作者: Tealeaf | 来源:发表于2016-01-02 13:13 被阅读0次
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;
}

相关文章

网友评论

      本文标题:From Processing to Gif Series 0

      本文链接:https://www.haomeiwen.com/subject/dluwhttx.html