Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


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


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.


Auto Save

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.


                 <div class="container">
   <div class='row'>
     <div class="col-sm-12" id="buttons-row">
        <h1>Web SnapChat Clone</h1>
       <h6> because sometimes bunnies & hamsters are cuter than humans</h6>
      <button class="btn btn-default"id="flower-crown"><img src=""></button>
      <button class="btn btn-default" id="bunny-ears"><img src=""></button> 
      <button class="btn btn-default"id="doggy"><img src=""></button>
      <button class="btn btn-default" id="hearts"><img src=""></button>     
       </div> <!-- end of col-sm-12 -->
    </div> <!-- end of row -->     
     <div class="row justify-content-center videorow">
      <video id="video" width="500" height="325" preload autoplay loop muted></video>
      <canvas id="canvas" width="500" height="325"></canvas>  
   </div><!-- end of row -->
       <div class="row justify-content-center videorow">
         <button class="btn btn-default" id="snap" onclick="snap()"></button>
</div> <!-- end of row -->
<div class="row">
       <div class="col-sm-12 justify-content-center videorow" id="output">
           <canvas id="canvas2" width="500" height="325"></canvas>                                                                      </div>
</div><!-- end of container -->

         <!-- CREDITS
0. No copyright infringments intended
1. Image:


                import url(",400i,700");

  background-image: url("");
  background-size: 100px;
 font-family: Lato, sans-serif; 
  margin-top: 150px;
  background-color:#FFFFFF ;
  border: 12px solid #FFFC00;
  width: 700px;
h1, h6{
  font-weight: 900;
  text-transform: uppercase;
   color: #8e7ba7;   

  margin: 30px;
 margin-bottom: 10px;

 background-color: #FFFFFF;
  text-transform: uppercase;
  border: 1px solid #8e7ba7;
  border-radius: 60px;
  height: 90px;
  width: 90px;
  width: 40px;
  height: 40px;
  border-radius: 40px;
  background-color: #FFFC00;
  width: 80px;
  height: 60px;
  margin-left: -8px;

  margin-left: -500px;
  /*border: 1px solid red; */



const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const tracker = new tracking.ObjectTracker('face');
const flowerCrownButton = document.getElementById('flower-crown');
const bunnyEarsButton = document.getElementById('bunny-ears');
const doggyButton = document.getElementById('doggy');
const heartsButton = document.getElementById('hearts');

// image constructor create new image element
//new Image();
// image(w,h)
const img = document.createElement("img");
img.setAttribute("id", "pic");
img.src = canvas.toDataURL();

let filterX = 0;
let filterY = 0;
let filterWidth = 0;
let filterHeight = 0;

function changePic (x, y, width, height, src) {
 // alert("function changePic")
  img.src = src;
  filterX = x;
  filterY = y;
  filterWidth = width;
  filterHeight = height;

function flowerCrown () {
  changePic(0, -0.5, 1, 1, '')

flowerCrownButton.addEventListener('click', flowerCrown);

bunnyEarsButton.addEventListener('click', () => {
  changePic(-0.5, -1, 2, 2, '')

function doggy () {
  changePic(0, -1, 1, 3, '')

doggyButton.addEventListener('click', doggy);

function hearts( ) {
  changePic(0, -1, 2, 2, '')

heartsButton.addEventListener('click', hearts);

//listen for track events
tracker.on('track', function(event) {
  //if ( === 0) {
    //alert("No objects were detected in this frame.");
  //} else {
context.clearRect(0, 0, canvas.width, canvas.height)> {
 context.drawImage(img, rect.x + (filterX * rect.width),
    rect.y + (filterY * rect.height),
    rect.width * filterWidth,
    rect.height * filterHeight

//start tracking
tracking.track('#video', tracker, { camera: true })

  var canvas2 = document.getElementById('canvas2');
var context2 = canvas2.getContext('2d');
var video = document.querySelector("video");
var w, h, ratio;

video.addEventListener("loadedmetadata", function() {
  ratio = video.videoWidth / video.videoHeight;
   w = video.videoWidth - 100;
     h = parseInt(w / ratio, 10);
    canvas2.width = w;
    canvas2.height = h;
}, false);

function snap(){
     context2.drawImage(video, 10, 10);