cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="container" style="display: none;">
  <canvas></canvas>
  <h1>Happy Holidays</h1>
</div>
            
          
!
            
              @import url("https://fonts.googleapis.com/css?family=Dancing+Script");

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: "Dancing Script", cursive;
  letter-spacing: 0;
  font-style: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: white;
  font-size: 72px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fbe9e7 0%, #fff3e0 100%);
}

h1 {
  padding: 24px;
  margin: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%) translateZ(80px);
}

canvas {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
}
.container {
  transform-style: preserve-3d;
  position: relative;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

* {
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

            
          
!
            
              const canvas = document.querySelector("canvas");
const container = document.querySelector(".container");

if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent) === false) {
  VanillaTilt.init(container, { speed: 2000 });
}

const imageSize = 60;
let lowest;

const resize = () => {
  const maxWidth = Math.floor((window.innerWidth - 56) / imageSize);
  const maxHeight = Math.floor((window.innerHeight - 56) / imageSize);

  lowest = maxWidth < maxHeight ? maxWidth : maxHeight;
  if (lowest > 10) lowest = 10;

  container.style.width = `${lowest * imageSize}px`;
  container.style.height = `${lowest * imageSize}px`;
  container.style.display = 'block';
  document.body.style.fontSize = `${lowest * imageSize / 10}px`;
};

const initialize = image => {
  const imageSize = 60;
  const pixelRatio = window.devicePixelRatio;
  resize();
  window.addEventListener("resize", resize);
  const columns = lowest * pixelRatio;
  const rows = lowest * pixelRatio;
  const multiplier = rows * rows;
  const duration = 0.6;
  const geometry = [{ x: 0, y: 0, z: 0 }];
  const pointSize = imageSize.toFixed(1);
  const step = 0.004;
  let forward = true;
  const offset = 0.5;
  const attributes = [
    {
      name: "aPositionStart",
      data: i => [0, -1.2, 0]
    },
    {
      name: "aControlPointOne",
      data: (i, total) => [0, 0, 0]
    },
    {
      name: "aControlPointTwo",
      data: (i, total) => [getRandom(1), getRandom(1), getRandom(1)]
    },
    {
      name: "aPositionEnd",
      data: i => [
        1 - ((i % rows) / rows + 0.5 / rows) * 2,
        1 - (Math.floor(i / rows) / rows + 0.5 / rows) * 2,
        0
      ]
    },
    {
      name: "aOffset",
      data: i => [i * ((1 - duration) / (multiplier - 1))]
    }
  ];

  const uniforms = [
    {
      name: "uProgress",
      type: "float",
      value: 0.0
    }
  ];

  const vertexShader = `
    attribute vec3 aPositionStart;
    attribute vec3 aControlPointOne;
    attribute vec3 aControlPointTwo;
    attribute vec3 aPositionEnd;
    attribute float aOffset;
    attribute vec3 aColor;

    uniform float uProgress;
    uniform mat4 uMVP;

    vec3 bezier4(vec3 a, vec3 b, vec3 c, vec3 d, float t) {
      return mix(mix(mix(a, b, t), mix(b, c, t), t), mix(mix(b, c, t), mix(c, d, t), t), t);
    }

    float easeInOutQuint(float t){
      return t < 0.5 ? 16.0 * t * t * t * t * t : 1.0 + 16.0 * (--t) * t * t * t * t;
    }

    void main () {
      float tProgress = easeInOutQuint(min(1.0, max(0.0, (uProgress - aOffset)) / ${duration}));
      vec3 newPosition = bezier4(aPositionStart, aControlPointOne, aControlPointTwo, aPositionEnd, tProgress);
      gl_PointSize = ${pointSize};
      gl_Position = uMVP * vec4(newPosition, 1.0);
    }
  `;

  const fragmentShader = `
    precision mediump float;

    uniform sampler2D uSampler;

    void main() {
      gl_FragColor = texture2D(uSampler, gl_PointCoord);
    }
  `;

  const onSetup = gl => {
    texture = gl.createTexture();
    gl.bindTexture(gl.TEXTURE_2D, texture);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, image);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
    gl.bindTexture(gl.TEXTURE_2D, null);
  };

  const onRepeat = (gl, program) => {
    const uSampler = gl.getUniformLocation(program, "uSampler");
    gl.activeTexture(gl.TEXTURE0);
    gl.bindTexture(gl.TEXTURE_2D, texture);
    gl.uniform1i(uSampler, 0);

    if (uniforms[0].value > 1) {
      forward = false;
    } else if (uniforms[0].value < 0) {
      forward = true;
    }
    uniforms[0].value += forward ? step : -step;
  };

  const options = {
    onSetup,
    onRepeat,
    pixelRatio
  };

  starlings(
    canvas,
    geometry,
    multiplier,
    attributes,
    uniforms,
    vertexShader,
    fragmentShader,
    options
  );
};

const getRandom = value => Math.random() * value - value / 2;

const loadImage = callback => {
  const image = new Image();
  image.onload = () => {
    callback(image);
  };
  image.crossOrigin = "Anonymous";
  image.src = `https://use-the-platform.com/${Math.random() > 0.1 ? 1 : 2}.png`;
};

loadImage(initialize);

            
          
!
999px
Loading ..................

Console