lines.phpt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. --TEST--
  2. imageline no AA
  3. --EXTENSIONS--
  4. gd
  5. --FILE--
  6. <?php
  7. $im = imagecreatetruecolor(6,6);
  8. imagefill($im, 0,0, 0xffffff);
  9. // Horizontal line
  10. imageline($im, 0,5, 5,5, 0x00ff00);
  11. $p1 = imagecolorat($im, 0,5)==0x00ff00;
  12. $p2 = imagecolorat($im, 5,5)==0x00ff00;
  13. $p3 = true;
  14. for ($x=1; $x<5; $x++) {
  15. $p3 = $p3 && (imagecolorat($im, $x,5)==0x00ff00);
  16. }
  17. if ($p1 && $p2 && $p3) {
  18. echo "Horizontal: ok\n";
  19. }
  20. $im = imagecreatetruecolor(6,6);
  21. imagefill($im, 0,0, 0xffffff);
  22. imageline($im, 0,0, 0,5, 0x00ff00);
  23. $p1 = imagecolorat($im, 0,0)==0x00ff00;
  24. $p2 = imagecolorat($im, 0,5)==0x00ff00;
  25. $p3 = true;
  26. for ($y=1; $y<5; $y++) {
  27. $p3 = $p3 && (imagecolorat($im, 0,$y)==0x00ff00);
  28. }
  29. if ($p1 && $p2 && $p3) {
  30. echo "Vertical: ok\n";
  31. }
  32. $im = imagecreatetruecolor(6,6);
  33. imagefill($im, 0,0, 0xffffff);
  34. imageline($im, 0,0, 5,5, 0x00ff00);
  35. // Diagonal
  36. $p1 = imagecolorat($im, 0,0)==0x00ff00;
  37. $p2 = imagecolorat($im, 5,5)==0x00ff00;
  38. $x=1;
  39. $p3 = true;
  40. for ($y=1; $y<5; $y++) {
  41. $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00);
  42. $x++;
  43. }
  44. if ($p1 && $p2 && $p3) {
  45. echo "Diagonal: ok\n";
  46. }
  47. // Outside
  48. $im = imagecreatetruecolor(6,6);
  49. imagefill($im, 0,0, 0xffffff);
  50. imageline($im, 12, 12, 23,23, 0x00ff00);
  51. $p3 = true;
  52. for ($x=0; $x<6; $x++) {
  53. for ($y=0; $y<6; $y++) {
  54. $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00);
  55. }
  56. }
  57. if ($p3) {
  58. echo "Outside 1: ok\n";
  59. }
  60. $im = imagecreatetruecolor(6,6);
  61. imagefill($im, 0,0, 0xffffff);
  62. imageline($im, -12, -12, -23,-23, 0x00ff00);
  63. $p3 = true;
  64. for ($x=0; $x<6; $x++) {
  65. for ($y=0; $y<6; $y++) {
  66. $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00);
  67. }
  68. }
  69. if ($p3) {
  70. echo "Outside 2: ok\n";
  71. }
  72. $im = imagecreatetruecolor(6,6);
  73. imagefill($im, 0,0, 0xffffff);
  74. imageline($im, -1, -1, 4,4, 0x00ff00);
  75. $p3 = true;
  76. for ($x=0; $x<5; $x++) {
  77. for ($y=0; $y<5; $y++) {
  78. $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00);
  79. }
  80. }
  81. if ($p3) {
  82. echo "Outside 2: ok\n";
  83. }
  84. ?>
  85. --EXPECT--
  86. Horizontal: ok
  87. Vertical: ok
  88. Diagonal: ok
  89. Outside 1: ok
  90. Outside 2: ok