I am looking to create a function that can calculate the second hex color of a button background gradient based on the first one (as shown in the sample below).
The idea is to use a color picker to select the initial color from the user and retrieve it using JavaScript (e.g. #ededed in the example). Then, I want to use JS to determine an offset to generate the second color for the gradient effect (#dfdfdf in the demonstration). The color shift will remain consistent; only the input and output hex colors will change.
Is there a formula or a specific function that I could utilize for this task? Thank you!
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf) );