libgd00100.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. --TEST--
  2. libgd #100 (spurious horizontal line drawn by gdImageFilledPolygon)
  3. --EXTENSIONS--
  4. gd
  5. --SKIPIF--
  6. <?php
  7. if (!GD_BUNDLED) die("skip requires bundled GD library\n");
  8. ?>
  9. --FILE--
  10. <?php
  11. $im = imagecreatetruecolor(256, 256);
  12. $white = imagecolorallocatealpha($im, 255, 255, 255, 10);
  13. $black = imagecolorallocatealpha($im, 0, 0, 0, 10);
  14. $red = imagecolorallocatealpha($im, 255, 0, 0, 10);
  15. $green = imagecolorallocatealpha($im, 0, 255, 0, 10);
  16. $blue = imagecolorallocatealpha($im, 0, 0, 255, 10);
  17. $yellow = imagecolorallocatealpha($im, 255, 255, 0, 10);
  18. $cyan = imagecolorallocatealpha($im, 0, 255, 255, 10);
  19. $magenta = imagecolorallocatealpha($im, 255, 0, 255, 10);
  20. $purple = imagecolorallocatealpha($im, 100, 0, 100, 10);
  21. imagefilledrectangle($im, 0, 0, 255, 255, $white);
  22. // M (bridge)
  23. $top = 240;
  24. $bot = 255;
  25. $d = 30;
  26. $x = 100;
  27. $points = array(
  28. $x, $top,
  29. $x+2*$d, $top,
  30. $x+2*$d, $bot,
  31. $x+$d, (int) (($top+$bot)/2),
  32. $x, $bot
  33. );
  34. imagefilledpolygon($im, $points, $yellow);
  35. // left-facing M not on baseline
  36. $top = 40;
  37. $bot = 70;
  38. $left = 120;
  39. $right = 180;
  40. $points = array(
  41. $left, $top,
  42. $right, $top,
  43. $right, $bot,
  44. $left, $bot,
  45. ($left+$right)/2, ($top+$bot)/2
  46. );
  47. imagefilledpolygon($im, $points, $purple);
  48. // left-facing M on baseline
  49. $top = 240;
  50. $bot = 270;
  51. $left = 20;
  52. $right = 80;
  53. $points = array(
  54. $left, $top,
  55. $right, $top,
  56. $right, $bot,
  57. $left, $bot,
  58. ($left+$right)/2, ($top+$bot)/2
  59. );
  60. imagefilledpolygon($im, $points, $magenta);
  61. // left-facing M on ceiling
  62. $top = -15;
  63. $bot = 15;
  64. $left = 20;
  65. $right = 80;
  66. $points = array(
  67. $left, $top,
  68. $right, $top,
  69. $right, $bot,
  70. $left, $bot,
  71. ($left+$right)/2, ($top+$bot)/2
  72. );
  73. imagefilledpolygon($im, $points, $blue);
  74. $d = 30;
  75. $x = 150;
  76. $y = 150;
  77. $diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
  78. imagefilledpolygon($im, $diamond, $green);
  79. $x = 180;
  80. $y = 225;
  81. $diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
  82. imagefilledpolygon($im, $diamond, $red);
  83. $x = 225;
  84. $y = 255;
  85. $diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
  86. imagefilledpolygon($im, $diamond, $cyan);
  87. // M (bridge) not touching bottom boundary
  88. $top = 100;
  89. $bot = 150;
  90. $x = 30;
  91. $points = array(
  92. $x, $top,
  93. $x+2*$d, $top,
  94. $x+2*$d, $bot,
  95. $x+$d, ($top+$bot)/2,
  96. $x, $bot
  97. );
  98. imagefilledpolygon($im, $points, $black);
  99. include_once __DIR__ . '/func.inc';
  100. test_image_equals_file(__DIR__ . '/libgd00100.png', $im);
  101. imagedestroy($im);
  102. ?>
  103. --EXPECT--
  104. The images are equal.