How do I drew clock
-
I'm working on a project with my programming professor to write a new curriculum for the IST 145 (entry-level programming) class, using Processing instead Java. (Since Processing is highly Java-based, it shouldn't cause any problems for higher programming classes).
I wrote a few quick programs to acquaint myself with Processing. I did not think any of them through ahead of time. Here's the snippet I'm most "proud" of, from my analog clock drawing program:
<FONT family="Courier New"> int h = hour();
int m = minute();
int s = second();
Point hourOut = polarToScreen((float)(Math.PI/2 - h * (Math.PI/6) - m * (Math.PI/360) - s * (Math.PI/21600)), HOUR_LENGTH);
Point minOut = polarToScreen((float)(Math.PI/2 - m * (Math.PI/30) - s * (Math.PI/1800)), MINUTE_LENGTH);
Point secOut = polarToScreen((float)(Math.PI/2 - s * (Math.PI/30)), SECOND_LENGTH);</FONT>It's better formatted than that in real life, but I wanted to imagine you all putting fingerprints on your screen trying to comprehend the paranthesis hash.
-
What's the big deal? The parens are pretty clear.
-
Fingerprints? A good IDE highlights one bracket when you put the cursor on the other.
Also, Linkification thinks Math.PI/2 is a URL. Heh.
-
Any good editor can highlight matching parentheses, so no need to put fingerprints on my screen (in fact, for me this is The Real WTF).
-
Yes, I have such an editor. You are reading this in a browser, though, which generally does not have such a feature.
-
What happens if the time rolls over from (say) 8:59 to 9:00 between the "h" and "m" assignments?
Anyhow, I'd find something like this easier to read (apologies if the syntax is incorrect):
[code]float s = second() / 60.0f;
float m = (minute() + s) / 60.0f;
float h = (hour() + m) / 12.0f;
Point hourOut = polarToScreen((float)(Math.PI / 2 - h * Math.PI * 2), HOUR_LENGTH);
Point minOut = polarToScreen((float)(Math.PI / 2 - m * Math.PI * 2), MINUTE_LENGTH);
Point secOut = polarToScreen((float)(Math.PI / 2 - s * Math.PI * 2), SECOND_LENGTH);[/code]
-
@curtmack said:
And I have 21 years of programming experience. I can read code with three levels of nested parentheses just fine without any highlighting.Yes, I have such an editor. You are reading this in a browser, though, which generally does not have such a feature.
-
@tdb said:
@curtmack said:
And I have 21 years of programming experience. I can read code with three levels of nested parentheses just fine without any highlighting.Yes, I have such an editor. You are reading this in a browser, though, which generally does not have such a feature.
FTFMYSELF.
I have 6 years of programming experience. I can read code with three levels of nested parentheses just fine without any highlighting.
-
@tdb said:
@curtmack said:
Yes, I have such an editor. You are reading this in a browser, though, which generally does not have such a feature.
I have 21 decades of programming experience. I can read code with thirty levels of nested parentheses even though I am blind and have no teeth.
-
-
@Anon Ymous said:
@tdb said:
@curtmack said:
Yes, I have such an editor. You are reading this in a browser, though, which generally does not have such a feature.
I have 21 decades of programming experience. I can read code with thirty levels of nested parentheses even though I am blind and have no teeth.
I'm a level 21 coding wizard. I can read the code from the filthy mind of the person who wrote thirty levels of nested parentheses
-
Seriously. Come back when you've done Lisp in a bare-bones command-line editor - and no, emacs doesn't count.
-
@RayS said:
@Anon Ymous said:
@tdb said:
@curtmack said:
Yes, I have such an editor. You are reading this in a browser, though, which generally does not have such a feature.
I have 21 decades of programming experience. I can read code with thirty levels of nested parentheses even though I am blind and have no teeth.
I'm a level 21 coding wizard. I can read the code from the filthy mind of the person who wrote thirty levels of nested parentheses
Ametures. I have 21 days of programming experience. I can read a plz send me teh codez forum post asking someone to interperet three levels of tested paranthesis without syntax highlighitng.
-
@lrucker said:
Seriously. Come back when you've done Lisp in a bare-bones command-line editor - and no, emacs doesn't count.
Does joe count?Man, I feel old.
-
@astonerbum said:
@RayS said:
Pffft, STFU and GTFO, I've played 21 before, and all of you are wrong. There are no parentheses...@Anon Ymous said:
Ametures. I have 21 days of programming experience. I can read a plz send me teh codez forum post asking someone to interperet three levels of tested paranthesis without syntax highlighitng.@tdb said:
I'm a level 21 coding wizard. I can read the code from the filthy mind of the person who wrote thirty levels of nested parentheses@curtmack said:
I have 21 decades of programming experience. I can read code with thirty levels of nested parentheses even though I am blind and have no teeth.Yes, I have such an editor. You are reading this in a browser, though, which generally does not have such a feature.
And I have 21 years of programming experience. I can read code with three levels of nested parentheses just fine without any highlighting.
-
@Zecc said:
Does Amiga ADVSYS count?@lrucker said:
Seriously. Come back when you've done Lisp in a bare-bones command-line editor - and no, emacs doesn't count.
Does joe count?Man, I feel old.