• fullscreen
  • SelfPrintingSketch2.pde
  • BufferedReader reader;
    String line, c, str;
    int count, w, pixelSize;
    boolean read;
    
    void setup(){
      background(0);
      reader = createReader("SelfPrintingSketch2.pde");
      read = true;
      pixelSize = 15;
      str = "";
     while(read){ 
       try{
        line = reader.readLine();
      } catch (IOException e){
        e.printStackTrace();
        line = null;
      }
      if (line == null){
        read = false;
      } else {
        for(int x = 0; x < line.length(); x++){
          c = String.valueOf(line.charAt(x));
          count++;
        }  
        str = str + line; 
      }
     }
      w = nearestSquare(count);
      size(w * pixelSize, w * pixelSize);
      
        for(int i = 0; i < str.length(); i++){
          fill(String.valueOf(str.charAt(i)).hashCode());
          rect(pixelSize*(i % w), pixelSize*(i / w) , pixelSize, pixelSize);
        }
    }
    
    int nearestSquare(int n){
      int i = 2;
      while(i*i < n){
        i++;
      }
      return i;
    }
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Richard Spellman

    Self Printing Sketch 1

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    First attempt at writing a sketch that prints itself out as an image. bit of a kludgy mess. have to copy the pde file into data folder before posting, which is annoying.
    doesn't seem to work consistently either, sometimes it just won't display. and there was something funny going on with the size of the sketch on import. works fine when run locally within processing...

    ale plus+
    1 Nov 2011
    Nice idea.
    ^-^
    ale plus+
    1 Nov 2011
    Maybe the output would be nicer without any stroke, only the colour information, donĀ“t know...
    ^-^
    You need to login/register to comment.