Public
Edited
Apr 17, 2018
6 stars
That colorful fontGooey glyph morphing?
Morphing glyphs with Opentype.js and flubber (#2)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// `prev` and `next` are both lists of opentype paths
function make_interpolators (prev, next, options = {}) {
// first, some edge cases
if (prev.length == 0 && 0 == next.length) {
return [];
}
if (next.length == 0) {
return prev.map(op => flubber.interpolate(op.toPathData(), [op_center(op)], options));
}
if (prev.length == 0) {
return next.map(op => flubber.interpolate([op_center(op)], op.toPathData(), options));
}
// normality
var prevpaths = prev.map(op => op.toPathData());
var nextpaths = next.map(op => op.toPathData());
const N = Math.min(prevpaths.length - 1, nextpaths.length - 1);
var interpolators = [];
for (var i = 0; i < N; i++) {
interpolators.push(flubber.interpolate(prevpaths[i], nextpaths[i], options));
}
if (prevpaths.length > nextpaths.length) {
interpolators = interpolators.concat(flubber.combine(
prevpaths.slice(N),
nextpaths[nextpaths.length - 1],
options
));
} else {
interpolators = interpolators.concat(flubber.separate(
prevpaths[prevpaths.length - 1],
nextpaths.slice(N),
options
));
}
return interpolators;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more