Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

roughjs

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

roughjs

Create graphics using HTML Canvas or SVG with a hand-drawn, sketchy, appearance.

  • 4.6.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
242K
increased by1.69%
Maintainers
1
Weekly downloads
 
Created

What is roughjs?

Rough.js is a graphics library that allows you to draw sketchy, hand-drawn-like graphics on the web. It is particularly useful for creating visuals that have a more organic and less computer-generated feel.

What are roughjs's main functionalities?

Drawing Basic Shapes

Rough.js allows you to draw basic shapes like rectangles, circles, and lines with a hand-drawn appearance. The code sample demonstrates how to draw a rectangle on a canvas element.

const rc = rough.canvas(document.getElementById('canvas'));
rc.rectangle(10, 10, 200, 100);

Drawing with SVG

Rough.js can also be used to draw on SVG elements. This code sample shows how to draw a circle using SVG, which can then be manipulated or styled further.

const rc = rough.svg(document.getElementById('svg'));
const node = rc.circle(50, 50, 80);
document.getElementById('svg').appendChild(node);

Customizing Appearance

You can customize the appearance of the shapes by adjusting properties like roughness, stroke color, and stroke width. This example demonstrates how to draw a rectangle with a custom appearance.

const rc = rough.canvas(document.getElementById('canvas'));
rc.rectangle(10, 10, 200, 100, { roughness: 2.8, stroke: 'red', strokeWidth: 3 });

Other packages similar to roughjs

Keywords

FAQs

Package last updated on 20 Nov 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc