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

              
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 210.33 125.85">
  <path d="M155,87.87l-3.77.89L148,90.86l-2.46,2.82-.9,3.77-1.5,3.23-3.59,5.81L136.71,112,135,116.52l-.54,2.07-.42,1.89,1,1.89,2.09-.76L139.4,119m-8.51-18.11-3.59-2.09-1.14-4.14,1.33-4.91,5.26-4L138.62,83l5.63-1.73,7.55-.9,10.42.54,6.95,2.63,3.77,3.24.42,4.31L171.27,96l-3.42,3.78L163.12,102,155,104.64,147.31,106l-4.56.77-5.09-.59" fill="none" stroke="#010101" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.56"/>
  <path d="M76.19,102.72v-.36l3-9.4,5.86-6.41,8.87-4.91,6.59-2.1,6.4.18,6,1,5.1,4.13,2.45,6,.78,4.31-1,7.79-2.81,7.55L112,117.65l-5.63,4.72L100.71,125l-9.41.56-6.59-3.2-3.77-7.73.72-10,3.23-6.23,5.09-6,5.09-2.64,4-1.85h2.45l2.64.35" fill="none" stroke="#010101" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.56"/>
  <path d="M65.84,87.87l-3.77.89-3.24,2.1-2.45,2.82-.9,3.77L54,100.68l-3.59,5.81L47.51,112l-1.67,4.51-.54,2.07-.42,1.89,1,1.89,2.09-.76L50.21,119M41.7,100.86l-3.59-2.09L37,94.63l1.32-4.91,5.27-4L49.43,83l5.63-1.73,7.55-.9L73,80.86l7,2.63,3.77,3.24L84.17,91,82.08,96l-3.42,3.78L73.93,102l-8.09,2.64L58.12,106l-4.56.77-5.09-.59" fill="none" stroke="#010101" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.56"/>
  <path d="M192.71,32.92l3-2.45,2.08-2.22,3.38-4.55,4.37-7.19,2-3.17-2-.42L195.17,34.84l-.95,5.09,1.51,2.64,4.72-.38,5.65-4.89,4-4.38m-12.25-9.76,12.25-.6" fill="none" stroke="#010101" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.56"/>
  <path d="M177.8,32.92,182,29.75l1.32-5.51-5.85,14.55,1.13,3.78,4.34.94,4.7-3.77,3.06-3.58,2-3.24m-5.63-17.55-1.7,2.28" fill="none" stroke="#010101" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.56"/>
  <path d="M140.28,33.7l4.9-2.45L149.32,29l2.09-3.41-.78-2.64-3.53-.36-7,4.14-2.82,2.09-3,3.6-1.89,3.17-.38,3,1.32,2.64,4.91,2.08,8.29-2.08L149.14,39l3.77-3.18,2.28-2.88" fill="none" stroke="#010101" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.56"/>
  <path d="M113.11,32.92l3.77-4.13,4-5.09m-1.5-1.14h5.12l6.77-4.31,6.59-6.83,3.41-5.09L142,2.2,139.31.28,134,2.2l-4.13,4.73-4,7.13-3.42,6.23-6.41,15.27-2.27,7.57,2.64-2.45,5.26-7.16,6-6.65,4.55-3.53,3-.18m-12,5.81,2.82,12.27L130.45,49l6.23,3.77h3.95l1.74-1.68.18-1.13-.18-2.09" fill="none" stroke="#010101" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.56"/>
  <path d="M113.14,32.92,110.86,36l-3,3.19L103.31,42l-3.59.75L98,40.11l.72-4.73,2.46-7.91-1.14,1.86L94,35.2l-6.39,5.29-5.29,2.26-2.64-2.82.38-5.27,5.47-6.41,6.79-4.19,4.91-1.5h4.92l.71.78" fill="none" stroke="#010101" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.56"/>
  <path d="M16,11.78l4.67-2,2.46-2.09,2.1-2.46,1.67-2.81L28.18,2,24.41,12.2,19.73,25,14.82,35l-4.55,7.73L6.32,46.34,2.54,47.47.28,44.83l1.13-3.77L8.2,32.74l9.26-10.18L29.32,11.42l7.37-4.31L41.42,6l4.31,1.68,2.1,5.51L46.87,25l-1.14,7.55-2,6.79,1.5-.38L49.5,32,60.11,16.15l4.51-6.41,4.15-3,3,.42,1.13,1.5.76,3-2.26,6.65-2.27,4.67L66.5,28.61,65.19,33.1v4.74l2.26,4.73,5.85-1,6.23-5.46,2.07-3.24" fill="none" stroke="#010101" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.56"/>
</svg>


<script type="x-shader/x-vertex" id="vertexshader">
  attribute float size;
  attribute vec3 customColor;
  varying vec3 vColor;

  void main() {
    vColor = customColor;
    vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
    gl_PointSize = size * ( 300.0 / -mvPosition.z );
    gl_Position = projectionMatrix * mvPosition;
  }
</script>

