UNPKG

@neo4j-ndl/react

Version:

React implementation of Neo4j Design System

46 lines (45 loc) 1.76 kB
/** * * Copyright (c) "Neo4j" * Neo4j Sweden AB [http://neo4j.com] * * This file is part of Neo4j. * * Neo4j is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* * AUTO-GENERATED FILE — DO NOT EDIT. * Source of truth: packages/style-rules/src/ * Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install). */ /** * Computes a linear interpolation weight in [0, 1] for `value` between * `startValue` and `endValue`. Values outside the range produce weights * outside [0, 1] — callers are responsible for clamping if needed. */ export function getWeight(startValue, endValue, value) { return (value - startValue) / (endValue - startValue); } /** * Linearly interpolates between two RGB colors by `weight` (0 = start, 1 = end). * Each channel is rounded to the nearest integer. */ export function lerpColor(startColor, endColor, weight) { return { b: Math.round(startColor.b * (1 - weight) + endColor.b * weight), g: Math.round(startColor.g * (1 - weight) + endColor.g * weight), r: Math.round(startColor.r * (1 - weight) + endColor.r * weight), }; } //# sourceMappingURL=color-utils.js.map