Image_3D
[ class tree: Image_3D ] [ index: Image_3D ] [ all elements ]

Source for file spotlights.php

Documentation is available at spotlights.php

  1. <?php
  2.  
  3. require_once('Image/3D.php');
  4.  
  5. $world = new Image_3D();
  6. $world->setColor(new Image_3D_Color(255, 255, 255));
  7.  
  8. $light = $world->createLight('Light', array(-2000, -2000, -2000));
  9. $light->setColor(new Image_3D_Color(255, 255, 255));
  10.  
  11. $redSpot = $world->createLight('Spotlight', array(0, 0, -200, 'aim' => array(0, -25, 0), 'angle' => 30, 'float' => 2));
  12. $redSpot->setColor(new Image_3D_Color(255, 0, 0));
  13.  
  14. $blueSpot = $world->createLight('Spotlight', array(0, 0, -200, 'aim' => array(-35, 25, 0), 'angle' => 30, 'float' => 2));
  15. $blueSpot->setColor(new Image_3D_Color(0, 0, 255));
  16.  
  17. $greenSpot = $world->createLight('Spotlight', array(0, 0, -200, 'aim' => array(35, 25, 0), 'angle' => 30, 'float' => 2));
  18. $greenSpot->setColor(new Image_3D_Color(0, 255, 0));
  19.  
  20. $map = $world->createObject('map');
  21.  
  22. $detail = 80;
  23. $size = 200;
  24. $height = 40;
  25.  
  26. $raster = 1 / $detail;
  27. for ($x = -1; $x <= 1; $x += $raster) {
  28.     $row = array();
  29.     for ($y = -1; $y <= 1; $y += $raster) {
  30.         $row[] = new Image_3D_Point($x * $size, $y * $size, sin($x * pi()) * sin($y * 2 * pi()) * $height);
  31.     }
  32.     $map->addRow($row);
  33. }
  34.  
  35. $map->setColor(new Image_3D_Color(150, 150, 150, 0));
  36.  
  37. $world->transform($world->createMatrix('Rotation', array(-20, 10, -10)));
  38.  
  39. $world->createRenderer('perspectively');
  40. $world->createDriver('GD');
  41. $world->render(400, 400, 'Image_3D_Spotlights.png');
  42.  
  43. echo $world->stats();

Documentation generated on Mon, 11 Mar 2019 15:48:14 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.