diff options
author | piernov <piernov@piernov.org> | 2014-03-13 16:48:55 +0100 |
---|---|---|
committer | piernov <piernov@piernov.org> | 2014-03-13 16:48:55 +0100 |
commit | c9af7bb67bfefc3f37b4cdd4a066a29138f202b3 (patch) | |
tree | 93bbee2437b6f78fb7f46d1193d00279b6852c35 /Processing/Synthe3000/Draw.pde | |
download | Synthe3000-master.tar.gz Synthe3000-master.tar.bz2 Synthe3000-master.tar.xz Synthe3000-master.zip |
Diffstat (limited to 'Processing/Synthe3000/Draw.pde')
-rw-r--r-- | Processing/Synthe3000/Draw.pde | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/Processing/Synthe3000/Draw.pde b/Processing/Synthe3000/Draw.pde new file mode 100644 index 0000000..7b28d50 --- /dev/null +++ b/Processing/Synthe3000/Draw.pde @@ -0,0 +1,86 @@ +/* Redéfinition de fonctions pour transformer les coordonnées relatives en coordonnées absolues */ +void rect(float i, float j, float k, float l) +{ + super.rect(i*windowSize[0], j*windowSize[1], k*windowSize[0], l*windowSize[1]); +} + +void triangle(float i, float j, float k, float l, float m, float n) +{ + super.triangle(i*windowSize[0], j*windowSize[1], k*windowSize[0], l*windowSize[1], m*windowSize[0], n*windowSize[1]); +} + +void ellipse(float i, float j, float k, float l) +{ + super.ellipse(i*windowSize[0], j*windowSize[1], k*windowSize[0], l*windowSize[0]); +} + +void text(String t, float x, float y) +{ + super.text(t, x*windowSize[0], y*windowSize[1]); +} + +void image(PImage p, float i, float j, float k, float l) +{ + super.image(p, i*windowSize[0], j*windowSize[1], k*windowSize[0], l*windowSize[1]); +} +/* Fin de redéfinition des fonctions */ + +void drawKeyboard() +{ + stroke(0); + // Dessine chaque octaves + for (int j=0; j<numOctaves; j++) { + fill(255); + // Dessine les touches blanches + for (int i=0; i<7; i++) { + if (keysPressed[1][(j*7)+i] != 0) fill(0, 255, 0); // Colorer la touche en vert si elle est appuyée + rect((keyWidth[1]/numOctaves)*i+(float)j/numOctaves, keyboardYCoordinate, keyWidth[1]/(numOctaves), keyHeight[1]); // Rectangle touche blanche + fill(255,0,255); + text(nomTouchesBlanches[i+(j*7)], 0.01+(keyWidth[1]/numOctaves)*i+(float)j/numOctaves, 0.962); // Affiche le caractère de la touche + fill(255); + } + fill(0); + // Dessine les touches noires + for (int i=0; i<keyXCoordinates.length; i++) { + if (keysPressed[0][(j*5)+i] != 0) fill(255, 255, 0); // Colorer la touche en jaune si elle est appuyée + rect((keyXCoordinates[i]/numOctaves)+(float)j/numOctaves, keyboardYCoordinate, keyWidth[0]/(numOctaves), keyHeight[0]); // Rectangle touche noire + fill(255,0,255); + text(nomTouchesNoires[i+(j*5)], 0.01+(keyXCoordinates[i]/numOctaves)+(float)j/numOctaves, keyboardYCoordinate+0.32); // Affiche le caractère de la touche + fill(0); + } + } +} + +void drawDisplay() // Dessine l'affichage, appelé lors du lancement et après chaque clic. +{ + stroke(0); + + /* Bouton lecture */ + if (events[MUSICSTARTED]) fill(0, 0, 255); // Colorisation du bouton lecture si activé + else fill(255); + ellipse(playButtonCoordinates[0], playButtonCoordinates[1], buttonRadius*2, buttonRadius*2); // Contour + fill(0); + triangle(playButtonCoordinates[0]-0.01, playButtonCoordinates[1]-0.02, playButtonCoordinates[0]+0.02, playButtonCoordinates[1], playButtonCoordinates[0]-0.01, playButtonCoordinates[1]+0.02); // Logo lecture + + /* Bouton enregistrer */ + if(events[MUSICPLAYED]) + { + if (events[RECORDINGSTARTED]) fill(255, 0, 0); // Colorisation du bouton enregistrer si activé + else fill(255); + ellipse(recordButtonCoordinates[0], recordButtonCoordinates[1], buttonRadius*2, buttonRadius*2); // Contour + fill(0); + ellipse(recordButtonCoordinates[0], recordButtonCoordinates[1], buttonRadius, buttonRadius); // Logo + } + + if (!events[RECORDINGSTARTED] && events[RECORDINGSTOPPED] && score != -1) + { + fill(255,0,255); + text("Score :" + Integer.toString(score), 0.86, 0.32); // Affichage du score + } + else + { + fill(255); + stroke(255); + rect(0.85, 0.25, 0.15, 0.10); + } +} |