blogblog SyKoHPaTh

Random Background Content Generator

New background. It's randomly generated:

Code Sample:
  1. <?php
  2. $db_img = imagecreate(800,600); //size of image
  3. $background = imagecolorallocate($db_img, 0,0,0);
  4. $textcolor = imagecolorallocate($db_img, 150,0,0);
  5. $linecolor = imagecolorallocate($db_img, 0,0,0);
  6. $characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890~!@#$%^&*()_ -=`[]{}:;'|,.<>/?";
  7. for($vcntr=-1;$vcntr<60;$vcntr =2) {
  8. for($cntr=-1; $cntr<80; $cntr =2){
  9. $letter = substr($characters, rand(0,(strlen($characters)-1)),1);
  10. $spacing = (rand(5,10) ($cntr*10)); //x spacing
  11. $vspacing = (rand(5,10) ($vcntr*10)); //y spacing
  12. imagestring ($db_img, 5, $spacing, $vspacing, $letter, $textcolor);
  13. }
  14. }
  15. imagesetthickness($db_img, 5);
  16. header( "Content-type: image/png"); //specify the type of image
  17. imagepng($db_img);
  18. imagecolordeallocate($linecolor);
  19. imagecolordeallocate($textcolor);
  20. imagecolordeallocate($background);
  21. imagedestroy($db_img);
  22. ?>


Save as something like, background.php. Next, call it in and it's MAGIC...css:

background: #ffffff url("background.php") fixed;



code, php