<script type="x-shader/x-fragment" id="fragmentshader">
  uniform vec3 color;

  varying vec3 vColor;
  varying float vOpacity;

  void main() {
    float strength = distance(gl_PointCoord, vec2(0.5));
    if (strength > 0.4) discard;
    strength = step(0.4, strength);
    strength = 1.0 - strength;
    gl_FragColor = vec4(vColor * strength, strength);
  }
</script>
              
            
!

CSS

              
                body {
  margin: 0;
  overflow: hidden;
  background: black;
}
canvas {
  position: absolute;
  filter: drop-shadow(2px 4px 6px rgba(255,255,255,0.3));
}
svg {
  position: absolute;
  display: none;
}
              
            
!

JS

              
                console.clear();

/* SETUP */
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
  75,
  window.innerWidth / window.innerHeight,
  0.1,
  2000
);
camera.position.z = 180;

const renderer = new THREE.WebGLRenderer({
  antialias: true,
  alpha: true
});
renderer.setPixelRatio(window.devicePixelRatio > 1 ? 2 : 1);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

/* CONTROLS */
const controlsWebGL = new THREE.OrbitControls(camera, renderer.domElement);

/* PARTICLES */
const gradient = chroma.scale(["ef476f","ffd166","06d6a0","118ab2","073b4c"]);

const paths = document.querySelectorAll("path");
const vertices = [];
let colors = [];
let sizes = [];
const tl = gsap.timeline({
  onReverseComplete: () => {
    tl.timeScale(1);
    tl.play(0);
  },
  onComplete: () => {
    tl.timeScale(1.3);
    tl.reverse(0);
  }
});
let delay = 0;
const lineMaterial = new THREE.LineBasicMaterial({
  color: 0xffffff
});
let totalLength = 0;
[...paths].forEach(p => totalLength += p.getTotalLength());
[...paths].reverse().forEach((path) => {
  const length = path.getTotalLength();
  for (let i = 0; i < length; i += 0.2) {
    const pointLength = i;
    const point = path.getPointAtLength(pointLength);
    const vector = new THREE.Vector3(
      point.x - 210.33 / 2,
      -point.y + 125.85 / 2,
      (Math.random() - 0.5) * 15
    );
    const end = new THREE.Vector3(
      vector.x + (Math.random() - 0.5) * 80,
      vector.y + (Math.random() - 0.5) * 80,
      vector.z + (Math.random() - 0.5) * 80
    );
    let coloursX = point.x / 210.33 + (Math.random() - 0.5) * 0.2;
    coloursX = end.distanceTo(new THREE.Vector3()) / 200;
    coloursX = (delay + pointLength) / totalLength;
    const color = gradient(coloursX).rgb();
    vector.opacity = 1;
    vertices.push(vector);
    vector.r = 1 - (vector.z + 7.5) / 15;
    vector.g = 1 - (vector.z + 7.5) / 15;
    vector.b = 1 - (vector.z + 7.5) / 15;
    tl.to(
      vector,
      {
        x: end.x,
        y: end.y,
        z: end.z,
        r: color[0] / 255,
        g: color[1] / 255,
        b: color[2] / 255,
        duration: 'random(0.5, 2)',
        ease: 'power2.out'
      },
      (delay + pointLength) * 0.0012 + 1.2
    );
    sizes.push((Math.random() * 6 + 2) * renderer.getPixelRatio());
  }
  delay += length;
});
const geometry = new THREE.BufferGeometry().setFromPoints(vertices);
geometry.setAttribute(
  "customColor",
  new THREE.Float32BufferAttribute(colors, 3)
);
geometry.setAttribute("size", new THREE.Float32BufferAttribute(sizes, 1));

let material = new THREE.ShaderMaterial({
  uniforms: {
    pointTexture: {
      value: new THREE.TextureLoader().load(
        "https://assets.codepen.io/127738/dotTexture.png"
      )
    }
  },
  vertexShader: document.getElementById("vertexshader").textContent,
  fragmentShader: document.getElementById("fragmentshader").textContent,
  transparent: true
});
const particles = new THREE.Points(geometry, material);
scene.add(particles);

/* RENDERING */
function render() {
  requestAnimationFrame(render);
  
  geometry.setFromPoints(vertices);
  
  let colours = [];
  vertices.forEach(v => {
    colours.push(v.r, v.g, v.b);
  });
  geometry.setAttribute("customColor", new THREE.Float32BufferAttribute(colours, 3));

  renderer.render(scene, camera);
}

/* EVENTS */
function onWindowResize() {
  camera.aspect = window.innerWidth / window.innerHeight;
  camera.updateProjectionMatrix();
  renderer.setSize(window.innerWidth, window.innerHeight);
}
function onMouseMove(e) {
  const x = (e.clientX - window.innerWidth / 2) / (window.innerWidth / 2);
  const y = (e.clientY - window.innerHeight / 2) / (window.innerHeight / 2);
  gsap.to(particles.rotation, {
    x: y * 0.2,
    y: x * 0.2,
    ease: 'power2.out',
    duration: 2
  });
}
window.addEventListener('resize', onWindowResize, false);
window.addEventListener('mousemove', onMouseMove, false);

requestAnimationFrame(render);

              
            
!
999px

Console