Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- size(800, 800);
- // println(rx);
- // println(ry);
- // println(float(ry)/rx);
- }
- float a = 0;
- float l = 400;
- int rx = int(random(100, 200));
- int ry = int(random(100, 200));
- float prev;
- float current;
- float x = cos(a)*l;
- float y = sin(a)*l;
- void draw() {
- background(0);
- translate(width/2, height/2);
- y = sin(a)*l;
- x = cos(a)*l;
- stroke(255);
- line(0, 0, x, y);
- strokeWeight(10);
- point(width/2, height/2);
- strokeWeight(1);
- a += PI/36;
- if (checkStatus(prev, curr, rx, ry)) {
- stroke(255);
- } else {
- stroke(0);
- }
- point(rx, ry);
- // println(y/x);
- }
- boolean checkStatus(float prev, float curr, int x, int y) {
- float slope = float(ry)/rx;
- if (slope <= prev && slope >= curr || slope >= prev && slope <= curr) {
- return true;
- } else {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement