Last active
August 29, 2015 14:10
-
-
Save darkwave/c856fdd2dc09a0a559e9 to your computer and use it in GitHub Desktop.
Esempio orologio versione 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Un orologio in Processing | |
Immagini di riferimento: | |
http://tinyurl.com/fusi004a | |
http://tinyurl.com/fusi004b | |
**/ | |
PImage quadrante = null; | |
PImage lancetta = null; | |
void setup() { | |
size(200, 200); | |
quadrante = loadImage("quadrante.png"); //dalla cartella /data | |
lancetta = loadImage("lancetta.png"); //dalla cartella /data | |
imageMode(CENTER); | |
} | |
void draw() { | |
background(#6666ff); | |
translate(width / 2, height / 2); | |
tint(255); | |
image(quadrante, 0, 0); | |
float seconds = second() * 6; | |
//map(variabile di partenza, min var, max var, min mappato, max mappato); | |
float hours = map(hour() % 12, 1, 12, 0, 360); | |
float minutes = map(minute(), 1, 60, 0, 360); | |
pushMatrix(); | |
rotate(radians(seconds)); | |
scale(0.5, 1); | |
image(lancetta, 0, 0); | |
popMatrix(); | |
pushMatrix(); | |
rotate(radians(minutes)); | |
tint(120); | |
image(lancetta, 0, 0); | |
popMatrix(); | |
pushMatrix(); | |
rotate(radians(hours)); | |
scale(1, 0.8); | |
tint(30); | |
image(lancetta, 0, 0); | |
popMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment