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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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="300" height="300"></canvas>


                body, html {
  height: 100%;

body {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: black;


                const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const startTime =;

(function drawRipple(timestamp) {
  const elapsedTimeUnits = (timestamp - startTime) / 50;
  const pixelData = ctx.createImageData(canvas.width, canvas.height);

  // Step through the array one pixel at a time
  for (let i = 0; i <; i += 4) {

    // We can find our (x, y) position on the canvas by comparing
    // our position in the array with the width of the canvas.
    let x = Math.floor(i / 4) % canvas.width;
    let y = Math.floor(i / (4 * canvas.width));

    // We need our origin to be in the center, so lets convert the (x, y)
    // from above (the "canvas coordinates") to their "reindexed" values
    // (what they would become if the origin were in the center).
    let reIndexedX = -((canvas.width - x) - (canvas.width / 2));
    let reIndexedY = (canvas.height - y) - (canvas.height / 2);

    // Instead of writing our own code for Pythagorean's theorem, we can
    // use JavaScript's built-in method to calculate the hypotenuse.
    let radialX = Math.hypot(reIndexedX, reIndexedY);

    // For reference, see
    let waveHeight = Math.sin((radialX - elapsedTimeUnits) / 8);

    // Normally, a sin wave fluctuates between -1 and 1, but we want ours
    // to fluctuate between 0 and 255 instead (the range for RGB values).
    let adjustedHeight = (waveHeight * 60 + (255/2));

    // Assign the adjustedHeight to R, G, and B equally, to make gray.[i]     = adjustedHeight; // red[i + 1] = adjustedHeight; // green[i + 2] = adjustedHeight; // blue[i + 3] = 255;            // opacity

  ctx.putImageData(pixelData, 0, 0);