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.


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.


  <video id="video" playsinline></video>
  <button id="access">Access Camera</button>
  <canvas id="canvas"></canvas>
  <div id="buttons">
  <button data-shader="gl_FragColor = vec4(color, 1.0);">Default</button>
  <button data-shader="gl_FragColor = vec4(color * vec3(0.9, 0.0, 1.0), 1.0);">Purple</button>
  <button data-shader="gl_FragColor = vec4(color * vec3(1.5, 1.5, 0.0), 1.0);">Yellow</button>
  <button data-shader="color = smoothstep(vec3(0.2), vec3(0.8), color); gl_FragColor = vec4(color, 1.0);">High Contrast</button>
  <button data-shader="gl_FragColor = vec4(vec3(1.0) - color, 1.0);">Invert</button>
  <button data-shader="color += vec3(sin(4.5 * u_time), sin(3.1 * u_time + 1.0), sin(2.7 * u_time)); gl_FragColor = vec4(color, 1.0);">Rave</button>


                main {
  align-items: center;
  display: flex;
  height: 100vh;
  justify-content: center;
  width: 100vw;

#buttons { 
  display: none; 

button {
  color: #558;
  cursor: pointer;
  border: 0.3em solid #558;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.35em 1em;
  transition: 0.2s;

button:active {
  background: #558;
  box-shadow: 0 0 3px #000;
  color: #fff;

#buttons {
  float: left;

#buttons {
  max-width: 400px;

#buttons button {
  display: block;
  margin: 10px 0 0 10px;
  text-align: center;
  width: 200px;

#access {
  display: block;
  font-size: 1.5em;

canvas {
  height: auto;
  max-width: 400px;


                const video = document.getElementById('video');
const buffer = document.createElement('canvas');
const canvas = document.getElementById('canvas');
let glslCanvas;

let fragColor = `gl_FragColor = vec4(color, 1.0);`;

function init() {
    audio: false,
    video: {
      facing: 'user'
  .catch((err) => console.log('There was an error 😱', err));

function setup(stream) { = 'block';
  document.getElementById('access').style.display = 'none';
  document.getElementById('buttons').style.display = 'block';
  video.srcObject = stream;;
  window.devicePixelRatio = 1;

function render() {

  buffer.width = video.videoWidth;
  buffer.height = video.videoHeight;
  buffer.getContext('2d').drawImage(video, 0, 0);

  canvas.width = buffer.width;
  canvas.height = buffer.height;

  if (!glslCanvas) {
    glslCanvas = new GlslCanvas(canvas);

  var dataURL = buffer.toDataURL();
  glslCanvas.setUniform('u_texture', dataURL);

function update() {

  const vertexShader = `
    #ifdef GL_ES
    precision mediump float;
    uniform sampler2D u_texture;
    uniform vec2 u_resolution;
    uniform float u_time;
    void main() {
      vec2 st = gl_FragCoord.xy / u_resolution.xy;
      float x = gl_FragCoord.x;
      float y = gl_FragCoord.y;
      vec3 color = texture2D(u_texture, st).rgb;

  if (glslCanvas) glslCanvas.load(vertexShader);

function toggle() {
  fragColor = this.getAttribute('data-shader');

document.getElementById('access').addEventListener('click', init);
video.addEventListener('canplay', render);

[...document.getElementById('buttons').children].forEach(button => {
  button.addEventListener('click', toggle);