UNPKG

synapse-react-client

Version:

[![Build Status](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client.svg?branch=main)](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client) [![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synaps

37 lines 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getColorPalette = exports.rgba2rgb = void 0; var colorPalette_1 = require("../utils/functions/colorPalette"); function rgba2rgb(background, color) { var alpha = color[3]; return [ Math.floor((1 - alpha) * background[0] + alpha * color[0] + 0.5), Math.floor((1 - alpha) * background[1] + alpha * color[1] + 0.5), Math.floor((1 - alpha) * background[2] + alpha * color[2] + 0.5), ]; } exports.rgba2rgb = rgba2rgb; function getColorPalette(start, end) { var colorPaletteSelection = []; var textColors = []; var offset = -1; if (start % 2 === 0) { colorPaletteSelection = colorPalette_1.COLOR_PALETTE_EVEN; offset = start * 5; } else { colorPaletteSelection = colorPalette_1.COLOR_PALETTE_ODD; offset = (start - 1) * 5; } var colorPalette = []; for (var i = 0; i < end; i += 1) { var textColor = i % 10 < 2 || i % 10 > 7 ? 'white' : 'black'; var color = "" + colorPaletteSelection[(offset + i) % colorPaletteSelection.length]; colorPalette.push(color); textColors.push(textColor); } return { colorPalette: colorPalette, textColors: textColors }; } exports.getColorPalette = getColorPalette; exports.default = getColorPalette; //# sourceMappingURL=ColorGradient.js.map