Wiki

Reso-nance numérique | Arts et cultures libres

Outils du site


logiciels:openframeworks:atelier:accueil

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
logiciels:openframeworks:atelier:accueil [2015/03/11 21:43]
resonance
logiciels:openframeworks:atelier:accueil [2016/02/01 00:11] (Version actuelle)
resonance
Ligne 1: Ligne 1:
 ====== Atelier OpenFrameworks ====== ====== Atelier OpenFrameworks ======
-Atelier donnée au LFO pour les [[http://reso-nance.org/lfo/article8/week-end-fablab|week-ends fablabs]], les 14 et 15 mars 2015.+Atelier donné au Fablab LFO pour les [[http://reso-nance.org/lfo/article8/week-end-fablab|week-ends fablabs]], les 14 et 15 mars 2015.
  
-<WRAP round download 100%> +<WRAP round download 55%> 
-Télécharger tous les fichiers (25 Mo): {{:logiciels:openframeworks:atelier:ofatelier.zip|}}+**Tous les fichiers (25 Mo) : {{:logiciels:openframeworks:atelier:ofatelier.zip|}}**
 </WRAP> </WRAP>
  
Ligne 9: Ligne 9:
  
 Pour commencer, il faut trois fichiers : main.cpp, ofApp.h et ofApp.cpp. Ces fichiers sont générés par le //ProjectGenerator//. Pour commencer, il faut trois fichiers : main.cpp, ofApp.h et ofApp.cpp. Ces fichiers sont générés par le //ProjectGenerator//.
- 
  
 ++++ main.cpp | ++++ main.cpp |
Ligne 646: Ligne 645:
         ofPopMatrix();         ofPopMatrix();
     easyCam.end();     easyCam.end();
 +}
 +</code>
 +++++
 +
 +===== Cours 7 : vidéo ASCII =====
 +  * Fichier police à mettre dans "data" : {{:logiciels:openframeworks:atelier:courriernewbold.zip|}}
 +
 +{{:logiciels:openframeworks:atelier:06a.png?200|}}
 +
 +++++ ofApp.h |
 +<code cpp>
 +#pragma once
 +#include "ofMain.h"
 +
 +class ofApp : public ofBaseApp{
 +
 + public:
 + void setup();
 + void update();
 + void draw();
 + void keyPressed(int key);
 +
 + ofVideoGrabber vidGrabber;
 + int camWidth;
 + int camHeight;
 +        string asciiCharacters;
 +        ofTrueTypeFont  font;
 +};
 +</code>
 +++++
 +
 +++++ ofApp.cpp |
 +<code cpp>
 +#include "ofApp.h"
 +
 +void ofApp::setup(){
 +    ofBackground(0,0,0);
 +    ofSetFrameRate(60);
 +    ofEnableAlphaBlending();
 + camWidth = 640; // try to grab at this size.
 + camHeight = 480;
 + vidGrabber.setVerbose(true);
 + vidGrabber.initGrabber(camWidth,camHeight);
 +    font.loadFont("Courier New Bold.ttf", 9);
 +
 +    //this set of characters comes from processing:
 +    //http://processing.org/learning/library/asciivideo.html
 + //changed order slightly to work better for mapping
 +    asciiCharacters = string("  ..,,,'''``--_:;^^**""=+<>iv%&xclrs)/){}I?!][1taeo7zjLunT#@JCwfy325Fp6mqSghVd4EgXPGZbYkOA8U$KHDBWNMR0Q");
 +}
 +
 +void ofApp::update(){
 + vidGrabber.update();
 +}
 +
 +void ofApp::draw(){
 +    // change background video alpha value based on the mouse position
 +    // float videoAlphaValue = ofMap(mouseX, 0,ofGetWidth(),0,255);
 +    // ofSetColor(255,255,255,videoAlphaValue);
 +    // vidGrabber.draw(0,0);
 +
 +    ofPixelsRef pixelsRef = vidGrabber.getPixelsRef();
 +    ofSetHexColor(0xffffff);
 +
 +    for (int i = 0; i < camWidth; i+= 7){
 +        for (int j = 0; j < camHeight; j+= 9){
 +            // get the pixel and its lightness (lightness is the average of its RGB values)
 +            float lightness = pixelsRef.getColor(i,j).getLightness();
 +            // calculate the index of the character from our asciiCharacters array
 +            int character = powf( ofMap(lightness, 0, 255, 0, 1), 2.5) * asciiCharacters.size();
 +            // draw the character at the correct location
 +            font.drawString(ofToString(asciiCharacters[character]), i, j);
 +        }
 +    }
 +}
 +
 +void ofApp::keyPressed (int key){
 + // in fullscreen mode, on a pc at least, the
 + // first time video settings the come up
 + // they come up *under* the fullscreen window
 + // use alt-tab to navigate to the settings
 + // window. we are working on a fix for this...
 + if (key == 's' || key == 'S'){
 + vidGrabber.videoSettings();
 + }
 } }
 </code> </code>
 ++++ ++++
/home/resonancg/www/wiki/data/attic/logiciels/openframeworks/atelier/accueil.1426106624.txt.gz · Dernière modification: 2015/03/11 21:43 de resonance