Advertisement
ujiajah1

garis.php

Oct 25th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.27 KB | None | 0 0
  1. <?php
  2. header("Content-type:image/jpeg");
  3. $gb= imagecreate(500,500);
  4. $bg_color= imagecolorallocate($gb,0,0,0);
  5. $line_color= imagecolorallocate($gb,255,255,255);
  6. //garis_hoizontal
  7. $width= 400;//dalam pixel
  8. $x_mulai=20;
  9. $y_mulai=50;
  10. $x_akhir= $width+$x_mulai;
  11. imageline($gb,$x_mulai,$y_mulai,$x_akhir,$y_mulai,$line_color);
  12. //garis vertikal
  13. $y_akhir=$width+$y_mulai;
  14. imageline($gb,$x_mulai,$y_mulai,$x_mulai,$y_akhir,$line_color);
  15. //garis diagonal
  16. imageline($gb,$x_mulai,$y_mulai,$x_akhir,$y_akhir,$line_color);
  17. imagejpeg($gb);
  18. imagedestroy($gb);
  19. ?>
  20. #===============================================================================================================================
  21.  
  22. <?php
  23. function garisPutus($gb,$x1,$y1,$x2,$y2,$fg,$bg){
  24.     $string= array($fg,$fg,$fg,$fg,$bg,$bg,$bg,$bg);
  25.     imagesetstyle($gb,$string);
  26.     imageline($gb,$x1,$y1,$x2,$y2,IMG_COLOR_STYLED);
  27. }
  28. header("Content-type:image/jpeg");
  29. $gb= imagecreate(500,500);
  30. $bg_color= imagecolorallocate($gb,0,0,0);
  31. $line_color= imagecolorallocate($gb,255,255,255);
  32. //garis_horisontal
  33. garisPutus($gb,20,50,320,50,$line_color,$bg_color);
  34. //garis_vertikal
  35. garisPutus($gb,20,50,20,320,$line_color,$bg_color);
  36. //garis_diagonal
  37. garisPutus($gb,20,50,320,320,$line_color,$bg_color);
  38. imagejpeg($gb);
  39. imagedestroy($gb);
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement