We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Clock problem (Read 1102 times)
Clock problem
Oct 6th, 2009, 9:45am
 
I'm trying to build a clock as in the tutorial, but am confused with part of the code, and why my example doesnt work quite as the tutorial does.

I understand all of the code up until the highlighted part, at which point I lose track of what's being done. If anyone could explain this last part to me, and what function I should try using to remove the 'old' second-hands from the clock I would much appreciate it! L.

        void setup() {
      size(800, 600);
      background(254);
      smooth();
      frameRate(20);
    }

    void draw(){
      smooth();
      noStroke();

float s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI;
stroke(100);
    strokeWeight(1);
    line(400, 300, cos(s) * 200 + 400, sin(s) * 200 + 300);
}
Re: Clock problem
Reply #1 - Oct 6th, 2009, 12:18pm
 
stroke(100): draw lines with a mid-gray (goes between 0 and 255)
strokeWeight(1): draw lines of width of 1 pixel (kind of minimal)
line: draw a line...
It is centered (starting point at 400, 300). It has a length of 200 (the multiplier). cos and sin varies between -1 and 1, and make that the end point is around a circle.
Re: Clock problem
Reply #2 - Oct 7th, 2009, 1:47am
 
Thanks!
Page Index Toggle Pages: 1