Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| outils:processing [2022/11/30 13:21] – amelietnomud | outils:processing [2022/11/30 16:43] (Version actuelle) – amelietnomud | ||
|---|---|---|---|
| Ligne 113: | Ligne 113: | ||
| {{: | {{: | ||
| {{: | {{: | ||
| + | |||
| + | ==== Générateur d' | ||
| + | |||
| + | Voici un exemple de programme qui permet de transformer une image en ASCII art : | ||
| + | |||
| + | char[] chars ={' | ||
| + | String loadPath = " | ||
| + | PImage picture; | ||
| + | int devisions = 3; // pixels | ||
| + | PFont font; | ||
| + | float xDiv; | ||
| + | float yDiv; | ||
| + | | ||
| + | void setup(){ | ||
| + | picture = loadImage(loadPath); | ||
| + | size(1800, | ||
| + | font = loadFont(" | ||
| + | xDiv = picture.width/ | ||
| + | yDiv = picture.height/ | ||
| + | println(xDiv); | ||
| + | } | ||
| + | | ||
| + | void draw(){ | ||
| + | background(255); | ||
| + | textFont(font, | ||
| + | for(int i = 0; i < height; i+= devisions){ | ||
| + | for(int j = 0; j < width; j+= devisions){ | ||
| + | float variation = random(5); | ||
| + | color filler = picture.get((int(j)+int(variation)), | ||
| + | fill(filler); | ||
| + | textAlign(CENTER); | ||
| + | //gets char depending on brightness | ||
| + | float value = brightness(filler); | ||
| + | char charac = chars[int(value/ | ||
| + | text(charac, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | void keyReleased() { | ||
| + | if(key==' | ||
| + | } | ||
| + | | ||
| + | Le sketch ouvre une image, charge une typographie monospace, puis il divise l' | ||
| + | |||
| + | {{: | ||
| + | {{: | ||
| ===== Utiliser des librairies ===== | ===== Utiliser des librairies ===== | ||