a2d/desk.acc/res/hex2px.pl
2017-09-27 19:41:40 -07:00

13 lines
312 B
Perl
Executable File

#!/usr/bin/env perl
# Convert $xx into px(bbbbbbb) - input to A2D_DRAW_PATTERN
use strict;
use warnings;
while (<STDIN>) {
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;
print;
}