function make_cut_image($row, $verts, $width, $height) { $center = new vertex(0, 0, 0); $image = imagecreatetruecolor($width, $height); if (isset($_REQUEST['usealpha'])) { $trans_color = imagecolorallocatealpha($image, 255, 255, 255, 0); imagefill($image, 0, 0, $trans_color); } $verticies = explode("\n", $verts); $start = new vertex(0, 0, 0); $start->parse_llvector($verticies[0]); $count = count($verticies); $x = 0.0; $t = 0.0; $start_color = new vertex(0, 128, 0); $end_color = new vertex(255, 255, 255); $previous = $start; foreach ($verticies as $point) { $current = new vertex(0, 0, 0); $current->parse_llvector($point); $center->add($current); ++$x; } $center->mult(1.0 / $x); $x = 0; imagesetthickness($image, 2); foreach ($verticies as $point) { $t = $x / $count; $current = new vertex(0, 0, 0); $current->parse_llvector($point); if ($verticies[0] != $point) { $vcolor = $start_color->get_interp($end_color, $t); $color = $vcolor->allocate_color($image); fill_pie($image, $center, $previous, $current, $width, $height, $color); } $previous = $current; ++$x; } $color = imagecolorallocate($image, $end_color->x, $end_color->y, $end_color->z); fill_pie($image, $center, $previous, $start, $width, $height, $color); $x = 0; foreach ($verticies as $point) { ++$x; $t = $x / $count; $current = new vertex(0, 0, 0); $current->parse_llvector($point); $current->x = ($current->x + 1) * 0.5; $current->y = 1.0 - ($current->y + 1) * 0.5; $current->x *= $width; $current->y *= $height; $color = $color = imagecolorallocate($image, 255 * $t, 0, 255 * (1 - $t)); imagefilledellipse($image, intval($current->x), intval($current->y), 8, 8, $color); } return $image; }