Colors
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © miivanov

//@version=5

// @description Helpers for color manipulations
library("Colors")

// @function Applies opacity to color
// @param oldColor color
// @param opacity opacity
// @returns color with opacity
export opacify(color oldColor, float opacity) =>
    color.rgb(color.r(oldColor), color.g(oldColor), color.b(oldColor), opacity)

// @function Gets two colors as parameters and number of colors you need. Returns range of colors between them
// @param topColor color color
// @param bottomColor color
// @param numColors number of colors in range
export getColorsRange(color topColor, color bottomColor, int numColors) =>
    var result = array.new<color>()
    for i = 1 to 6
        array.push(result, color.from_gradient(i, 1, numColors, topColor, bottomColor))
    result