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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <div class="container" id="container">
  <canvas class="canvas" id="canvas"></canvas>
  <div class="foreground"></div>
</div>
              
            
!

CSS

              
                body {
  height: 100vh;
  display: grid;
  place-items: center;
  background: #000;
}

.container {
  --color-1: rgb(90, 106, 142);
  --color-2: rgb(51, 63, 89);
  --color-3: rgb(100, 116, 152);
  --color-4: rgb(140, 160, 194);
  --color-5: rgb(199, 209, 222);
  position: relative;
  width: clamp(180px, 720px, 80vw);
  height: clamp(160px, 640px, 71vw);
  cursor: pointer;
  background: repeating-linear-gradient(
    var(--color-1) .5%,
    var(--color-2) 1%,
    var(--color-2) 1.5%,
    var(--color-3) 2%,
    var(--color-3) 2.5%,
    var(--color-4) 3%,
    var(--color-4) 3.5%,
    var(--color-5) 4%,
    var(--color-5) 5%
  );
  animation: move 1s infinite linear;
}

@keyframes move {
  to {
    background-position: 0% 4vh;
  }
}

.foreground {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  background: url(https://assets.codepen.io/25387/noctilucent-640-sm.png) no-repeat;
  background-size: 100% 100%;
  object-fit: contain;
}

.canvas {
  position: absolute;
  bottom: 0;
}
              
            
!

JS

              
                // https://codepen.io/pavlovsk/pen/MVVYZx
function getRandomWave(x, y) {
  return noise.simplex2(x, y)
}

var canvas = document.getElementById('canvas')
canvas.width = 720
canvas.height = 440
var ctx = canvas.getContext('2d')
var container = document.getElementById('container')
container.addEventListener('click', reset)
window.addEventListener('resize', _.debounce(() => {
  const dimensions = container.getBoundingClientRect()
  canvas.width = dimensions.width
  canvas.height = dimensions.height
  reset()
}, 300))

var noiseX, noiseY, difference, x, y, thickness, frequency, gap, wavelength, baseY

function reset() {
  noiseX = noiseY = 0
  x = y = 0
  difference = .0125
  thickness = 5 + Math.round(Math.random() * 5)
  frequency = Math.ceil(Math.random() * 3)
  gap = thickness + Math.round(Math.random() * 2)
  wavelength = 100
  baseY = -wavelength
  noise.seed(Math.random())
  draw(null, true)
}

function draw(ts, isFirst) {
  if (baseY < window.innerHeight + wavelength) {
    requestAnimationFrame(draw)
  }

  if (isFirst) {
    ctx.clearRect(0, 0, window.innerWidth, window.innerHeight)
  }

  x = 0
  baseY += gap
  noiseX = 0
  noiseY += difference

  while (x < window.innerWidth) {
    ctx.beginPath()
    ctx.moveTo(x, y + baseY)

    x += frequency

    y = getRandomWave(
      noiseX += .004,
      noiseY
    ) * wavelength

    ctx.lineTo(x, y + baseY)
    ctx.lineWidth = thickness
    ctx.lineCap = 'round'
    ctx.strokeStyle = 'black'
    ctx.stroke()
  }

}

const image = new Image()
image.src = 'https://assets.codepen.io/25387/noctilucent-640-sm.png'
image.onload = () => {
  reset()
}

              
            
!
999px

Console