import color from "color"; /** * Turn the main color of a line into a color suitable for using as a border. * @param {string} mainColor Original color. * @returns {string} Hexadecimal representation of the border color. */ export const makeBorderColor = mainColor => { return color(mainColor).darken(0.2).hex(); }; /** * Turn the main color of a line into a color suitable for using as a border. * @param {string} mainColor Original color. * @returns {string} Hexadecimal representation of the border color. */ export const makeCourseColor = mainColor => { return color(mainColor).lighten(0.2).hex(); }; /** * Make an OpenLayers style function cache its results. * @param {Function} createStyle Create a style based on the cache key value. * @param {Function} [cacheKey] Return the cache key for each feature * (default: identity function). * @return {Function} Style function that caches the generated styles. */ export const cacheStyle = (createStyle, cacheKey = x => x) => { const cache = {}; return (feature) => { const key = cacheKey(feature); if (!(key in cache)) { cache[key] = createStyle(key); } return cache[key]; }; }; export const sizes = { segmentOuter: 8, segmentInner: 6, stopRadius: 6, stopBorder: 1.5, courseSize: 15, courseOuterBorder: 13, courseBorder: 10, courseInnerBorder: 7 };