Socket
Socket
Sign inDemoInstall

@drauu/core

Package Overview
Dependencies
1
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.1 to 0.3.2

171

dist/index.global.js

@@ -22,7 +22,7 @@ "use strict";

// ../../node_modules/.pnpm/perfect-freehand@1.1.0/node_modules/perfect-freehand/dist/esm/index.js
function W(e, t, u, x = (g) => g) {
// ../../node_modules/.pnpm/perfect-freehand@1.2.0/node_modules/perfect-freehand/dist/esm/index.js
function $(e, t, u, x = (h) => h) {
return e * x(0.5 - t * (0.5 - u));
}
function re(e) {
function se(e) {
return [-e[0], -e[1]];

@@ -39,3 +39,3 @@ }

}
function le(e, t) {
function he(e, t) {
return [e[0] / t, e[1] / t];

@@ -46,139 +46,140 @@ }

}
function ne(e, t) {
function B(e, t) {
return e[0] * t[0] + e[1] * t[1];
}
function oe(e, t) {
function ue(e, t) {
return e[0] === t[0] && e[1] === t[1];
}
function fe(e) {
function ge(e) {
return Math.hypot(e[0], e[1]);
}
function be(e) {
function de(e) {
return e[0] * e[0] + e[1] * e[1];
}
function Y(e, t) {
return be(a(e, t));
function A(e, t) {
return de(a(e, t));
}
function H(e) {
return le(e, fe(e));
function G(e) {
return he(e, ge(e));
}
function ue(e, t) {
function ie(e, t) {
return Math.hypot(e[1] - t[1], e[0] - t[0]);
}
function L(e, t, u) {
let x = Math.sin(u), g = Math.cos(u), y = e[0] - t[0], n = e[1] - t[1], f = y * g - n * x, d = y * x + n * g;
let x = Math.sin(u), h = Math.cos(u), y = e[0] - t[0], n = e[1] - t[1], f = y * h - n * x, d = y * x + n * h;
return [f + t[0], d + t[1]];
}
function V(e, t, u) {
function K(e, t, u) {
return l(e, b(a(t, e), u));
}
function Z(e, t, u) {
function ee(e, t, u) {
return l(e, b(t, u));
}
var { min: T, PI: ge } = Math;
var se = 0.275;
var j = ge + 1e-4;
function ie(e, t = {}) {
let { size: u = 16, smoothing: x = 0.5, thinning: g = 0.5, simulatePressure: y = true, easing: n = (r) => r, start: f = {}, end: d = {}, last: _ = false } = t, { cap: S = true, easing: q = (r) => r * (2 - r) } = f, { cap: C = true, easing: p = (r) => --r * r * r + 1 } = d;
var { min: C, PI: xe } = Math;
var pe = 0.275;
var V = xe + 1e-4;
function ce(e, t = {}) {
let { size: u = 16, smoothing: x = 0.5, thinning: h = 0.5, simulatePressure: y = true, easing: n = (r) => r, start: f = {}, end: d = {}, last: D2 = false } = t, { cap: S = true, easing: j = (r) => r * (2 - r) } = f, { cap: q = true, easing: c = (r) => --r * r * r + 1 } = d;
if (e.length === 0 || u <= 0)
return [];
let m = e[e.length - 1].runningLength, h = f.taper === false ? 0 : f.taper === true ? Math.max(u, m) : f.taper, z = d.taper === false ? 0 : d.taper === true ? Math.max(u, m) : d.taper, $ = Math.pow(u * x, 2), D2 = [], M = [], N = e.slice(0, 10).reduce((r, i) => {
let p = e[e.length - 1].runningLength, g = f.taper === false ? 0 : f.taper === true ? Math.max(u, p) : f.taper, T = d.taper === false ? 0 : d.taper === true ? Math.max(u, p) : d.taper, te = Math.pow(u * x, 2), _ = [], M = [], H = e.slice(0, 10).reduce((r, i) => {
let o = i.pressure;
if (y) {
let s = T(1, i.distance / u), J = T(1, 1 - s);
o = T(1, r + (J - r) * (s * se));
let s = C(1, i.distance / u), W = C(1, 1 - s);
o = C(1, r + (W - r) * (s * pe));
}
return (r + o) / 2;
}, e[0].pressure), c = W(u, g, e[e.length - 1].pressure, n), U, B = e[0].vector, I = e[0].point, F = I, O = I, E = F;
}, e[0].pressure), m = $(u, h, e[e.length - 1].pressure, n), U, X = e[0].vector, z = e[0].point, F = z, O = z, E = F, J = false;
for (let r = 0; r < e.length; r++) {
let { pressure: i } = e[r], { point: o, vector: s, distance: J, runningLength: K } = e[r];
if (r < e.length - 1 && m - K < 3)
let { pressure: i } = e[r], { point: o, vector: s, distance: W, runningLength: I } = e[r];
if (r < e.length - 1 && p - I < 3)
continue;
if (g) {
if (h) {
if (y) {
let v = T(1, J / u), Q = T(1, 1 - v);
i = T(1, N + (Q - N) * (v * se));
let v = C(1, W / u), Z = C(1, 1 - v);
i = C(1, H + (Z - H) * (v * pe));
}
c = W(u, g, i, n);
m = $(u, h, i, n);
} else
c = u / 2;
U === void 0 && (U = c);
let ce = K < h ? q(K / h) : 1, ae = m - K < z ? p((m - K) / z) : 1;
if (c = Math.max(0.01, c * Math.min(ce, ae)), r === e.length - 1) {
let v = b(R(s), c);
D2.push(a(o, v)), M.push(l(o, v));
m = u / 2;
U === void 0 && (U = m);
let le = I < g ? j(I / g) : 1, fe = p - I < T ? c((p - I) / T) : 1;
m = Math.max(0.01, m * Math.min(le, fe));
let re = (r < e.length - 1 ? e[r + 1] : e[r]).vector, Y = r < e.length - 1 ? B(s, re) : 1, be = B(s, X) < 0 && !J, ne = Y !== null && Y < 0;
if (be || ne) {
let v = b(R(X), m);
for (let Z = 1 / 13, w = 0; w <= 1; w += Z)
O = L(a(o, v), o, V * w), _.push(O), E = L(l(o, v), o, V * -w), M.push(E);
z = O, F = E, ne && (J = true);
continue;
}
let A = e[r + 1].vector, ee = ne(s, A);
if (ee < 0) {
let v = b(R(B), c);
for (let Q = 1 / 13, G = 0; G <= 1; G += Q)
O = L(a(o, v), o, j * G), D2.push(O), E = L(l(o, v), o, j * -G), M.push(E);
I = O, F = E;
if (J = false, r === e.length - 1) {
let v = b(R(s), m);
_.push(a(o, v)), M.push(l(o, v));
continue;
}
let te = b(R(V(A, s, ee)), c);
O = a(o, te), (r <= 1 || Y(I, O) > $) && (D2.push(O), I = O), E = l(o, te), (r <= 1 || Y(F, E) > $) && (M.push(E), F = E), N = i, B = s;
let oe = b(R(K(re, s, Y)), m);
O = a(o, oe), (r <= 1 || A(z, O) > te) && (_.push(O), z = O), E = l(o, oe), (r <= 1 || A(F, E) > te) && (M.push(E), F = E), H = i, X = s;
}
let k = e[0].point.slice(0, 2), P = e.length > 1 ? e[e.length - 1].point.slice(0, 2) : l(e[0].point, [1, 1]), X = [], w = [];
let P = e[0].point.slice(0, 2), k = e.length > 1 ? e[e.length - 1].point.slice(0, 2) : l(e[0].point, [1, 1]), Q = [], N = [];
if (e.length === 1) {
if (!(h || z) || _) {
let r = Z(k, H(R(a(k, P))), -(U || c)), i = [];
if (!(g || T) || D2) {
let r = ee(P, G(R(a(P, k))), -(U || m)), i = [];
for (let o = 1 / 13, s = o; s <= 1; s += o)
i.push(L(r, k, j * 2 * s));
i.push(L(r, P, V * 2 * s));
return i;
}
} else {
if (!(h || z && e.length === 1))
if (!(g || T && e.length === 1))
if (S)
for (let i = 1 / 13, o = i; o <= 1; o += i) {
let s = L(M[0], k, j * o);
X.push(s);
let s = L(M[0], P, V * o);
Q.push(s);
}
else {
let i = a(D2[0], M[0]), o = b(i, 0.5), s = b(i, 0.51);
X.push(a(k, o), a(k, s), l(k, s), l(k, o));
let i = a(_[0], M[0]), o = b(i, 0.5), s = b(i, 0.51);
Q.push(a(P, o), a(P, s), l(P, s), l(P, o));
}
let r = R(re(e[e.length - 1].vector));
if (z || h && e.length === 1)
w.push(P);
else if (C) {
let i = Z(P, r, c);
let r = R(se(e[e.length - 1].vector));
if (T || g && e.length === 1)
N.push(k);
else if (q) {
let i = ee(k, r, m);
for (let o = 1 / 29, s = o; s < 1; s += o)
w.push(L(i, P, j * 3 * s));
N.push(L(i, k, V * 3 * s));
} else
w.push(l(P, b(r, c)), l(P, b(r, c * 0.99)), a(P, b(r, c * 0.99)), a(P, b(r, c)));
N.push(l(k, b(r, m)), l(k, b(r, m * 0.99)), a(k, b(r, m * 0.99)), a(k, b(r, m)));
}
return D2.concat(w, M.reverse(), X);
return _.concat(N, M.reverse(), Q);
}
function me(e, t = {}) {
var C;
let { streamline: u = 0.5, size: x = 16, last: g = false } = t;
var q;
let { streamline: u = 0.5, size: x = 16, last: h = false } = t;
if (e.length === 0)
return [];
let y = 0.15 + (1 - u) * 0.85, n = Array.isArray(e[0]) ? e : e.map(({ x: p, y: m, pressure: h = 0.5 }) => [p, m, h]);
let y = 0.15 + (1 - u) * 0.85, n = Array.isArray(e[0]) ? e : e.map(({ x: c, y: p, pressure: g = 0.5 }) => [c, p, g]);
if (n.length === 2) {
let p = n[1];
let c = n[1];
n = n.slice(0, -1);
for (let m = 1; m < 5; m++)
n.push(V(n[0], p, m / 4));
for (let p = 1; p < 5; p++)
n.push(K(n[0], c, p / 4));
}
n.length === 1 && (n = [...n, [...l(n[0], [1, 1]), ...n[0].slice(2)]]);
let f = [{ point: [n[0][0], n[0][1]], pressure: n[0][2] >= 0 ? n[0][2] : 0.25, vector: [1, 1], distance: 0, runningLength: 0 }], d = false, _ = 0, S = f[0], q = n.length - 1;
for (let p = 1; p < n.length; p++) {
let m = g && p === q ? n[p].slice(0, 2) : V(S.point, n[p], y);
if (oe(S.point, m))
let f = [{ point: [n[0][0], n[0][1]], pressure: n[0][2] >= 0 ? n[0][2] : 0.25, vector: [1, 1], distance: 0, runningLength: 0 }], d = false, D2 = 0, S = f[0], j = n.length - 1;
for (let c = 1; c < n.length; c++) {
let p = h && c === j ? n[c].slice(0, 2) : K(S.point, n[c], y);
if (ue(S.point, p))
continue;
let h = ue(m, S.point);
if (_ += h, p < q && !d) {
if (_ < x)
let g = ie(p, S.point);
if (D2 += g, c < j && !d) {
if (D2 < x)
continue;
d = true;
}
S = { point: m, pressure: n[p][2] >= 0 ? n[p][2] : 0.5, vector: H(a(S.point, m)), distance: h, runningLength: _ }, f.push(S);
S = { point: p, pressure: n[c][2] >= 0 ? n[c][2] : 0.5, vector: G(a(S.point, p)), distance: g, runningLength: D2 }, f.push(S);
}
return f[0].vector = ((C = f[1]) == null ? void 0 : C.vector) || [0, 0], f;
return f[0].vector = ((q = f[1]) == null ? void 0 : q.vector) || [0, 0], f;
}
function pe(e, t = {}) {
return ie(me(e, t), t);
function ae(e, t = {}) {
return ce(me(e, t), t);
}

@@ -327,3 +328,3 @@

getSvgData(points) {
const stroke = pe(points, {
const stroke = ae(points, {
size: this.brush.size * 2,

@@ -647,3 +648,3 @@ thinning: 0.9,

return {
length: Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthY, 2)),
length: Math.sqrt(lengthX ** 2 + lengthY ** 2),
angle: Math.atan2(lengthY, lengthX)

@@ -689,5 +690,5 @@ };

const pathLength = ele.getTotalLength();
for (let j2 = 0; j2 < this.pathSubFactor; j2++) {
const pos1 = ele.getPointAtLength(pathLength * j2 / this.pathSubFactor);
const pos2 = ele.getPointAtLength(pathLength * (j2 + 1) / this.pathSubFactor);
for (let j = 0; j < this.pathSubFactor; j++) {
const pos1 = ele.getPointAtLength(pathLength * j / this.pathSubFactor);
const pos2 = ele.getPointAtLength(pathLength * (j + 1) / this.pathSubFactor);
this.pathFragments.push({

@@ -698,3 +699,3 @@ x1: pos1.x,

y2: pos2.y,
segment: j2,
segment: j,
element: element || ele

@@ -701,0 +702,0 @@ });

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;

@@ -18,2 +20,6 @@ var __export = (target, all) => {

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -49,3 +55,3 @@

// src/models/stylus.ts
var import_perfect_freehand = require("perfect-freehand");
var pf = __toESM(require("perfect-freehand"));

@@ -193,3 +199,3 @@ // src/utils/index.ts

getSvgData(points) {
const stroke = (0, import_perfect_freehand.getStroke)(points, {
const stroke = pf.getStroke(points, {
size: this.brush.size * 2,

@@ -513,3 +519,3 @@ thinning: 0.9,

return {
length: Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthY, 2)),
length: Math.sqrt(lengthX ** 2 + lengthY ** 2),
angle: Math.atan2(lengthY, lengthX)

@@ -516,0 +522,0 @@ };

{
"name": "@drauu/core",
"version": "0.3.1",
"keywords": [],
"version": "0.3.2",
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
"license": "MIT",
"funding": "https://github.com/sponsors/antfu",
"homepage": "https://github.com/antfu/drauu#readme",
"repository": {

@@ -10,7 +12,6 @@ "type": "git",

},
"funding": "https://github.com/sponsors/antfu",
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
"files": [
"dist"
],
"bugs": {
"url": "https://github.com/antfu/drauu/issues"
},
"keywords": [],
"exports": {

@@ -25,11 +26,10 @@ ".": {

"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"jsdelivr": "dist/index.global.js",
"bugs": {
"url": "https://github.com/antfu/drauu/issues"
},
"homepage": "https://github.com/antfu/drauu#readme",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"dependencies": {
"perfect-freehand": "^1.1.0"
"perfect-freehand": "^1.2.0"
},

@@ -36,0 +36,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc