Ich habe eine Galaxieskizze in p5.js mit Rotationen und Radianten erstellt, aber sie wird jedes Mal gelöscht, wenn der Hintergrund() geladen wird, während draw() ausgeführt wird. Gibt es eine Möglichkeit, die background() -Funktion zu übersteuern? Ich möchte, dass die Galaxien im Blick bleiben.Die Funktion background() in p5.js überschreiben?
var stars;
function preload(){
//for (var i = 0; i < planetArray.length; i++) {
//stars = loadImage('Assets/stars.png');
}
function setup(){
createCanvas(windowWidth, windowHeight);
}
function draw() {
//background(0);
star()
//function mousepressed(){
}
function star(){
//angle = map(mouseX, 0,width, 0,360);
//rotate(radians(angle*100));
noStroke();
//translate(width/2, height/2);
translate(mouseX,mouseY);
fill(0);
rotate(radians(frameCount%360)); //rotates output of ellipses
rotate(radians(1000*frameCount%360));
for(var i =0; i < 20; i++){
push();
noStroke();
fill(random(200),0,random(150),random(2));
// fill(random(125),random(250),random(100));
ellipse(10*frameCount % (width/10),0,10,10);
//image(stars, 10*frameCount % (width/2),0,10,10)
//image((10*frameCount % (width/2),0,10,10)
//
pop();
}
}
Vielen Dank! Ich lege es in Setup() und alles sieht gut aus. Ich wünschte, ich könnte dir deine Cupcakes füttern. – Claire
Ha! Vielen Dank. Ich bin mir nicht sicher, ob Cupcakes durch die Post sehr gut reisen würden! –