Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                // TODO
//
// Make the lines grow with random twists
// Animate the things moving around
// Move the tendrils during animation
// Have them eat each other?
// Animated gradients, like waves

let POS = Math.PI / 3;
let JITTER = Math.PI / 15;
let radius = 5;
let critters = [];
let waves = null;

function setup(){
    createCanvas(400, 400);
    waves = new Waves();
    frameRate(24);
    for (let i = 0; i < 20; i++){
        let s = color(50, 50, 50, 10 * i);
        let f = color(20, 40, 80, 8 * i);
        critters[i] = new Critter(s, f);
    }
}

function draw(){
    waves.roll();
    critters.forEach(c => {c.move(); c.draw()});
}

function jitter(){
    return random(-JITTER, JITTER);
}

class Point{
    constructor(x, y){
        this.x = x;
        this.y = y;
    }
}

class Cycle{
  constructor(range){
    this.value = random(-range, range);
    this.increasing = random(-1, 1) > 0;
  }
  next(){
    if (this.increasing){
      this.value += 0.1;
      if (this.value > 2){
        this.increasing = false;
      }
    }else{
      this.value -= 0.1;
      if (this.value < -2){
        this.increasing = true;
      }
    }
    return this.value;
  }
}

class ColorCycle{
  constructor(idx){
    this.idx = idx === undefined ?  random(360): idx;
  }
  next(){
    colorMode(HSB);
    this.idx = (this.idx + 1) % 360;
    return color(this.idx, 90, 50);
  }
}

class Waves{
    constructor(){
        this.cycle = new ColorCycle();
    }

    roll(){
        for (let i = -40; i < 400; i++){
            stroke(this.cycle.next());
            line(0, 400 - i, 399, 360 - i);
        }
    }
}



class Critter{
    constructor(stroke, fill){
        this.stroke = stroke;
        this.fill = fill;
        this.origin = createVector(random(50, 350), random(50, 350));
        this.cycle_x = new Cycle(2);
        this.cycle_y = new Cycle(2);
    }

    dx(rot, rad){
        return cos(rot * POS + jitter()) * radius * rad + origin.x;
     }

    dy(rot, rad){
        return sin(rot * POS + jitter()) * radius * rad + origin.y;
    }

    move(){
        push();
        this.origin.add(createVector(this.cycle_x.next(), this.cycle_y.next()));
        translate(this.origin.x, this.origin.y)
        rotate((PI / 180) * frameCount);
        translate(-this.origin.x, -this.origin.y);
        this.draw();
        pop();
    }

    draw(){
        stroke(this.stroke);
        fill(this.fill);
        ellipse(this.origin.x,this.origin.y,radius*2,radius*2);
        for (let rot = 0; rot < 6; rot++){
            // draw radiating lines
            let x1 = this.dx(rot, 1);
            let y1 = this.dy(rot, 1);
            for (let j = 2; j < 6; j++){
                let x2 = this.dx(rot, j);
                let y2 = this.dy(rot, j);
                line(x1, y1, x2, y2);
                x1 = x2;
                y1 = y2;
            }
        }
    }
}


              
            
!
999px

Console