Skip to content

Instantly share code, notes, and snippets.

@tamask
Created December 9, 2011 17:16
Show Gist options
  • Save tamask/1452436 to your computer and use it in GitHub Desktop.
Save tamask/1452436 to your computer and use it in GitHub Desktop.
texpack atlas to css (default texpack format)
import sys
atlas = sys.stdin.read()
for item in atlas.split('\n'):
if not item:
continue
tokens = item.split('\t')
atlas = tokens[0]
source = tokens[1]
left = int(tokens[2])
top = int(tokens[3])
right = int(tokens[4])
bottom = int(tokens[5])
print (
'.%s { '
'background: url(%s) -%spx -%spx no-repeat; '
'width: %spx; '
'height: %spx; '
'}'
) % (source, atlas, left, top, (right - left), (bottom - top))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment