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.


Auto Save

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 class='circle-zazz'></canvas>


                .circle-zazz {
  position: relative;
  transform: translateX(-3px)


                let canvas = document.querySelector('.circle-zazz')

let myCircle = {
  size: 40
}, {
  duration: 1,
  size: 0,
  repeat: -1,
  repeatDelay: 0.25,
  yoyo: true,
  onUpdate: () => draw(canvas)

function draw(canvas) {
  const ctx = canvas.getContext("2d");
  const circleSize = 80; // Size of the circles
  const padding = 3; // Padding between circle and square

  const canvasWidth = window.innerWidth + 6;
  const numRows = 2; // Number of rows

  // Calculate the square size based on the available width and padding
  const squareSize =
    (canvasWidth - 2 * padding) /
    Math.ceil(canvasWidth / (circleSize + 2 * padding));

  // Calculate the number of circles that can fit in a row
  const numCirclesPerRow = Math.floor(canvasWidth / squareSize);

  // Calculate the total width of the circles and padding
  const totalWidth = numCirclesPerRow * squareSize;

  // Calculate the left margin to center the circles
  const marginLeft = (canvasWidth - totalWidth) / 2;

  // Calculate the canvas height based on the number of rows
  const canvasHeight = numRows * squareSize;

  // Set the canvas dimensions
  canvas.width = canvasWidth;
  canvas.height = canvasHeight;

  // Clear the canvas
  ctx.clearRect(0, 0, canvas.width, canvas.height);

  // Loop through the rows and columns to draw the circles
  for (let row = 0; row < numRows; row++) {
    for (let col = 0; col < numCirclesPerRow; col++) {
      // Calculate the x and y coordinates for the current circle
      const x = marginLeft + col * squareSize;
      const y = row * squareSize;

      // Determine the starting color combination for each row
      const isBlueCircle = (row + col) % 2 === 0;

      // Set the fill color and draw the square
      ctx.fillStyle = isBlueCircle ? "blue" : "white";
      ctx.fillRect(x, y, squareSize, squareSize);

      // Draw the circle
        x + squareSize / 2,
        y + squareSize / 2,
        2 * Math.PI
      ctx.fillStyle = isBlueCircle ? "white" : "blue";