Last active
December 14, 2018 14:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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