生成艺术:Processing视觉创意入门
作者:华好
绘者:刘晨晰
出版社:电子工业出版社
出版时间:2021年8月
ISBN:9787121417115
一、向量
- PVector的方法非常多,常用的有加法add()、减法sub()、求向量长度mag()、归一化normalize()、线性差值lerp(),等等。
float r=160;
int n=360;
void setup(){
size(400,400);
}
void draw() {
background(255);
stroke(255,0,0);
translate(200, 200);
float s=2 +frameCount/100 ; //1+0.01*frameCount;
for (int i=0; i<n; i++) {
float ta= 2*PI*i/n;
float tb= s*ta;
PVector a= new PVector(cos(ta), sin(ta));
PVector b= new PVector(cos(tb), sin(tb));
a.mult(r);
b.mult(r);
line(a.x, a.y, b.x, b.y);
// PVector v= PVector.lerp(a, b, 0.5);
// ellipse(v.x, v.y, 8,8);
}
}