Skip to content

Instantly share code, notes, and snippets.

@Soulwest
Last active September 29, 2021 19:11
Show Gist options
  • Save Soulwest/fcbe82f06608354dcb41a69b88dd50bd to your computer and use it in GitHub Desktop.
Save Soulwest/fcbe82f06608354dcb41a69b88dd50bd to your computer and use it in GitHub Desktop.
import logging
import sys
import re
logging.basicConfig(level=logging.DEBUG)
logging.info('Convert shadow to convertful config format')
print("Enter rules: ")
rule = '\n'.join(iter(input, ''))
logging.info('Rules: '+rule)
lines = rule.split("\n")
for line in lines:
# Clean and format input
line = re.sub(r'VM\d+:\d+ ', '', line)
args = line.replace(', ', ',').split()
if not args:
logging.warning('Empty shadow')
sys.exit(1)
for i, arg in enumerate(args):
args[i] = arg.replace('px', '')
print('''[
'dx' => {1},
'dy' => {2},
'blur' => {3},
'color' => '{0}',
],'''.format(*args))
$('h1').each(function(k, v){
var shadows = getComputedStyle(v).textShadow;
console.log(shadows.replaceAll(', rgb', ",\nrgb"))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment