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 is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


              <!DOCTYPE html>
<html lang="en">
	<meta charset="UTF-8">
	<title>Basic Shapes on Canvas</title>
	<script src="main.js"></script>

	  <canvas id="myCanvas" height="500" width="500"></canvas>


              #myCanvas {
  border: 2px dotted black;    


              (() => {
  // get canvas by id
    // get canvas by id
  const canvas = document.querySelector("#myCanvas")
  const width = 500
  const height = 500
  canvas.width = width
  canvas.height = height
  // get 2d context of our canvas
  const ctx = canvas.getContext("2d")
  const drawFillRect = (x, y, width, height, hexColor, ctx) =>{
    ctx.rect(x, y, width, height)
    ctx.fillStyle = hexColor
  // background color
  drawFillRect(20, 20, 460, 460, "#FAFCF1", ctx)
  // rectangle at the center
    drawFillRect((width/2)-100, (height/2)-150, 200, 300,  "#F26D85", ctx)
  // rectangle 2
  drawFillRect(280, 20, 120, 190, "#E97FF4", ctx)
  // circle 1
  ctx.arc(347, 260, 50, 0, 2*Math.PI)
  ctx.fillStyle = "#9193F6"
  // rectangle 3
  drawFillRect(80, 300, 100, 110, "#A4F3F8", ctx)
  // triangle
  ctx.moveTo(250, 400);
  ctx.lineTo(200, 450);
  ctx.lineTo(300, 450);
  ctx.fillStyle = "#B6FAC1"