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.

            
              <script src="https://underscorejs.org/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.2/TweenMax.min.js"></script>

<div id="background"></div>
<button id="record">RECORD</button>
<button id="stop">STOP RECORD</button>
<div class="playbackControls">
<button id="playbackBtn">PLAYBACK</button>
<button id="resumeBtn">RESUME</button>  
<button id="pauseBtn">PAUSE</button>  
</div>  
<div id="container"></div>


<div id="playback">
  <div id="loader">LOADING...</div>
  <div class="film">
    
  </div>
  <progress class="totalProgress" value="0"></progress> 
</div>
            
          
!
            
              #background{
  width:100%;
  height:100%;
  position:fixed;
  background: rgb(169,3,41); /* Old browsers */
background: -moz-radial-gradient(center, ellipse cover,  rgba(169,3,41,1) 0%, rgba(143,2,34,1) 44%, rgba(109,0,25,1) 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(169,3,41,1)), color-stop(44%,rgba(143,2,34,1)), color-stop(100%,rgba(109,0,25,1))); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover,  rgba(169,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover,  rgba(169,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover,  rgba(169,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); /* IE10+ */
background: radial-gradient(ellipse at center,  rgba(169,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a90329', endColorstr='#6d0019',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */


}

button{
  position:relative;
  float:left;
}

#container{
  top:50px;
  position:absolute;
}

body{
  margin:0px;
  padding:0px;
}

#playback{
  position:absolute;
  left:600px;
  text-align:center;
  color:#fff;
  width:578px;
  height:200px;
  border:2px solid;
  top:50px;
}

.playbackControls{
  display:none;
}

#playbackBtn{
  float:left;
}

.totalProgress{
  width:100%;
}

#loader{
  vertical-align:middle;
  margin:0 auto;
  position:absolute;
  width:100%;
  height:100%;
}

.film{
  width:100%;
  height:100%;
  overflow:hidden;
}

.film>img{
  position:absolute;
  left:0px;
  top:0px;
}
            
          
!
            
              var requestID = window.requestAnimationFrame(storeCanvas);
var storage = [];
var stage;
var cc;
var stop = true;
var allImages = [];
var timer;
var tl = new TimelineMax({repeat:0,  paused:true, align:'sequence', onComplete:onComplete});

$(document).ready(function(){
  stage = new Kinetic.Stage({
        container: 'container',
        width: 578,
        height: 200,
        id:"canv"
      });
      var layer = new Kinetic.Layer();
      var rectX = stage.getWidth() / 2 - 50;
      var rectY = stage.getHeight() / 2 - 25;
      
      var bg = new Kinetic.Rect({
        width:578,
        height:200,
        x:0,
        y:0,
        stroke:'black',
        fill:'#ffffff'
      });
  
      var box = new Kinetic.Rect({
        x: rectX,
        y: rectY,
        width: 100,
        height: 50,
        fill: '#00D2FF',
        stroke: 'black',
        strokeWidth: 4,
        draggable: true
      });

      // add cursor styling
      box.on('mouseover', function() {
        document.body.style.cursor = 'pointer';
      });
      box.on('mouseout', function() {
        document.body.style.cursor = 'default';
      });
  
      layer.add(bg);
      layer.add(box);
      
      stage.add(layer);
  
  $("#record").click(function(){
    $(".film").empty();
    $("#record").attr("disabled","disabled");
    storage = [];
    stop = false;
    storeCanvas();
    
    // some change //
    timer = setTimeout(changeColor, 1500,[box]);
    //setTimeout(stopRecord,1000);
  });
  
  
  $("#stop").click(function(){
    stopRecord();
    loadImages();
    window.console.log(allImages);
    $("#record").removeAttr("disabled");
    timer = false;
  });
  
  $("#playbackBtn").click(function(){
    tl.play();
  });
  
  $("#pauseBtn").click(function(){
    tl.pause();
  });
  
  $("#resumeBtn").click(function(){
    tl.resume();
  });
  
  
  ////////////////
});

function beforeRepeat(){
  $(".film").children().css("display","block");
}

function onComplete(){
  $(".film").children().css("display","block");
  $(".totalProgress").attr("value",0);
  window.console.log("COMPLETED PLAYBACK");
}

function loadImages(){
  
  allImages = [];
  var promises = [];
  var images = [];
  for(var i=0;i<storage.length;i=i+1){
    
    var img = storage[i];
    
    promises.push(imageLoaded(img));
   
  }
  
  $.when.apply($, promises).done(function () {
    
    $("#loader").css("display","none");
    console.log(allImages.length);
    $(".totalProgress").attr("max",allImages.length);
    for(var i=0;i<allImages.length;i=i+1){
      $(".film").prepend(allImages[i]);
      tl.add( TweenLite.to(allImages[i], 0.1, {display:'none',onComplete:function(){
        var prevValue = Number($(".totalProgress").attr("value"));
        $(".totalProgress").attr("value",prevValue+1);
      }}) );
    }
    
    $(".playbackControls").css("display","block");
  });
  
  //return images;
}
  
function imageLoaded(src){
  var deferred = $.Deferred();
  var sprite = new Image();
  sprite.className = 'filmstrip';
  sprite.onload = function() {
    allImages.push(sprite);  
    deferred.resolve();
  };
  sprite.src = LZString.decompress(src);
  return deferred.promise();
}  

function stopRecord(){
  stop = true;
  window.cancelAnimationFrame(requestID);
}

function storeCanvas(){
  
  if(stop === false){
  stage.toDataURL({
    callback: function(dataUrl) {
      var data = LZString.compress(dataUrl);
      window.console.log(dataUrl.length, data.length);
      storage.push(data);
      if(stop === false){
        var lazyLayout = _.debounce(storeCanvas, 25);
        requestID = requestAnimationFrame(lazyLayout);
        //window.console.log(storage);
      }
    }});
  }
}

function changeColor(box){
  box[0].setFill(get_random_color());
  stage.draw();
  if(timer !== false){
    timer = setTimeout(changeColor, 3000, [box[0]]);
  }
}

function get_random_color() {
    var letters = '0123456789ABCDEF'.split('');
    var color = '#';
    for (var i = 0; i < 6; i++ ) {
        color += letters[Math.round(Math.random() * 15)];
    }
    return color;
}




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

Console