Created
October 18, 2023 12:40
-
-
Save aabele/ca14cc6ea09be9caaa612311d31b76d5 to your computer and use it in GitHub Desktop.
When you have input color and output color and you want to calculate the right `amount` value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
desired_output = '*{color:#2290f0}' | |
# Iterate through possible values of 'amount' | |
for amount in range(1, 100): # Adjust the range as needed | |
# Create the Sass code with the current 'amount' | |
sass_code = f'*{{color:darken(#3a9cf2, {amount})}}' | |
# Run the Sass command and capture the output | |
result = subprocess.run( | |
f'echo "{sass_code}" | sass --stdin --style=compressed', | |
shell=True, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
text=True, | |
) | |
# Check if the resulting CSS matches the desired output | |
if result.stdout.strip() == desired_output: | |
print(f"Found the correct 'amount' value: {amount}") | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo npm install -g sass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment