• fullscreen
  • sketch48672.pde
  • /**
    sKeTch is audiovisual application
    
    Aris Bezas Sat, 16 July 2011, 17:31
    
    SC-CODE
    =======
    s.boot;
    (
    SynthDef("Xaraktiki", 
                { arg  amp = 0.5, pan = 0, out = 0;
                    var source;
                    var panned_source;
                    source = HPF.ar(BrownNoise.ar(amp, 0), MouseX.kr(1000,8000));
                    panned_source = Pan2.ar(source, MouseX.kr(-0.9, 0.9));
                    Out.ar( out, panned_source); 
                }
           ).send(s);
    )
    
    // OSC router
    p = NetAddr("127.0.0.1", 12000);  // send to Processing
    z = Synth("Xaraktiki");
    OSCresponder(nil, "amp", { | time, resp, message |
            z.set("amp", message[1]);
    }).add;
    
    
    */
    import processing.opengl.*;
    //import oscP5.*;  
    //import netP5.*;
    
    //OscP5 oscP5;
    //NetAddress myRemoteLocation;
    
    boolean miden, smoothFade;
    boolean xar=true;
    
    // Sound Input Variables
    float amp1, freq1, amp2, freq2, ampout, freqout;
    float ElegxosAmp;
    
    SketchLine  line0, line1, line2;
    float x1, y1, x2, y2; 
    PImage cur;
    
    int stoixeia = 30, lineAlpha = 50;
    
    //  Color Variables
    int colorL=255,strokeL, strokeValue = 20, strokeBackground = 5;
    int paintCount = 0, alphaSform;
    int r0,g0,b0,r1,g1,b1;
    
    // Physics Variables
    float[] x = new float[stoixeia];
    float[] y = new float[stoixeia];
    float[] epitaxinsiX = new float[stoixeia];
    float[] epitaxinsiY = new float[stoixeia];
    float[] elastikotita = new float[stoixeia];
    float[] aposbesi = new float[stoixeia];
    float[] deltaX = new float[stoixeia];
    float[] deltaY = new float[stoixeia];
    float fxMouse, fyMouse;
    
    void setup()  {
      frameRate(240);
      size(900,450);
    
      //oscP5 = new OscP5(this,46100);   //listening
      //myRemoteLocation = new NetAddress("127.0.0.1",57120);  //  speak to
      
      line0 = new SketchLine(30);
      line1 = new SketchLine(stoixeia);
      line2 = new SketchLine(stoixeia + 1);
    
      line0.calcType( 0.2, 0.65 );// 0.2, 0.65 writeLine
      line1.calcType( 0.1, 0.65 );// 0.2, 0.65 writeLine
      line2.calcType( 0.3, 0.65 );// 0.2, 0.65 writeLine
    
      background(0);
      noFill();
      smooth();
    //  noCursor();
      //cur = loadImage("cursor10black.png");
      //cur.resize(8, 8);
      //cursor(cur, mouseX, mouseY);
    
      for (int i=0; i<stoixeia; i++){
        elastikotita[i] = 0.2*(.07*(i+1));// 0.05  kai 0.005
        aposbesi[i] = 0.55-(0.02*i);
      }
    }
    
    void draw()  {
      myLine();
      noFill();
      if (mousePressed == true)  {  
        line0.calcPoints(mouseX, mouseY);
        line0.render(255,0,0, lineAlpha);
        line1.calcPoints(mouseX, mouseY);
        line1.render(255,255,0, lineAlpha);
        line2.calcPoints(mouseX, mouseY);
        line2.render(255,255,255, lineAlpha);
      } else {
          line0.calcPoints(mouseX, mouseY);
        line0.render(255,0,0, 0);
        line1.calcPoints(mouseX, mouseY);
        line1.render(255,255,0, 0);
        line2.calcPoints(mouseX, mouseY);
        line2.render(255,255,255, 0);
      
      }
      if (smoothFade) {
        fill(0,12);
        rect(-10,-10,width,height);
      } 
    }
    
    void myLine(){
    
      if (mousePressed == true)  {  
        if(miden == true) {
          for (int i=0; i<stoixeia; i++){
            x[i] = mouseX;// move worm
            y[i] = mouseY;
            miden = false;
          }
          //cursor(cur, 0,0);
        }
        strokeL = strokeValue;
      }
    
    
      noFill(); 
      drawline();
    
    }
    
    
    void drawline(){
        fxMouse = mouseX;
        fyMouse = mouseY;
     // beginShape();
        for (int i=0; i<5; i++){
        if (i==0){
          deltaX[i] = (fxMouse - x[i]);
          deltaY[i] = (fyMouse - y[i]);
          if (mousePressed && xar)  {
            //OscMessage amp = new OscMessage("amp");  
            //ElegxosAmp = map(abs(deltaX[i])+abs(deltaY[i]), 0, 340, 0, 0.2  );
           // amp.add(ElegxosAmp); 
           // oscP5.send(amp, myRemoteLocation);      
          }
          
        }
        else {
          deltaX[i] = (x[i-1]-x[i]);
          deltaY[i] = (y[i-1]-y[i]);
        }
        deltaX[i] *= elastikotita[i];    // create elastikotita effect
        deltaY[i] *= elastikotita[i];
        epitaxinsiX[i] += deltaX[i];
        epitaxinsiY[i] += deltaY[i];
        x[i] += epitaxinsiX[i];// move it
        y[i] += epitaxinsiY[i];
        vertex(x[i],y[i]);
        epitaxinsiX[i] *= aposbesi[i];    // slow down elastikotita
        epitaxinsiY[i] *= aposbesi[i];
      }
      endShape();
    }
    
    
    
    void mouseReleased()  {
      if(xar)  {
       // OscMessage silence = new OscMessage("amp");  
       // silence.add(0); 
       // oscP5.send(silence, myRemoteLocation);      
      }
    
      line0.calcPointsStart(mouseX, mouseY);
    }
    
    void mousePressed()  {
      line0.calcPointsStart(mouseX, mouseY);
      line1.calcPointsStart(mouseX, mouseY);
      line2.calcPointsStart(mouseX, mouseY);  
    }
    
    
    void mouseDragged() {
    }
    
    
    void keyPressed(){
      if (key == 'z') {
        //cursor(cur, 0, 0);
      }
      if (key == 'b') {
        background(0);
      }  
      if (key == 's') {
        smoothFade = !smoothFade;
      }  
    
    }
    
    
    // ==========  SKETCH CLASS  ===================
    /*
     091027 Igoumeninja Aris Bezas
     class: sKeTch
     variables:  stoixeia, elastikotita, aposvesi, red, green, blue, alpha
     methods:  calcType, calcPoints, render
     */
    
    class  SketchLine  {
      int stoixeia = 1000, colorR, colorG, colorB, lineAlpha = 25; 
      float elast, aposv;
      float[] x = new float[stoixeia];
      float[] y = new float[stoixeia];
      float[] epitaxinsiX = new float[stoixeia];
      float[] epitaxinsiY = new float[stoixeia];
      float[] elastikotita = new float[stoixeia];
      float[] aposvesi = new float[stoixeia];
      float[] deltaX = new float[stoixeia];
      float[] deltaY = new float[stoixeia];
    
      float pointX, pointY;
    
    
      SketchLine(int stoixeiaVar)  {
        stoixeia = stoixeiaVar;
      }
    
      void calcType(float elastikotitaVar, float aposvesiVar)  {
        elast = elastikotitaVar;
        aposv = aposvesiVar;
        for (int i=0; i < stoixeia; i++){
          elastikotita[i] = elast*(.07*(i+1));// 0.05  kai 0.005
          aposvesi[i] = aposv-(0.02*i);
        }
      }
    
      void calcPoints(float pointXVar, float pointYVar)  {
        pointX = pointXVar;
        pointY = pointYVar;
    
        for (int i=0; i<stoixeia; i++){
          if (i==0){
            deltaX[i] = (pointX - x[i]);
            deltaY[i] = (pointY - y[i]);
    //        if (mousePressed)  {
    //          OscMessage amp = new OscMessage("amp");  
    //          ElegxosAmp = map(abs(deltaX[i])+abs(deltaY[i]),0,340,0,1.6  );
    //          amp.add(ElegxosAmp); 
    //          oscP5.send(amp, myRemoteLocation);      
    //        }
          }  
          else  {
            deltaX[i] = (x[i-1]-x[i]);
            deltaY[i] = (y[i-1]-y[i]);
          }
          deltaX[i] *= elastikotita[i];    // create elastikotita effect
          deltaY[i] *= elastikotita[i];
          epitaxinsiX[i] += deltaX[i];
          epitaxinsiY[i] += deltaY[i];
          x[i] += epitaxinsiX[i];// move it
          y[i] += epitaxinsiY[i];
          epitaxinsiX[i] *= aposvesi[i];    // slow down elastikotita
          epitaxinsiY[i] *= aposvesi[i];
        }
      }
      void calcPointsStart(float pointXVar, float pointYVar)  {
        pointX = pointXVar;
        pointY = pointYVar;
        for (int i=0; i<stoixeia; i++){
          x[i] = mouseX;
          y[i] = mouseY;
        }
      }
    
    
      void render(int colorRVar, int colorGVar, int colorBVar, int lineAlphaVar)  {
        colorR = colorRVar;
        colorG = colorGVar;
        colorB = colorBVar;    
        lineAlpha = lineAlphaVar;    
        noFill();
        stroke(colorR, colorG, colorB, lineAlpha);
        beginShape();
        for (int i = 0; i < stoixeia; i++)  {
          curveVertex(x[i], y[i]);
        }
        endShape();
      }
    
    }                                                                                               

    code

    tweaks (18)

    about this sketch

    This sketch is running in HTML5 using Processingjs.

    license

    advertisement

    Aris Bezas
    Kris Sankaran
    25 Dec 2011
    This is beautiful! Thank you for sharing.
    Aris Bezas
    25 Dec 2011
    Thanks Kris, it's my pleasure sharing.
    wade
    30 Dec 2011
    Excellent work. Love it.
    Aris Bezas
    30 Dec 2011
    Thanks wade,
    very sexy!
    Aris Bezas
    23 Jan 2012
    Ευχαριστώ πολύ Sinan.
    Jonathan Chemla
    27 Jan 2012
    Really really beautiful ! :)
    Aris Bezas
    28 Jan 2012
    Thank you Jonathan.
    Yi Zhao
    25 Mar 2012
    All it needs is an erase button!
    Aris Bezas
    27 Mar 2012
    Thanks, press 'b' button.
    bob
    17 Apr 2012
    Hey, great work man!
    Can you please help me with the 'calcPoints' function.
    Also, that mesh like effect, is created where? Hope you can help. :)
    Aris Bezas
    17 Apr 2012
    Hi Bob, thanks a lot. calcPoints function is calculate the point. Is using physics from Newton theory (accelaration, damping and elasticity). The mesh like effect is the result of beginShape() at render function.
    bob
    17 Apr 2012
    Oh, right. Hey, can i message you somewhere? Gotta couple of doubts regarding supercollider?
    Aris Bezas
    18 Apr 2012
    Yes, sure! You can find my mail at my contact page (http://igoumeninja.org/en/pmwiki.php/Site/Contact)
    super
    is there any download?
    best
    Aris Bezas
    26 Apr 2012
    Thanks, you can download the application from: http://igoumeninja.org/media/apps/
    Ondrej Bezdek
    2 May 2012
    i need draw line in android as chalk
    gireesh bogu
    7 May 2012
    Great sketch!!
    I would like know, Is it possible to apply this sketch to specific data co-ordinates ?
    Aris Bezas
    7 May 2012
    Thanks a lot,
    I think it's not a problem to read x,y coordinates from a data file: http://processing.org/reference/BufferedReader_readLine_.html . If you have a specific problem or idea I can help.
    Have a nice day.
    Elac
    10 May 2012
    WOW!!! just awesome. Such beautiful flow.
    Aris Bezas
    14 May 2012
    Thanks Elac! I am very glad for your feedback.
    merci encore : excellent

    as a painter : i am "drawing" with this sketch and it works excellently;

    now I have a special technical question:
    1. I draw one or two lines
    2. I go ahead
    3. suppose the second sep is not satisfactory i and i want to go back to
    step 1. where it was- this means hat i want to erase step 2. drawings in the same picture
    got so far (step1. achieved)

    is there something you could advice or help me with

    merci Aris
    Aris Bezas
    24 May 2012
    Thanks again Gottfried,
    I saw your work at http://www.anversauxabbesses.fr/artistes/user/beyreuther and I like it a lot. It's an honer for me.
    I update the sketch, and now you can erase while you are pressing the 'e' button. You can also draw with smooth erasing with button 's' (press it again if you want to stop "smooth erasing"). I upload the new version from http://igoumeninja.org/media/apps/sketchEraseUpdate.zip.
    Greeting from Igoumeninja - Greece.
    bonsoir

    merci, we get a bit ahead

    here on the web site I can make the variable work

    but in the zipped update: i get the message: oscP5 does not exist, library missing

    this is for audio output i think.....

    is it possible to upload the whole thing as a Mac OSX pakage her into your protofolio, ready to be downloaded

    sorry for asking so much
    thanks in advance !

    my familly are very impressed by the high level aesthetik of your work
    best
    gottfried
    Aris Bezas
    29 May 2012
    Bonjour Gottfried, if you unzip the download zip file you will find inside an "application.macosx" folder that include the Mac OSX application.
    bonjour

    yes of course: but it says: osc p5 not found

    --- may be there is something which complicates the sketch: the graphical aspect and the sound
    in the same time
    i tried to double slash ( // ) in front of all the lines dealing with the sound
    and then the graphical part is working curiously: i mean with very very little light

    sorry to bother you Ari
    best
    g
    Aris Bezas
    30 May 2012
    You have right my friend,
    I upload a new version "sketchUpdateNoOSC".
    And you don't bother. I like it!
    Have a nice day.
    yes

    but when where

    and why not the osc lets say in a second version

    i am doing some music making with sythetitsisers quite "in phase" with your drawing

    and to say it in total:

    i am trying to connect a "kinect" terminal in order to have a scene with:

    1. a dancer/performer in front of the kinect
    2. visual effects like yours
    3. sound as a moderator.

    thanks to go ahead more or less together
    best gottfried
    Pedro Gonzalez
    9 Oct 2012
    very nice!
    Ben Reynolds
    13 Oct 2012
    Beautiful.
    Aris Bezas
    14 Oct 2012
    Thanks a lot. Any feedback is welcome.
    NikPap
    4 Jan 2013
    zoriko filaraki!wraios
    Aris Bezas
    4 Jan 2013
    Ευχαριστώ πολύ μαστερ Νικολάϊ.
    Batman symbol
    Superman symbol
    Jean Gilbert
    2 Mar 2013
    Hi Aris,
    I use your sketch for AV performances with body motion drawing and painting and live music. See the credits and more augmented reality stuff on http://www.jean-gilbert.com
    thank you
    Jean Gilbert
    Aris Bezas
    11 Mar 2013
    Hi Jean,
    Thank you for the honor to play with sketch. Very beautiful performance. For any development I am at your service.
    Greta
    20 Mar 2013
    OMG!
    Jean Gilbert
    24 Mar 2013
    Hi Aris,
    thank you, I am generally interested in painting programs as this one or interactive games and music modulation programs for use with the kinect camera.
    Best Regards,
    Gil
    rochelle smith
    14 Sep 2013
    how do you do this i dont understand this just makes spots of colors
    theutu
    14 Nov 2013
    Beautiful! I like the continuous painting hidden trick :). For everyone out there, click without releasing mouse btn, drag outside the painting area, release and go back in black area.
    Can you add a save option?
    Thanks alot Aris.

    Best regards,

    Theo
    Kallen Lonbom
    17 Nov 2013
    Erasing and smooth erasing don't seem to be working
    Aris Bezas
    18 Nov 2013
    Hi Austin, key 's' toggle smoothErase effect.
    You need to login/register to comment.