Changeset 84 for trollforge


Ignore:
Timestamp:
11/23/05 18:49:54 (7 years ago)
Author:
sam
Message:
  • randomise background images
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trollforge/lastmeasure/index.php

    r83 r84  
    1313 
    1414/* Print a random image name, with its 'image/' prefix. */ 
     15$imagelist = array(); 
     16$dh = opendir('images/'); 
     17while(($file = readdir($dh)) != false) { 
     18  $ext = substr($file, -3); 
     19  if($ext == 'jpg' || $ext == 'gif') { 
     20    $imagelist[] = $file; 
     21  } 
     22} 
     23closedir($dh); 
    1524function random_image() { 
    16    static $imagelist = null; 
    17    if(!$imagelist) { 
    18       $imagelist = array(); 
    19       $dh = opendir('images/'); 
    20       while(($file = readdir($dh)) != false) { 
    21          $ext = substr($file, -3); 
    22          if($ext == 'jpg' || $ext == 'gif') { 
    23             $imagelist[] = $file; 
    24          } 
    25       } 
    26       closedir($dh); 
    27    } 
     25   global $imagelist; 
    2826   echo 'images/'.$imagelist[rand(0,count($imagelist)-1)]; 
    2927} 
     
    4543function move_around($w, $h) { ?> 
    4644  <script> 
     45    var images = new Array; 
     46    <?php 
     47    global $imagelist; 
     48    echo "var imagecount = ".count($imagelist).";\n"; 
     49    for($i = 0; $i < count($imagelist); $i++) { 
     50      echo "images[".($i+1)."] = 'images/".$imagelist[$i]."';\n"; 
     51    } ?> 
     52 
    4753    var delay = 10; 
    4854    var step = .2; 
    49     var currStep = 0; 
     55    var curstep = 0; 
    5056 
    5157    window.resizeTo(<?php echo "$w, $h";?>); 
    5258    var centerX = (self.screen.width - document.body.clientWidth) / 2; 
    53     var centerY = (self.screen.height - document.body.clientHeight) / 2; 
     59    var centerY = (self.screen.height - document.body.clientHeight - 120) / 2; 
    5460    movew0w(); 
    5561 
     
    5763      var j; 
    5864      for (j = 0; j < 5; j++) { 
    59         var s = Math.sin(currStep / 10) - 1.0; 
    60         var c = Math.cos(currStep / 10) - 1.0; 
    61         var factorX = 0.5 + s*s*s/2.0; /* -0.5 : 0.5 */ 
    62         var factorY = 0.5 + c*c*c/2.0; /* -0.5 : 0.5 */ 
    63  
    64         factorX += 0.5 * Math.sin((20*Math.sin(currStep/20))+j*70) 
    65                        * (Math.sin(10+currStep/(10+j))+0.2) 
    66                        * Math.cos((currStep + j*25)/10); 
    67         factorY += 0.5 * Math.cos((20*Math.sin(currStep/(20+j)))+j*70) 
    68                        * (Math.sin(10+currStep/10)+0.2) 
    69                        * Math.cos((currStep + j*25)/10); 
     65        var factorX = Math.sin(curstep * 5) * 0.8; 
     66        var factorY = Math.cos(curstep * 5) * 0.8; 
     67 
     68        factorX += Math.sin((20*Math.sin(curstep/20))+j*70) 
     69                    * (Math.sin(10+curstep/(10+j))+0.2) 
     70                    * Math.cos((curstep + j*25)/10); 
     71        factorY += Math.cos((20*Math.sin(curstep/(20+j)))+j*70) 
     72                    * (Math.sin(10+curstep/10)+0.2) 
     73                    * Math.cos((curstep + j*25)/10); 
    7074        self.moveTo(centerX * (1.0 + factorX), centerY * (1.0 + factorY)); 
    7175      } 
    72       currStep += step; 
     76      curstep += step; 
     77      document.body.background = images[(Math.floor(curstep) % imagecount) + 1]; 
    7378      setTimeout("movew0w()", delay); 
    7479    } 
     
    141146  </head> 
    142147<?php 
    143     /* Just connected! Get the clipboard and post it */ 
     148 
     149    /* 
     150     * 
     151     *  First window ever, this should be our entry point 
     152     * 
     153     */ 
     154 
    144155    if(!$popup && !$send && !$procreate && !$music) { ?> 
    145156    <body> 
     
    162173    </body><?php 
    163174 
    164     /* First connection. Spawn shit. */ 
     175    /* 
     176     * 
     177     *  This is still the first window, but we got the clipboard contents 
     178     * 
     179     */ 
     180 
    165181    } elseif($send) { 
    166182      ?> 
     
    168184      <?php if($br_ie6) { ?>onLoad="setTimeout('main()',100)" <?php } ?> 
    169185      leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> 
    170   <?php move_around(500, 400);?> 
     186  <?php move_around(800, 600);?> 
    171187  <?php if($br_ie6) { 
    172188          activate_applets(); 
     
    226242</body><?php 
    227243 
     244    /* 
     245     * 
     246     *  Window is a music helper window 
     247     * 
     248     */ 
     249 
    228250    } elseif($music) { 
    229251      ?> 
     
    238260</body><?php 
    239261 
     262    /* 
     263     * 
     264     *  Window is a procreate window 
     265     * 
     266     */ 
     267 
    240268    } elseif($procreate) { 
    241269      ?> 
     
    244272      onKeyDown="altf4key();ctrlkey();delkey();" 
    245273      onMouseOver="procreate();movew0w();"> 
    246   <?php move_around(500, 400);?> 
     274  <?php move_around(800, 600);?> 
    247275  <h1>PROCREATING LAST MEASURE!!!</h1> 
    248276  <h1>GNAA > j00</h1> 
     
    257285<?php 
    258286 
     287    /* 
     288     * 
     289     *  Window is a popup 
     290     * 
     291     */ 
     292 
    259293    } elseif($popup) { 
    260294      ?> 
     
    266300      onKeyDown="altf4key();ctrlkey();delkey();" 
    267301      onMouseOver="procreate();movew0w();"> 
    268   <?php move_around(500, 400);?> 
     302  <?php move_around(800, 600);?> 
    269303  <?php if($br_ie6) { 
    270304          activate_applets(); 
Note: See TracChangeset for help on using the changeset viewer.