function draw_cube ($image_size, $degree_x, $degree_y, $degree_z, $vdist, $dist, $vertex_color, $face_color, $wireframe, $dashes, $rainbow
{
$degree_x = $degree_x % 360;
$degree_y = $degree_y % 360;
$degree_z = $degree_z % 360;
// construct the cube polygons
$size = 400; // the size is arbitrary
$x1$size/2;
$x0=-($size/2);
$y1$size/2;
$y0=-($size/2);
$z1$size/2;
$z0=-($size/2);
$sides = array();
$sides[] = array$x0$y0$z0, $x0$y0$z1, $x0$y1$z1, $x0$y1$z0);
$sides[] = array$x1$y0$z0, $x1$y0$z1, $x1$y1$z1, $x1$y1$z0);
$sides[] = array$x0$y0$z0, $x0$y0$z1, $x1$y0$z1, $x1$y0$z0);
$sides[] = array$x0$y1$z0, $x0$y1$z1, $x1$y1$z1, $x1$y1$z0);
$sides[] = array$x0$y0$z0, $x0$y1$z0, $x1$y1$z0, $x1$y0$z0);
$sides[] = array$x0$y0$z1, $x0$y1$z1, $x1$y1$z1, $x1$y0$z1);
// project each of the 6 polygons that makes up the cube
for ($i=0; $icount$sides); $i++) {
$points[] = project_polygon$sides$i], $degree_x, $degree_y, $degree_z, 0, 0, 0, $vdist+($size/2), $dist+($size/2), true);
}
// scale the image somewhat
$scale = $image_size/($size*1.8);
if ($rainbow) {
$face_color = array'ff0000', '00d000', 'ffff00', 'a000a0', '0000ff', 'FF8040');
}
return render_polygons$points, $vertex_color, $face_color, $wireframe, $dashes, $image_size, $scale);
}