Book Image

WebRTC Cookbook

By : Andrii Sergiienko
Book Image

WebRTC Cookbook

By: Andrii Sergiienko

Overview of this book

Table of Contents (15 chapters)
WebRTC Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing the dropped shadow effect


In this recipe, we will cover the process of implementing the dropped shadow effect. This filter can be used for decoration purposes. Although it utilizes CPU resources very actively, don't put it on every page.

How to do it…

Follow these steps:

  1. Add a control element to the appropriate web page of the application—using this object we will control intensity of the effect:

    Shadow
    <input type="range" oninput="doShadow(this.valueAsNumber);" value="0" step="5" min="0" max="50">
  2. Add the onLoad handler to HTML's body tag of the web page. By using this method, we will initialize the dropped shadow effect.

    <body onload="doShadow(0);">
  3. Add an appropriate JavaScript function:

    function doShadow(val) {
      var v = document.getElementById("localVideo");
      v.style.webkitFilter="drop-shadow(" + val + "px " + val + "px 10px green)";
    };

    We have added the px postfix for the filter's value—this is because of the effect's intensity is setting in pixels. Also, you can see...