Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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

              
                .mask
.disc
.play
.overlay
              
            
!

CSS

              
                $b: #2374C6;
$r: #C20F00;
$y: #FFDD22;
$bl: #111;

body{
  display:flex;
  justify-content:center;
  align-items:center;
  height:100vh;
  background:$b;
  transition:background 0.1s ease-in-out;
  overflow:hidden;
  .overlay{
    content:'';
    position:absolute;
    z-index:99;
    pointer-events:none;
    width:100vw;
    height:100vh;
    top:0;
    left:0;
    transition:0.3s ease-in-out;
    transition-delay:0.3s;
    background:$b;
  }
  &.ready{
    .overlay{
      opacity:0;
    }
  }
  .play{
    position:absolute;
    z-index:13;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 15px 0 15px 25px;
    border-color: transparent transparent transparent #fff;
    top:calc(50% + 325px);
    box-shadow:0px 0 0 #fff;
    transform:rotate(0deg) translateX(0px);
    transition:0.2s ease-in-out;
    cursor:pointer;
    &:hover{
      border-color: transparent transparent transparent $y;
      &:before{
        box-shadow:inset 0 0 0 5px $y;
      }
    }
    &:before{
      content:'';
      position:absolute;
      width:75px;
      height:75px;
      box-shadow:inset 0 0 0 5px #fff;
      border-radius:100%;
      left:50%;
      top:50%;
      transform:translate(calc(-50% - 17.5px), -50%);
      transition:0.2s ease-in-out;
    }
  }
  &.playing{
    background:$r;
    .play{
        height:30px;
        border-width:0 0 0 7.5px;
        box-shadow:-20px 0 0 #fff;
        transform:rotate(180deg) translateX(10px);
        &:hover{
          box-shadow:-20px 0 0 $y;
        }
        &:before{
          transform:translate(calc(-50% - 15px), -50%);
        }
    }
    &:before{
     box-shadow:0 15px 40px -5px rgba(0,0,0,0.5), 0 0 0 10vw $r;
    }
    &.inverted{
      &:after, .mask{
        background:$bl;
      }
    }
    &:after, .mask{
      background:$r;
    }
  }
  &:before, .disc{
    content:'';
    position:absolute;
    width:750px;
    height:550px;
    z-index:11;
    box-shadow:0 15px 40px -5px rgba(0,0,0,0.5), 0 0 0 10vw $b;
    transition:box-shadow 0.1s ease-in-out;
  }
  &.inverted{
    .disc{
      clip-path: circle(200% at 50% 50%);
    }
  }
  .disc{
    box-shadow:0 15px 40px -5px rgba(0,0,0,0.5), 0 0 0 50vw $bl;
    will-change:clip-path;
    transition:clip-path 0.75s ease-in-out;
    clip-path: circle(25% at 50% 50%);
  }
  &:hover{
    video, &:after, .mask{
      clip-path: polygon(60% 0, 100% 0, 100% 100%, 40% 100%);
    }
  }
  canvas{
    transform:translateX(-20px) scaleX(-1);
    z-index:7;
    position:relative;
  }
  video, &:after, .mask{
    position:absolute;
    min-width:800px;
    min-height:601px;
    z-index:9;
    opacity:1;
    top:calc(50% - 302px);
    left:calc(50% - 405px);
    filter:saturate(0) brightness(1.75) contrast(1.5);
    transition:clip-path 0.75s ease-in-out, background 0.2s ease-in-out;
    clip-path: polygon(100% 0, 100% 0, 100% 100%, 105% 100%);
    mix-blend-mode:lighten;
    transform:scaleX(-1);
  }
  &:after, .mask{
    content:'';
    position:absolute;
    filter:none;
    z-index:10;
    background:$b;
    mix-blend-mode:overlay;
  }
  .mask{
    z-index:8;
    mix-blend-mode:normal;
  }
}
              
            
!

JS

              
                let camera;
let whiteStripes;
let totalSize = 1.25;
let shiftSize = 0;
let vidHeight = 20;
let vidWidth = 54;
let stepUp = 0;
let sizeMod = 0;
let prevMod = 0;
let playing = 0;
let level;
let amplitude;
let timer = 10;
let invert = 0;
let invertimer = 0;
let fr = 1;

function preload() {
  sound = loadSound('https://assets.codepen.io/383755/fellinlove.mp3');
}

function setup() {
  setTimeout(function(){ fr = 30; document.body.classList.add("ready");}, 1000);
  pixelDensity(1);
  whiteStripes = createCanvas(800, 600);
  camera = createCapture(VIDEO);
  camera.size((width / vidWidth) * totalSize, (height / vidHeight) * totalSize);
  frameRate(fr);
  amplitude = new p5.Amplitude();
  fft = new p5.FFT(0.9, 1024);
  fft.setInput(sound);
}

function mousePressed() {
    if (playing == 0){
      sound.play();
      playing = 1;
      document.body.classList.add("playing");
    }
    else{
      sound.pause();
      stopSong();
    }
    scaleUpdate();
}

function stopSong(){
  playing = 0;
  document.body.classList.remove("playing");
}

function scaleUpdate(){
    prevMod = sizeMod;
    sizeMod = (Math.round(Math.random() * (6 - 1) + 1) * 0.25);
    if (sizeMod == prevMod){
      sizeMod = sizeMod - 0.25;
    }
  totalSize = 2.5 - sizeMod;
  timer = 10;
  camera.size((width / vidWidth) * totalSize, (height / vidHeight) * totalSize);
}

