Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int raio;
- int currentSeconds = 0;
- class Ponto{
- int x;
- int y;
- Ponto(int x, int y){
- this.x = x;
- this.y = y;
- }
- }
- void setup(){
- size(500,500);
- raio = (width-100)/2 - 20;
- }
- void draw(){
- background(125);
- drawClock();
- movePointer();
- }
- Ponto polares(float angulo, int raio){
- return new Ponto(
- round(cos(angulo) * raio),
- round(sin(angulo) * raio)
- );
- }
- void drawClock(){
- strokeWeight(5);
- stroke(0);
- ellipse(width/2,height/2,width-100,width-100);
- }
- void movePointer(){
- if(millis()/1000.0 > currentSeconds+1){
- currentSeconds++;
- }
- Ponto p = polares((2*PI/60.0)*currentSeconds - PI/2,raio);
- strokeWeight(6);
- stroke(255,0,0);
- line(width/2,height/2, width/2 + p.x, height/2 + p.y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement