Ich versuche, eine Verarbeitung Skizze in meine WordPress-Blog mit processing.js einzufügen.Verarbeitung js nicht looping zeichnen Funktion
Das Problem ist, dass ich ein eingefrorenes Bild anstelle eines beweglichen bekomme. Es ist so, als würde die Zeichenfunktion nicht loopen. (Auf meinem PC funktioniert die Skizze gut)
was könnte die Ursache dafür sein? und wie kann ich es reparieren?
<script type="text/processing" data-processing-target="MySketch">
ball[] balls;
int numBalls = 20;
void setup(){
size (300,300,P3D);
background(255);balls=new ball[numBalls];
for(int i=0; i<numBalls;i++){
float r=random(5,20);
balls[i] = new ball(random(r,width-r),random(r,height-r),0,r,random(-1,10),random(-1,10));
}
}
void draw(){
background(255);
for(int i=0; i<numBalls;i++){
ball b; b=balls[i];
b.drawBall();
b.moveBall();
b.boundaries();
}
}
class ball{
float x;
float y;
float z;
float r;
float vx;
float vy;
ball(float x1,float y1,float z1,float r1,float vx1,float vy1){
x=x1;
y=y1;
z=z1;
r=r1;
vx=vx1;
vy=vy1;
}
void drawBall(){
noStroke();
fill(255,0,0);
lights();
pushMatrix();
translate(x, y,z);
sphere(r);
popMatrix();
}
void moveBall(){
x=x+vx;
y=y+vy;
}
void boundaries(){
if(x>=width-r || x<0+r)
vx=vx*-1;
if(y>=height-r || y<0+r)
vy=vy*-1;
}
}
</script>
<canvas id="MySketch"></canvas>
Sie möchten vielleicht ein paar Minuten damit verbringen, Ihren Code zu formatieren, damit er den richtigen Einzug verwendet. Wenn nicht für unsere Gesundheit, dann für Ihre eigenen! –