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

flubber

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flubber - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

test/array-test.js

2

package.json
{
"name": "flubber",
"version": "0.2.2",
"version": "0.2.3",
"description": "Best-guess methods for smoothly interpolating and animating between shapes.",

@@ -5,0 +5,0 @@ "main": "build/flubber.min.js",

@@ -20,7 +20,22 @@ import { interpolateRing } from "./interpolate.js";

if (single) {
let merged = toPathString(fromRing);
let multiInterpolator = string
? t => interpolators.map(fn => fn(t)).join(" ")
: t => interpolators.map(fn => fn(t));
if (string) {
return t => (t < 1e-4 ? merged : interpolators.map(i => i(t)).join(" "));
let useFrom = typeof fromShape === "string" && fromShape,
useTo = toShapes.every(s => typeof s === "string") && toShapes.join(" ");
if (useFrom || useTo) {
return t => (t < 1e-4 && useFrom) || (1 - t < 1e-4 && useTo) || multiInterpolator(t);
}
}
return t => interpolators.map(i => i(t));
return multiInterpolator;
} else if (string) {
return interpolators.map((fn, i) => {
if (typeof toShapes[i] === "string") {
return t => (1 - t < 1e-4 ? toShapes[i] : fn(t));
}
return fn;
});
}

@@ -27,0 +42,0 @@

@@ -59,3 +59,4 @@ import { neighbors, mergeArcs, feature } from "topojson-client";

export function collapseTopology(topology, numPieces) {
const geometries = topology.objects.triangles.geometries, bisect = bisector(d => d.area).left;
const geometries = topology.objects.triangles.geometries,
bisect = bisector(d => d.area).left;

@@ -62,0 +63,0 @@ while (geometries.length > numPieces) {

import { supertape } from "./utils.js";
import normalizeRing from "../src/normalize.js";
import interpolate from "../src/interpolate.js";
import { separate, combine } from "../src/multiple.js";
import { toPathString, splitPathString, pathStringToRing } from "../src/svg.js";

@@ -8,2 +9,6 @@

let halfcircle = "M0,0 A50,50,0,0,0,100,0Z",
bezier =
"M636.5,315c-0.4-18.7,1.9-27.9-5.3-35.9c-22.7-25-107.3-2.8-118.3,35.9c-7,24.4,20.6,37.2,16,71c-4,29.6-30.8,60.7-56.5,61.1c-30.8,0.4-32.9-43.8-81.7-70.2c-50.9-27.6-110.1-12.9-125.2-9.2c-66.1,16.4-82.2,56.9-109.2,47.3c-38-13.6-55.9-112.1-19.8-143.5c39-34,121.2,27.7,148.1-3.8c18-21.1,3.1-74.3-25.2-105.3c-31.1-34.1-70.1-32.4-105.3-76.3c-8.2-10.2-16.9-23.8-15.3-39.7c1.2-11.4,7.5-23.3,15.3-29c33.8-25,101.6,62.6,193.1,59.5c40.1-1.3,38.7-18.5,99.2-38.9c126.2-42.6,242.4-4.9,297.7,13c54.7,17.7,105.4,35,129.8,82.4c13,25.3,22.9,67.7,4.6,87c-11.6,12.3-25.1,5.1-46.6,20.6c-2.8,2-28.9,21.4-32.1,49.6c-3.1,27.4,18.7,35,29,70.2c8.8,30.1,8.5,77.8-18.3,99.2c-32.3,25.8-87,0.6-100-5.3c-69.6-32-67.2-88.4-73.3-109.2z";
tape("toPathString", function(test) {

@@ -69,6 +74,2 @@ test.equal(toPathString([[0, 0], [1, 1], [2, 2]]), "M0,0L1,1L2,2Z");

tape("interpolate preserve string at t=0, t=1", function(test) {
let halfcircle = "M0,0 A50,50,0,0,0,100,0Z",
bezier =
"M636.5,315c-0.4-18.7,1.9-27.9-5.3-35.9c-22.7-25-107.3-2.8-118.3,35.9c-7,24.4,20.6,37.2,16,71c-4,29.6-30.8,60.7-56.5,61.1c-30.8,0.4-32.9-43.8-81.7-70.2c-50.9-27.6-110.1-12.9-125.2-9.2c-66.1,16.4-82.2,56.9-109.2,47.3c-38-13.6-55.9-112.1-19.8-143.5c39-34,121.2,27.7,148.1-3.8c18-21.1,3.1-74.3-25.2-105.3c-31.1-34.1-70.1-32.4-105.3-76.3c-8.2-10.2-16.9-23.8-15.3-39.7c1.2-11.4,7.5-23.3,15.3-29c33.8-25,101.6,62.6,193.1,59.5c40.1-1.3,38.7-18.5,99.2-38.9c126.2-42.6,242.4-4.9,297.7,13c54.7,17.7,105.4,35,129.8,82.4c13,25.3,22.9,67.7,4.6,87c-11.6,12.3-25.1,5.1-46.6,20.6c-2.8,2-28.9,21.4-32.1,49.6c-3.1,27.4,18.7,35,29,70.2c8.8,30.1,8.5,77.8-18.3,99.2c-32.3,25.8-87,0.6-100-5.3c-69.6-32-67.2-88.4-73.3-109.2z";
let interpolator = interpolate(halfcircle, bezier);

@@ -80,4 +81,4 @@

let ringInterpolator = interpolate(halfcircle, bezier, { string: false }),
first = ringInterpolator(0),
last = ringInterpolator(1);
first = ringInterpolator(0),
last = ringInterpolator(1);

@@ -111,1 +112,36 @@ test.deepEqual(first.length, last.length);

});
tape("separate/combine single preserve string at t=0, t=1", function(test) {
let square = "M0,0L100,0L100,100L0,100Z";
let separator = separate(square, [halfcircle, bezier], { single: true }),
combiner = combine([halfcircle, bezier], square, { single: true });
test.equal(separator(0), square);
test.equal(separator(1), [halfcircle, bezier].join(" "));
test.equal(separator(0), combiner(1));
test.equal(separator(1), combiner(0));
test.end();
});
tape("separate/combine preserve string at t=1", function(test) {
let square = "M0,0L100,0L100,100L0,100Z";
let separator = separate(square, [halfcircle, bezier]),
combiner = combine([halfcircle, bezier], square);
test.equal(separator[0](1), halfcircle);
test.equal(separator[1](1), bezier);
test.equal(separator[0](1), combiner[0](0));
test.equal(separator[1](1), combiner[1](0));
test.equal(separator.length, combiner.length);
test.assert(
separator.every(function(fn) {
let val = fn(0.5);
return typeof val === "string";
})
);
test.end();
});

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