Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
gradientee
Advanced tools
Readme
Gradientee is a tiny, self-contained library to create randomized gradient backgrounds based on triangles, squares or quadrilaterals. It is using Jake Archibald's seeded random function to get predictable results and avoid significant pattern changes on rerenders, for example during box resize
You can install package from npm:
bash npm install gradientee
or use CDN:
<script src="https://unpkg.com/gradientee@latest/dist/gradientee.min.js"></script>
Include script
<script type="text/javascript" src="https://unpkg.com/gradientee/dist/gradientee.min.js"></script>
and then use
<canvas id="canvas"></canvas>
const node = document.getElementById("canvas");
const ctx = node.getContext("2d");
const options = {
width: node.width,
height: node.height,
colorFrom: "#f00",
colorTo: "#ff0",
};
paintTriangles(ctx, options);
(experimental)
Due to experimental nature of Paint API that solution will work only for chrome-based browsers.
Please consult Can I Use for current browser state
Be advised to implement workarounds for other major browsers
To use CSS Houdini paint worklet, add module import into <script>
tags in header of your page
<script type="text/javascript">
CSS.paintWorklet.addModule("https://unpkg.com/gradientee/dist/gradientee-worklet.min.js");
</script>
and then use the css paint:
.selector-to-paint {
width: 1000px;
height: 400px;
background-image: paint(gradientee);
--gradientee-color-from: #00ff00;
--gradientee-color-to: #0000ff;
--gradientee-box-size: 60;
--gradientee-seed: 1234;
--gradientee-deflection-level: 20;
--gradientee-color-randomness: 0;
}
To control the canvas generator, use options js object
{
boxSize: 20,
colorFrom: "#fff",
colorTo: "#000",
colorRandomness: 0,
deflectionLevel: 20,
triangles: true,
seed: 1234
}
For CSS, all options have respective custom properties, formed by applying --gradientee
prefix to a kebab-case formatted option name
.selector-to-paint {
--gradientee-box-size: 20;
--gradientee-color-from: #fff;
--gradientee-color-to: #000;
--gradientee-color-randomness: 0;
--gradientee-deflection-level: 20;
--gradientee-triangles: 1;
--gradientee-seed: 1234;
}
Math.rand()
To build, simply run:
> npm install
> npm run build
FAQs
Randomized gradient background generator
The npm package gradientee receives a total of 0 weekly downloads. As such, gradientee popularity was classified as not popular.
We found that gradientee demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.