![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
gradient-all
Advanced tools
gradient.js is a javascript module that takes your source colors array and configuration object, and returns a gradient suitable for your needs.
gradient.js is built on top of chroma-js
color manipulation library (Copyright (c) 2011-2017, Gregor Aisch).
You need to install chroma-js
as a dependency to start working with gradient.js.
npm install --save-dev gradient-all
<script src="https://unpkg.com/gradient-all@1.0.0/gradient.js">
Depending on your needs, you can use one of the three modules: Base
, Css
and Svg
. The Css
and Svg
modules are using Base
under the hood as an internal dependency.
So if you want to get a gradient as an array of arrays of rgb(a) numbers, type the following code:
import { Base } from 'gradient'
const base = new Base()
const rawGradient = base.get(yourColors, yourConfig) // number[][]
If you want to get a css gradient, you don't need to use the Base
. Css
does it for you.
import { Css } from 'gradient'
const css = new Css()
const cssGradient = css.get(yourColors, yourConfig) // css string
The same applies to the SVG module
import { Svg } from 'gradient'
const svg = new Svg()
const svgGradient = svg.get(yourColors, yourConfig) // svg gradient element
Colors input should be an array of numbers in rgb or rgba format.
[
[0, 222, 31, 0.4],
[12, 22, 34]
]
Or an array of css rgb(a) strings.
[
'rgba(10, 23, 34, 0.5)',
'rgba(47, 3, 120, 0.5)'
]
Please note that the input colors are the source for further creation of probably bigger amount of outputs. Try to insert max. 5 colors as an input for better visual effect.
The shape of the options object will change depending on the module you are going to use. So in case of getting raw numbers gradient you will need the Base
options object.
If you want to get a css gradient, the options will have to consist of two entries with two configuration objects.
You must always pass the Base
options to your configuration.
import { Base, Css, Svg } from 'gradient'
const colors = [
[10, 33, 22, 0.90],
[120, 23, 44, 1]
]
const baseConfig = {
interpolation: 'bezier',
mode: 'none',
samples: 10,
lightnessCorrection: true
}
const base = new Base()
const css = new Css()
const svg = new Svg()
const rawGradient = base.get(colors, baseConfig)
const cssGradient = css.get({
base: baseConfig,
css: {
type: 'radial',
shape: 'ellipse',
top: 44,
left: 30,
extent: 'farthest-side'
}
})
const svgGradient = svg.get(colors, {
base: baseConfig,
svg: {
type: 'radial',
cx: 0.5,
cy: 0.5,
r: 0.4,
spreadMethod: 'reflect'
}
}) // returns svg gradient element
const rawSvgGradient = svg.get(colors, {
base: baseConfig,
svg: {
type: 'radial',
cx: 0.5,
cy: 0.5,
r: 0.4,
spreadMethod: 'reflect'
},
true
}) // returns an object
bezier
interpolation ignores opacity values.FAQs
Gradient creation library running in the browser
The npm package gradient-all receives a total of 2 weekly downloads. As such, gradient-all popularity was classified as not popular.
We found that gradient-all demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.