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 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.


                <canvas id="canvas" width="800" height="200">
      Canvas is not supported by your browser.


                canvas {
  border: 1px solid black;


                    const img = new Image();

    img.src = ",_Yosemite_National_Park.jpg";
    canvasXSize = 800;
    canvasYSize = 200;
    let speed = 30;
    let scale = 1.05;
    let y = -4.5;

    let dx = 0.75;
    let imgW
    let imgH;
    let x = 0;
    let ctx;   

    img.onload = function() {
        imgW = img.width * scale;
        imgH = img.height * scale;

        if (imgW > canvasXSize) {
          x = canvasXSize - imgW;

        ctx = document.getElementById('canvas').getContext('2d');
        window.setInterval(draw, speed);

    function draw() {
      ctx.clearRect(0, 0, canvasXSize, canvasYSize);
      ctx.drawImage(img, x, y, imgW, imgH);

      //add additional images before the current one if needed
      if (x > 0) {
        let prevX = x;
        do {
          prevX -= imgW;
          ctx.drawImage(img, prevX, y, imgW, imgH);
        } while (prevX > 0);

      //add additional images after the current one if needed
      if (x + imgW < canvasXSize) {
        let nextX = x;
        do {
          nextX += imgW;
          ctx.drawImage(img, nextX, y, imgW, imgH);
        } while (nextX + imgW < canvasXSize);
      x += dx;