求大神求大神求大神!!帮帮我我很绝望
processing吧
全部回复
仅看楼主
level 1
Fyhashin 楼主
//rslider = {};
float angle = 0;
float ratio = 1.5;
float bend = 0;
float press = 0;
void setup() {
size (500, 500);
}
void draw() {
blendMode(BLEND);
background(255);//point(200, 200);
blendMode(DARKEST);
stroke(0);
angle = 0.5 + 0.05 * sin((PI / 2)* sin(800 / 40));
angle /= 1.3;
ratio = 1.43;
float mx = constrain(40, 0, 500);
float my = constrain(40, 0, 500);
// var t = frameCount / 20;
// var r = 50 + 50 * cos(2 * t);
// mx = map(r * cos(t), -100, 100, 0, 500);
// my = map(r * sin(t), -100, 100, 0, 500);
mx = 250 + 250 * cos(800 / 100);
translate(250, 500);
bend = map(mx, 0, 500, -0.2, 0.2);
press = map(my, 0, 500, 0, 0.5);
branch(1, 120, 1);
}
void branch(int index, float len, float rank) {
if(len < 7) {
blendMode(BLEND);
noStroke();
fill(255, 0, 50,100);
float r = 12 + sin(rank * 1.5);
ellipse(0, 0, r, r);
blendMode(DARKEST);
return;
}
strokeWeight(10 / index);
stroke(index * 25);
line(0, 0, 0, -len);
pushMatrix();
translate(0, -len);
rotate((1 + press) * (angle + bend));
branch(index + 1, len / ratio, rank);
popMatrix();
pushMatrix();
translate(0, -len);
rotate((1 + press) * (-angle + bend));
rank++;
branch(index + 1, len / ratio, rank);
popMatrix();
}
在这个程序下面怎么写才能鼠标点击让小球下落就像果实掉了一样啊!!呜呜呜呜
2017年10月25日 06点10分 1
1