Source for file ZBuffer.php
Documentation is available at ZBuffer.php
imageSaveAlpha ($this->_image, true );
protected function _getColor(Image_3D_Color $color, $alpha = 1. )
$values = $color->getValues ();
$values[0 ] = (int) round($values[0 ] * 255 );
$values[1 ] = (int) round($values[1 ] * 255 );
$values[2 ] = (int) round($values[2 ] * 255 );
$values[3 ] = (int) round((1 - ((1 - $values[3 ]) * $alpha)) * 127 );
// Tranzparente Farbe allokieren
$color = imageColorExactAlpha ($this->_image, $values[0 ], $values[1 ], $values[2 ], $values[3 ]);
// Wenn nicht Farbe neu alloziieren
$color = imageColorAllocateAlpha ($this->_image, $values[0 ], $values[1 ], $values[2 ], $values[3 ]);
// Deckende Farbe allozieren
$color = imageColorExact ($this->_image, $values[0 ], $values[1 ], $values[2 ]);
// Wenn nicht Farbe neu alloziieren
$color = imageColorAllocate ($this->_image, $values[0 ], $values[1 ], $values[2 ]);
protected function _drawLine(Image_3D_Point $p1, Image_3D_Point $p2)
list ($x1, $y1) = $p1->getScreenCoordinates ();
list ($x2, $y2) = $p2->getScreenCoordinates ();
$xdiff = ($x2 - $x1) / $steps;
$ydiff = ($y2 - $y1) / $steps;
$zdiff = ($z2 - $z1) / $steps;
$points = array ('height' => array (), 'coverage' => array ());
for ($i = 0; $i < $steps; $i++ ) {
if (!isset ($points['coverage'][(int) $xFloor][(int) $yCeil])) {
$points['height'][(int) $xFloor][(int) $yCeil] = $z1 + $i * $zdiff;
$points['coverage'][(int) $xFloor][(int) $yCeil] = (1 - $xOffset) * $yOffset;
$points['coverage'][(int) $xFloor][(int) $yCeil] += (1 - $xOffset) * $yOffset;
if (!isset ($points['coverage'][(int) $xFloor][(int) $yFloor])) {
$points['height'][(int) $xFloor][(int) $yFloor] = $z1 + $i * $zdiff;
$points['coverage'][(int) $xFloor][(int) $yFloor] = (1 - $xOffset) * (1 - $yOffset);
$points['coverage'][(int) $xFloor][(int) $yFloor] += (1 - $xOffset) * (1 - $yOffset);
if (!isset ($points['coverage'][(int) $xCeil][(int) $yCeil])) {
$points['height'][(int) $xCeil][(int) $yCeil] = $z1 + $i * $zdiff;
$points['coverage'][(int) $xCeil][(int) $yCeil] = $xOffset * $yOffset;
$points['coverage'][(int) $xCeil][(int) $yCeil] += $xOffset * $yOffset;
if (!isset ($points['coverage'][(int) $xCeil][(int) $yFloor])) {
$points['height'][(int) $xCeil][(int) $yFloor] = $z1 + $i * $zdiff;
$points['coverage'][(int) $xCeil][(int) $yFloor] = $xOffset * (1 - $yOffset);
$points['coverage'][(int) $xCeil][(int) $yFloor] += $xOffset * (1 - $yOffset);
$map = array ('height' => array (), 'coverage' => array ());
$last = end($pointArray);
foreach ($pointArray as $point) {
foreach ($line['height'] as $x => $row) {
foreach ($row as $y => $height) {
$map['height'][(int) $x][(int) $y] = $height;
$map['coverage'][(int) $x][(int) $y] = $line['coverage'][(int) $x][(int) $y];
foreach ($points['coverage'] as $x => $row) {
$zStart = $points['height'][$x][$start];
$zEnd = $points['height'][$x][$end];
$zStep = ($zEnd - $zStart) / ($end - $start);
$this->_heigth[$x][$start][(int) ($zStart * 100 )] = $this->_getColor($polygon->getColor (), $points['coverage'][$x][$start]);
for ($y = $start + 1; $y < $end; $y++ ) {
$this->_heigth[$x][$y][(int) (($zStart + $zStep * ($y - $start)) * 100 )] = $this->_getColor($polygon->getColor ());
$this->_points[$x][$end][(int) ($zEnd * 100 )] = $this->_getColor($polygon->getColor (), $points['coverage'][$x][$end]);
if (in_array($type, array ('png', 'jpeg'))) {
public function save($file)
foreach ($this->_heigth as $x => $row) {
foreach ($row as $y => $points) {
foreach ($points as $color) {
Documentation generated on Mon, 11 Mar 2019 15:48:15 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|