Drawing a Circle (with Processing)

See that, above? That’s something I’ve wanted to do for years.

If you understand Processing, the programming language that pretty much foremost amongst the art/coding subset, you usually have a pretty good grasp of mathematics. Personally, despite my grade B at GCSE, I’m pretty shakey. That’s why it took me at least two years to be able to draw a bunch of dots in a circle, using Processing.

I am happy I’ve done it though; it means that I’m no longer banging my head against it as a problem that is beyond me. One more thing I can cross of my list of things that I want to do with Processing.

I’ve written in more depth about the mathematics behind the program, and posted a video of it in action, at my vimeo page. If you’d like to find out about what it’s about, read that. I’ve also uploaded the source code and the program itself as a stand-alone application for Windows, OS X and Linux, and you can download that below.

draw_a_circle2 (source files and apps)

UPDATE: The Vimeo page seems to have completely failed me (again) and so I’ve put a version up on Flickr using their new video function. If it doesn’t embed in the RSS feed, check out my photo page over there.

Comments

5 Comments so far. Comments are closed.
  1. Your vid is private. Well done, it looks teh veh hardcore.

  2. If you want the dots to be evenly spaced, try this (two changes from your code):

    void draw() {
    translate(width/2, height/2);

    background(125);
    //point(x,y); //(a centre point)
    for (int i=1; i<=pts; i++) {
    angle = i*(360.0/pts); // needs 360.0 not 360 to force floating point division
    px = x+cos(radians(angle))*radius;
    py = y+sin(radians(angle))*radius;
    point(px,py);
    }
    pts++;
    text(pts,-10,-10); // moved from inside the for loop
    if (pts == 360) {
    pts = 1;
    }
    }

  3. admin,

    Thank you so much Brenda – and especially for showing me that the text could be moved outside the for loop.

  4. Crikey bonzah mate. What do you think the chances are of that happening? Two of them?

  5. admin,

    I know! I was confuzzled for a bit as I tried to work out when brenda had got so good at coding, and then realised it was actually Brenda-with-a-capital-’B’.