Add yet-another-react-lightbox package and update .gitignore to exclude node_modules

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-12 18:50:30 +00:00
parent bd2a5570a9
commit c92f4a5edd
9304 changed files with 29 additions and 2008667 deletions

View File

@@ -1,4 +0,0 @@
.DS_Store
.git*
test
package-lock.json

View File

@@ -1,5 +0,0 @@
language: node_js
node_js:
- "4"
- "6"
sudo: false

View File

@@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2015 yr.no
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,23 +0,0 @@
[![NPM Version](https://img.shields.io/npm/v/@yr/monotone-cubic-spline.svg?style=flat)](https://npmjs.org/package/@yr/monotone-cubic-spline)
[![Build Status](https://img.shields.io/travis/YR/monotone-cubic-spline.svg?style=flat)](https://travis-ci.org/YR/monotone-cubic-spline?branch=master)
Convert a series of points to a monotone cubic spline (based on D3.js implementation)
## Usage
```js
const spline = require('@yr/monotone-cubic-spline');
const points = spline.points([[0,0], [1,1], [2,1], [3,0], [4,0]]);
const svgPath = spline.svgPath(points);
console.log(svgPath);
// => 'M0 0C0.08333333333333333, 0.08333333333333333, ...'
```
## API
**points(points)**: convert array of points (x,y) to array of bezier points (c1x,c1y,c2x,c2y,x,y)
**slice(points, start, end)**: slice a segment of converted points
**svgPath(points)**: convert array of bezier points to svg path (`d`) string

View File

@@ -1,166 +0,0 @@
'use strict';
/**
* Convert a series of points to a monotone cubic spline
* Algorithm based on https://github.com/mbostock/d3
* https://github.com/yr/monotone-cubic-spline
* @copyright Yr
* @license MIT
*/
var ε = 1e-6;
module.exports = {
/**
* Convert 'points' to bezier
* @param {Array} points
* @returns {Array}
*/
points: function points(_points) {
var tgts = tangents(_points);
var p = _points[1];
var p0 = _points[0];
var pts = [];
var t = tgts[1];
var t0 = tgts[0];
// Add starting 'M' and 'C' points
pts.push(p0, [p0[0] + t0[0], p0[1] + t0[1], p[0] - t[0], p[1] - t[1], p[0], p[1]]);
// Add 'S' points
for (var i = 2, n = tgts.length; i < n; i++) {
var _p = _points[i];
var _t = tgts[i];
pts.push([_p[0] - _t[0], _p[1] - _t[1], _p[0], _p[1]]);
}
return pts;
},
/**
* Slice out a segment of 'points'
* @param {Array} points
* @param {Number} start
* @param {Number} end
* @returns {Array}
*/
slice: function slice(points, start, end) {
var pts = points.slice(start, end);
if (start) {
// Add additional 'C' points
if (pts[1].length < 6) {
var n = pts[0].length;
pts[1] = [pts[0][n - 2] * 2 - pts[0][n - 4], pts[0][n - 1] * 2 - pts[0][n - 3]].concat(pts[1]);
}
// Remove control points for 'M'
pts[0] = pts[0].slice(-2);
}
return pts;
},
/**
* Convert 'points' to svg path
* @param {Array} points
* @returns {String}
*/
svgPath: function svgPath(points) {
var p = '';
for (var i = 0; i < points.length; i++) {
var point = points[i];
var n = point.length;
if (!i) {
p += 'M' + point[n - 2] + ' ' + point[n - 1];
} else if (n > 4) {
p += 'C' + point[0] + ', ' + point[1];
p += ', ' + point[2] + ', ' + point[3];
p += ', ' + point[4] + ', ' + point[5];
} else {
p += 'S' + point[0] + ', ' + point[1];
p += ', ' + point[2] + ', ' + point[3];
}
}
return p;
}
};
/**
* Generate tangents for 'points'
* @param {Array} points
* @returns {Array}
*/
function tangents(points) {
var m = finiteDifferences(points);
var n = points.length - 1;
var tgts = [];
var a = void 0,
b = void 0,
d = void 0,
s = void 0;
for (var i = 0; i < n; i++) {
d = slope(points[i], points[i + 1]);
if (Math.abs(d) < ε) {
m[i] = m[i + 1] = 0;
} else {
a = m[i] / d;
b = m[i + 1] / d;
s = a * a + b * b;
if (s > 9) {
s = d * 3 / Math.sqrt(s);
m[i] = s * a;
m[i + 1] = s * b;
}
}
}
for (var _i = 0; _i <= n; _i++) {
s = (points[Math.min(n, _i + 1)][0] - points[Math.max(0, _i - 1)][0]) / (6 * (1 + m[_i] * m[_i]));
tgts.push([s || 0, m[_i] * s || 0]);
}
return tgts;
}
/**
* Compute slope from point 'p0' to 'p1'
* @param {Array} p0
* @param {Array} p1
* @returns {Number}
*/
function slope(p0, p1) {
return (p1[1] - p0[1]) / (p1[0] - p0[0]);
}
/**
* Compute three-point differences for 'points'
* @param {Array} points
* @returns {Array}
*/
function finiteDifferences(points) {
var m = [];
var p0 = points[0];
var p1 = points[1];
var d = m[0] = slope(p0, p1);
var i = 1;
for (var n = points.length - 1; i < n; i++) {
p0 = p1;
p1 = points[i + 1];
m[i] = (d + (d = slope(p0, p1))) * 0.5;
}
m[i] = d;
return m;
}

View File

@@ -1,57 +0,0 @@
{
"name": "@yr/monotone-cubic-spline",
"description": "Convert a series of points to a monotone cubic spline",
"version": "1.0.3",
"author": "Alexander Pope <alexander.pope@nrk.no>",
"dependencies": {},
"devDependencies": {
"babel-plugin-syntax-trailing-function-commas": "6.22.0",
"babel-plugin-transform-async-generator-functions": "6.24.1",
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-plugin-transform-es2015-arrow-functions": "6.22.0",
"babel-plugin-transform-es2015-block-scoped-functions": "6.22.0",
"babel-plugin-transform-es2015-block-scoping": "6.24.1",
"babel-plugin-transform-es2015-classes": "6.24.1",
"babel-plugin-transform-es2015-computed-properties": "6.24.1",
"babel-plugin-transform-es2015-destructuring": "6.23.0",
"babel-plugin-transform-es2015-duplicate-keys": "6.24.1",
"babel-plugin-transform-es2015-for-of": "6.23.0",
"babel-plugin-transform-es2015-function-name": "6.24.1",
"babel-plugin-transform-es2015-literals": "6.22.0",
"babel-plugin-transform-es2015-object-super": "6.24.1",
"babel-plugin-transform-es2015-parameters": "6.24.1",
"babel-plugin-transform-es2015-shorthand-properties": "6.24.1",
"babel-plugin-transform-es2015-spread": "6.22.0",
"babel-plugin-transform-es2015-sticky-regex": "6.24.1",
"babel-plugin-transform-es2015-template-literals": "6.22.0",
"babel-plugin-transform-es2015-unicode-regex": "6.24.1",
"babel-plugin-transform-es5-property-mutators": "6.24.1",
"babel-plugin-transform-exponentiation-operator": "6.24.1",
"babel-plugin-transform-object-rest-spread": "6.23.0",
"buddy": "6.x.x",
"expect.js": "*",
"mocha": "*"
},
"main": "src/index.js",
"repository": "https://github.com/YR/monotone-cubic-spline.git",
"license": "MIT",
"scripts": {
"prepublish": "buddy build",
"test": "NODE_ENV=test mocha test/lib-test.js --reporter spec"
},
"browser": "index.js",
"buddy": {
"build": [
{
"input": "src/",
"output": ".",
"bundle": false,
"version": "es5"
},
{
"input": "src/index.js",
"output": "test/lib.js"
}
]
}
}

View File

@@ -1,161 +0,0 @@
'use strict';
/**
* Convert a series of points to a monotone cubic spline
* Algorithm based on https://github.com/mbostock/d3
* https://github.com/yr/monotone-cubic-spline
* @copyright Yr
* @license MIT
*/
const ε = 1e-6;
module.exports = {
/**
* Convert 'points' to bezier
* @param {Array} points
* @returns {Array}
*/
points(points) {
const tgts = tangents(points);
const p = points[1];
const p0 = points[0];
const pts = [];
const t = tgts[1];
const t0 = tgts[0];
// Add starting 'M' and 'C' points
pts.push(p0, [p0[0] + t0[0], p0[1] + t0[1], p[0] - t[0], p[1] - t[1], p[0], p[1]]);
// Add 'S' points
for (let i = 2, n = tgts.length; i < n; i++) {
const p = points[i];
const t = tgts[i];
pts.push([p[0] - t[0], p[1] - t[1], p[0], p[1]]);
}
return pts;
},
/**
* Slice out a segment of 'points'
* @param {Array} points
* @param {Number} start
* @param {Number} end
* @returns {Array}
*/
slice(points, start, end) {
const pts = points.slice(start, end);
if (start) {
// Add additional 'C' points
if (pts[1].length < 6) {
const n = pts[0].length;
pts[1] = [pts[0][n - 2] * 2 - pts[0][n - 4], pts[0][n - 1] * 2 - pts[0][n - 3]].concat(pts[1]);
}
// Remove control points for 'M'
pts[0] = pts[0].slice(-2);
}
return pts;
},
/**
* Convert 'points' to svg path
* @param {Array} points
* @returns {String}
*/
svgPath(points) {
let p = '';
for (let i = 0; i < points.length; i++) {
const point = points[i];
const n = point.length;
if (!i) {
p += `M${point[n - 2]} ${point[n - 1]}`;
} else if (n > 4) {
p += `C${point[0]}, ${point[1]}`;
p += `, ${point[2]}, ${point[3]}`;
p += `, ${point[4]}, ${point[5]}`;
} else {
p += `S${point[0]}, ${point[1]}`;
p += `, ${point[2]}, ${point[3]}`;
}
}
return p;
}
};
/**
* Generate tangents for 'points'
* @param {Array} points
* @returns {Array}
*/
function tangents(points) {
const m = finiteDifferences(points);
const n = points.length - 1;
const tgts = [];
let a, b, d, s;
for (let i = 0; i < n; i++) {
d = slope(points[i], points[i + 1]);
if (Math.abs(d) < ε) {
m[i] = m[i + 1] = 0;
} else {
a = m[i] / d;
b = m[i + 1] / d;
s = a * a + b * b;
if (s > 9) {
s = d * 3 / Math.sqrt(s);
m[i] = s * a;
m[i + 1] = s * b;
}
}
}
for (let i = 0; i <= n; i++) {
s = (points[Math.min(n, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i]));
tgts.push([s || 0, m[i] * s || 0]);
}
return tgts;
}
/**
* Compute slope from point 'p0' to 'p1'
* @param {Array} p0
* @param {Array} p1
* @returns {Number}
*/
function slope(p0, p1) {
return (p1[1] - p0[1]) / (p1[0] - p0[0]);
}
/**
* Compute three-point differences for 'points'
* @param {Array} points
* @returns {Array}
*/
function finiteDifferences(points) {
const m = [];
let p0 = points[0];
let p1 = points[1];
let d = (m[0] = slope(p0, p1));
let i = 1;
for (let n = points.length - 1; i < n; i++) {
p0 = p1;
p1 = points[i + 1];
m[i] = (d + (d = slope(p0, p1))) * 0.5;
}
m[i] = d;
return m;
}