Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
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.
linear-gradient-parser
Advanced tools
Readme
Converts a linear gradient SVG String / Json rep into CSS background property
npm i linear-gradient-parser
Linear gradient parser comes in handy when you need get a svg linear gradient as background. It can accepts both SVG linearGradient string / Json as input in order to produce it's background.
import parser from 'linear-gradient-parser';
// SVG String input
const linearGradientString = `
<linearGradient xmlns="http://www.w3.org/2000/svg" gradientUnits="userSpaceOnUse" x1="17.5001" y1="32" x2="17.5001" y2="2.9711">
<stop offset="0" style="stop-color:#FCB3A4"/>
<stop offset="1" style="stop-color:#DA5899"/>
</linearGradient>
`
const stringResult = parser.getBackground(linearGradientString);
console.log(stringResult)
//outputs : {background: "linear-gradient(0deg, rgb(252, 179, 164) 0%, rgb(218, 88, 153) 100%)", angle: 0}
// JSON input
const linearGradient = {
x1: '17.5001',
y1: '32',
x2: '17.5001',
y2: '2.9711',
stops: [
{ color: '#FCC3A4', offset: '0', opacity: 0.5 },
{ color: '#AAA899', offset: '1' }
]
};
const jsonResult = parser.getBackground(linearGradient);
console.log(jsonResult)
//outputs : {background: "linear-gradient(0deg, rgb(252, 179, 164) 0%, rgb(218, 88, 153) 100%)", angle: 0}
// Using angle generator
const gradientCords = parser.getGradientCords(90);
//outputs : { x1: 0, x2: 1, y1: 0, y2: 0 }
Converts a linear gradient into a background representation.
Name | Type | Default Value | Required? | Description |
---|---|---|---|---|
linearGradient | `String | LinearGradient` | undefined | Yes |
Returns: { angle: Number , background: String }
Builds a linear gradient position attributes for a given angle.
Name | Type | Default Value | Required? | Description |
---|---|---|---|---|
angle | Number | 0 | Yes | The angle to create the x1 / x2 / y1 / y2 cords from. |
Returns: { x1: Number, x2: Number, y1: Number, y2: Number }
FAQs
Parses a SVG linear gradient string / parsed JSON into css background image property
The npm package linear-gradient-parser receives a total of 915 weekly downloads. As such, linear-gradient-parser popularity was classified as not popular.
We found that linear-gradient-parser 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
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.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.