• fullscreen
  • ColorDrop.pde
  • graffiti_demo.pde
  • class ColorDrop {
      float initPosX = 0.0, initPosY = 0.0; // initial position of each drop
      float posY = 0.0; // variable to set and get position of painting drop (if initPosY+posY < initPosY+lengthDrop then move the drop down)
      float lengthDrop = random(50, 200); // length of the drop line
      float diameterDrop = random(1.1, 3.0); // diameter of the drop
      float dropSpeed = random(0.1, 5);
      color colorDrop; // color of the drop
    
        ColorDrop(float initPosX_, float initPosY_, color colorDrop_) { // position & color
        initPosX = initPosX_;
        initPosY = initPosY_;
        colorDrop = colorDrop_;
      }
    
      ColorDrop(float initPosX_, float initPosY_, color colorDrop_, float lengthDrop_) { // position, color & length
        initPosX = initPosX_;
        initPosY = initPosY_;
        lengthDrop = lengthDrop_;
        colorDrop = colorDrop_;
      }
    
      ColorDrop(float initPosX_, float initPosY_, color colorDrop_, float lengthDrop_, float diameterDrop_) { // position, color, length & width
        initPosX = initPosX_;
        initPosY = initPosY_;
        lengthDrop = lengthDrop_;
        diameterDrop = diameterDrop_;
        colorDrop = colorDrop_;
      }
    
      boolean moveDrop() {
        if (posY <= lengthDrop) {
          posY += noise(1) * dropSpeed;
          return true;
        } 
        else {
          return false;
        }
      }
    
      void drawDrop() {
        noStroke();
        fill(colorDrop, 255 - int(posY / lengthDrop * 250));
        strokeWeight(1);
        ellipseMode(CENTER);
        ellipse(initPosX, initPosY + posY, diameterDrop, diameterDrop * 2);
      }
    }
    
    
    //import fullscreen.*;
    //FullScreen fullscreenGraffiti;
    
    ColorDrop[] drops, delDrops;
    
    color pencil = #2E792B; // color of the spray painter
    int dropAlpha = 255;
    int randomDrop = 10; // percentaged possibility to generate a color drop
    
    // --- setup procedure ---
    void setup() {
      size(1024, 768);
      frameRate(60);
    
      //fullscreenGraffiti = new FullScreen(this);
      //fullscreenGraffiti.enter();
    
      drops = new ColorDrop[0];
      delDrops = new ColorDrop[0];
    
      stroke(pencil, dropAlpha);
      strokeWeight(20);
      background(0);
      smooth();
    }
    
    // --- draw procedure ---
    void draw() {
      for (int i = 0; i < drops.length; i++) {
        if (drops[i].moveDrop())
          drops[i].drawDrop();
      }
    
      stroke(100);
      strokeWeight(1);
      noFill();
      rect(0, 0, width-1, height-1);
    }
    
    void mouseDragged() {
      if (mouseButton == LEFT) {
        // normal spray drawing foo
        stroke(pencil, dropAlpha);
        strokeWeight(20);
        line(pmouseX, pmouseY, mouseX, mouseY);
    
        // drop generating
        int randomValueForDrop = floor(random(0, 100));
        if (randomValueForDrop <= randomDrop) {
          ColorDrop setDrop = new ColorDrop(mouseX, mouseY, pencil);
          drops = (ColorDrop[]) append(drops, setDrop);
        }
      }
    
      if (mouseButton == RIGHT) {
        drops = delDrops;
        background(0);
      }
    }
    
    
    
    
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement

    DeadDealer

    Graffiti (beta)

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

    click left to draw a green line with drop effects, right to reset. Will be updated later
    ... sorry, little bug ^_^ not clicking is important, but dragging - left and right :/

    You need to login/register to comment.