Guest User

Untitled

a guest
Dec 14th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. my $string = "unsigned char pixels[] = {";
  7.  
  8. my %facecolors = (
  9. a => "255, 0, 0",
  10. b => "0, 0, 255",
  11. c => "0, 255, 0",
  12. d => "255, 0, 255",
  13. e => "0, 255, 255",
  14. f => "255, 255, 0"
  15. );
  16.  
  17. foreach my $color (sort keys %facecolors) {
  18. if (!($facecolors{$color} eq "255, 255, 0")) {
  19. for (my $i = 0; $i < 64; $i++) {
  20. if ($i % 3 == 0) {
  21. $string .= "\n\t";
  22. }
  23. $string .= qq[$facecolors{$color}, ];
  24. }
  25. $string .= "\n";
  26. } else {
  27. for (my $i = 0; $i < 63; $i++) {
  28. if ($i % 3 == 0) {
  29. $string .= "\n\t";
  30. }
  31. $string .= qq[$facecolors{$color}, ];
  32. }
  33. $string .= qq[\n\t$facecolors{$color}\n];
  34. }
  35. }
  36. $string .= "};\n";
  37. print $string;
Add Comment
Please, Sign In to add comment