pixelart.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. require_once 'bootstrap.php';
  3. //$pixelCraft = new PixelCraft();
  4. $pixelMap = '
  5. 1111111111111111111111111
  6. 1000000000000000000000001
  7. 1000000000001000000000001
  8. 1000000000011100000000001
  9. 1001000000011100000001001
  10. 1001100000011100000011001
  11. 1001110000011100000111001
  12. 1001111000011100001111001
  13. 1001101100011100011011001
  14. 1001101100011100011011001
  15. 1001100110011100110011001
  16. 1001100110011100110011001
  17. 1001100110011100110011001
  18. 1001100110011100110011001
  19. 1001100110011100110011001
  20. 1001100110011100110011001
  21. 1001100110011100110011001
  22. 1001111100010100011111001
  23. 1001111000110110001111001
  24. 1001101101100011011011001
  25. 1001100111110111110011001
  26. 1001100011011101100011001
  27. 1001100011001001100011001
  28. 1001111111111111111111001
  29. 1001111111111111111111001
  30. 1000000011001001100000001
  31. 1000000001101011000000001
  32. 1000000000111110000000001
  33. 1000000000001000000000001
  34. 1000000000000000000000001
  35. 1111111111111111111111111
  36. ';
  37. $pixelCraft->createImage(25,31);
  38. $pixelCraft->addColor('foreground', 227, 209, 54);
  39. $pixelCraft->addColor('background', 73, 140, 204);
  40. $pixelMap=trim($pixelMap);
  41. $pixelMap=explode(PHP_EOL,$pixelMap);
  42. foreach ($pixelMap as $y=>$xAxis) {
  43. $xAxis=str_split($xAxis);
  44. foreach ($xAxis as $x=>$pixel) {
  45. if ($pixel) {
  46. $pixelCraft->drawPixel($x,$y,'foreground');
  47. } else {
  48. $pixelCraft->drawPixel($x,$y,'background');
  49. }
  50. }
  51. }
  52. $pixelCraft->scale(16);
  53. $pixelCraft->renderImage();