libgd00100.phpt 2.5 KB

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