1
我想創建一個包含隨機放置的隨機角度和strokeWeight線條的草圖。這個想法是,在每一幀,線條都會根據預先設定的規則稍微改變其傾斜度,而這依然取決於strokeWeight和其他參數。爲此,我想我需要在設置時記錄每一行的座標,然後轉換它們,然後再次記錄它們。如果這是有道理的。 基本上這個問題歸結爲我如何記錄畫布上所有線條的座標?如何在畫布上存儲所有形狀的座標
這是我到目前爲止寫,但我怎麼保存的形狀座標:
//Sets up the random lines on the canvas
//Sets up the authorities (line widths)
//Sets up the connections between lines
void setup() {
background(204);
size(800, 800);
for (int x=1;x <1000;x +=1){
fill(75, 70, 80);
//For the x y cords
float r = random(800);
float s = random(800);
//for the strokeWeight
float fat = random(5);
//for the stroke colour which varies with stroke weight
float col = random(350);
float red = random(350);
float g = random(350);
float b = random(350);
//for the initial tilt
float rot = random(360);
//stroke(242, 204, 47, 255);
strokeWeight(fat);
//stroke (red,green,blue,opacity)
stroke(fat*100, 180, 180);
//stroke(242, 204, 47, 255);
line(r,s,r+10,s+10);
rotate(radians(rot));
}
}
//This part is the diffusion animation
void draw() {
}
很好。我必須移動for(Line line:lines){等塊設置,否則它會連續繪製隨機線條,導致畫布變黑。否則完美。我在學習...... –
@SebastianZeki這不是我的代碼。這隻會在你將我的調用去掉「background(0)'後纔會發生,然後將這些行的隨機化移動到他們的'draw()'函數中,這是你不應該做的。 –
Ahhhh。謝謝凱文。現在排序 –