Flexible JavaScript library for creating squircley magic ✨

Overview

squircley.js

squircley.js is the core squirclular magic from https://squircley.app wrapped up into a simple, 0 dependency JavaScript library.

squircley.js can generate SVG's, add squircle backgrounds to DOM elements, and even generate base64 encoded squirculated strings ready to use with img tags.

You can currently find squircley.js on NPM https://www.npmjs.com/package/squircleyjs 📦

Note Right now squircley.js is just an ES module. I'll add UMD support etc if folks need it in the future, I just didn't want to get lost in rollup land too early 🙏

Usage

createSquircle

Options

Name Type Default Description
format String SVGNode The format of the squircle. Accepts SVGNode, backgroundImage, base64
viewBox Array [0, 0, 200, 200] SVG viewbox (x, y, w, h)
width Number 200 Width of the squircle
height Number 200 Height of the squircle
curvature Number 0.5 Value 0 - 1 that determines how round the squircle is
fill String 0.5 Fill color of the squircle
rotate Number 0 Rotation of the squircle

Examples

import { createSquircle } from 'squircleyjs';

// Create an SVG squircle and append it to the DOM
const target = document.querySelector('.target');
const squircleSVG = createSquircle({
    format: 'SVGNode',
    viewBox: [0, 0, 200, 200],
    width: 150,
    height: 150,
    curvature: 0.1,
    fill: '#fadb5f',
    rotate: 0,
});

target.appendChild(squircleSVG);

// Create a base64 encoded squircle and set it as the src attribute for an image
const target = document.querySelector('img');
const squircleBase64 = createSquircle({
    format: 'base64',
    viewBox: [0, 0, 200, 200],
    width: 150,
    height: 150,
    curvature: 0.1,
    fill: '#e46a3c',
    rotate: 0,
});

target.src = squircleBase64;

// Create a urlEncoded background-image squircle ready to use in CSS / attach to a custom property
const squircleBackgroundImage = createSquircle({
  format: "backgroundImage",
  viewBox: [0, 0, 200, 200],
  width: 150,
  height: 150,
  curvature: 0.1,
  fill: "#908cfa",
  rotate: 0
});

// store in custom property to use throughout app?
document.documentElement.style.setProperty(
  "--svg-squircle",
  squircleBackgroundImage
);

// directly apply as CSS
document.body.style.backgroundImage = squircleBackgroundImage;

...

squircleBackground

Options

squircleBackground is simple a wrapper around createSquircle. The options are identical.

Examples

import { squircleBackground } from 'squircleyjs';

// Add a quick squircle background image to a div
squircleBackground('.squircle-background-test', {
    fill: '#f78e8e',
});
You might also like...

It's an AI Tag (Prompt) generator for magic drawer! We have many tags and support to generate prompts easily!

It's an AI Tag (Prompt) generator for magic drawer! We have many tags and support to generate prompts easily!

魔导绪论 AI 魔咒生成器, 使用由 B 站 UP 主 十二今天也很可爱 提供的 4 万个 tag 并提供中文检索,并提供了魔咒社区方便魔法师们直接复制生成。永远免费,永无广告,无商业。 v2 版本更新内容 使用 Netlify 的云函数提供更为快速的社区数据操作!(暂时不知道花费多少) 查看自己的

Jan 1, 2023

A flexible and extensible javascript library for letters animation simulations.

LetterLoading LetterLoading js is a javascript library for making awesome letter simulations. It default simulation is a letter loading simulation. Co

Mar 22, 2022

Complete, flexible, extensible and easy to use page transition library for your static web.

Complete, flexible, extensible and easy to use page transition library for your static web.

We're looking for maintainers! Complete, flexible, extensible and easy to use page transition library for your static web. Here's what's new in v2. Ch

Jan 2, 2023

A fast, portable, flexible JavaScript component framework

SAN 一个快速、轻量、灵活的 JavaScript 组件框架 A fast, portable, flexible JavaScript component framework. HomePage 网站 安装(Install) NPM: $ npm i san CDN: script src=

Dec 29, 2022

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more

Apache MXNet (incubating) for Deep Learning Apache MXNet is a deep learning framework designed for both efficiency and flexibility. It allows you to m

Jan 5, 2023

A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more

Glide.js is a dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more What can co

Jan 3, 2023

Simple yet flexible charting Lightning Web Component using Chart.js for admins & developers

Simple yet flexible charting Lightning Web Component using Chart.js for admins & developers

Lightning Web Chart.js Component Simple yet flexible charting Lightning Web Component using Chart.js for admins & developers Documentation Getting sta

Dec 9, 2022

Easy and flexible jQuery tabbed functionality without all the styling.

JQuery EasyTabs Plugin Tabs with(out) style. EasyTabs creates tabs with all the functionality, no unwanted changes to your markup, and no hidden styli

Nov 23, 2022
Comments
  • Create a transpiled UMD build

    Create a transpiled UMD build

    Right now squircley.js is just a simple, raw ES module. This is fine for folks using parcel / webpack etc, but for better browser support squircley.js should also be available as a UMD build.

    enhancement 
    opened by georgedoescode 0
  • Add more tests!

    Add more tests!

    Adding an issue here to add some tests. There should be some already, but I actually wasn't expecting this lib to get much real world use initially so thought I had a little bit more runway!

    good first issue 
    opened by georgedoescode 0
Releases(1.0.7)
Owner
George Francis
UI ⚡️ Generative everything ❤️ I write about creative coding & front-end development ✨
George Francis
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Flexible, powerful and modern library for creating the running horizontal blocks effect, also known as ticker or the «marquee effect».

Cuberto Reeller Flexible, powerful and modern library for creating the running horizontal blocks effect, also known as ticker or the «marquee effect».

Cuberto 41 Jan 4, 2023
Weather-magic - Working with APIs to create a weather dashboard

Weather Magic link to website Following the link above will bring you to the Wea

null 1 Feb 3, 2022
Querying Solana Blockchain, leveraging Magic Eden Apis!

Solana Bot Deployment Instructions- Create a bot on discord dev portal learn basics here Copy the Bot Token and go to OAuth field for URL generation F

Yog 5 Sep 8, 2022
Adds a handy $parent magic property to your Alpine components.

✨ Help support the maintenance of this package by sponsoring me. Alpine $parent Access parent components using a handy $parent magic variable. This pa

Ryan Chandler 10 Aug 29, 2022
Extended magic-string with extra utilities

DEPRECATED. It has been ported back to magic-string >= 0.26.0 magic-string-extra Extended Rich-Harris/magic-string with extra utilities. Install npm i

Anthony Fu 130 Sep 8, 2022
The Remix Stack for Web2 apps and Web3 DApps with authentication with Magic, testing, linting, formatting, etc.

Remix French House Stack Learn more about Remix Stacks. npx create-remix --template janhesters/french-house-stack What's in the Stack? The French Hou

Jan Hesters 26 Dec 26, 2022
MagicSniffer is a amazing tool could help you decrypt GI traffic by MAGIC of WindSeedClientNotify

MagicSniffer We have posted an article about this on sdl.moe: 原神 2.8 KCP 验证密钥交互流程解析与流量解密 As everyone knows, RSA is the most secure way to encrypt data

Sorapointa 49 Dec 29, 2022
Kittos is NFT Marketplace built with Next Js, Hardhat, Solidity, Arweave + Bundlr Client and All The CSS Magic with TailwindCSS. 😺

Kittos NFT Marketplace ?? Built with Next Js, Hardhat, Solidity, Arweave, Bundlr and Tailwind CSS. Functionalities New Listed Assets Mint NFT Buy NFT

Aakrut 7 Dec 24, 2022