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

smooth-corners

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smooth-corners

CSS superellipse masks with the Houdini API

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by4.56%
Maintainers
1
Weekly downloads
 
Created
Source

Smooth Corners

npm npm deps bundlephobia

checks devDeps sponsor

Superellipse masks using the CSS Houdini API

Static demo of Smooth Corners

Usage

CSS

Add mask-image: paint(smooth-corners) to the elements you want to mask

Default (Squircle)

Without a --smooth-corners variable set it will default to a value of 4

.squircle {
  mask-image: paint(smooth-corners);
  -webkit-mask-image: paint(smooth-corners);
  background: #d01257; /* So you can see it */
}
Customise Shape / Roundness
.mask {
  /* Integer 1 to 100. Scoped locally or globally in :root {}
     2 is a perfect circle
     < 2 are diamonds / asteroids
     > 2 are rounded squares */
  --smooth-corners: 3;
  mask-image: paint(smooth-corners);
  -webkit-mask-image: paint(smooth-corners);
  background: #d01257; /* So you can see it */

Registering the Paint Worklet

Register the Paint Worklet to the distributed path of paint.js.

Register with a CDN (preferred)

Use any CDN that serves packages from the NPM registry, for example:

<script>
  if (CSS && 'paintWorklet' in CSS) CSS.paintWorklet.addModule('https://unpkg.com/smooth-corners')
</script>
Register with a file path

Download paint.js or install with npm install smooth-corners

// src/assets/paint.js
import 'smooth-corners' // ES Modules
// src/assets/paint.js
require('smooth-corners') // CommonJS

Like Web Workers, the Paint Worklet API requests the module path in the browser during runtime and must be a seperate entryfile. This is not the path to the source code location.

<script>
  if (CSS && 'paintWorklet' in CSS) CSS.paintWorklet.addModule('/assets/paint.js')
</script>

Result

2 examples: A rounded pink square and a pink squircle

Keywords

FAQs

Package last updated on 28 Jul 2020

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