// PerecAlphabetsV15.pde // // 12-12-2015 // // Processing 2.0.3 en Mode JavaScript OK Mac Safari Firefox Chrome Opera // // Pour que ce sketch s'execute en mode JavaScript: // Voir: http://processingjs.org/reference/ // 1 Ne pas utiliser loadFont et font .vlw // Utiliser loadFont ou createFont et font .ttf ou .otf dans data // http://processingjs.org/reference/font/ // et Menu JavaScript -> Playback Settings (Directives) -> "font": to load... // 2 Datatype char: Remplacer 'x' par "x" partout sauf pour key == 'x' // http://processingjs.org/articles/jsQuickStart.html#nochartype // 3 Ne pas utiliser dataPath() // 4 Ne pas utiliser frame.setTitle(NomFichier); // 5 Ne pas utiliser saveFrame // 6 Ne pas utiliser File XXX = new File() et XXX.exists; // 7 Ne pas utiliser import java.xxx // "Processing.js is actually JavaScript, // it does not support importing Java-based libraries." // // the files (UTF-8 text files): // "PerecAlphabets1.txt" // "PerecAlphabets2.txt" // "PerecAlphabets3.txt" // cf http://www.editions-galilee.fr/images/3/9782718605760.pdf // "PerecAlphabets14.txt" // "PerecAlphabets24.txt" // "PerecAlphabets44.txt" // "PerecAlphabets88.txt" // "PerecAlphabets108.txt" // "PerecAlphabets176.txt" // "Helvetica-Light.otf" // "Helvetica-LightOblique.otf" // must be in the "data" folder. // // Si la derniere ligne du fichier PerecAlphabetsXXX.txt est Italic, // le texte s'affiche en italique // 2 x "Retour chariot" a la fin de chaque fichier // // Touche Clavier: // Fleche -> Onzain suivant // Fleche <- Onzain precedent // /** * Taper flèche <- ou -> *
*
* D'après: Georges Perec - Alphabets - * Cent soixante-seize onzains hétérogrammatiques - * Edition Galilée, 1976 *
* Voir: http://www.editions-galilee.fr/images/3/9782718605760.pdf *
*
* Voir: http://gerard.paresys.free.fr/Theme/PerecAlphabets/ *
*/ // Pour mode JavaScript: /* @pjs font="Helvetica-Light-Light-Italic.ttf,Helvetica-Light.otf,Helvetica-LightOblique.otf"; */ String NomFichier = "PerecAlphabets1.txt"; int Longueur = 11; int DecalX = 12; int DecalY = 28; int EcartY = 29; // a cause de PerecAlphabets108.txt int DecalXRouge = 490; int DecalYRouge = 310; int EcartXRouge = 22; int EcartYRouge = 22; int Onzain = 1; String[] lignes; PFont Police, PoliceItalic; char c, Caractere; int Ligne, Place, j; boolean Trouve = false; int X, Y; int PlaceSouris = -1; void setup() { size(800, 600); // Police = loadFont("Helvetica-Light.otf"); Police = createFont("Helvetica-Light.otf", 24); // PoliceItalic = loadFont("Helvetica-LightOblique.otf"); PoliceItalic = createFont("Helvetica-LightOblique.otf", 24); // PoliceItalic = loadFont("Helvetica-Light-Light-Italic.ttf"); // PoliceItalic = createFont("Helvetica-Light-Light-Italic.ttf",24); OuvertureFichier(); } void draw() { background(255); if (lignes[lignes.length - 1].equals("Italic")) textFont(PoliceItalic, 24); else textFont(Police, 24); fill(0); for (Ligne = 0; Ligne < lignes.length - 1; Ligne = Ligne+1) text(lignes[Ligne], DecalX, DecalY + Ligne * EcartY); textFont(Police, 24); fill(150); text(NomFichier, DecalX, height - 10); textFont(Police, 24); Place = 0; for (Ligne = 0; Ligne < lignes.length - 1; Ligne = Ligne+1) { for (j = 0; j < lignes[Ligne].length(); j = j+1) { c = lignes[Ligne].toUpperCase().charAt(j); if ((c == "À") || (c == "Â")) c = "A"; if ((c == "É") || (c == "È") || (c == "Ê")) c = "E"; if ((c == "Ï")) c = "I"; if ((c == "Ô")) c = "O"; if ((c == "Ù") || (c == "Û") || (c == "Ü")) c = "U"; if ( c == "Œ") { Ecrire("O"); c = "E"; } if ( c == "Ç") c = "C"; if (c == " ") ; else if (c == ",") ; else if (c == ";") ; else if (c == "'") ; else if (c == ".") ; else if (c == ":") ; else if (c == "!") ; else if (c == "?") ; else if (c == "-") ; else if (c == "…") ; else if (c == "(") ; else if (c == ")") ; else Ecrire(c); } } X = mouseX; Y = mouseY; X = floor(float((X - DecalXRouge)) / float(EcartXRouge)); Y = floor((float((Y - DecalYRouge)) / float(EcartYRouge))) + 1; if ((X >= 0) && (Y >= 0) && (X < Longueur) && (Y < Longueur)) { PlaceSouris = X + (Y * Longueur); } else { PlaceSouris = -1; Caractere = " "; } } void keyPressed() { if (key == CODED) { if (keyCode == LEFT) OuvertureMoins1(); else if (keyCode == RIGHT) OuverturePlus1(); } } void Ecrire(char car) { if (Place == PlaceSouris) Caractere = car; if (car == Caractere) fill(255, 0, 0); // Rouge else fill(0, 0, 0); // Noir text(car, DecalXRouge + EcartXRouge * int(Place % Longueur), DecalYRouge + EcartYRouge * int(Place / Longueur)); Place = Place + 1; } void OuverturePlus1() { Trouve = false; while (!Trouve) { Onzain = Onzain + 1; if (Onzain > 176) Onzain = 1; OuvertureFichier(); } } void OuvertureMoins1() { Trouve = false; while (!Trouve) { Onzain = Onzain - 1; if (Onzain < 0) Onzain = 176; OuvertureFichier(); } } void OuvertureFichier() { NomFichier = "PerecAlphabets" + Onzain + ".txt"; try { lignes = loadStrings(NomFichier); if (lignes != null) Trouve = true; } catch(Exception e) { } }