Socket
Socket
Sign inDemoInstall

canvas-extras

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    canvas-extras

Adds extra handy bits to canvas, including Progress Bars, rounded rectangles, and stadiums.


Version published
Weekly downloads
145
decreased by-76.46%
Maintainers
1
Install size
6.06 kB
Created
Weekly downloads
 

Readme

Source

canvas-extras adds extra handy bits to canvas, including Progress Bars, rounded rectangles, and stadiums.

Installation

npm i canvas-extras

Usage

Prerequisites

To use canvas-extras, you must already:

  • Have canvas installed and required
  • Have a functioning canvas and 2D context to work with

Progress bars

ctx.progressBar(currentProgress, maxProgress, x, y, width, height, barFillColor, emptyFillColor)
Note

For the progress bar to work correctly, do not use any code that changes the bar's appearance (e.g. fill() or stroke()) as it will cause the bar to appear incorrectly.

Example
ctx.beginPath();
ctx.progressBar(5, 10, 50, 50, 200, 100, 'orange');
ctx.endPath();

This will yield this result:

![Image of progress bar.] (https://rollbot.net/images/progress1.png)

Rounded rectangles

ctx.roundRect(x,y, width, height, roundness)
Example
ctx.beginPath();
ctx.fillStyle = '#aaaaaa';
ctx.roundRect(50,50, 100, 100, 25);
ctx.fill();
ctx.closePath();

This will yield this result:

![Image of rounded square.] (https://rollbot.net/images/square.png)

Stadiums

Stadiums are also known as capsule shapes or pill shapes

ctx.stadium(x,y, width, height)
Example
ctx.beginPath();
ctx.fillStyle = '#aaaaaa';
ctx.stadium(50,50, 500, 100);
ctx.fill();
ctx.closePath();

This will yield this result:

![Image of stadium.] (https://rollbot.net/images/stadium.png)

Other bits

I'd really appreciate it if you gave a bit of credit to me if you use my package!

Thanks!

Keywords

FAQs

Last updated on 21 Aug 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc