Skip to content

Instantly share code, notes, and snippets.

@hikiko
Last active December 14, 2018 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hikiko/d730a74948da143922b9f52e31bd3bbe to your computer and use it in GitHub Desktop.
Save hikiko/d730a74948da143922b9f52e31bd3bbe to your computer and use it in GitHub Desktop.
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