[Generator] JavaScript Library for Creating Squircley Magic ✨ | squircley.js

squircley.js is the core magic of Squirclular ✨ from https://squircley.app wrapped in a simple 0-dependency JavaScript library.

squircley.js can generate SVG files, add square backgrounds to DOM elements, and even create nested base64-encoded strings ready to use with img tags.

Note Now squircley.js is just an ES module. I’ll add UMD support etc if people need it in the future, I didn’t want to get lost in the land of a backlog so early 🙏

squircleBackground

Options

squircleBackground are simply a wrapper around createSquircle. The options are identical.

Must Read: A Flexible Tabs Component for Vue.js | vue-magic-line

How to make use of it:

1. Import Squircley.js as an ES module.

import { 
  // core
  createSquircle, 
  // squircle background image
  squircleBackground 
} from './src/squircley.js';

2. Create an SVG-based squircle and customize the form with the next options:

const squircleSVG = createSquircle({
      format: 'SVGNode',
      curvature: 0.5,
      fill: '#4C3EF7',
      rotate: 0
});

3. Generate a base64 encoded squircle and append it to a picture.

const target = document.querySelector('img');
const squircleBase64 = createSquircle({
      format: 'base64',
      // options here
});
target.src = squircleBase64;

4. Generate a URL-encoded background picture.

const squircleBackgroundImage = createSquircle({
      format: "backgroundImage",
      // options here
});
// apply the background image to an element
document.documentElement.style.setProperty(
  "--svg-squircle",
  squircleBackgroundImage
);
// or
document.body.style.backgroundImage = squircleBackgroundImage;

5. Or instantly use the squircleBackground module.

squircleBackground('.squircle-background', {
  // options here
});

createSquircle

Options

Must Read: JavaScript Library To Automatically Detect And Extract An Image From A Screenshot | MagicCrop

NameTypeDefaultDescription
formatStringSVGNodeThe format of the squircle. Accepts SVGNodebackgroundImagebase64
viewBoxArray[0, 0, 200, 200]SVG view box (x, y, w, h)
widthNumber200Width of the squircle
heightNumber200Height of the squircle
curvatureNumber0.5Value 0 - 1 that determines how round the squircle is
fillString0.5Fill the color of the squircle
rotateNumber0Rotation of the squircle

See Demo And Download

JavaScript-Library-for-Creating-Squircley-Magic

Official Website(georgedoescode): Click Here

This superior jQuery/javascript plugin is developed by georgedoescode. For extra Advanced usage, please go to the official website.

Related Posts

Google-Translate-Dropdown-Customize-With-Country-Flag

Google Translate Dropdown Customize With Country Flag | GT API

Flag google translates jQuery text that takes advantage of the Google Cloud Translation API to translate web content between languages by selecting a country from the dropdown…

Bootstrap-Fileinput

HTML 5 File Input Optimized for Bootstrap 4.x./3.x with File Preview | Bootstrap Fileinput

bootstrap-fileinput is an improved HTML 5 file input  Bootstrap 5.x, 4.x and 3.x with file preview for different files, provides multiple selections, resumable section uploads, and more….

HStack-and-VStack-in-CSS

CSS Layout Components Horizontal/Vertical Stack | HStack and VStack

HStack and VStack in CSS – CSS layout components that (basically) stack anything horizontally and vertically. A pure CSS library that makes it easy to stack elements…

Floating-Whatsapp-Chat-Button

How to Add Floating Whatsapp Chat Button In HTML | venom-button

Venom Button is a very simple plugin for the jQuery floating WhatsApp button. Adds a floating button to your site that calls WhatsApp Click to Chat API. It will automatically start the WhatsApp…

Data-Table-Generator-Tabulator

Interactive Data Table Generator with JS/jQuery and JSON | Tabulator

Tabulator allows you to create interactive tables in seconds from any HTML Table, JavaScript array, AJAX data source, or JSON format data. Just include the library in your…

alert-confirm-prompt-attention-js

Simple Alert, Confirm, Prompt Popup Using Vanilla JavaScript Library | attention.js

JavaScript provides various built-in functionality to display popup messages for different purposes. Attention JS is a vanillaJS plugin used to create a custom alert, confirm, or Prompt…

Leave a Reply

Your email address will not be published. Required fields are marked *