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.

            
              <button id="startBtn">start</button>

<svg width="350" heigth="150" viewBox="0 0 350 150">
  <defs>

    <!-- EYE SHAPE -->
    <path
          id="eyeShape"
          d="
             M 27,75
             S 40 52 75 52
             120 75 120 75
             105 93 75 93
             27 75 27 75 
             z
             "   
          />

    <symbol id="eye">
      <use class="fillEye" xlink:href="#eyeShape"/>

      <g clip-path="url(#maskeye)">
        <g id="irisPupil">
          <ellipse id="iris" class="iris" cx="74" cy="72" rx="22" ry="22" />
          <ellipse id="pupil" class="pupil" cx="74" cy="72" rx="8" ry="8"  />   
        </g>
      </g>

      <use class="strokeEye" xlink:href="#eyeShape"/>
    </symbol>


    <clipPath id="maskeye">
      <use xlink:href="#eyeShape" />
    </clipPath>
  </defs>


  <use xlink:href="#eye"/>
  <use x="183" xlink:href="#eye" />
</svg>

            
          
!
            
              body {
  background-color: #FFF;
  margin: 20px;
  margin-top: 10px;
}


/* Eye */
svg {
  margin-top: 20px;
  display: block;
  background-color: #999;
  max-width: 100%;
  height: auto;
}
.fillEye {
  fill:  #fff;
  stroke-width: 1px;
  stroke:  #666;
}

.strokeEye {
  stroke: #333;
  stroke-width: 6px;
  fill:  none;
  stroke-dasharray: 2px 5px;
}

.iris {
  fill: brown;
}
            
          
!
            
              const startBtn = document.getElementById("startBtn");

const animePupil = (function() {
  let rafID = null;
  let f = 0;

  const NF = 25;
  const irisPupil = document.getElementById("irisPupil");

  const frame = () => {
    f++;
    const progress = f / NF;

    irisPupil.setAttribute("transform", `translate( ${progress * 23} )`);

    if (f >= NF) {
      cancelAnimationFrame(rafID);
      f = 0;
      rafID = null;
      return;
    }

    rafID = requestAnimationFrame(frame);
  };
  const play = () => {
    rafID = requestAnimationFrame(frame);
  };
  return {
    play: play
  };
})();

startBtn.addEventListener(
  "click",
  () => {
    animePupil.play();
  },
  false
);

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

Console