Socket
Socket
Sign inDemoInstall

perfect-freehand

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

perfect-freehand - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

dist/esm/index.mjs

6

package.json
{
"version": "1.2.0",
"version": "1.2.1",
"name": "perfect-freehand",

@@ -28,3 +28,3 @@ "private": false,

"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
"import": "./dist/esm/index.mjs"
}

@@ -34,3 +34,3 @@ },

"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"module": "./dist/esm/index.mjs",
"types": "./dist/types/index.d.ts",

@@ -37,0 +37,0 @@ "typings": "./dist/types/index.d.ts",

@@ -267,22 +267,31 @@ # ![Screenshot](assets/perfect-freehand-logo.svg 'Perfect Freehand')

function getSvgPathFromStroke(stroke) {
function getSvgPathFromStroke(points, closed = true) {
const len = points.length
if (!len) {
return ''
if (len < 4) {
return ``
}
const first = points[0]
let result = `M${first[0].toFixed(3)},${first[1].toFixed(3)}Q`
let a = points[0]
let b = points[1]
const c = points[2]
for (let i = 0, max = len - 1; i < max; i++) {
const a = points[i]
const b = points[i + 1]
result += `${a[0].toFixed(3)},${a[1].toFixed(3)} ${average(
a[0],
b[0]
).toFixed(3)},${average(a[1], b[1]).toFixed(3)} `
let result = `M${a[0].toFixed(2)},${a[1].toFixed(2)} Q${b[0].toFixed(
2
)},${b[1].toFixed(2)} ${average(b[0], c[0]).toFixed(2)},${average(
b[1],
c[1]
).toFixed(2)} T`
for (let i = 2, max = len - 1; i < max; i++) {
a = points[i]
b = points[i + 1]
result += `${average(a[0], b[0]).toFixed(2)},${average(a[1], b[1]).toFixed(
2
)} `
}
result += 'Z'
if (closed) {
result += 'Z'
}

@@ -289,0 +298,0 @@ return result

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