Mais conteúdo relacionado Semelhante a Proga 0706 (20) Mais de Atsushi Tadokoro (20) Proga 070610. /* time01.pde*/
Clock myClock = new Clock();
void setup() {
colorMode(HSB, 360, 100, 100, 100);
size(600,300);
stroke(0);
}
void draw() {
myClock.getTime();
myClock.display();
}
11. /* Clock.pde */
class Clock {
int s, m, h;
int lastSecond = 0;
void getTime(){
s = second();
m = minute();
h = hour()%12;
}
void display(){
if(s != lastSecond){
background(0);
fill(200,100,50);
for(int i = 0; i < s; i++){
float rectWidth = width/60;
float pos_s = rectWidth*i;
rect(pos_s, 0, rectWidth, height/3);
}
12. for(int i = 0; i < m; i++){
float rectWidth = width/60;
float pos_m = rectWidth*i;
rect(pos_m, height/3, rectWidth, height/3);
}
for(int i = 0; i < h; i++){
float rectWidth = width/24;
float pos_h = rectWidth * i;
rect(pos_h,height/3*2,rectWidth,height/3);
}
lastSecond = s;
}
}
}
14. /* time02.pde*/
Clock myClock = new Clock();
void setup() {
size(800,200);
frameRate(30);
noStroke();
colorMode(HSB, 360, 100, 100, 100);
}
void draw() {
myClock.getTime();
myClock.display();
}
15. class Clock {
float ms, s, m, h;
void getTime(){
ms = millis()%1000;
s = second();
m = minute();
h = hour();
}
void display(){
background(0);
fill(200, 100, 100*(ms/1000));
rect(width/4*3,0,width/4,height);
fill(200, 100, 100*(s/60));
rect(width/4*2,0,width/4,height);
fill(200, 100, 100*(m/60));
rect(width/4,0,width/4,height);
fill(200, 100, 100*(h/24));
rect(0,0,width/4,height);
}
}
17. /* time03.pde*/
Clock myClock = new Clock();
void setup() {
size(800,200);
frameRate(30);
noStroke();
colorMode(HSB, 360, 100, 100, 100);
}
void draw() {
myClock.getTime();
myClock.display();
}
18. class Clock {
float ms, s, m, h;
void getTime(){
ms = millis()%1000;
s = second();
m = minute();
h = hour()%12;
}
void display(){
fill(360*(ms/1000),50, 100);
rect(width/4*3,0,width/4,height);
fill(360*(s/60), 50, 100);
rect(width/4*2,0,width/4,height);
fill(360*(m/60), 50, 100);
rect(width/4,0,width/4,height);
fill(360*(h/12), 50, 100);
rect(0,0,width/4,height);
}
}
20. /* time04.pde */
Clock myClock = new Clock();
PFont font;
void setup() {
font = loadFont("clock.vlw");
textFont(font);
colorMode(HSB, 360, 100, 100, 100);
size(400,400);
frameRate(30);
smooth();
noStroke();
background(0);
}
void draw() {
myClock.getTime();
myClock.display();
}
21. /* time04.pde */
Clock myClock = new Clock();
PFont font;
void setup() {
font = loadFont("clock.vlw");
textFont(font);
colorMode(HSB, 360, 100, 100, 100);
size(400,400);
frameRate(30);
smooth();
noStroke();
background(0);
}
void draw() {
myClock.getTime();
myClock.display();
}
22. class Clock {
int s, m, h;
int lastSecond=0;
void getTime(){
s = second();
m = minute();
h = hour()%12;
}
void display(){
if(lastSecond != s){
textAlign(CENTER);
fill(0,0,0,20);
rect(0, 0, width, height);
fill(0,0,100,100);
String t = nf(s,2) + "n" + nf(m, 2)+ "n" + nf(h, 2);
pushMatrix();
translate(width/2, height/2);
rotate(radians(6.0*s));
text(t, 0, -height/2.5);
popMatrix();
lastSecond = s;
}
}
}
24. /* time05.pde */
Clock myClock = new Clock();
PFont font;
void setup() {
font = loadFont("clock.vlw");
textFont(font);
colorMode(HSB, 360, 100, 100, 100);
size(400,400);
frameRate(30);
smooth();
noStroke();
}
void draw() {
myClock.getTime();
myClock.display();
}
25. class Clock {
int s, m, h;
int lastSecond=0;
void getTime(){
s = second();
m = minute();
h = hour()%12;
}
void display(){
if(lastSecond != s){
background(0,0,100);
translate(width/2, height/2);
//
fill(0,100,100,30);
String ts = nf(s,2);
pushMatrix();
rotate(radians(6.0*s));
textAlign(CENTER);
text(ts, 0, 40);
popMatrix();
26. //
fill(120,100,100,30);
String tm = nf(m,2);
pushMatrix();
rotate(radians(6.0*m));
textAlign(CENTER);
text(tm, 0, 40);
popMatrix();
//
fill(240,100,100,30);
String th = nf(h,2);
pushMatrix();
rotate(radians(30*h));
textAlign(CENTER);
text(th, 0, 40);
popMatrix();
lastSecond = s;
}
}
}
28. /* time06.pde */
Clock myClock = new Clock();
void setup() {
colorMode(HSB, 360, 100, 100, 100);
size(600,400);
frameRate(30);
smooth();
noStroke();
}
void draw() {
myClock.getTime();
myClock.display();
}
29. class Clock {
int s, m, h;
int lastSecond=0;
void getTime(){
s = second();
m = minute();
h = hour()%12;
}
void display(){
if(lastSecond != s){
background(0);
String bs = nf(int(binary(s)), 6);
String bm = nf(int(binary(m)), 6);
String bh = nf(int(binary(h)), 6);
float radius = width/12;
for(int i = 0; i < 6; i++){
if(bs.charAt(i) == '1'){
fill(0, 50, 50);
30. } else {
fill(0, 0, 20);
}
float locX = width/7.0*(i+1);
float locY = height/4.0;
ellipse(locX, locY, radius, radius);
}
for(int i = 0; i < 6; i++){
if(bm.charAt(i) == '1'){
fill(0, 50, 50);
} else {
fill(0, 0, 20);
}
float locX = width/7.0*(i+1);
float locY = height/4.0*2;
ellipse(locX, locY, radius, radius);
}
for(int i = 0; i < 6; i++){
if(bh.charAt(i) == '1'){
fill(0, 50, 50);
31. } else {
fill(0, 0, 20);
}
float locX = width/7.0*(i+1);
float locY = height/4.0*3;
ellipse(locX, locY, radius, radius);
}
lastSecond = s;
}
}
}
33. /* time07.pde */
Clock myClock;
void setup() {
colorMode(HSB, 360, 100, 100, 100);
size(400,400);
frameRate(30);
smooth();
myClock = new Clock();
}
void draw() {
myClock.getTime();
myClock.display();
}
34. /* Clock.pde */
class Clock {
float s, m, h;
float lastSecond=0;
Ring[] rings;
int numRings = 60;
int currentRing = 0;
Clock(){
rings = new Ring[numRings];
for(int i = 0; i < numRings; i++){
rings[i] = new Ring();
}
}
void getTime(){
s = second();
m = minute();
h = hour()%12;
}
35. void display(){
background(0);
for(int i = 0; i < numRings; i++){
rings[i].grow();
rings[i].display();
}
if(lastSecond != s){
float r = width/4.0;
float posX = r * cos(radians(s*6.0)) + width/2;
float posY = r * sin(radians(s*6.0)) + height/2;
rings[int(s)].start(posX, posY);
lastSecond = s;
}
}
}
36. /* Ring.pde */
class Ring {
float x, y, diameter;
boolean on = false;
color col;
void start(float _x, float _y){
x = _x;
y = _y;
on = true;
diameter = 1;
col = color(random(360), 50, 100, 50);
}
void grow() {
if(on) {
diameter+=0.1;
if(diameter > width){
on = false;
}
}
}
37. void display(){
if(on){
noFill();
stroke(col);
strokeWeight(2);
ellipse(x, y, diameter, diameter);
}
}
}