LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code
JS
document.getElementById("start").onclick = function() {
        var w = window.open("", "", "width=350, height=300");
        //w.moveBy(50, 50);
        with (w) {
            document.addEventListener("webkitvisibilitychange", function() {alert("No minimizing!")});
            document.title = "Webcam green screen";
            var drawing = document.createElement("canvas");
            drawing.width = 350;
            drawing.height = 250;
            drawing.style.width = 350;
            drawing.style.height = 250;
            drawing.style.margin = "0";
            document.body.style.margin = "0";
            document.body.style.padding = "0";
            document.body.appendChild(drawing);
            var c = drawing.getContext("2d");
            var video = document.createElement("video");
            video.autoplay = true;
            video.width = 350;
            video.height = 250;
            video.style.display = "none";
            document.body.appendChild(video);
            var soof = document.createElement("div");
            soof.style.width = "350px";
            soof.style.height = "50px";
            soof.style.padding = "11px";
            soof.style.cursor = "pointer";
            soof.style.display = "block";
            soof.style.textAlign = "center";
            soof.style.font = "20px 'lucida grande', sans-serif";
            soof.style.margin = "0";
            soof.style.boxSizing = "border-box";
            soof.style.border = "1px outset #e5e5e5"
            soof.style.background = "linear-gradient(#eee, #ddd)";
            soof.innerHTML = "I have stepped out of the frame";
            document.body.appendChild(soof);
            function onerr(e) {
                alert("A problem occured. Your browser may not support navigator.getUserMedia or clicked Deny when you were prompted to allow this site camera access. Error: "+e);
            }
            if (typeof navigator.getUserMedia == typeof navigator.webkitUserMedia) {
                navigator.getUserMedia = navigator.webkitGetUserMedia;
            }
            var effectNameElt = document.createElement("div");
            effectNameElt.innerHTML = "Please step out of the frame.";
            with (effectNameElt.style) {
              font = "15px 'gill sans', sans-serif";
              position = "absolute";
              left = "0";
              top = "0";
              right = "0";
              textAlign = "center";
              padding = "5px";
              color = "white";
            }
            document.body.appendChild(effectNameElt);
            var pixels;
            navigator.getUserMedia({video:true, audio:false}, 
            function(mediaStream) {
                onerror = function(err) {
                    errorsallowed--;
                    if (errorsallowed < 0) return;
                    alert(err);
                }
                var out = video;
                var url = window.URL || window.webkitURL;
                var stuff = url.createObjectURL(mediaStream);
                out.src = stuff;
                out.play();
                window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
                var TOLERANCE = 20;
                function isCloseTo(a, b) {
                    return Math.abs(a-b) < TOLERANCE;
                }
                var counter = 0;
                var mapNum = function(X, A, B, C, D) {
                    var Y = (X-A)/(B-A) * (D-C) + C;
                    return Y;
                }
                function lerp(mn, mx, a) {
                    return mapNum(a, 0, 1, mn, mx);
                }
                var effect = 1;
                var effectNames = [null, "Hologram effect", "Ghost effect", "Black background effect", "Inverted background foreground (negative image ghost)", "Seethrough foreground white background (translucency effect)", "Foreground hue-rotate 60° (green skin effect)", "Background inverted grayscale foreground redscale (bloody effect)"];
                var currentEffectName = "Hologram effect";
                function nextEffect() {
                  effect++;
                  if (effect > 7) effect = 1;
                  TOLERANCE = 25;
                  if (effect == 3) {
                    TOLERANCE = 40;
                  }
                  currentEffectName = effectNames[effect];
                  effectNameElt.innerHTML = currentEffectName;
                }
                document.body.addEventListener("keydown", function() { if (steppedOut) nextEffect(); });
                function update() {
                    counter++;
                    c.drawImage(out, 0, 0, 350, 250);
                    if (steppedOut) {
                        var info = c.getImageData(0, 0, 350, 250);
                        for (var i=0;i
Term
Sat, 01/13/2018 - 08:31

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv