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 mt-4 bg-darker">
  <svg class="border bg-darker" id="svg" viewBox="0 0 1000 700" version="1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

          <defs>
            <linearGradient id="line-gradient" x1="0" y1="0" x2="0" y2="-250" gradientUnits="userSpaceOnUse">
              <stop stop-color="#B9B075" offset="0%"/>
              <stop stop-color="#F44336" offset="25%"/>
              <stop stop-color="#9C27B0" offset="50%"/>
              <stop stop-color="#4CAF50" offset="75%"/>
              <stop stop-color="#2196F3" offset="100%"/>
            </linearGradient>
          </defs>

          <defs>
            <path id="window" d="M11 11H26V26H11z"/>
            <filter x="-110%" y="-110%" width="320%" height="320%" filterUnits="objectBoundingBox" id="filter-2">
              <feMorphology radius="2" operator="dilate" in="SourceAlpha" result="shadowSpreadOuter1"/>
              <feOffset in="shadowSpreadOuter1" result="shadowOffsetOuter1"/>
              <feGaussianBlur stdDeviation="4" in="shadowOffsetOuter1" result="shadowBlurOuter1"/>
              <feColorMatrix values="0 0 0 0 0.988235294   0 0 0 0 0.933333333   0 0 0 0 0.568627451  0 0 0 0.483214447 0" in="shadowBlurOuter1"/>
            </filter>
          </defs>
    
          <g id="moon" transform="translate(700, 50) scale(0.7)">
            <defs>
              <circle stroke="none" id="moon-circle" cx="132" cy="132" r="132"/>
            </defs>
            <mask id="moon-mask" fill="#fff">
              <use xlink:href="#moon-circle"/>
            </mask>
            <use id="Mask" stroke="none" fill="#F9F9FA" xlink:href="#moon-circle"/>
            <ellipse id="moon-bg"  fill="#2C3540" mask="url(#moon-mask)" cx="104" cy="115" rx="132" ry="135"/>
          </g>
          

          <g transform="translate(550, 100)">
            <path class="building" id="building-long" fill="#4D617B" fill-rule="evenodd" d="M83.9359452 47.2418612L93.1161245 47.2418612 93.1161245 34.9967116 64.0094672 34.9967116 64.0094672 12.2451496 67.6251385 12.2451496 67.6251385 0 34.4646994 0 34.4646994 12.2451496 37.4760802 12.2451496 37.4760802 34.9967116 8.97371336 34.9967116 8.97371336 47.2418612 16.6230235 47.2418612 16.6230235 71.7074975 0 71.7074975 0 600 100 600 100 71.7074975 83.9359452 71.7074975 83.9359452 47.2418612"/>
          </g>

          <g transform="scale(0.6) translate(600 400)">
            <g transform="translate(500 280)">
              <line class="wheel-line no-opacity" x1="0" y1="0" x2="0" y2="-250" stroke="url(#line-gradient)" stroke-width="2" />

              <circle class="wheel-circle" stroke="#5DE2F9" fill="none" cx="0" cy="0" r="100" ></circle>
              <circle class="wheel-circle" stroke="#5DE2F9" fill="none" cx="0" cy="0" r="175" ></circle>
              <circle class="wheel-circle" stroke="#5DE2F9" fill="none" cx="0" cy="0" r="240" ></circle>
              <circle class="wheel-circle" stroke="#537AAC" fill="none" cx="0" cy="0" r="250" stroke-width="4" ></circle>
            </g>
            
            <g transform="translate(395, 280)">
              <path class="wheel-base" stroke="#5DE2F9" stroke-width="2" d="M155 162L105 112 55 162 205 302 105 2 5 302 155 162 105 2 105 302" fill="none" fill-rule="evenodd" stroke-linejoin="bevel" />
            </g>

            <g transform="translate(480, 30)">
              <path class="wheel-cart no-opacity"  fill="#B9B075" d="M20,0 C31.045695,0 40,8.954305 40,20 L40,30 C40,41.045695 31.045695,50 20,50 C8.954305,50 0,41.045695 0,30 L0,20 C0,8.954305 8.954305,0 20,0 Z M37,27 L37,20 C37,10.6111593 29.3888407,3 20,3 C10.6111593,3 3,10.6111593 3,20 L3,27 L37,27 Z" fill="none" fill-rule="evenodd"/>
            </g>
          </g>

          <g transform="translate(900, 300)  scale(-1,1)">
            <path class="building" id="building-wide" fill="#31455F" fill-rule="evenodd" fill="#31455F"  d="M632.058757 0L505.469049 52.3460874 505.469049 262.095303 490.46078 262.095303 490.46078 143.718226 475.979117 143.718226 475.979117 134.061443 484.255002 134.061443 484.255002 129.235484 458.01096 129.235484 458.01096 120.25492 461.275009 120.25492 461.275009 115.428961 431.376504 115.428961 431.376504 120.25492 434.095788 120.25492 434.095788 129.235484 408.396511 129.235484 408.396511 134.061443 415.292325 134.061443 415.292325 143.718226 400.311294 143.718226 400.311294 283.33536 336.900678 283.33536 336.900678 252.852035 308.332306 252.852035 308.332306 244.143903 324.65709 244.143903 324.65709 239.794702 215.931126 239.789837 215.931126 135.316582 218.432504 135.316582 218.432504 129.274403 145.143487 129.274403 145.143487 135.316582 148.911443 135.316582 148.911443 274.35966 78.3008528 274.35966 78.3008528 277.803994 86.6130549 277.803994 86.6130549 284.697526 70.787639 284.697526 70.787639 75.0504731 73.2935569 75.0504731 73.2935569 69.0034297 0 69.0034297 0 75.0504731 3.76795616 75.0504731 3.76795616 400 695.641882 400 695.641882 266.322882 700 266.322882 700 262.095303 632.058757 262.095303 632.058757 0"/>
          </g>
          <g transform="translate(800, 200)">
            <path class="building" id="building-other" fill-rule="evenodd" fill="#39557A" d="M188.195241 20.4207855L194.941346 20.4207855 194.941346 15.1316421 173.552159 15.1316421 173.552159 5.28914339 176.209155 5.28914339 176.209155 0 151.841024 0 151.841024 5.28914339 154.053954 5.28914339 154.053954 15.1316421 133.108833 15.1316421 133.105133 20.4207855 138.729971 20.4207855 138.729971 31.0044041 126.514451 31.0044041 126.514451 217.617326 100.514377 217.617326 100.514377 70.0118366 104.066906 70.0118366 104.066906 63.9015963 0 63.9015963 0 70.0118366 5.34729675 70.0118366 5.34729675 500 200 500 200 31.0044041 188.195241 31.0044041 188.195241 20.4207855"/>
          </g>

          <g class="window no-opacity" transform="translate(555, 200)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(555, 215)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(605, 200)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(290, 370)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(340, 450)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(340, 465)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(420, 450)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(450, 490)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(690, 450)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(820, 300)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(820, 400)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(855, 350)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>
          <g class="window no-opacity" transform="translate(945, 225)">
            <use fill="#000" filter="url(#filter-2)" xlink:href="#window"/>
            <use fill="#D0BF52" xlink:href="#window"/>
          </g>


        </svg>
