imagedashedline_basic.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --TEST--
  2. imagedashedline()
  3. --SKIPIF--
  4. <?php
  5. if (!function_exists('imagedashedline')) die('skip imagedashedline() not available');
  6. if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled');
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : bool imagedashedline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
  11. * Description: Draws a dashed line.
  12. * This function is deprecated. Use combination of imagesetstyle() and imageline() instead.
  13. * Source code: ext/standard/image.c
  14. * Alias to functions:
  15. */
  16. echo "Simple test of imagedashedline() function\n";
  17. $dest = dirname(realpath(__FILE__)) . '/imagedashedline.png';
  18. // create a blank image
  19. $image = imagecreatetruecolor(250, 250);
  20. // set the background color to black
  21. $bg = imagecolorallocate($image, 0, 0, 0);
  22. // red dashed lines
  23. $col_line = imagecolorallocate($image, 255, 0, 0);
  24. // draw a couple of vertical dashed lines
  25. imagedashedline($image, 100, 20, 100, 230, $col_line );
  26. imagedashedline($image, 150, 20, 150, 230, $col_line );
  27. // output the picture to a file
  28. imagepng($image, $dest);
  29. //check color of a point on edge..
  30. $col1 = imagecolorat($image, 100, 230);
  31. // ..and a point on background
  32. $col2 = imagecolorat($image, 5, 5);
  33. $color1 = imagecolorsforindex($image, $col1);
  34. $color2 = imagecolorsforindex($image, $col2);
  35. var_dump($color1, $color2);
  36. imagedestroy($image);
  37. echo "Done\n";
  38. ?>
  39. --CLEAN--
  40. <?php
  41. $dest = dirname(realpath(__FILE__)) . '/imagedashedline.png';
  42. @unlink($dest);
  43. ?>
  44. --EXPECT--
  45. Simple test of imagedashedline() function
  46. array(4) {
  47. ["red"]=>
  48. int(255)
  49. ["green"]=>
  50. int(0)
  51. ["blue"]=>
  52. int(0)
  53. ["alpha"]=>
  54. int(0)
  55. }
  56. array(4) {
  57. ["red"]=>
  58. int(0)
  59. ["green"]=>
  60. int(0)
  61. ["blue"]=>
  62. int(0)
  63. ["alpha"]=>
  64. int(0)
  65. }
  66. Done