function make_sculpty($verts, $sc, $o, $width, $height, $upsample, $smooth) { $image = imagecreatetruecolor($width, $height); $scale = new vertex(0, 0, 0); $orig = new vertex(0, 0, 0); $orig->load($o); $orig->mult(-1); $scale->load($sc); $scale->mult(0.5); //Radius $this_row = 0; foreach ($verts as $vert_row) { $x = 0; $row = explode("|", $vert_row); $point = FALSE; if (count($row) == 1) { $point = TRUE; } $y = $height - 1 - $this_row; foreach ($row as $v) { $vert = new vertex(0, 0, 0); $vert->load(explode(",", $v)); $vert->add($orig); $vert->combine($scale); $vert = $vert->get_color(); $color = $vert->allocate_color($image); if ($point) { imageline($image, 0, $y, $width - 1, $y, $color); break; } else { imagesetpixel($image, $x, $y, $color); } ++$x; if ($x >= $width) { break; } } $this_row++; if ($this_row >= $height) { break; } } //Up-sample the image if ($upsample) { $new_h = $height * 2; $new_w = $width * 2; $image_resampled = imagecreatetruecolor($new_w, $new_h); imagecopyresized($image_resampled, $image, 0, 0, 0, 0, $new_w, $new_h, $width, $height); imagedestroy($image); $image = $image_resampled; } if ($smooth == "gaussian") { $gaussian = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0)); imageconvolution($image, $gaussian, 16, 0); } if ($smooth == "linear") { $linear = array(array(1.0, 1.0, 1.0), array(1.0, 1.0, 1.0), array(1.0, 1.0, 1.0)); imageconvolution($image, $linear, 9, 0); } return $image; }