has several problems and caveats
Usually people donβt use a function like darken() to get the color that they already know they want to finish (they just add the color value that they already know they want). However, I assume that there is more to this issue.
darken() function
The darken() LESS function affects part of the "brightness" or "lightness" of a color, viewed from the point of view of its hsl settings (hue, saturation, lightness). Here, your two colors are considered from this point of view ( based on this site , I noticed some options between sites - some of them are probably more accurate than others):
#952262 = hsl(327, 63%, 36%)
Thus, the darkness you are looking for can be calculated manually from this site, simply by subtraction, 36% - 25% = 11% . Including this in your function:
darken(@base_color, 11%);
Productivity
#671844
Hey! This did not fit my purpose!
Please note that the above s (saturation) value differs from 1% from the base to your target, which means that technically you cannot get from the base color to the target color only through the darken() function, Instead you need to either use another function to change the value of s , or your goal should be slightly adjusted to the following (which keeps s at 63% ):
But this number ( #681844 ) still does not match the LESS output ( #671844 ). The website shows LESS output as hsl(327, 62%, 25%) (note that the saturation value has dropped to 62% ). I suspect that this means the difference in rounding calculations between website calculations and LESS function calculations. This may be the reason why your original number was turned off by 1% during saturation, no matter which program you used rounded differently than on the website. This is probably not a big problem, as it brings you closer to the target value.
Using LESS to calculate
Now, depending on what you are actually doing, you can use LESS to calculate this percentage, instead of calculating it manually using the lightness() function. Suppose you adjusted your target to #681844 based on a website. Then this is an example of getting the desired percentage (I use the fake color-calc property to show the calculation:
@base_color:
Outputs:
.test { color-calc: 11%; color: #671844; }
Note that he calculated the difference of 11% in the dark. Also, note that it still ends with a value slightly different from the target due to this rounding problem (I suppose). Enabling the final LESS value generates ( #671844 ), since the target still gives the same 11% value for darken() .