我正在使用橢圓,旋轉,弧度等在mouseX和mouseY上創建迷你星系的項目。但是,如果每個迷你星系都可以向左或向右旋轉,我會喜歡它,因此它看起來像是一個在太空中緩慢轉動的星系。不知道我該怎麼做,但會喜歡一些指導。我是否必須創建一個數組來保存每個星系的橢圓,然後以某種方式旋轉它?我可以簡單地爲每個橢圓設置一個rotate(),因爲它繪製到屏幕上嗎?謝謝你的幫助!旋轉/車削橢圓組
var bgimg;
function preload(){
//for (var i = 0; i < planetArray.length; i++) {
bgimg = loadImage('Assets/galaxy_background.jpg');
}
function setup(){
createCanvas(1301, 822);
background(bgimg, 100);
//background(25,25,22);
}
function draw() {
//background(0);
fill(255);
noStroke();
textSize(19);
text("Create mini-galaxies by holding your mouse in a location. Move to create another.", 20, 40);
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();
tint(255, 127);
fill(random(230),5,random(210),random(230));
// fill(random(125),random(250),random(100));
ellipse(10*frameCount % (width/20),0,5,5);
rotate(radians(mouseX, mouseY));
//image(stars, 10*frameCount % (width/2),0,10,10)
//image((10*frameCount % (width/2),0,10,10)
//
pop();
}
}