Python 使用while循环-如何在画布上编码随机椭圆的数量
如何使用while循环在画布上绘制随机椭圆 例如:如果用户输入10,那么画布上随机出现10个圆圈 如果用户输入5,那么5椭圆也应该出现在画布上的不同位置 我相信这可能是生成random()函数的开始代码Python 使用while循环-如何在画布上编码随机椭圆的数量,python,processing,Python,Processing,如何使用while循环在画布上绘制随机椭圆 例如:如果用户输入10,那么画布上随机出现10个圆圈 如果用户输入5,那么5椭圆也应该出现在画布上的不同位置 我相信这可能是生成random()函数的开始代码 x = int(random(0, 200)) y = int(random(0, 200)) 然而,我不知道如何进一步扩大 void setup(){ void setup() { size(300, 300); noLoop(); // we only want 5 not h
x = int(random(0, 200))
y = int(random(0, 200))
然而,我不知道如何进一步扩大 void setup(){
void setup() {
size(300, 300);
noLoop(); // we only want 5 not hundreds
}
void draw() {
int i = 0;
int sizeOfEllipse = 0;
int xPos = 0;
int yPos = 0;
while (i < 5) {
xPos = int(random(width));
yPos = int(random(height));
sizeOfEllipse = int(random(10, 50)); // minimum size of 10 max 50
ellipse(xPos, yPos, sizeOfEllipse, sizeOfEllipse); // circles are a special case of an ellipse
i = i + 1;
}
}
大小(300300);
noLoop();//我们只想要5个而不是100个
}
作废提款(){
int i=0;
int-sizeofillipse=0;
int xPos=0;
int-yPos=0;
而(i<5){
xPos=int(随机(宽度));
yPos=int(随机(高度));
sizeOfEllipse=int(随机(10,50));//最小值为10,最大值为50
椭圆(xPos,yPos,sizeOfEllipse,sizeOfEllipse);//圆是椭圆的特例
i=i+1;
}
}
我先在谷歌上搜索“python while loop”或“python for loop”。@Vex143堆栈不是完成工作的地方,请检查