imagedashedline_basic.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --TEST--
  2. imagedashedline()
  3. --EXTENSIONS--
  4. gd
  5. --SKIPIF--
  6. <?php
  7. if (!function_exists('imagedashedline')) die('skip imagedashedline() not available');
  8. ?>
  9. --FILE--
  10. <?php
  11. echo "Simple test of imagedashedline() function\n";
  12. $dest = dirname(realpath(__FILE__)) . '/imagedashedline.png';
  13. // create a blank image
  14. $image = imagecreatetruecolor(250, 250);
  15. // set the background color to black
  16. $bg = imagecolorallocate($image, 0, 0, 0);
  17. // red dashed lines
  18. $col_line = imagecolorallocate($image, 255, 0, 0);
  19. // draw a couple of vertical dashed lines
  20. imagedashedline($image, 100, 20, 100, 230, $col_line );
  21. imagedashedline($image, 150, 20, 150, 230, $col_line );
  22. // output the picture to a file
  23. imagepng($image, $dest);
  24. //check color of a point on edge..
  25. $col1 = imagecolorat($image, 100, 230);
  26. // ..and a point on background
  27. $col2 = imagecolorat($image, 5, 5);
  28. $color1 = imagecolorsforindex($image, $col1);
  29. $color2 = imagecolorsforindex($image, $col2);
  30. var_dump($color1, $color2);
  31. imagedestroy($image);
  32. echo "Done\n";
  33. ?>
  34. --CLEAN--
  35. <?php
  36. $dest = dirname(realpath(__FILE__)) . '/imagedashedline.png';
  37. @unlink($dest);
  38. ?>
  39. --EXPECT--
  40. Simple test of imagedashedline() function
  41. array(4) {
  42. ["red"]=>
  43. int(255)
  44. ["green"]=>
  45. int(0)
  46. ["blue"]=>
  47. int(0)
  48. ["alpha"]=>
  49. int(0)
  50. }
  51. array(4) {
  52. ["red"]=>
  53. int(0)
  54. ["green"]=>
  55. int(0)
  56. ["blue"]=>
  57. int(0)
  58. ["alpha"]=>
  59. int(0)
  60. }
  61. Done