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

              
                %svg{ :width => "100%", :height => "100%", :perserveAspectRatio => 'xMidYMid meet', :version => "1.1", :viewbox => "0 0 800 400", :xmlns => "http://www.w3.org/2000/svg", "xmlns:xlink" => "http://www.w3.org/1999/xlink"}

  %defs
    %clipPath#clip
      %path{ :d => "M351,189 C352.93568,194.323121 355.551997,196.085581 361,196 C366.810061,195.908731 374.45176,193.644719 376,189 L423,189 C425.086777,194.738637 429,201 438,202 C451,202 448.043389,193.304752 449,189 L451,27 L350,27 L351,189 Z", :fill => "#D8D8D8" }

    %g#eye
      %circle{:cx => "14", :cy => "14", :fill => "#FFFFFF", :r => "14"}
      %circle{:cx => "14", :cy => "14", :fill => "#4C4543", :r => "10"}
      %circle#eye-l1{:cx => "9", :cy => "10", :fill => "#FFFFFF", :r => "6"}
      %circle#eye-l2{:cx => "18", :cy => "23", :fill => "#FFFFFF", :r => "4" }

  %g#table{ :fill => 'none', :stroke => "#E8E8CA", "stroke-linecap" => "round", "stroke-linejoin" => "round", "stroke-width" => "4", :transform => "translate(210.000000, 294.000000)" }
    %polygon{ :points => "70 0 380 0 310 50 0 50" }
    %rect{ :height => "13", :width => "310", :x => "0", :y => "50" }
    %polygon{ :fill => "#E8E8CA", :points => "310 50 380 0 380 12 310 63" }

  %g#knife{ :fill => "#E8E8CA", 'fill-opacity' => 0.5, :transform => "translate(551.000000, 152.000000) rotate(-180.000000) translate(-551.000000, -152.000000) translate(536.000000, 27.000000)" }
    %path{ :d => "M30,184 L30,239.558781 C30,253.480406 10,253.480406 10,239.558781 L10,184 L30,184 Z M20,242 C21.6568542,242 23,240.656854 23,239 C23,237.343146 21.6568542,236 20,236 C18.3431458,236 17,237.343146 17,239 C17,240.656854 18.3431458,242 20,242 Z" }
    %path{ :d => "M30,184 L30,0 C14.9178086,13.0218593 0.847564706,36.5600023 0,184 L30,184 Z" }

  %g#apple{ :transform => "translate(322.000000, 133.000000)" }
    %path{ :d => "M17,187 L143,185", :stroke => "#E8E8CA", "stroke-linecap" => "round", "stroke-width" => "6" }
    %path{ :fill => "#FF555B", :d => "M79.1568508,48.9919404 C90.1703481,48.9919404 165.262375,18.6434756 156.251332,112.067728 C147.240289,205.491981 89.1691211,186.156749 79.1568508,186.156749 C69.1445805,186.156749 12.0746398,206.493184 1.06114249,112.067728 C-9.95235484,17.6422727 68.1433535,48.9919404 79.1568508,48.9919404 Z" }
    %path{ :fill => "#4C4543", "fill-opacity" => "0.14", :d => "M106.202689,44.2567375 C130.96081,42.2856004 161.971758,49.772812 156,111.688 C150.050858,173.368705 122.691565,185.839269 101.93819,187.206169 C139,131 139,96 106.202689,44.2567375 Z" }
    %ellipse{ :cx => "29.1209946", :cy => "160.233989", :fill => "#CC2F36", :rx => "13", :ry => "6.16951343", :transform => "translate(29.120995, 160.233989) rotate(-122.000000) translate(-29.120995, -160.233989) " }
    %ellipse{ :cx => "42", :cy => "57.5", :fill => "#CC2F36", :rx => "13", :ry => "6.5", :transform => "translate(42.000000, 57.500000) rotate(-11.000000) translate(-42.000000, -57.500000) " }
    %ellipse{ :cx => "115", :cy => "60.5", :fill => "#CC2F36", :rx => "13", :ry => "9.5", :transform => "translate(115.000000, 60.500000) rotate(15.000000) translate(-115.000000, -60.500000) " }
    %path{ :fill => "#4C4543", "fill-opacity" => "0.3", :d => "M31.3542046,162.73074 C39.7330506,162.531343 43.437782,160.387159 43.437782,158.489613 C43.437782,156.592067 38.53302,155.522774 31.3533182,155.522774 C24.1736165,155.522774 18.7398216,156.488388 18.7398216,158.385934 C18.7398216,160.28348 22.9753586,162.930137 31.3542046,162.73074 Z", :transform => "translate(31.088802, 159.132076) rotate(-122.000000) translate(-31.088802, -159.132076) "}
    %path{ :fill => "#4C4543", "fill-opacity" => "0.3", :d => "M42.9982472,63.981796 C49.6256641,63.981796 55.1890561,60.9854502 55.1890561,58.5001688 C55.1890561,56.0148874 49.6256641,54.981796 42.9982472,54.981796 C36.3708302,54.981796 30.9982472,56.9965146 30.9982472,59.481796 C30.9982472,61.9670773 36.3708302,63.981796 42.9982472,63.981796 Z", :transform => "translate(43.093652, 59.481796) rotate(-11.000000) translate(-43.093652, -59.481796) "}
    %path{ :fill => "#4C4543", "fill-opacity" => "0.3", :d => "M114.512304,70.0346518 C121.692005,70.0346518 126.371524,66.1568308 127.512304,62.3695367 C128.653083,58.5822425 121.692005,54.7044216 114.512304,54.7044216 C107.332602,54.7044216 103.06125,56.6825765 102.21941,61.1447918 C101.377571,65.6070071 107.332602,70.0346518 114.512304,70.0346518 Z", :transform => "translate(114.887755, 62.369537) rotate(15.000000) translate(-114.887755, -62.369537) "}
    %use{ 'xlink:href' => '#eye', :x => 25, :y => 87 }
    %use{ 'xlink:href' => '#eye', :x => 65, :y => 87 }
    %path#appleMouth{ :d => "M52,121 C57.7632653,117.473469 60.8228571,119.354286 64,121 L52,121 Z", :stroke => "#4C4543", "stroke-linecap" => "round", "stroke-linejoin" => "round", "stroke-width" => "4" }
    %path{ :fill => '#9CD652', 'fill-opacity' => 0.75, :d => "M79,49.7207031 C84.1233391,18.8164852 72.9874057,2.98704787 48,0 C54.3772061,21.9097928 63.7355566,39.7984668 79,49.7207031 Z" }
    %path{ :d => "M80,48 C85.3202324,26.1757911 97.4697929,14.4541452 112,9", :fill => 'none', :stroke => "#4C4543", "stroke-linecap" => "round", "stroke-width" => "4" }

  %path#path.hide{:d => "M363,218 C361.186667,106 373.4,50 399.64,50 C425.88,50 438.666667,106 438,218", :stroke => "#F5A623"}

  %g.hide#wormFace
    %circle#Oval-2{:cx => "11", :cy => "11", :fill => "#FFCDCD", :r => "11"}
    %path#mouth{:d => "M3,18.0193733 C5.39206103,12.4378976 8.12763926,11.8725839 11.0318938,12.0193733 C15.4123729,12.2407755 19.6013232,15.6140807 19,18.0193733 C19,19.3527067 13.6666667,19.3527067 3,18.0193733 Z", :fill => "#4C4543", :transform => "translate(11.028902, 15.509687) scale(1, -1) translate(-11.028902, -15.509687) "}
    %circle#Oval-3{:cx => "7", :cy => "8", :fill => "#4C4543", :r => "2"}
    %circle#Oval-3{:cx => "15", :cy => "8", :fill => "#4C4543", :r => "2"}

  %circle#wormBodyCircle{ :style => 'opacity: 0;',  :cx => "197", :cy => "119", :fill => "#FFCDCD", :r => "11" }

  %g#wormContainer{'clip-path' => 'url(#clip)' }


