css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <!--my first shot: https://dribbble.com/shots/2875904-Hello-Dribbble-->
<div class="loading">
     <div class="bubble-1"></div>
     <div class="bubble-2"></div>
</div>

<canvas id="canvas3"></canvas>
<canvas id="canvas2"></canvas>
<canvas id="canvas1"></canvas>

            
          
!
            
              *{
  margin: 0;
  padding: 0
}

/*loading*/
.loading {
    position: absolute;
    top: calc(50% - 22px);
    left: calc(50% - 22px);
    width: 45px;
    height: 50px;
    margin: 0 auto;
    z-index: 100;
}

.loading-done{
  display: none;
}

.bubble-1,
.bubble-2 {
    position: absolute;
    top: 0;
    width: 25px;
    height: 25px;
    border-radius: 100%;
    background-color: #fff;
}

.bubble-2 {
    top: auto;
    bottom: 0;
}

.loading {
  animation: loading 2s linear infinite;
}
.bubble-1, .bubble-2 {
  animation: bounce 2s ease-in-out infinite;
}
.bubble-2 {
  animation-delay: -1.0s;
}

@keyframes loading {
    100% {transform: rotate(360deg);}
}

@keyframes bounce  {
  0%, 100% {transform: scale(0.0);}
  50% {transform: scale(1.0);}
}


/*canvas*/

#canvas3{
  background: #ffb200;
}

canvas{
  position: absolute;
}
            
          
!
            
              window.onload = function(){
  
  helloImage.src = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/593507/hello2.png" + "?" + new Date().getTime();
  helloImage.crossOrigin = "Anonymous";
  
  logoImage.src = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/593507/logo.png" + "?" + new Date().getTime();
  logoImage.crossOrigin = "Anonymous";
  
  var loaderImage = function(n, callback){
    var count = 0;
    return function(){
      count++;
      if(count >= n) callback();
    }
  }
  
  var loader = loaderImage(2, function(){
    var loading = document.querySelector(".loading");
    loading.classList.add("loading-done");
    setHelloPixel();
    setLogoPixel();
    draw();
  });
  
  helloImage.onload = loader;
  logoImage.onload = loader;
}

const canvas1 = document.getElementById("canvas1"),
    context1 = canvas1.getContext("2d"),
    canvas2 = document.getElementById("canvas2"),
    context2 = canvas2.getContext("2d"),
    canvas3 = document.getElementById("canvas3"),
    context3 = canvas3.getContext("2d"),
    canvasBg = document.createElement("canvas"),
    contextBg = canvasBg.getContext("2d"),
    width = canvasBg.width = canvas1.width = canvas2.width = canvas3.width = window.innerWidth * 2,
    height = canvasBg.height = canvas1.height = canvas2.height = canvas3.height = window.innerHeight * 2,
    density1 = 8,
    density2 = 6,
    baseColor1 = "#ffb200",
    baseColor2 = "#ff435e",
    fontColor1 = "#f8f3d4",
    fontColor2 = fontColor1;

var bgBalls = [],
    helloPixels = [],
    logoPixels = [],
    hello = {},
    logo = {},
    helloImage = new Image(),
    logoImage = new Image();

canvas1.style.width = canvas2.style.width = canvas3.style.width = window.innerWidth + "px";
canvas1.style.height = canvas2.style.height = canvas3.style.height = window.innerHeight + "px";

class BgAnimBall{
  constructor(){
    this.x = width / 2;
    this.y = height / 2;
    this.r = 32;
    this.diffR = 2 +  .8 * Math.random();
    this.angle = Math.PI * 2 * Math.random();
    this.vx = Math.cos(this.angle) * 5.5;
    this.vy = Math.sin(this.angle) * 5.5;
    this.ax = this.vx * .12;
    this.ay = this.vy * .12;
  }
  
  update(){
    this.diffR += .1 + .3 * Math.random();
    this.r += this.diffR;
    
    this.vx += this.ax;
    this.vy += this.ay;
    this.x += this.vx;
    this.y += this.vy;
  }
}

class helloPixel{
  constructor(x, y){
    this.x = this.originX = x;
    this.y = this.originY = y;
    this.r = this.originR = 7 + 2 * Math.random();
    this.vy = this.originVy = 2.2 + 4 * Math.random();
    this.vx = this.originVx = -2 + 4 * Math.random();
    this.ay = this.originAy = .1 + Math.random();
  }
  
  update(){
    this.vy += this.ay;
    this.y -= this.vy;
    this.x += this.vx;
  }
}

