Proga 0629

  • 958 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
958
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
4
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. // second(); // minute(); // hour()
  • 2. void setup() { frameRate(30); } void draw() { int h = hour(); int m = minute(); int s = second(); println(" "+h+":"+m+":"+s); }
  • 3. 0 0 360 2π 270 90 3π/2 π/2 π 180
  • 4. void setup() { size(300,300); stroke(255); smooth(); frameRate(30); } void draw() { background(0); float s = second(); float m = minute(); float h = hour() % 12; translate(width/2, height/2); ellipse(0,0,width,height); rotate(radians(180)); noFill(); stroke(255); // pushMatrix(); rotate(radians(s*(360/60))); strokeWeight(1);
  • 5. line(0,0,0,width/2); popMatrix(); // pushMatrix(); rotate(radians(m*(360/60))); strokeWeight(2); line(0,0,0,width/2); popMatrix(); // pushMatrix(); rotate(radians(h*(360/12))); strokeWeight(4); line(0,0,0,width/3); popMatrix(); }
  • 6. void setup() { size(300,300); stroke(255); smooth(); frameRate(30); } void draw() { background(0); float s = second(); float m = minute() + (s/60.0); float h = hour()%12 + (m/60.0); translate(width/2, height/2); ellipse(0,0,width,height); rotate(radians(180)); noFill(); stroke(255);
  • 7. // pushMatrix(); rotate(radians(s*(360/60))); strokeWeight(1); line(0,0,0,width/2); popMatrix(); // pushMatrix(); rotate(radians(m*(360/60))); strokeWeight(2); line(0,0,0,width/2); popMatrix(); // pushMatrix(); rotate(radians(h*(360/12))); strokeWeight(4); line(0,0,0,width/3); popMatrix(); }
  • 8. int MARGIN = 20; void setup() { size(300,300); stroke(255); smooth(); frameRate(30); } void draw() { background(0); float s = second(); float m = minute() + (s/60.0); float h = hour()%12 + (m/60.0); translate(width/2, height/2); rotate(radians(180)); // pushMatrix(); fill(128); noStroke();
  • 9. for(int i=0; i<60; i++){ rotate(radians(6)); ellipse(width/2-MARGIN,0,3,3); } for(int i=0; i<12; i++){ rotate(radians(30)); ellipse(width/2-MARGIN,0,10,10); } popMatrix(); noFill(); stroke(255); // pushMatrix(); rotate(radians(s*(360/60))); strokeWeight(1); line(0,0,0,width/2-MARGIN); popMatrix(); // pushMatrix(); rotate(radians(m*(360/60)));
  • 10. strokeWeight(2); line(0,0,0,width/2-MARGIN); popMatrix(); // pushMatrix(); rotate(radians(h*(360/12))); strokeWeight(4); line(0,0,0,width/3-MARGIN); popMatrix(); }
  • 11. int MARGIN = 20; Clock myClock = new Clock(); void setup() { size(300,300); stroke(255); smooth(); frameRate(30); } void draw() { background(0); myClock.getTime(); myClock.draw(); }
  • 12. class Clock { float s, m, h; Clock(){ } void getTime(){ s = second(); m = minute() + (s/60.0); h = hour()%12 + (m/60.0); } void draw(){ translate(width/2, height/2); rotate(radians(180)); pushMatrix(); fill(128); noStroke(); for(int i=0; i<60; i++){ rotate(radians(6)); ellipse(width/2-MARGIN,0,3,3); }
  • 13. for(int i=0; i<12; i++){ rotate(radians(30)); ellipse(width/2-MARGIN,0,10,10); } popMatrix(); noFill(); stroke(255); pushMatrix(); rotate(radians(s*(360/60))); strokeWeight(1); line(0,0,0,width/2-MARGIN); popMatrix(); pushMatrix(); rotate(radians(m*(360/60))); strokeWeight(2); line(0,0,0,width/2-MARGIN); popMatrix(); pushMatrix(); rotate(radians(h*(360/12))); strokeWeight(4); line(0,0,0,width/3-MARGIN); popMatrix(); } }
  • 14. void setup() { size(300,300); colorMode(HSB,360,100,100,100); background(0); noStroke(); smooth(); frameRate(15); } void draw() { drawFade(); fill(200,100,100); float s = second(); float m = minute(); float h = hour()%12; float pos_s = width/60*s; rect(pos_s,0,width/60,height/3);
  • 15. float pos_m = width/60*m; rect(pos_m,height/3,width/60,height/3); float pos_h = width/12*h; rect(pos_h,height/3*2,width/12,height/3); } void drawFade(){ noStroke(); fill(0,0,0,1); rect(0,0,width,height); }
  • 16. void setup() { size(800,200); background(0); noStroke(); smooth(); frameRate(30); } void draw() { background(0); float ms = millis(); float s = second(); float m = minute(); float h = hour()%12; fill(255*(ms%1000/1000)); rect(width/4*3,0,width/4,height); fill(255*(s/60)); rect(width/4*2,0,width/4,height);
  • 17. fill(255*(m/60)); rect(width/4,0,width/4,height); fill(255*(h/12)); rect(0,0,width/4,height); }
  • 18. void setup() { size(800,200); background(0); noStroke(); smooth(); frameRate(30); } void draw() { background(0); float ms = millis(); float s = second(); float m = minute(); float h = hour()%12; fill(255*(ms%1000/1000)); rect(width/4*3,0,width/4,height); fill(255*(s/60)); rect(width/4*2,0,width/4,height);
  • 19. fill(255*(m/60)); rect(width/4,0,width/4,height); fill(255*(h/12)); rect(0,0,width/4,height); }