Package Exports
- @gradient-js/svg
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@gradient-js/svg) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@gradient-js/svg
gradient-js
module for svg gradient generation
Installation
CLI
Yarn
yarn add @gradient-js/svg
Npm
npm install --save @gradient-js/svg
CDN
<script src="https://unpkg.com/gradient-js/svg@x.x.x/svg.js">
Usage
import { Svg } from '@gradient-js/svg';
const svg = new Svg();
const gradient = svg.get(colors, config);
Inputs
In order to create a gradient you will need to pass an array of colors
and an options
object to the Svg's get
method. colors
should be an array of strings in any valid css format (rgb(a), hex or hsl(a)). options
object consists of the CoreOptions and following properties:
type SvgOptions = CoreOptions & {
id: string;
type: 'linear' | 'radial';
gradientUnits?: 'objectBoundingBox' | 'userSpaceOnUse';
linearOptions?: SvgLinearGradientOptions;
radialOptions?: SvgRadialGradientOptions;
};
SvgLinearGradientOptions
type SvgLinearGradientOptions = {
angle: number;
x1: number;
y1: number;
x2: number;
y2: number;
};
SvgRadialGradientOptions
type SvgRadialGradientOptions = {
cx: number;
cy: number;
r: number;
fx: number;
fy: number;
spreadMethod: 'pad' | 'repeat' | 'reflect';
};