function draw() {
  frameRate(fr);
  if (timer > 0){
    timer--;
  }
  if (invertimer > 0){
    invertimer--;
  }
  sound.onended(stopSong);
  let spectrum = fft.analyze();
    for (i = 0; i < spectrum.length; i++) {
      var amp = spectrum[i];
      if ((amp > 235) && (timer == 0)){
         scaleUpdate();
       }
      if ((amp > 246) && (invertimer == 0)){
        invertimer = 40;
        if (invert == 1){
          invert = 0;
          document.body.classList.remove("inverted");
        }
        else{
          invert = 1;
          document.body.classList.add("inverted");
        }
      }
    }
  if (invert == 0){
    background("#fdfdfd");
  }
  else{
    background("#111");
  }
  camera.loadPixels();
  loadPixels();
  for (let y = 0; y < camera.height; y++) {
    for (let x = 0; x < camera.width; x++) {
      let index = (x + y * camera.width) * 4;
      let r = camera.pixels[index + 0];
      let g = camera.pixels[index + 1];
      let b = camera.pixels[index + 2];
      let rgbTotal = (r + g + b)/3;

      if (invert == 0){
          r = 230;
          g = 230;
          b = 230;
        
        if ((rgbTotal > 95) && (rgbTotal < 120)){
          //yellow
          r = 255;
          g = 221;
          b = 34;
        }
        if ((rgbTotal > 80) && (rgbTotal < 95)){
          //red
          r = 194;
          g = 15;
          b = 0;
        }
        if ((rgbTotal > 70) && (rgbTotal < 80)){
          //blue
          r = 35;
          g = 116;
          b = 198;
        }
        if (rgbTotal < 70){
          r = 15;
          g = 15;
          b = 15;
        }
      }
      if (invert == 1){
          r = 15;
          g = 15;
          b = 15;
        if ((rgbTotal > 95) && (rgbTotal < 120)){
          r = 35;
          g = 116;
          b = 198;
        }
        if ((rgbTotal > 80) && (rgbTotal < 95)){
          r = 255;
          g = 221;
          b = 34;
        }
        if ((rgbTotal > 70) && (rgbTotal < 80)){
          r = 194;
          g = 15;
          b = 0;
        }
        if (rgbTotal < 70){
          r = 230;
          g = 230;
          b = 230;
        }
      }
      if (rgbTotal < 150){
      noStroke();
      fill(r - 15, g - 15, b - 15);
      quad((x * vidWidth) / totalSize - shiftSize, (y * vidHeight - 4) / totalSize,
           (x * vidWidth + 10.5) / totalSize - shiftSize, (y * vidHeight) / totalSize,
           (x * vidWidth + 10.5) / totalSize - shiftSize, (y * vidHeight + vidHeight + 4) / totalSize,
           (x * vidWidth) / totalSize - shiftSize, (y * vidHeight + vidHeight - 4) / totalSize);
      fill(r + 25, g + 25, b + 25);
      quad((x * vidWidth) / totalSize - shiftSize, (y * vidHeight - 4) / totalSize,
           (x * vidWidth + 42) / totalSize - shiftSize, (y * vidHeight - 4) / totalSize,
           (x * vidWidth + 55) / totalSize - shiftSize, (y * vidHeight + 4.75) / totalSize,
           (x * vidWidth + 10) / totalSize - shiftSize, (y * vidHeight + 4.75) / totalSize);
	  fill(r, g, b);
      rect((x * vidWidth + 10) / totalSize - shiftSize, (y * vidHeight + 4) / totalSize, (vidWidth - 10) / totalSize, (vidHeight) / totalSize);
      fill(r + 10, g + 10, b + 10);
      ellipse((x * vidWidth + 10) / totalSize - shiftSize, (y * vidHeight - 3.5) / totalSize, 10 / totalSize, 6 / totalSize);
      ellipse((x * vidWidth + 38) / totalSize - shiftSize, (y * vidHeight - 3.5) / totalSize, 10 / totalSize, 6 / totalSize);
      fill(r - 20, g - 20, b - 20);
      ellipse((x * vidWidth + 10) / totalSize - shiftSize,(y * vidHeight - 4.5) / totalSize, 9 / totalSize, 3 / totalSize);
      ellipse((x * vidWidth + 38) / totalSize - shiftSize, (y * vidHeight - 4.5) / totalSize, 9 / totalSize, 3 / totalSize);
      fill(r + 10, g + 10, b + 10);
      ellipse((x * vidWidth + 16) / totalSize - shiftSize, (y * vidHeight) / totalSize, 10 / totalSize, 6 / totalSize);
      ellipse((x * vidWidth + 45) / totalSize - shiftSize, (y * vidHeight) / totalSize, 10 / totalSize, 6 / totalSize);
      fill(r - 20, g - 20, b - 20);
      ellipse((x * vidWidth + 16) / totalSize - shiftSize, (y * vidHeight - 1) / totalSize, 9 / totalSize, 3 / totalSize);
      ellipse((x * vidWidth + 45) / totalSize - shiftSize, (y * vidHeight - 1) / totalSize, 9 / totalSize, 3 / totalSize);
      }
    }
  }

}


              
            
!
999px

Console