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.

              <div class="section">
  <div class="emoji-switcher">
    <div class="heart-emoji"></div>
  <div id="emoji-canvas"></div>
      background-color: red !important;
    background: -webkit-gradient(linear, left top, left bottom, from(#f3f3f3), to(white));
    background: -webkit-linear-gradient(top, #f3f3f3, white) !important;
    background: -moz-linear-gradient(top, #f3f3f3, white) !important;
    background: -ms-linear-gradient(top, #f3f3f3, white) !important;
    background: -o-linear-gradient(top, #f3f3f3, white) !important;
 * Easing Functions - inspired from http://gizma.com/easing/
 * only considering the t value for the range [0, 1] => [0, 1]
EasingFunctions = {
  // no easing, no acceleration
  linear: function (t) { return t },
  // accelerating from zero velocity
  easeInQuad: function (t) { return t*t },
  // decelerating to zero velocity
  easeOutQuad: function (t) { return t*(2-t) },
  // acceleration until halfway, then deceleration
  easeInOutQuad: function (t) { return t<.5 ? 2*t*t : -1+(4-2*t)*t },
  // accelerating from zero velocity 
  easeInCubic: function (t) { return t*t*t },
  // decelerating to zero velocity 
  easeOutCubic: function (t) { return (--t)*t*t+1 },
  // acceleration until halfway, then deceleration 
  easeInOutCubic: function (t) { return t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1 },
  // accelerating from zero velocity 
  easeInQuart: function (t) { return t*t*t*t },
  // decelerating to zero velocity 
  easeOutQuart: function (t) { return 1-(--t)*t*t*t },
  // acceleration until halfway, then deceleration
  easeInOutQuart: function (t) { return t<.5 ? 8*t*t*t*t : 1-8*(--t)*t*t*t },
  // accelerating from zero velocity
  easeInQuint: function (t) { return t*t*t*t*t },
  // decelerating to zero velocity
  easeOutQuint: function (t) { return 1+(--t)*t*t*t*t },
  // acceleration until halfway, then deceleration 
  easeInOutQuint: function (t) { return t<.5 ? 16*t*t*t*t*t : 1+16*(--t)*t*t*t*t }

var timSetter = function(timeLimit, rate, callIn){
  var frameRate = rate||100;
  var delta = timeLimit||3000;
    var timer = setInterval(function(){
      var perc = (delta/timeLimit)*100;
        clearInterval( timer );
    }, frameRate);

//used to change the y direction
//return random number 10-109
var getRandomY = function(){
  return Math.floor(Math.random() * 100)+10;

//used to alter the frequency of the direction changing
//return sum of 2 random numbers
var getRangeRand = function(){
  return Math.floor(Math.random() * 10)+Math.floor(Math.random() * 20);

//set the width and height to be changed later by events.
var stageH = document.getElementById("emoji-canvas").clientHeight,
    stageW = document.getElementById("emoji-canvas").clientWidth 

//hold your canvas layer
const stage = new Konva.Stage({
  container: "emoji-canvas",

var layer = new Konva.Layer({
  name:"Base Layer"

var circle = new Konva.Circle({
  x: stageW+50,
  y: stageH*(getRandomY()/100),
  radius: 10,
  fill: 'red'
  var frame = a-EasingFunctions.easeOutQuad(1);
    circle['xRange'] = frame-getRangeRand();
    circle['xRange'] =frame-getRangeRand();
    circle['yrange'] = getRandomY()+getRangeRand()-10;
  if(circle.y()*(getRandomY()/100)+30 <=circle['yrange'] ){
  }else if(circle.y()*(getRandomY()/100)-10>= circle['yrange']){

🕑 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 ..................