</div>
              
            
!

CSS

              
                $darker: #252B33;
$dark:   #3A4451;
$cyan:   #5DE2F9;
$pink:   #FF6EA8;

.bg-darker {
  background-color: $darker;
  background-image: radial-gradient(50% -1%, $dark 11%, $darker 100%);
}

.hidden {
  visibility: hidden;
}

.no-opacity {
  opacity: 0;
}
.scale-0 {
  transform: scale(0);
}

.border {
  border: 1px solid grey;
}

.main {
  min-height: 500px;
}

              
            
!

JS

              
                const themeColors = {
  darker: '#252B33',
  dark: '#3A4451',
  cyan: '#5DE2F9',
  pink: '#FF6EA8',
};

const colors = {
  yellow: '#FFEB3B',
  red: '#F44336',
  purple: '#9C27B0',
  green: '#4CAF50',
  blue: '#2196F3',
};

const SPIN_DURATION = 36;

const getCoord = (index, num) => {
  const angPI = index * 360 / num * Math.PI / 180;
  const x = Math.cos(angPI) * 250;
  const y = Math.sin(angPI) * 250 + 250;
  return { x, y };
};

const wheelScene = function() {
  let points = [];
  for (let index = 0; index < 360; index++) {
    points.push(getCoord(index, 360));
  }
  points = [...points.slice(270), ...points.slice(0, 270)];
  const tl = new TimelineMax();
  tl.add('wheel-start');
  tl.add(wheelCartScene(points), 'wheel-start');
  tl.add(wheelLinesScene(), 'wheel-start');
  tl.add(wheelCirclesScene(), '0.8-=wheel-start');
  tl.add(wheelBaseScene(), '0.8-=wheel-start');
  tl.add(spinCartsScene(points), 'wheel-spin');
  tl.add(spinLinesScene(), 'wheel-spin');
  return tl;
};

