Processing 如何在特定区域内绘制随机线。(处理)

Processing 如何在特定区域内绘制随机线。(处理),processing,Processing,我想知道如何在一个圆内绘制随机(法线或曲线)线,这意味着这些线不会通过圆的边界 下面是绘制圆的代码: size(900, 900); background(80, 89, 81); int n = 50; // aantal (element count) for (int i = 0; i <n; i++) { float x1 = 20*i; float x2 =-10+20*i; float x3 =x2+20; float x11 = 10+20*i; floa

我想知道如何在一个圆内绘制随机(法线或曲线)线,这意味着这些线不会通过圆的边界

下面是绘制圆的代码:

size(900, 900);
background(80, 89, 81);
int n = 50; // aantal (element count)
for (int i = 0; i <n; i++) {
  float x1 = 20*i;
  float x2 =-10+20*i;
  float x3 =x2+20;
  float x11 = 10+20*i;
  float x22 = x1;
  float x33= x22+20;
  for (int j = 0; j < n; j++) {
    float y1 = 30+30*j;
    float y2 = 30*j;
    float y3 = y2;
    float y11 = y2;
    float y22 = y1;
    float y33 = y1;
    float a = random(10, 90);
    if (j%2==0) { 
      noStroke();
      fill(0);    
      triangle(x1, y1, x2, y2, x3, y3);
      fill(255, 255, 255, a);
      triangle(x11, y11, x22, y22, x33, y33);
    } else {
      noStroke();
      fill(255, 255, 255, a);    
      triangle(x1, y1, x2, y2, x3, y3);
      fill(0);
      triangle(x11, y11, x22, y22, x33, y33);
    }
  }
}

for (int t=0; t<40; t++) {

  ellipse(450, 450, 800-20*t, 800-20*t);
  fill(0+t*2, 0+t*2, 0+t*2);
}
尺寸(900900);
背景(80,89,81);
int n=50;//安塔尔(元素计数)

对于(int i=0;i如果你知道圆的中心,知道圆的半径,那么你可以使用基本trig来获取圆内的点。类似这样:

float circleX = 100;
float circleY = 100;
float circleR = 50;

void setup() {
  size(200, 200);
  ellipseMode(RADIUS);
}

void draw() {
  background(0);
  ellipse(circleX, circleY, circleR, circleR); 

  stroke(0);
  for (int i = 0; i < 10; i++) {
    float x1 = circleX + cos(random(2*PI)) * random(circleR);
    float y1 = circleY + sin(random(2*PI)) * random(circleR);
    float x2 = circleX + cos(random(2*PI)) * random(circleR);
    float y2 = circleY + sin(random(2*PI)) * random(circleR);

    line(x1, y1, x2, y2);
  }
}
float circleX=100;
浮点数=100;
浮圈器=50;
无效设置(){
大小(200200);
椭圆模型(半径);
}
作废提款(){
背景(0);
椭圆(圆环、圆环、圆环、圆环);
冲程(0);
对于(int i=0;i<10;i++){
浮点x1=圈+cos(随机(2*PI))*随机(圈);
浮点y1=圆圈+sin(随机(2*PI))*随机(圆圈);
float x2=圈数+cos(随机(2*PI))*随机(圈数);
浮点数y2=circleY+sin(随机(2*PI))*随机(圆圈);
线(x1,y1,x2,y2);
}
}