Skip to content

Instantly share code, notes, and snippets.

@darrenbarklie
Last active October 5, 2019 11:42
Show Gist options
  • Save darrenbarklie/7938a8350f8f90753d941e7fecc65734 to your computer and use it in GitHub Desktop.
Save darrenbarklie/7938a8350f8f90753d941e7fecc65734 to your computer and use it in GitHub Desktop.
VSP Photo Capture
Display the source blob
Display the rendered blob
Raw
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 720"><defs><style>.cls-1{fill:none;stroke:#00ff6a;stroke-linecap:round;stroke-linejoin:round;stroke-width:16px;}</style></defs><title>Artboard 1</title><path class="cls-1" d="M26.75,673.82c56.35-14.36,68.4-14.71,119-29.32A62.92,62.92,0,0,0,191.07,584V525.82l-7.74-8.68A158.31,158.31,0,0,1,144.9,435s-20.58.18-23.6-18.54c-9.21-57.25-15.87-59.73-15.87-84.88s9.32-31.1,20.52-24.6a155.24,155.24,0,0,1-5.7-38.56C116.42,133.13,205.42,44.45,309.73,44.45s193.32,88.68,189.49,223.94A154.62,154.62,0,0,1,493.51,307c11.21-6.5,20.52-.52,20.52,24.6s-6.65,27.63-15.86,84.88c-3,18.72-23.6,18.54-23.6,18.54a158.31,158.31,0,0,1-38.43,82.17l-7.74,8.68V584a62.92,62.92,0,0,0,45.36,60.5c50.56,14.61,46.88,11,103.24,25.39"/></svg>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Photo</title>
<style>
body {
padding: 0;
margin: 0;
}
.container {
border: 2px solid black;
}
.container-viewfinder {
position: relative;
width: 600px;
height: 720px;
margin: 0 auto;
background-color: #004000;
}
.overlay {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
</style>
</head>
<body>
<div class="container">
<div class="container-viewfinder">
<div class="overlay">
<img src="frame-selfie.svg" />
</div>
<video autoplay class="viewfinder"></video>
</div>
</div>
<script>
function hasGetUserMedia() {
return !!(
navigator.mediaDevices && navigator.mediaDevices.getUserMedia
);
}
if (hasGetUserMedia()) {
const constraints = {
// video: true
video: {
width: { ideal: 600 },
height: { ideal: 720 }
}
};
const captureVideoButton = document.querySelector(
"#screenshot .capture-button"
);
const video = document.querySelector("video");
navigator.mediaDevices.getUserMedia(constraints).then(stream => {
video.srcObject = stream;
});
} else {
alert(
"Your browser or device doesn't support image capture. Please contact support."
);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment