a2d/desk.acc/res/hex2px.pl

13 lines
312 B
Perl
Raw Normal View History

2017-09-10 00:43:37 +00:00
#!/usr/bin/env perl
# Convert $xx into px(bbbbbbb) - input to A2D_DRAW_PATTERN
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;
}