• fullscreen
  • PerlinArt.pde
  • int WIDTH;
    int HEIGHT;
    
    ArrayList particles;
    Particle tempParticle;
    color leftColor;//Color for the left of the screen
    color rightColor;//Color for the right of the screen
    color particleColor;//Color lerped from leftColor and rightColor
    long timer = 10;//How long until auto restart
    long lastTime = 0;//Used with timer
    
    void setup()
    {
      size(800, 600, P2D);
      WIDTH = 800;
      HEIGHT = 600;
      frameRate(500);
      smooth();
      restart();
    }
    
    void restart()
    {
      particles = new ArrayList();
      leftColor = color(random(255), random(255), random(255));
      rightColor = color(random(255), random(255), random(255));
      for(int i = 0; i < 3000; i++)
      {
        particleColor = lerpColor(leftColor, rightColor, float(i) / WIDTH);
        particles.add(new Particle(random(0, WIDTH), random(0, HEIGHT), particleColor));
      }
      noiseSeed(second());//Creates a new noise pattern
      background(0);
    }
    
    void draw()
    {
      for(int i = 0; i < particles.size(); i++)
      {
        tempParticle = (Particle) particles.get(i);
        tempParticle.update();
        tempParticle.drawPoint();
      }
      
      if(second() - lastTime >= timer)
      {
        lastTime = second();
        restart();
      }
    }
    
    void mouseReleased()
    {
      lastTime = second();
        restart();
    }
    
    class Particle
    {
      float posX;
      float posY;
      float r, g, b, a;
      color clr;
      
      protected Particle(float x, float y, color c)
      {
        posX = x;
        posY = y;
        r = red(c);
        g = green(c);
        b = blue(c);
        a = 10;
      }
      
      public void update()
      {
        clr = lerpColor(leftColor, rightColor, (float)posX / WIDTH);
        r = red(clr);
        g = green(clr);
        b = blue(clr);
        posY += sin(noise(posX * 0.01, posY * 0.01) * TWO_PI);
        posX += cos(noise(posX * 0.01, posY * 0.01) * TWO_PI);
        if(posY < 0 || posY > HEIGHT - 1)
        {
          posY = random(0, HEIGHT);
          posX = random(0, WIDTH);
        }
        if(posX < 0 || posX > WIDTH - 1)
        {
          posY = random(0, HEIGHT);
          posX = random(0, WIDTH);
        }
      }
      
      public void drawPoint()
      {
        stroke(r, g, b, a);
        point(posX, posY);
      }
    }
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement


    CgRobot

    Perlin Art

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

    Inspired by this sketch http://openprocessing.org/sketch/6707
    I decided to make a visual with perlin noise myself.

    Click to restart with new random colors.
    It will auto restart after 10 seconds. It occasionally glitches and won't restart automatically. I don't know why. Just click and it should be fine.
    Enjoy!

    P.S. I have run this in fullscreen and although it runs slower than normal, it doesn't really lag. I recommend that you try it for yourself.

    You need to login/register to comment.