.credits
  %span
    by &nbsp;
    %a{ :href => 'https://twitter.com/pixelia_me', :target => '_blank', :rel => 'noopener noreferrer', :title => 'Noel Delgado' }
      %svg{ :height => '12', :viewBox => '0 0 57 30' }
        %path{ :d => 'M28.1312,9.5341 C29.7966,9.5341 32.1025,10.627 34.248,12.368 C49.3297,11.5836 53.8793,-0.4796 55.5773,0.6783 C57.8326,3.2476 50.8638,16.3535 39.4,19.088 C39.8655,20.2628 40.1364,21.4786 40.1364,22.6983 C40.1364,25.9478 38.837,26.7409 36.7281,28.8974 L36.704,28.824 C36.4799,29.0276 36.208,29.2318 35.8945,29.4 C35.8945,29.4 36.1346,27.0065 34.9341,26.7672 C34.9341,26.7672 34.3739,27.4054 33.0133,27.2459 C32.8532,25.8896 32.293,25.4109 32.1329,25.3311 C31.4126,25.4109 30.9324,26.5278 30.132,26.5278 C29.8,26.1969 29.5184,25.5615 29.312,24.972 C29.0201,25.4221 28.6036,26.1128 28.2512,26.2885 C27.8796,26.2885 27.1476,25.2858 26.836,24.832 C26.6262,25.4581 26.3285,26.1707 25.9702,26.5278 C25.1699,26.5278 24.6896,25.4109 23.9694,25.3311 C23.8093,25.4109 23.249,25.8896 23.089,27.2459 C21.7284,27.4054 21.1681,26.7672 21.1681,26.7672 C19.9676,27.0065 20.2077,29.4 20.2077,29.4 C19.6122,29.0804 19.1739,28.6307 18.908,28.304 L18.8667,28.3947 C17.1544,26.3262 16.1259,25.5896 16.1259,22.6983 C16.1259,21.4938 16.3637,20.2895 16.784,19.128 C5.2094,16.4922 -1.8448,3.2615 0.4227,0.6783 C2.119,-0.4785 6.6627,11.5578 21.708,12.364 C23.8143,10.6244 26.1724,9.5341 28.1312,9.5341 Z M28.8514,20.3048 C28.8514,20.3048 30.4121,21.7409 32.213,21.7409 C34.0137,21.7409 35.3343,19.3474 35.3343,19.3474 L28.8514,20.3048 Z M20.6879,19.3474 C20.6879,19.3474 22.2486,21.7409 24.0494,21.7409 C25.8502,21.7409 27.1707,20.3048 27.1707,20.3048 L20.6879,19.3474 Z', 'fill-rule' => 'evenodd' }
              
            
