PageRenderTime 57ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/good/ext/gd/tests/libgd00100.php

https://gitlab.com/iranjith4/hhvm
PHP | 109 lines | 91 code | 13 blank | 5 comment | 0 complexity | 1adc6f26110094bd04e64acfe1ac3385 MD5 | raw file
  1. <?php
  2. $im = imagecreatetruecolor(256, 256);
  3. $white = imagecolorallocatealpha($im, 255, 255, 255, 10);
  4. $black = imagecolorallocatealpha($im, 0, 0, 0, 10);
  5. $red = imagecolorallocatealpha($im, 255, 0, 0, 10);
  6. $green = imagecolorallocatealpha($im, 0, 255, 0, 10);
  7. $blue = imagecolorallocatealpha($im, 0, 0, 255, 10);
  8. $yellow = imagecolorallocatealpha($im, 255, 255, 0, 10);
  9. $cyan = imagecolorallocatealpha($im, 0, 255, 255, 10);
  10. $magenta = imagecolorallocatealpha($im, 255, 0, 255, 10);
  11. $purple = imagecolorallocatealpha($im, 100, 0, 100, 10);
  12. imagefilledrectangle($im, 0, 0, 255, 255, $white);
  13. // M (bridge)
  14. $top = 240;
  15. $bot = 255;
  16. $d = 30;
  17. $x = 100;
  18. $points = array(
  19. $x, $top,
  20. $x+2*$d, $top,
  21. $x+2*$d, $bot,
  22. $x+$d, ($top+$bot)/2,
  23. $x, $bot
  24. );
  25. imagefilledpolygon($im, $points, 5, $yellow);
  26. // left-facing M not on baseline
  27. $top = 40;
  28. $bot = 70;
  29. $left = 120;
  30. $right = 180;
  31. $points = array(
  32. $left, $top,
  33. $right, $top,
  34. $right, $bot,
  35. $left, $bot,
  36. ($left+$right)/2, ($top+$bot)/2
  37. );
  38. imagefilledpolygon($im, $points, 5, $purple);
  39. // left-facing M on baseline
  40. $top = 240;
  41. $bot = 270;
  42. $left = 20;
  43. $right = 80;
  44. $points = array(
  45. $left, $top,
  46. $right, $top,
  47. $right, $bot,
  48. $left, $bot,
  49. ($left+$right)/2, ($top+$bot)/2
  50. );
  51. imagefilledpolygon($im, $points, 5, $magenta);
  52. // left-facing M on ceiling
  53. $top = -15;
  54. $bot = 15;
  55. $left = 20;
  56. $right = 80;
  57. $points = array(
  58. $left, $top,
  59. $right, $top,
  60. $right, $bot,
  61. $left, $bot,
  62. ($left+$right)/2, ($top+$bot)/2
  63. );
  64. imagefilledpolygon($im, $points, 5, $blue);
  65. $d = 30;
  66. $x = 150;
  67. $y = 150;
  68. $diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
  69. imagefilledpolygon($im, $diamond, 4, $green);
  70. $x = 180;
  71. $y = 225;
  72. $diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
  73. imagefilledpolygon($im, $diamond, 4, $red);
  74. $x = 225;
  75. $y = 255;
  76. $diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
  77. imagefilledpolygon($im, $diamond, 4, $cyan);
  78. // M (bridge) not touching bottom boundary
  79. $top = 100;
  80. $bot = 150;
  81. $x = 30;
  82. $points = array(
  83. $x, $top,
  84. $x+2*$d, $top,
  85. $x+2*$d, $bot,
  86. $x+$d, ($top+$bot)/2,
  87. $x, $bot
  88. );
  89. imagefilledpolygon($im, $points, 5, $black);
  90. ob_start();
  91. imagepng($im);
  92. $png = ob_get_contents();
  93. ob_end_clean();
  94. echo md5($png);
  95. imagedestroy($im);
  96. ?>