求大佬帮忙把processing java代码换成python代码 5
intnum=50;ArrayList<Particle>particles;PVectorRotate;ParticletempP;voidsetup(){size(1...
int num = 50;
ArrayList<Particle> particles;
PVector Rotate;
Particle tempP;
void setup(){
size(1080,680,P3D);
colorMode(HSB);
Rotate = new PVector();
particles = new ArrayList<Particle>();
for(int i = 0; i < num; i++){
particles.add( new Particle() );
}
background(255);
}
void draw(){
noStroke();
fill(255, 18);
rect(0,0,width,height);
Rotate = new PVector(frameCount*0.003, frameCount*0.04, frameCount*0.03);
pushMatrix();
translate(width/2, height/2);
rotateX(Rotate.x);
rotateY(Rotate.y);
rotateZ(Rotate.z);
for(int i = particles.size()-1; i >= 0; i--){
tempP = particles.get(i);
tempP.move();
}
popMatrix();
}
class Particle{
PVector pos,radian;
float dis,h,s,b;
float _weight = 10;
Particle(){
radian = new PVector(random(TWO_PI), random(TWO_PI));
pos = new PVector();
dis = 160;
}
void move(){
update();
display();
}
void update(){
pos.x = dis*sin(radian.x)*cos(radian.y);
pos.y = dis*cos(radian.x)*cos(radian.y);
pos.z = dis*sin(radian.y);
}
void display(){
h = noise(radian.x*0.3, frameCount*0.012)*95 + 130 + map(mouseX, 0 ,width, -20, 20);
noStroke();
fill(h,85,255);
translate(pos.x,pos.y,pos.z);
sphere(_weight);
translate(-pos.x,-pos.y,-pos.z);
}
} 展开
ArrayList<Particle> particles;
PVector Rotate;
Particle tempP;
void setup(){
size(1080,680,P3D);
colorMode(HSB);
Rotate = new PVector();
particles = new ArrayList<Particle>();
for(int i = 0; i < num; i++){
particles.add( new Particle() );
}
background(255);
}
void draw(){
noStroke();
fill(255, 18);
rect(0,0,width,height);
Rotate = new PVector(frameCount*0.003, frameCount*0.04, frameCount*0.03);
pushMatrix();
translate(width/2, height/2);
rotateX(Rotate.x);
rotateY(Rotate.y);
rotateZ(Rotate.z);
for(int i = particles.size()-1; i >= 0; i--){
tempP = particles.get(i);
tempP.move();
}
popMatrix();
}
class Particle{
PVector pos,radian;
float dis,h,s,b;
float _weight = 10;
Particle(){
radian = new PVector(random(TWO_PI), random(TWO_PI));
pos = new PVector();
dis = 160;
}
void move(){
update();
display();
}
void update(){
pos.x = dis*sin(radian.x)*cos(radian.y);
pos.y = dis*cos(radian.x)*cos(radian.y);
pos.z = dis*sin(radian.y);
}
void display(){
h = noise(radian.x*0.3, frameCount*0.012)*95 + 130 + map(mouseX, 0 ,width, -20, 20);
noStroke();
fill(h,85,255);
translate(pos.x,pos.y,pos.z);
sphere(_weight);
translate(-pos.x,-pos.y,-pos.z);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询