!

CSS

              
                :root {
  font-size: 12px;
  font-family: monospace;
  --color: #FF555B;
  --bg: #FDFDF2;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  overflow: hidden;
}

body {
  width: 100vw;
  height: 100vh;
  color: var(--color);
  background-color: var(--bg);
}

a {
  color: inherit;
}

svg {
  display: block;
  fill: currentColor;
}

.credits {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  font-size: 0.75rem;
}

.credits > span {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.hide {
  opacity: 0;
}
              
            
!

JS

              
                const { log } = console;

log('🍎');

const internals = {};

internals.clip = document.getElementById('clip');
internals.path = document.getElementById('path');
internals.apple = document.getElementById('apple');
internals.appleMouth = document.getElementById('appleMouth');
internals.appleEyeL1 = document.getElementById('eye-l1');
internals.appleEyeL2 = document.getElementById('eye-l2');
internals.wormBodyCircle = document.getElementById('wormBodyCircle');
internals.wormFace = document.getElementById('wormFace');
internals.wormContainer = document.getElementById('wormContainer');

internals.circlePathData = MorphSVGPlugin.pathDataToBezier(internals.path, { align: internals.wormBodyCircle });
internals.facePathData = MorphSVGPlugin.pathDataToBezier(internals.path, { align: internals.wormFace });

// -------

TweenLite.defaultEase = Linear.easeNone;
TweenLite.set(internals.apple, { transformOrigin: 'center bottom' });
TweenLite.set(internals.appleMouth, { transformOrigin: 'center',  scale: 0.5 });
TweenLite.set(internals.appleEyeL2, { transformOrigin: 'bottom right' });
TweenLite.set(internals.wormContainer, { transformOrigin: 'center bottom' });
TweenLite.set(internals.wormBodyCircle, { transformOrigin: 'center', x: 11 });
TweenLite.set(internals.wormFace, { transformOrigin: 'center', x: 11 });

// -------

TweenMax.to(internals.clip.querySelector('path'), 2, { y: -10, repeat: -1, yoyo: true });
TweenMax.to(internals.apple, 2, { scaleY: 1.1, repeat: -1, yoyo: true });
TweenMax.to(internals.appleMouth, 2, { scale: 1, repeat: -1, yoyo: true });
TweenMax.to(internals.appleEyeL1, .25, { scale: 1.1, repeat: -1, yoyo: true });
TweenMax.to(internals.appleEyeL2, .25, { scale: 1.2, repeat: -1, yoyo: true });

internals.timelineWorm = new TimelineMax({ repeat: -1 });
internals.timelineWorm.add(getWormAnimation(internals.wormFace, internals.facePathData));

for (let i = 0; i < 10; i++) {
  internals.timelineWorm.add(getWormAnimation(), i * .02);
}

// -------

function getWormAnimation(el = internals.wormBodyCircle, values = internals.circlePathData) {

  el = el.cloneNode(true);
  el.style.opacity = 1;

  internals.wormContainer.insertBefore(el, internals.wormContainer.firstChild);

  return TweenLite.to(el, 1.5, {
    bezier: {
      type: 'cubic',
      autoRotate: true,
      values
    },
    ease: SlowMo.ease.config(0.1, 0.7, false)
  })
}
              
            
!
999px

Console