a2d/res/hex2px.pl

13 lines
304 B
Perl
Raw Normal View History

2017-09-09 17:43:37 -07:00
#!/usr/bin/env perl
2018-01-28 21:18:00 -08:00
# Convert $xx into px(bbbbbbb) - MGTK pattern/bits
2017-09-09 17:43:37 -07:00
use strict;
use warnings;
while (<STDIN>) {
2017-09-27 19:41:40 -07:00
s/(\$([0-7][0-9A-F])\b)/'px(%' . reverse(sprintf('%07b', hex($2))) . ')'/ieg;
s/(\$([89A-F][0-9A-F])\b)/'PX(%' . reverse(sprintf('%07b', 0x7f & hex($2))) . ')'/ieg;
2017-09-09 17:43:37 -07:00
print;
}