Contenu connexe
Similaire à Proga 0629 (14)
Plus de Atsushi Tadokoro (20)
Proga 0629
- 7. void setup() {
frameRate(30);
}
void draw() {
int h = hour();
int m = minute();
int s = second();
println(" "+h+":"+m+":"+s);
}
- 11. 0 0
360 2π
270 90 3π/2 π/2
π
180
- 12. 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);
- 13. 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();
}
- 17. 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);
- 18. //
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();
}
- 21. 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();
- 22. 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)));
- 23. 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();
}
- 25. 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();
}
- 26. 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);
}
- 27. 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();
}
}
- 30. 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);
- 31. 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);
}
- 33. 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);
- 34. fill(255*(m/60));
rect(width/4,0,width/4,height);
fill(255*(h/12));
rect(0,0,width/4,height);
}
- 36. 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);
- 37. fill(255*(m/60));
rect(width/4,0,width/4,height);
fill(255*(h/12));
rect(0,0,width/4,height);
}