New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

svg-polygon-decorator

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg-polygon-decorator - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

lib/index.js

16

package.json
{
"name": "svg-polygon-decorator",
"version": "1.0.1",
"version": "1.0.2",
"description": "Svg polygon decorator (cloud)",

@@ -21,6 +21,18 @@ "main": "src/decorator.js",

"serve": "serve -p 3002",
"lint": "eslint ./src/ && eslint ./demo/index.js"
"lint": "eslint ./src/ && eslint ./demo/index.js",
"prebuild": "npm run lint",
"build": "browserify -v -t [ babelify --presets [ es2015 ] ] -s svgCloud src/decorator.js -o lib/index.js",
"prepublish": "npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com:rumax/svg-polygon-decorator.git"
},
"bugs": {
"url": "https://github.com/rumax/svg-polygon-decorator/issues"
},
"homepage": "https://github.com/rumax/svg-polygon-decorator#readme",
"keywords": [
"svg",
"decorator",
"cloud"

@@ -27,0 +39,0 @@ ],

44

src/decorator.js

@@ -5,3 +5,3 @@

*
* @param {Polygon} poligon
* @param {Polygon} polygon
*

@@ -91,13 +91,15 @@ * @return {SVG Path}

const cloudALine = (line, radius) => {
let intersection = getIntersection(line, radius * 2);
const cloudALine = (line, radius, inward) => {
let point = getIntersection(line, radius * 2);
let remainingLine = line;
let arc;
const cloud = [`M ${line[0][0]}, ${line[0][1]}`];
const cloud = [`M${line[0][X]}, ${line[0][Y]}`];
const sweep = true === inward ? 0 : 1;
const lArc = true === inward ? 0 : 1;
while (intersection) {
arc = ` A ${radius} ${radius} 0 1 1 ${intersection[0]} ${intersection[1]}`;
while (point) {
arc = ` A ${radius} ${radius} 0 ${lArc} ${sweep} ${point[X]} ${point[Y]}`;
cloud.push(arc);
remainingLine = [intersection, remainingLine[1]];
intersection = getIntersection(remainingLine, radius * 2);
remainingLine = [point, remainingLine[1]];
point = getIntersection(remainingLine, radius * 2);
}

@@ -113,22 +115,28 @@

return length / segments / 2;
return 0 < length ? length / segments / 2 : radius;
};
const svgCloud = (poligon, radius) => {
let cloud = `M ${poligon[0][0]}, ${poligon[0][1]}`;
const svgCloud = (polyline, radius, closed, inward) => {
let cloud = '';
let ind = 1;
let line;
const cnt = poligon.length;
const cnt = polyline.length;
for (; ind < cnt; ++ind) {
line = [poligon[ind - 1], poligon[ind]];
cloud += cloudALine(line, fixRadiusToFitLine(line, radius));
if (0 >= ind) {
cloud += ' ';
}
line = [polyline[ind - 1], polyline[ind]];
cloud += cloudALine(line, fixRadiusToFitLine(line, radius), inward);
}
// Last line (last point to first point)
line = [poligon[ind - 1], poligon[0]];
cloud += cloudALine(line, fixRadiusToFitLine(line, radius));
// close to get polygon
if (true === closed) {
line = [polyline[ind - 1], polyline[0]];
cloud += ' ' + cloudALine(line, fixRadiusToFitLine(line, radius), inward);
}
return cloud;
// SVG complains about empty path strings
return cloud || 'M0 0';
};

@@ -135,0 +143,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc