Skip to content

Instantly share code, notes, and snippets.

@hikiko hikiko/uncompressed.pl
Last active Dec 14, 2018

Embed
What would you like to do?
only prints an array with the 6 8x8 cube faces colors to paste in my .h file
#!/usr/bin/perl
use strict;
use warnings;
my $string = "unsigned char pixels[] = {";
my %facecolors = (
a => "255, 0, 0",
b => "0, 0, 255",
c => "0, 255, 0",
d => "255, 0, 255",
e => "0, 255, 255",
f => "255, 255, 0"
);
foreach my $color (sort keys %facecolors) {
if (!($facecolors{$color} eq "255, 255, 0")) {
for (my $i = 0; $i < 64; $i++) {
if ($i % 3 == 0) {
$string .= "\n\t";
}
$string .= qq[$facecolors{$color}, ];
}
$string .= "\n";
} else {
for (my $i = 0; $i < 63; $i++) {
if ($i % 3 == 0) {
$string .= "\n\t";
}
$string .= qq[$facecolors{$color}, ];
}
$string .= qq[\n\t$facecolors{$color}\n];
}
}
$string .= "};\n";
print $string;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.