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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

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.


                <p><button id="start" onclick="start()">start camera!</button></p>

 <div style="float:left;margin-right:5px;">
  <p><video id="video-tag" width="240" height="180" autoplay/></p>
 <div style="float:left">
  <p><img id="image-tag" width="240"> </img></p>
<div style="width: 240px">
  <p><button onclick="takePhoto()">take photo</button></p>
  <div hidden>
    <label for="pan-slider">Pan</label>
    <input id="pan-slider" min="0", max="0" name="pan" title="Pan" type="range" />
    <output id="pan-slider-value"></output>
  <div hidden>
    <label for="tilt-slider">Tilt</label>
    <input id="tilt-slider" min="0", max="0" name="tilt" title="Tilt" type="range" />
    <output id="tilt-slider-value"></output>
  <div hidden>
    <label for="zoom-slider">Zoom</label>
    <input id="zoom-slider" min="0", max="0" name="zoom" title="Zoom" type="range" />
    <output id="zoom-slider-value"></output>





                const constraints = {
  video: {width: { exact: 320 }, pan: true, tilt: true, zoom: true}
var videoTag = document.getElementById('video-tag');
var imageTag = document.getElementById('image-tag');
var panSlider = document.getElementById("pan-slider");
var panSliderValue = document.getElementById("pan-slider-value");
var tiltSlider = document.getElementById("tilt-slider");
var tiltSliderValue = document.getElementById("tilt-slider-value");
var zoomSlider = document.getElementById("zoom-slider");
var zoomSliderValue = document.getElementById("zoom-slider-value");
var imageCapturer;

function start() {
    .catch(e => { console.error('getUserMedia() failed: ', e); });

function gotMedia(mediastream) {
  videoTag.srcObject = mediastream;
  document.getElementById('start').disabled = true;
  var videoTrack = mediastream.getVideoTracks()[0];
  imageCapturer = new ImageCapture(videoTrack);

  // Timeout needed in Chrome, see
  setTimeout(() => {
    const capabilities = videoTrack.getCapabilities()
    const settings = videoTrack.getSettings();

    // Check whether pan is supported or not.
    if (capabilities.pan) {
      // Map pan to a slider element.
      panSlider.min = capabilities.pan.min;
      panSlider.max = capabilities.pan.max;
      panSlider.step = capabilities.pan.step;
      panSlider.value = settings.pan;
      panSlider.oninput = function(event) {
        panSliderValue.value = panSlider.value;
        videoTrack.applyConstraints({advanced: [{pan:}]});
      panSlider.parentElement.hidden = false;

    // Check whether tilt is supported or not.
    if (capabilities.tilt) {
      // Map tilt to a slider element.
      tiltSlider.min = capabilities.tilt.min;
      tiltSlider.max = capabilities.tilt.max;
      tiltSlider.step = capabilities.tilt.step;
      tiltSlider.value = settings.tilt;
      tiltSlider.oninput = function(event) {
        tiltSliderValue.value = tiltSlider.value;
        videoTrack.applyConstraints({advanced: [{tilt:}]});
      tiltSlider.parentElement.hidden = false;

    // Check whether zoom is supported or not.
    if (capabilities.zoom) {
      // Map zoom to a slider element.
      zoomSlider.min = capabilities.zoom.min;
      zoomSlider.max = capabilities.zoom.max;
      zoomSlider.step = capabilities.zoom.step;
      zoomSlider.value = settings.zoom;
      zoomSlider.oninput = function(event) {
        zoomSliderValue.value = zoomSlider.value;
        videoTrack.applyConstraints({advanced: [{zoom:}]});
      zoomSlider.parentElement.hidden = false;
  }, 500);

function takePhoto() {
    .then((blob) => {
      console.log("Photo taken: " + blob.type + ", " + blob.size + "B")
      imageTag.src = URL.createObjectURL(blob);
    .catch((err) => { 
      console.error("takePhoto() failed: ", e);