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-js/Draw.pde | |
download | Synthe3000-master.tar.gz Synthe3000-master.tar.bz2 Synthe3000-master.tar.xz Synthe3000-master.zip |
Diffstat (limited to 'Processing-js/Draw.pde')
-rw-r--r-- | Processing-js/Draw.pde | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/Processing-js/Draw.pde b/Processing-js/Draw.pde new file mode 100644 index 0000000..c0fb685 --- /dev/null +++ b/Processing-js/Draw.pde @@ -0,0 +1,86 @@ +/* Redéfinition de fonctions pour transformer les coordonnées relatives en coordonnées absolues */ +void drect(float i, float j, float k, float l) +{ + rect(i*windowSize[0], j*windowSize[1], k*windowSize[0], l*windowSize[1]); +} + +void dtriangle(float i, float j, float k, float l, float m, float n) +{ + triangle(i*windowSize[0], j*windowSize[1], k*windowSize[0], l*windowSize[1], m*windowSize[0], n*windowSize[1]); +} + +void dellipse(float i, float j, float k, float l) +{ + ellipse(i*windowSize[0], j*windowSize[1], k*windowSize[0], l*windowSize[0]); +} + +void dtext(String t, float x, float y) +{ + text(t, x*windowSize[0], y*windowSize[1]); +} + +void dimage(PImage p, float i, float j, float k, float l) +{ + 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); + drect((keyWidth[1]/numOctaves)*i+(float)j/numOctaves, keyboardYCoordinate, keyWidth[1]/(numOctaves), keyHeight[1]); + fill(255,0,255); + dtext(nomTouchesBlanches[i+(j*7)], 0.01+(keyWidth[1]/numOctaves)*i+(float)j/numOctaves, 0.962); + 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); + drect((keyXCoordinates[i]/numOctaves)+(float)j/numOctaves, keyboardYCoordinate, keyWidth[0]/(numOctaves), keyHeight[0]); + fill(255,0,255); + dtext(nomTouchesNoires[i+(j*5)], 0.01+(keyXCoordinates[i]/numOctaves)+(float)j/numOctaves, keyboardYCoordinate+0.32); + 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); + dellipse(playButtonCoordinates[0], playButtonCoordinates[1], buttonRadius*2, buttonRadius*2); // Contour + fill(0); + dtriangle(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); + dellipse(recordButtonCoordinates[0], recordButtonCoordinates[1], buttonRadius*2, buttonRadius*2); // Contour + fill(0); + dellipse(recordButtonCoordinates[0], recordButtonCoordinates[1], buttonRadius, buttonRadius); // Logo + } + + if (!events[RECORDINGSTARTED] && events[RECORDINGSTOPPED] && score != -1) + { + fill(255,0,255); + dtext("Score :" + Integer.toString(score), 0.86, 0.32); // Affichage du score + } + else + { + fill(255); + stroke(255); + drect(0.85, 0.25, 0.15, 0.10); + } +} |