How to make a simple radar

edited May 2016 in How To...

Hi. A pretty new beginner here.

If you have any ellipse, how can i make a line(x1, y1, x2, y2) where x1 and y1 are in the middle of the ellipse (i know this part), but where x2 and y2 continuously make the line go around the ellipse's perimeter? Thanks in advance

Tagged:

Answers

  • There are a couple of ways.

    void setup(){
      size(800,400);
      noFill();
    }
    
    void draw(){
      float m = map(millis()%10000,0,10000,0,TWO_PI);
      background(0);
      stroke(255,128,128);
      translate(200,200);
      ellipse(0,0,380,380);
      pushMatrix();
      rotate(m);
      line(0,0,190,0);
      popMatrix();
    
      translate(400,0);
      stroke(128,128,255);
      ellipse(0,0,380,380);
      line(0,0,190*cos(m),190*sin(m));
    }
    
Sign In or Register to comment.