imagedashedline_basic.phpt 1.6 KB

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