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。谢谢凯文。现在排序 –