UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

21 lines (20 loc) 665 B
"use strict"; const Color = require("../Color.cjs"); const type = require("../utils/type.cjs"); const index = require("../interpolator/index.cjs"); const mix = (col1, col2, f = 0.5, ...rest) => { let mode = rest[0] || "lrgb"; if (!index[mode] && !rest.length) { mode = Object.keys(index)[0]; } if (!index[mode]) { throw new Error(`interpolation mode ${mode} is not defined`); } if (type(col1) !== "object") col1 = new Color(col1); if (type(col2) !== "object") col2 = new Color(col2); return index[mode](col1, col2, f).alpha( col1.alpha() + f * (col2.alpha() - col1.alpha()) ); }; module.exports = mix; //# sourceMappingURL=mix.cjs.map