This article introduces the custom and vector diagram examples. First draw a three-pointed star, respectively, by "front", "Back" and three "side" composition. Custom Polygon
Code:
<?php
Require_once (' image/3d.php ');
$image = new Image_3d ();
$image->setcolor (New Image_3d_color (255, 255, 255));
To create a light source
$light 1 = $image->createlight (' Light ', array (-50,-50,-50));
$light 1->setcolor (New Image_3d_color (100, 250, 100));
$light 2 = $image->createlight (' Light ', array (50,-50, 0));
$light 2->setcolor (New Image_3d_color (100, 100, 250));
$light 3 = $image->createlight (' Light ', array (50, 50, 0));
$light 3->setcolor (New Image_3d_color (50, 0, 100));
Creating an array of polygons
$polygons = Array ();
Front Point coordinates
$polygons [] = Array (
Array (0, -120, 0), Array (-18,-12, 0),
Array ( -86, 0), array (0, 18, 0),
Array (0), Array (18,-12, 0)
);
Back Point coordinates
$polygons [] = Array (
Array (0, -120,), Array (-18,-12, 60),
Array ( -86, M, m), array (0, 18, 60),
Array (18,-12, 60).
);
Three-side point coordinates
$polygons [] = Array (
Array (0, -120, 0), Array (-18,-12, 0),
Array ( -86, 0), Array (-86, 48, 60),
Array ( -18, -12,), array (0,-120, 60)
);
$polygons [] = Array (
Array ( -86, 0), array (0, 18, 0),
Array (0), Array (86, 48, 60),
Array (0, a), array (-86, 48, 60)
);
$polygons [] = Array (
Array (0), Array (18,-12, 0),
Array (0, -120, 0), array (0,-120, 60),
Array ( -12,), Array (86, 48, 60)
);
Draw a 3D image
foreach ($polygons as $poly) {
$points = Array ();
foreach ($poly as $set) {
$points [] = new Image_3d_point ($set [0], $set [1], $set [2]);
}
$p = $image->createobject (' polygon ', $points);
$p->setcolor (New Image_3d_color (255, 255, 255));
}
$image->transform ($image->creatematrix (' rotation ', array (-10,-25,-15));
$image->createrenderer (' perspectively ');
$image->createdriver (' GD ');
$image->render ("Anim.png");
Echo ' ';
?>
Effect Chart: