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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <canvas id="canvas"></canvas>

<!-- Pulled from https://codepen.io/mullany/pen/kkYNNQ cause awesome :D -->
<div class="title__container">
  <svg width="1000px" height="400px" viewBox="50 -50 1000 300" color-interpolation-filters="sRGB" class="title__svg">
    <defs>
      <filter id="strangify">
         <!--Composite the original with a variable opacity cloud texture -->
        <feTurbulence type="fractalNoise" baseFrequency=".013" numOctaves="1" seed="46"/>
        <feColorMatrix type="matrix" values="0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.1 0"/>
        <feComposite operator="in" in="SourceGraphic" result="intermediate-1"/>

        <!--Boost the contrast of the alpha channel and blur the resulting "highlights" -->
        <feComponentTransfer>
          <feFuncA type="table" tableValues="0 0 0 0 1 1 1"/>
        </feComponentTransfer>
         <feGaussianBlur stdDeviation="4"/>
        <!--Increase the blur's intensity by boosting the post-blur alpha channel -->

           <!--Combine the flickering highlights with the intermediate result -->
        <feComposite operator="over" in2="intermediate-1"/>
      </filter>
    </defs>

    <g filter="url(#strangify)">
    <rect x="240" y="0" fill="none" stroke="#ed2b12" stroke-width="1.5" width="563" height="6"/>
    <rect x="245" y="160" fill="none" stroke="#ed2b12" stroke-width="1.5" width="50" height="6"/>
    <rect x="712" y="160" fill="none" stroke="#ed2b12" stroke-width="1.5" width="80" height="6"/>
    <text font-family="ITC Benguiat W01"  x="240" y="110" stroke="#ed2b12" fill="none" font-size="8rem" font-weight="800" stroke-width="2">
      <tspan font-size="11rem" dy="31">P</tspan>
      <tspan font-size="8rem" dy="-31" dx="-45,0,0,0,-8,0">ARTICL</tspan>
      <tspan font-size="11rem" dy="31" dx="-40">E</tspan>
      <tspan font-size="7.5rem" dx="-520" dy="80">T</tspan>
      <tspan font-size="7.5rem" dx="-35,0,0,-8,0,0,0" dy="0">HINGS</tspan>
    </text>
    </g>

  </svg>
</div>
              
            
!

CSS

              
                body { 
  background-image: linear-gradient(to top, hsl(204, 80%, 15%) 35%, hsl(192, 84%, 32%) 42.5%, hsl(193, 71%, 41%) 50%, hsl(189, 95%, 56%) 100%);
  overflow: hidden;
}

canvas {
  max-width: 100%;
  max-height: 100%;
}

.title__svg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  margin: auto;
}

              
            
!

JS

              
                //Particle effect for trees to resemble Stranger Things forest view
const canvas = document.getElementById("canvas");
const context = canvas.getContext("2d");

//Setting up the array for trees
let treeArray = [];
let dustArray = [];

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

window.addEventListener("resize", function() {
  canvas.height = window.innerHeight;
  canvas.width = window.innerWidth;
});

class Tree {
  constructor() {
    this.width = parseInt(Math.random() * 100 + 10);
    this.height = canvas.height;
    this.positionX = parseInt(Math.random() * canvas.width - 200 + 200);
  }
}

class Dust {
  constructor() {
    this.width = parseInt(Math.random() * 5 + 1);
    this.positionX = parseInt(Math.random() * canvas.width * 0.9);
    this.positionY = parseInt(Math.random() * canvas.height * 0.7);
    this.opacity = 0;
  }
}

let createObject = (objectArray, ParticleObject, particleMax) => {
  for (let i = 0; i < particleMax; i++) {
    let particleObject = new ParticleObject();
    objectArray.push(particleObject);
  }

  //Sort the array by width so the smaller trees appear in the background :D
  objectArray.sort((a, b) =>  a.width - b.width);
};

let drawTree = treeObject => {
  context.beginPath();

  //Base color for the trunk
  let baseGradient = context.createLinearGradient(
    treeObject.positionX,
    0,
    treeObject.positionX + treeObject.width,
    2
  );
  baseGradient.addColorStop(0.5, "hsl(204, 80%, 10%)");
  baseGradient.addColorStop(0.9, "hsl(204, 95%, 15%)");
  baseGradient.addColorStop(1, "hsl(204, 90%, 12.5%)");

  //Check for the inverse and get the absolute value so thinner trees have less saturation
  let depthOverlay = Math.abs(treeObject.width / 100 - 1).toFixed(2);
  treeObject.height = parseInt(
    canvas.height * (treeObject.width / 100) + canvas.height * 0.6
  );

  //Bottom shadow of tree
  let overlayGradient = context.createLinearGradient(0, canvas.height, 0, 20);
  overlayGradient.addColorStop(0.2, "hsla(204, 80%, 15%, 1)");
  overlayGradient.addColorStop(
    0.9,
    "hsla(204, 10%, " + 30 * depthOverlay + "%, " + depthOverlay + ")"
  );

  context.fillStyle = baseGradient;
  context.fillRect(
    treeObject.positionX,
    0,
    treeObject.width,
    treeObject.height
  );
  context.fillStyle = overlayGradient;
  context.fillRect(
    treeObject.positionX,
    0,
    treeObject.width,
    treeObject.height
  );

  context.closePath();
  moveTree(treeObject);
};

let drawDust = dustObject => {
  context.save();
  //Running this before it's draw to determine opacity
  moveDust(dustObject);

  context.beginPath();
  context.arc(
    dustObject.positionX,
    dustObject.positionY,
    dustObject.width,
    0,
    2 * Math.PI
  );
  context.fillStyle = "rgba(255, 255, 255, " + dustObject.opacity + ")";
  context.shadowBlur = 10;
  context.shadowColor = "white";
  context.fill();

  context.closePath();
  context.restore();
};

let moveTree = treeObject => {
  treeObject.positionX += parseInt(treeObject.width / 150 * 3 + 1);
  if (treeObject.positionX > canvas.width) {
    treeObject.positionX = 0 - treeObject.width;
  }
};

let moveDust = dustObject => {
  dustObject.positionX += parseInt(dustObject.width / 4 * 3 + 1);
  dustObject.positionY += -1;

  if (dustObject.positionX > canvas.width)
    dustObject.positionX = 0 - dustObject.width;
  if (dustObject.positionY < 0) {
    dustObject.positionY = canvas.height - dustObject.width;
    dustObject.opacity = 0;
  } else if (dustObject.positionY > 0 && dustObject.opacity < 1.0) {
    dustObject.opacity += 0.005;
  }
};

let drawStage = () => {
  context.clearRect(0, 0, canvas.width, canvas.height);

  for (let i = 0, n = dustArray.length, m = 0; i < n; i++) {
    if (i % 6 == 0) {
      drawTree(treeArray[m]);
      m++;
    }
    drawDust(dustArray[i]);
  }

  requestAnimationFrame(drawStage);
};

let init = () => {
  createObject(treeArray, Tree, 15);
  createObject(dustArray, Dust, 90);
  drawStage();
};

//Run the things
init();
              
            
!
999px

Console