class logoPixel{
  constructor(x, y){
    this.x = this.originX = x;
    this.y = this.originY = y;
    this.r = this.originR = 2 + 4 * Math.random();
    this.ay = this.originAy = .1 + 1.1 * Math.random();
    this.vy = this.originVy = 2.2 + 5.5 * Math.random();
    this.vx = this.originVx = -2 + 4 * Math.random();
  }
  
  update(){
    this.vy += this.ay;
    this.y -= this.vy;
    this.x += this.vx;
  }
}


function setHelloPixel(){
  hello.w_Min = width / 2 - helloImage.width / 2
  hello.w_Max = hello.w_Min + helloImage.width;
  contextBg.drawImage(helloImage, hello.w_Min, 0);
  
  var imageData = contextBg.getImageData(0, 0, width, height);
  var buffer32 = new Uint32Array(imageData.data.buffer); 
  
  for(var h = 0; h < height; h += density1){
    if((h / density1) % 2 === 0){
      for(var w = 0; w < width; w += density1){
        if(buffer32[w + h * width]) helloPixels.push(new helloPixel(w, h));
      }
    } else {
      for(var w = density1 / 2; w < width; w += density1){
        if(buffer32[w + h * width]) helloPixels.push(new helloPixel(w, h));
     }
   }
}
  
  hello.h_Max = Math.max.apply(null, helloPixels.map(function(o){
    return o.y;
  }));

  hello.h_Min = Math.min.apply(null, helloPixels.map(function(o){
    return o.y;
  }));
  
  hello.textHeight = hello.h_Max - hello.h_Min;
  hello.textWidth = hello.w_Max - hello.w_Min;
  
  hello.heightAdj = hello.h_Min - (height - hello.textHeight) / 2;
  
  hello.h_Max -= hello.heightAdj;
  hello.h_Min -= hello.heightAdj;
  
  for(var i = 0, len = helloPixels.length; i < len; i++){
    var p = helloPixels[i];
    p.y -= hello.heightAdj;
    p.originY = p.y;
  }
  
}

function setLogoPixel(){
  contextBg.clearRect(0, 0, width, height);
  logo.textHeight = 280;
  logo.textWidth = logoImage.width * logo.textHeight / logoImage.height;
  contextBg.drawImage(logoImage, (width - logo.textWidth) / 2 , (height - logo.textHeight) / 2, logo.textWidth, logo.textHeight);
  
  
  var imageData = contextBg.getImageData(0, 0, width, height);
  var buffer32 = new Uint32Array(imageData.data.buffer); 
  
  for(var h = 0; h < height; h += density2){
    if((h / density2) % 2 === 0){
      for(var w = 0; w < width; w += density2){
        if(buffer32[w + h * width]) logoPixels.push(new logoPixel(w, h));
      }
    } else {
      for(var w = density2 / 2; w < width; w += density2){
        if(buffer32[w + h * width]) logoPixels.push(new logoPixel(w, h));
     }
   }
}
  
  logo.h_Max = Math.max.apply(null, logoPixels.map(function(o){
    return o.y;
  }));

  logo.h_Min = Math.min.apply(null, logoPixels.map(function(o){
    return o.y;
  }));
  
  logo.w_Max = Math.max.apply(null, logoPixels.map(function(o){
    return o.x;
  }));

  logo.w_Min = Math.min.apply(null, logoPixels.map(function(o){
    return o.x;
  }));
  
  logo.textHeight = logo.h_Max - logo.h_Min;
  logo.textWidth = logo.w_Max - logo.w_Min;
  
  logo.heightAdj = logo.h_Min - (height - logo.textHeight) / 2;
  
  logo.h_Max -= logo.heightAdj;
  logo.h_Min -= logo.heightAdj;
  
  //adjust height
  logoPixels.map(function(o){
    return o.y -= logo.heightAdj;
  });
  
  contextBg.clearRect(0, 0, width, height);
}

function draw(){
  context1.fillStyle = fontColor1;
  for(var i = 0; i < helloPixels.length; i++){
    var p = helloPixels[i];
    
    context1.beginPath();
    context1.arc(p.x, p.y, p.r, 0, Math.PI * 2, false);
    context1.fill();
  }
  
 tweenSet();
}

