Skip to content

Instantly share code, notes, and snippets.

@jeffnoko
Created March 13, 2018 17:55
Show Gist options
  • Select an option

  • Save jeffnoko/df73433ae56903a7dd5a5d46b2218221 to your computer and use it in GitHub Desktop.

Select an option

Save jeffnoko/df73433ae56903a7dd5a5d46b2218221 to your computer and use it in GitHub Desktop.
random points within a circle
import processing.serial.*;
Serial myPort;
int radius = 300;
float angle = 0;
float angleStep = .001;
float r,s,p,q;
int rLimit1;
int rLimit2;
int gLimit1;
int gLimit2;
int startX = 500;
int startY = 500;
void setup() {
myPort = new Serial(this, Serial.list()[0],9600);
size(1500, 1200);
background(0);
stroke(255);
noFill();
smooth();
}
void draw() {
while( angle < PI){
r = startX + radius*cos(angle);
s = startX + radius*cos(angle + PI);
p = startY + radius*sin(angle);
q = startY + radius*sin(angle + PI);
float x = random(s,r);
float y = random(q,p);
print(r);print(" ");
print(s);print(" ");
print(x);println(" ");
angle += angleStep;
fill(255);
ellipse(x,y,1,1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment