Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@visactor/vutils

Package Overview
Dependencies
Maintainers
15
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visactor/vutils - npm Package Compare versions

Comparing version 0.18.8 to 0.18.9

8

cjs/angle.d.ts

@@ -14,1 +14,9 @@ import type { IPointLike } from './data-structure/point';

export declare function normalizeAngle(angle: number): number;
export declare function findBoundaryAngles(startAngle: number, endAngle: number): number[];
export declare function calculateMaxRadius(rect: {
width: number;
height: number;
}, center: {
x: number;
y: number;
}, startAngle: number, endAngle: number): number;

29

cjs/angle.js

@@ -5,3 +5,3 @@ "use strict";

value: !0
}), exports.normalizeAngle = exports.getAngleByPoint = exports.polarToCartesian = exports.clampAngleByDegree = exports.clampDegree = exports.clampAngleByRadian = exports.clampRadian = exports.radianToDegree = exports.degreeToRadian = void 0;
}), exports.calculateMaxRadius = exports.findBoundaryAngles = exports.normalizeAngle = exports.getAngleByPoint = exports.polarToCartesian = exports.clampAngleByDegree = exports.clampDegree = exports.clampAngleByRadian = exports.clampRadian = exports.radianToDegree = exports.degreeToRadian = void 0;

@@ -30,5 +30,8 @@ const math_1 = require("./math");

function polarToCartesian(center, radius, angleInRadian) {
return {
return radius ? {
x: center.x + radius * Math.cos(angleInRadian),
y: center.y + radius * Math.sin(angleInRadian)
} : {
x: center.x,
y: center.y
};

@@ -47,4 +50,24 @@ }

function findBoundaryAngles(startAngle, endAngle) {
const deltaAngle = Math.abs(endAngle - startAngle);
if (deltaAngle >= 2 * Math.PI || 2 * Math.PI - deltaAngle < 1e-6) return [ 0, Math.PI / 2, Math.PI, 1.5 * Math.PI ];
const normalMin = normalizeAngle(Math.min(startAngle, endAngle)), normalMax = normalMin + deltaAngle, steps = [ normalMin, normalMax ];
let directionAngle = Math.floor(normalMin / Math.PI) * Math.PI / 2;
for (;directionAngle < normalMax; ) directionAngle > normalMin && steps.push(directionAngle),
directionAngle += Math.PI / 2;
return steps;
}
function calculateMaxRadius(rect, center, startAngle, endAngle) {
const {x: x, y: y} = center, steps = findBoundaryAngles(startAngle, endAngle), {width: width, height: height} = rect, radiusList = [];
return steps.forEach((step => {
const sin = Math.sin(step), cos = Math.cos(step);
1 === sin ? radiusList.push(height - y) : -1 === sin ? radiusList.push(y) : 1 === cos ? radiusList.push(width - x) : -1 === cos ? radiusList.push(x) : (sin > 0 ? radiusList.push(Math.abs((height - y) / cos)) : radiusList.push(Math.abs(y / cos)),
cos > 0 ? radiusList.push(Math.abs((width - x) / sin)) : radiusList.push(Math.abs(x / sin)));
})), Math.min.apply(null, radiusList);
}
exports.clampDegree = clampDegree, exports.clampAngleByDegree = exports.clampDegree,
exports.polarToCartesian = polarToCartesian, exports.getAngleByPoint = getAngleByPoint,
exports.normalizeAngle = normalizeAngle;
exports.normalizeAngle = normalizeAngle, exports.findBoundaryAngles = findBoundaryAngles,
exports.calculateMaxRadius = calculateMaxRadius;

@@ -14,1 +14,9 @@ import type { IPointLike } from './data-structure/point';

export declare function normalizeAngle(angle: number): number;
export declare function findBoundaryAngles(startAngle: number, endAngle: number): number[];
export declare function calculateMaxRadius(rect: {
width: number;
height: number;
}, center: {
x: number;
y: number;
}, startAngle: number, endAngle: number): number;

@@ -23,5 +23,8 @@ import { tau } from "./math";

export function polarToCartesian(center, radius, angleInRadian) {
return {
return radius ? {
x: center.x + radius * Math.cos(angleInRadian),
y: center.y + radius * Math.sin(angleInRadian)
} : {
x: center.x,
y: center.y
};

@@ -38,2 +41,21 @@ }

return angle;
}
export function findBoundaryAngles(startAngle, endAngle) {
const deltaAngle = Math.abs(endAngle - startAngle);
if (deltaAngle >= 2 * Math.PI || 2 * Math.PI - deltaAngle < 1e-6) return [ 0, Math.PI / 2, Math.PI, 1.5 * Math.PI ];
const normalMin = normalizeAngle(Math.min(startAngle, endAngle)), normalMax = normalMin + deltaAngle, steps = [ normalMin, normalMax ];
let directionAngle = Math.floor(normalMin / Math.PI) * Math.PI / 2;
for (;directionAngle < normalMax; ) directionAngle > normalMin && steps.push(directionAngle),
directionAngle += Math.PI / 2;
return steps;
}
export function calculateMaxRadius(rect, center, startAngle, endAngle) {
const {x: x, y: y} = center, steps = findBoundaryAngles(startAngle, endAngle), {width: width, height: height} = rect, radiusList = [];
return steps.forEach((step => {
const sin = Math.sin(step), cos = Math.cos(step);
1 === sin ? radiusList.push(height - y) : -1 === sin ? radiusList.push(y) : 1 === cos ? radiusList.push(width - x) : -1 === cos ? radiusList.push(x) : (sin > 0 ? radiusList.push(Math.abs((height - y) / cos)) : radiusList.push(Math.abs(y / cos)),
cos > 0 ? radiusList.push(Math.abs((width - x) / sin)) : radiusList.push(Math.abs(x / sin)));
})), Math.min.apply(null, radiusList);
}

6

package.json
{
"name": "@visactor/vutils",
"version": "0.18.8",
"version": "0.18.9",
"main": "cjs/index.js",

@@ -31,5 +31,5 @@ "module": "es/index.js",

"@internal/bundler": "0.0.1",
"@internal/eslint-config": "0.0.1",
"@internal/ts-config": "0.0.1",
"@internal/jest-config": "0.0.1"
"@internal/jest-config": "0.0.1",
"@internal/eslint-config": "0.0.1"
},

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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