function tweenSet(){

  var fontMotion1 = mojs.easing.path('M0,100C0,100,1.6,0,14.1,0C26,0,16.6,100,27.3,100C38.2,100,31.4,0,44.6,0C56.6,0,49,100,58.9,100c9.6,0,6.5-100,17.6-100C87.4,0,83.8,100,91,100c8.3,0,9-100,9-100');
  
  var scaleEasing1 = mojs.easing.path("M0,100c0,0,10.7,67.3,27.3-50C48.7-101.3,60.8,0,60.8,0s1.9,18,7,17.7C73,17.4,74.8,0,74.8,0s2.2-16.3,5-16c2.9,0.3,2.4,23.2,6,23.4C88.1,7.4,89.3,0,89.3,0H100");
  
  var pRadius = mojs.easing.path("M0,100c0,0,0.9,97.8,11.1,97.8c8.2,0,1.9-140.8,24.2-172.1C55.2-2.3,100,0,100,0");
  
  var logoR = mojs.easing.path("M0,100c0,0,20.2,52.9,41.6-10.9C62.6,26,77.5,0,100,0");
  
  var scaleP = mojs.easing.path("M0,100c0,0,5.9-6.3,13.4-6.3s6.9,11.8,16.4,11.8c9.9,0,18.4-55.5,18.4-55.5S58-16.4,67.6-16.4C86.6-16.4,100,0,100,0");
  
  var bgR1 = mojs.easing.path("M0,100c0,0,50-0.3,58.6-5.7C74.7,84.6,74.1,7,83.2,0C102-14.4,100,0,100,0");
  
  var maxR = Math.sqrt(width * width / 4 + height * height / 4);
  
  var tween1 = new mojs.Tween({
   delay: 400,
   duration: 1000,
   onUpdate: function(progress){
     var progressY = fontMotion1(progress);
     var progressX = mojs.easing.cubic.in(progress);
     var progressBgR = bgR1(progress) * maxR;
     var motionOrigin = {};
     
     var progressScale = scaleEasing1(progress);
     var scale1 = 1 + progressScale * .4;
 
     context1.clearRect(0, 0, width, height);
     context2.clearRect(0, 0, width, height);
     context3.clearRect(0, 0, width, height);
     context1.save();
     
     //background
     bgBalls.push(new BgAnimBall(), new BgAnimBall());
     context3.fillStyle = baseColor2;
     
     for(var i = 0, len = bgBalls.length; i < len; i++){
       var b = bgBalls[i];
       b.update();
       context3.beginPath();
       context3.arc(b.x, b.y, b.r, 0, Math.PI * 2, false);
       context3.fill();
     }
     
     context3.beginPath();
     context3.arc(width / 2, height / 2, progressBgR, 0, Math.PI * 2, false);
     context3.fill();
     
     context1.translate(width / 2 - scale1 * width / 2, height / 2 - scale1 * height / 2);
     context1.scale(scale1, scale1);
     
     motionOrigin.x = hello.w_Min - 600 + (hello.textWidth + 1200) * progress;
     motionOrigin.y = hello.h_Min - 100 + (hello.textHeight + 200) * progressY;
     
     /* motion direction */
     // context1.beginPath();
     // context1.arc(motionOrigin.x, motionOrigin.y, 20, 0, Math.PI * 2, false);
     // context1.fill();
     
     for(var i = 0; i < helloPixels.length; i++){
       var p = helloPixels[i];
       var dist = Math.sqrt((motionOrigin.x - p.x) * (motionOrigin.x - p.x) + (motionOrigin.y - p.y) * (motionOrigin.y - p.y));
       
       var scaleParticle = (p.x > motionOrigin.x + 200) ? Math.max(Math.min(18 - dist / 35, 9 + Math.random() * 19), 1) : Math.max(Math.min(18 - dist / 35, 9 + Math.random() * 19), 4);
       
       context1.fillStyle = fontColor1;
      
       context1.beginPath();
       context1.arc(p.x, p.y, Math.max(scaleParticle * 2.4, p.r), 0, Math.PI * 2, false);
       context1.fill();
     }
     context1.restore();
   },
   onComplete: function(){
     bgBalls = [];
     var scale = 1.4;
     context1.save();
     context1.translate(width / 2 - scale * width / 2, height / 2 - scale * height / 2);
     context1.scale(scale, scale);
     context1.fillStyle = fontColor1;
     tween2.play();
     tween3.play();
   }
 }).play();

  var tween2 = new mojs.Tween({
    duration: 16000,
    speed: 8,
    onUpdate: function(progress){
      context1.clearRect(0, 0, width, height);
      
      var progressR = pRadius(progress);

      for(var i = 0; i < helloPixels.length; i++){
        var p = helloPixels[i];
        p.r = 12 - 13 * progressR;

        p.update();
        
        if(p.r > 0){
          context1.beginPath();
          context1.arc(p.x, p.y, p.r, 0, Math.PI * 2, false);
          context1.fill();
        }
      }
    },
    onComplete: function(){
      context1.restore();
    }
  });
  
  
  var tween3 = new mojs.Tween({
    delay: 190,
    duration: 700,
    onUpdate: function(progress){
      var progressY = fontMotion1(progress);
      var progressR = pRadius(progress);
      var progressScale = scaleEasing1(progress);
      
      var scale1 = 1.5 - progressScale * .25;
      var offsetR = 50 - 47 * progressR;
      
      var motionOriginY = logo.h_Min - 25 + (logo.textHeight + 50) * progressY;
      var motionOriginX = logo.w_Min + (logo.textWidth + 100) * progress;
      
      var dist = motionOriginX * motionOriginX + motionOriginY * motionOriginY;
      
      context2.clearRect(0, 0, width, height);
      context2.fillStyle = fontColor2;
      
      // context2.beginPath();
      // context2.arc(motionOriginX, motionOriginY, 10, 0, Math.PI * 2, false);
      // context2.fill();
      
      context2.save();
      context2.translate(width / 2 - scale1 * width / 2, height / 2 - scale1 * height / 2);
      context2.scale(scale1, scale1);
      
      
      for(var i = 0, len = logoPixels.length; i < len; i++){
        var p = logoPixels[i];
        
        if((p.x <= motionOriginX && p.y >= motionOriginY) || p.x * p.x + p.y * p.y  <= dist){
          context2.beginPath();
          context2.arc(p.x, p.y, p.r + offsetR, 0, Math.PI * 2, false);
          context2.fill();
        }
      }
      context2.restore();
    },
    onComplete: function(){
      context2.save();
      var scale = 1.25;
      context2.translate(width / 2 - scale * width / 2, height / 2 - scale * height / 2);
      context2.scale(scale, scale);
      
      for(var i = 0, len = logoPixels.length; i < len; i++){
        var p = logoPixels[i];
        p.r += 3;
      }
      tween3_5.play();
      tween4.play();
    }
  });
 
  var tween3_5 = new mojs.Tween({
    duration: 1000,
    onUpdate: function(progress){
      var progressBgR = bgR1(progress) * maxR;
      context3.clearRect(0, 0, width, height);
      
      context3.fillStyle = baseColor2;
      context3.fillRect(0, 0, width, height);
      
      bgBalls.push(new BgAnimBall(), new BgAnimBall());
      context3.fillStyle = baseColor1;
    
     for(var i = 0, len = bgBalls.length; i < len; i++){
       var b = bgBalls[i];
       b.update();
       context3.beginPath();
       context3.arc(b.x, b.y, b.r, 0, Math.PI * 2, false);
       context3.fill();
     }
     
     context3.beginPath();
     context3.arc(width / 2, height / 2, progressBgR, 0, Math.PI * 2, false);
     context3.fill();
      
    },
    onComplete: function(){
      bgBalls = [];
    }
  });
  
  var tween4 = new mojs.Tween({
    duration: 10000,
    speed: 6,
    delay: 1000,
    onUpdate: function(progress){
      var progressR = pRadius(progress * 1.1);
      context2.clearRect(0, 0, width, height);

      
      for(var i = 0; i < logoPixels.length; i++){
        var p = logoPixels[i];
        var r = p.r * 1.5 - p.r * 1.5 * progressR;
        if(r > 0){
          p.update();
          context2.beginPath();
          context2.arc(p.x, p.y, r, Math.PI * 2, false);
          context2.fill();
        }
      }
    },
    onComplete: function(){
      bgBalls = [];
      context2.restore();
      context3.clearRect(0, 0, width, height);
      context2.clearRect(0, 0, width, height);
      context1.clearRect(0, 0, width, height);
      for(var i = 0, len = helloPixels.length; i < len; i++){
        var p0 = helloPixels[i];
        p0.x = p0.originX;
        p0.y = p0.originY;
        p0.r = p0.originR;
        p0.vx = p0.originVx;
        p0.vy = p0.originVy;
        p0.ay = p0.originAy;
      }
      
      for(var i = 0, len = logoPixels.length; i < len; i++){
        var p1 = logoPixels[i];
        p1.x = p1.originX;
        p1.y = p1.originY;
        p1.r = p1.originR;
        p1.vx = p1.originVx;
        p1.vy = p1.originVy;
        p1.ay = p1.originAy;
      }
      draw();
    }
  });
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console