• fullscreen
  • pixel_noise.pde
  • /** 
      *  Pixel Noise 
      *  by Joel C. Doyle 
      *  Pixelated noise like a TV set. 
    //GUI library import
    import interfascia.*;
    GUIController c;      //declare a GUIController object
    IFButton b1, b2, b3, b4;  //create four buttons
    //end GUI stuff
    int psize;  //size of "pixels" 
    int frame_rate = 30;  //FYI, no noticable difference in speed after 30fps
    int x_count ;  //horizontal "pixel" count 
    int y_count ;  //vertical "pixel" count 
    void setup(){ 
      //set size of the window, P2D mode gives fast performance
      size(720, 640, P2D); 
      //radio button code
      c = new GUIController (this); //define the GUIController object
      //define the 4 buttons (label, xpos, ypos, xsize, ysize)
      b1 = new IFButton ("16", 30, 20, 40, 17);
      b2 = new IFButton ("8", 30, 40, 40, 17);
      b3 = new IFButton ("4", 30, 60, 40, 17);
      b4 = new IFButton ("2", 30, 80, 40, 17);
      //buttons apparently have a addActionListener method. i'm new to java.
      //add the buttons to the controller?
      c.add (b1);
      c.add (b2);
      c.add (b3);
      c.add (b4);
      //end radio button code
    void draw(){ 
      noStroke(); //commenting this out gives a neat effect
      //draw the "pixels"
      for(int i=0; i<y_count; i++){ 
        for(int j=0; j<x_count; j++){ 
          //pick a random grayscale value before drawing each rectangle. (thanks subpixel!)
          rect(j*psize, i*psize, psize, psize); 
    //what to do when the buttons are pushed
    void actionPerformed (GUIEvent e) {
      if (e.getSource() == b1) {  //if button one ("16") is pushed 
        psize = 16;               //change the "pixel" size
        x_count = (width/psize);  //update the number of "pixels" drawn
        y_count = (height/psize);
      else if (e.getSource() == b2) {
        psize = 8;
        x_count = (width/psize);   
        y_count = (height/psize);  
      else if (e.getSource() == b3) {
        psize = 4;
        x_count = (width/psize);  
        y_count = (height/psize);  
      else if (e.getSource() == b4) {
        psize = 2;
        x_count = (width/psize);  
        y_count = (height/psize);  


    tweaks (0)

    about this sketch

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



    Report Sketch

    Report for inappropriate content

    Please provide details if possible:

    Your have successfully reported the sketch. Thank you very much for helping to keep OpenProcessing clean and tidy :)

    Make a Copyright Infringement claim

    Joel C. Doyle

    Pixel Noise

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

    Pixelated Noise. Looks like static on an analog TV set. Change the size of the pixels for extra fun!

    Used interfascia GUI library: http://www.superstable.net/interfascia/index.htm

    18 Jan 2010

    Hey Joel, if you don't need to keep track of the values in checker_array[], you don't need it. Eliminate the first pair of nested for() loops in draw() and just pick the random fill() value in the second pair.

    Also, I wonder what causes the kind of diamond-shaped patterns that appear in this (especially noticeable at the sizes 8 and 16).

    Joel C. Doyle
    18 Jan 2010
    Thanks, spxl. I don't know what I was thinking with the array. Stoned, I guess.
    Joel C. Doyle
    18 Jan 2010
    Oh, yeah. I thought it might be faster to lookup the values rather than generate them randomly each time. But, it's not faster at all!
    You need to login/register to comment.