a2d/res/hex2px.pl

13 lines
304 B
Perl
Raw Normal View History

2017-09-10 00:43:37 +00:00
#!/usr/bin/env perl
2018-01-29 05:18:00 +00:00
# Convert $xx into px(bbbbbbb) - MGTK pattern/bits
2017-09-10 00:43:37 +00:00
use strict;
use warnings;
while (<STDIN>) {
2017-09-28 02:41:40 +00: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-10 00:43:37 +00:00
print;
}