const wheelCartScene = function(points) {
  const numberOfCarts = 8;
  let colorsCycle = Object.values(colors);
  while (colorsCycle.length < numberOfCarts) {
    colorsCycle = [...colorsCycle, ...colorsCycle];
  }
  const $cart = $('.wheel-cart');
  // TweenMax.set($cart, { fill: colorsCycle[0] });
  for (let i = 1; i < numberOfCarts; i++) {
    $cart.clone().insertAfter($cart);
    // TweenMax.set($cart, { fill: colorsCycle[i] });
  }
  const mult = 360 / numberOfCarts;
  return TweenMax.staggerTo(
    '.wheel-cart',
    1,
    {
      opacity: 1,
      transformOrigin: 'center 230px',
      cycle: {
        bezier: function(index) {
          return {
            type: 'soft',
            values: points.slice(0, (index + 1) * mult),
          };
        },
      },
    },
    0.1
  );
};

const wheelLinesScene = function() {
  const numberOfWheels = 36;
  const $line = $('.wheel-line');
  for (let i = 0; i < numberOfWheels; i++) {
    $line.clone().insertAfter($line);
  }
  return TweenMax.staggerTo(
    '.wheel-line',
    1,
    {
      opacity: 1,
      transformOrigin: 'center bottom',
      cycle: {
        rotation: function(index) {
          const angle = index * 360 / numberOfWheels;
          return `${angle}__cw`;
        },
      },
    },
    0.01
  );
};

const wheelCirclesScene = function() {
  return TweenMax.staggerFrom(
    '.wheel-circle',
    1.5,
    {
      scale: '0',
      transformOrigin: 'center center',
      ease: Elastic.easeOut.config(0.5, 0.4),
    },
    0.2
  );
};

const wheelBaseScene = function() {
  return TweenMax.from('.wheel-base', 1, {
    scale: '0.3',
    opacity: 0,
    transformOrigin: 'center top',
  });
};

const spinCartsScene = function(points) {
  const tl = new TimelineMax();
  const numberOfCarts = $('.wheel-cart').length;
  const mult = 360 / numberOfCarts;
  tl.add('spin-start');
  $('.wheel-cart').each(function(index) {
    const pointsAdjusted = [
      ...points.slice((index + 1) * mult),
      ...points.slice(0, (index + 1) * mult),
    ];
    tl.to(
      $(this),
      SPIN_DURATION,
      {
        bezier: {
          type: 'thru',
          values: pointsAdjusted,
        },
        ease: Power0.easeNone,
        repeat: -1,
      },
      'spin-start'
    );
  });
  return tl;
};

const spinLinesScene = function() {
  return TweenMax.to('.wheel-line', SPIN_DURATION, {
    rotation: '+=360',
    modifiers: {
      rotation: angle => angle % 360,
    },
    transformOrigin: 'center bottom',
    ease: Power0.easeNone,
    repeat: -1,
  });
};

const buildingScene = function() {
  return TweenMax.from('.building', 3, {
    y: '100%',
  });
};
const windowsScene = function(delay) {
  TweenMax.set('.window', { delay, opacity: 1 });
  return TweenMax.staggerFrom(
    '.window',
    0.4,
    {
      scale: 0,
      ease: Back.easeOut.config(4),
    },
    0.075
  );
};

const moonScene = function() {
  const tl = new TimelineMax();
  tl.from(
    '#moon',
    2,
    {
      y: 300,
      opacity: 0,
    },
    'moon'
  );
  tl.from(
    '#moon-bg',
    2,
    {
      attr: {
        cx: 0,
        cy: 0,
      },
    },
    'moon'
  );
  return tl;
};

function createStars() {
  const numOfStars = 100;
  const s = Snap('#svg');
  const { x, y, width, height } = s.getBBox();
  for (let i = 0; i < numOfStars; i++) {
    const xpos = Math.floor(Math.random() * (width + x));
    const ypos = Math.floor(Math.random() * (height + y));
    const r = Math.floor(Math.random() * 3 + 1);
    const star = Snap().circle(xpos, ypos, r);
    star
      .attr({
        fill: '#B9B075',
        // opacity: 0.6,
      })
      .addClass('no-opacity')
      .addClass('star');
    s.prepend(star);
  }
}

function starsScene() {
  const tl = new TimelineMax();
  tl.to('.star', 0.75, { opacity: 0.6 }, 'star-start');
  $('.star').each(function() {
    tl.to(
      $(this),
      1,
      {
        opacity: 0,
        yoyo: true,
        repeat: -1,
        delay: Math.random() * 3,
      },
      'star-start'
    );
  });
  return tl;
}

$(document).ready(function() {
  createStars();
  const masterScene = new TimelineMax();
  // const building = buildingScene();
  // masterScene.add(building, 'building');
  masterScene.add(windowsScene(1), 'windows');
  masterScene.add(moonScene(), 'windows');
  masterScene.add(starsScene(), 'wheelScene');
  masterScene.add(wheelScene(), 'wheelScene');

  // masterScene.seek('wheelScene')
});
              
            
!
999px

Console