最近在玩processing
已经用过smooth()
但感觉轨迹光滑程度还是达不到满意的效果
代码如下,请大家指点
float t = 0.007;
PVector p0=new PVector(0,400);
void setup(){
size(800,800);
color(255);
smooth();
}
int value =1;
PVector p = new PVector(400,400);
void draw(){
float sk = random(100);
if (sk>75){
p = new PVector(p.x+sk*t,p.y+(100-sk)*t);
value=0;}
else {
if (sk>50){
p = new PVector(p.x+sk*t,p.y-(100-sk)*t);
//p = new PVector(p.x+s*t,p.y);
value=1;}
else {
if (sk>25){
p = new PVector(p.x-sk*t,p.y+(100-sk)*t);
//p = new PVector(p.x,p.y+(1-s)*t);
}
else {
p = new PVector(p.x-sk*t,p.y-(100-sk)*t);
//p = new PVector(p.x,p.y);
}
}
}
if (p.x>800) p.x-=800;
else {
if (p.x<0) p.x+=800;
}
if (p.y>800) p.y-=800;
else {
if (p.y<0) p.y+=800;
}
ellipse(p.x,p.y,20,20);
fill(#7FFFD4);
}