软件:processing
语言:java
时间期限:6月12号
备注:代码旁需要有中文注释,如下图
预想效果阐述:1、一群紫色小粒子
2、运动状态往前穿梭
3、鼠标点击画面会向鼠标聚集
1、紫色颜色参考:
2、参考粒子视觉效果:https://www.openprocessing.org/sketch/96948
(参考粒子的样子,例如:粒子后有小尾巴、大小等)
3、参考粒子运动轨迹:https://www.openprocessing.org/sketch/492680
(参考粒子的运动方向、轨迹、速度等)
4、参考鼠标点击画面会向鼠标聚集:
参考方向在文件包视频里面的1分40秒。
参考粒子视觉效果的代码:
class star {
float x, y, speed, d, age,sizeIncr;
int wachsen;
star() {
x = random(width);
y = random(height);
speed = random(0.2, 5);
wachsen= int(random(0, 2));
if(wachsen==1)d = 0;
else {
d= random(0.2, 3);
}
age=0;
sizeIncr= random(0,0.03);
}
void render() {
age++;
if (age<200){
if (wachsen==1){
d+=sizeIncr;
if (d>3||d<-3) d=3;
}else {
if (d>3||d<-3) d=3;
d= d+0.2-0.6*noise(x, y, frameCount);
}
}
else{
if (d>3||d<-3) d=3;
}
ellipse(x, y, d*(map(noise(x, y,0.001*frameCount),0,1,0.2,1.5)), d*(map(noise(x, y,0.001*frameCount),0,1,0.2,1.5)));
}
void move() {
x =x-map(mouseX, 0, width, -0.05*speed, 0.05*speed)*(w2-x);
y =y-map(mouseY, 0, height, -0.05*speed, 0.05*speed)*(h2-y);
}
}
star neuerStern;
ArrayList
float h2;//=height/2
float w2;//=width/2
float d2;//=diagonal/2
int numberOfStars = 20000;
int newStars =50;
void setup() {
size(900, 900);
w2=width/2;
h2= height/2;
d2 = dist(0, 0, w2, h2);
noStroke();
neuerStern= new star();
frameRate(9000);
background(0);
}
void draw() {
fill(0, map(dist(mouseX, mouseY, w2, h2), 0, d2, 255, -10));
rect(0, 0, width, height);
fill(255);
neuerStern.render();
for (int i = 0; i
starArray.get(i).move();
starArray.get(i).render();
}
if (starArray.size()>numberOfStars) {//
for (int i = 0; i
p[i] = new Particle();
}
}
}
class Particle {
float n;
float r;
float o;
int l;
Particle() {
l = 1;
n = random(1, width/2);
r = random(0, TWO_PI);
o = random(1, random(1, width/n));
}
void draw() {
l++;
pushMatrix();
rotate(r);
translate(drawDist(), 0);
fill(255, min(l, 255));
ellipse(0, 0, width/o/8, width/o/8);
popMatrix();
o-=0.07;
}
float drawDist() {
return atan(n/o)*width/HALF_PI;
}
}
参考鼠标点击聚集效果代码:视频附件中有。