Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <canvas class="canvas"
        height="500"
        id="canvas"
        width="1000"></canvas>

              
            
!

CSS

              
                .canvas {
  display: block;
  height: 500px;
  margin: 0 auto;
  width: 1000px;
}

              
            
!

JS

              
                const canvas = document.getElementById('canvas')
const context = canvas.getContext('2d')

function drawCircle() {
  const x = 75
  const y = 75
  const radius = 50
  const startAngle = 0
  const endAngle = 2 * Math.PI

  context.strokeStyle = '#EC2059'
  context.lineWidth = 5
  
  context.beginPath()
  context.arc(x, y, radius, startAngle, endAngle)
  context.stroke()
}

function drawCustomShape() {
  context.fillStyle = '#EC2059'
  
  context.beginPath()
  context.moveTo(150, 75)
  context.lineTo(200, 25)
  context.lineTo(250, 25)
  context.lineTo(250, 75)
  context.lineTo(200, 125)
  context.lineTo(200, 75)
  context.fill()
}

function drawImage() {
  const image = new Image()
  image.addEventListener('load', (event) => {
    const sourceX = 100
    const sourceY = 200
    const sourceWidth = 1000
    const sourceHeight = 350
    const x = 0
    const y = 150
    const width = 1000
    const height = 350
    
    context.drawImage(image, sourceX, sourceY, sourceWidth, sourceHeight, x, y, width, height)
  })
  image.src = 'https://www.pendo.io/wp-content/uploads/2020/06/Pendo_DiversityandInclusion_FeaturedPage_1200x750.png'
}

function drawMaskedShape() {
    context.save()

    context.beginPath()
    context.moveTo(275, 75)
    context.lineTo(320, 25)
    context.lineTo(375, 25)
    context.lineTo(375, 75)
    context.lineTo(320, 125)
    context.lineTo(320, 75)
    context.closePath()
    context.clip()

    context.fillStyle = '#55CDFC'

    context.beginPath()
    context.moveTo(275, 75)
    context.lineTo(320, 25)
    context.lineTo(340, 25)
    context.lineTo(275, 95)
    context.closePath()  
    context.fill()
  
    context.beginPath()
    context.moveTo(320, 125)
    context.lineTo(375, 75)
    context.lineTo(375, 55)
    context.lineTo(320, 105)
    context.closePath()
    context.fill()

    context.fillStyle = '#F7A8B8'

    context.beginPath()
    context.moveTo(275, 95)
    context.lineTo(340, 25)
    context.lineTo(360, 25)
    context.lineTo(275, 115)
    context.closePath()  
    context.fill()
  
    context.beginPath()
    context.moveTo(320, 105)
    context.lineTo(375, 55)
    context.lineTo(375, 35)
    context.lineTo(320, 85)
    context.closePath()
    context.fill()
  
    context.restore()
}

function drawRectangle() {
  const x1 = 400
  const y1 = 25
  const x2 = 500
  const y2 = 125
  
  const gradient = context.createLinearGradient(x1, y1, x2, y2)
  gradient.addColorStop(0, '#FF218E')
  gradient.addColorStop(.5, '#FCD800')
  gradient.addColorStop(1, '#0194FC')
  context.fillStyle = gradient
  
  const x = 400
  const y = 25
  const width = 100
  const height = 100
  
  context.fillRect(x, y, width, height)
}

function drawText() {
  const x = 525
  const y = 88
  
  context.fillStyle = '#000'
  context.font = '50px arial'
  context.fillText('Pendo', x, y)
}

drawCircle()
drawCustomShape()
drawImage()
drawMaskedShape()
drawRectangle()
drawText()

              
            
!
999px

Console