function rectangles($table, $width, $height) { $svg = rectangle($table); if (!is_array($svg)) { echo $svg; } else { header("Content-Type: image/svg+xml"); echo "<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' \r\n\t\t\t\t'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>"; echo "\n<svg xmlns='http://www.w3.org/2000/svg' width='{$width}' \r\n\t\t\theight='{$height}'>"; echo "<g transform='translate(10,10),scale(1,-1)'>"; echo join("\n", $svg); echo "</g></svg>"; } }
echo "The area is "; echo square($side, $side); echo "\n"; } else { if ($shape == "triangle") { $height = readline("Enter Height: "); $length = readline("Enter Length: "); echo "The area is "; echo triangle($height, $length); echo "\n"; } else { if ($shape == "rectangle") { $length = readline("Enter Length: "); $width = readline("Enter Width: "); echo "The area is "; echo rectangle($length, $width); echo "\n"; } else { if ($shape == "circle") { $radius = readline("Enter Radius: "); echo "The area is "; echo circle($radius); echo "\n"; } else { if ($shape == "trapezoid") { $base1 = readline("Enter 1st base length: "); $base2 = readline("Enter 2nd base length: "); $height = readline("Enter height: "); echo "The area is "; echo trapezoid($base1, $base2, $height); echo "\n";
return $length * $length; } function circle($radius) { return M_PI * ($radius * $radius); } function regularpolygon($sidelength, $sideamount) { return $sidelength / 2 / tan(360 / $sideamount / 2) * 2 * $sideamount; } "\n"; if ($shape == "rectangle") { echo "Your shape is " . $shape . "\n"; $length = readline("What is the length: "); $width = readline("What is the width: "); echo "The area of your rectangle is: " . rectangle($length, $width) . "\n"; } else { if ($shape == "square") { echo "Your shape is " . $shape . "\n"; $length = readline("What is the length: "); echo "The area of your square is: " . square($length) . "\n"; } else { if ($shape == "circle") { echo "Your shape is " . $shape . "\n"; $radius = readline("What is the radius: "); echo "The area of your circle is: " . circle($radius) . "\n"; } else { if ($shape == "regular polygon") { echo "Your shape is: " . $shape . "\n"; $sidelength = readline("What is the length of one side: "); $sideamount = readline("How many sides are there: ");
$break = false; foreach ($words as $word) { $word = arabic($word); $current = textbox($word, $settings["font"], $settings["size"]); $will_take = $current["width"] + $current["left"] + $spacing; $break = $x + $will_take > $settings["width"] ? true : false; $x = $break ? $will_take : $x + $will_take; $i = $break ? $i + 1 : $i; $y = $begin["height"] * $i + $top + ($i != 0 ? $interline : 0); imagettftext($content, $settings["size"], 0, $settings["width"] - $x, $y, $white, $settings["font"], $word); $first_word = false; } /** Calculate text height */ $textheight = $y + $begin["height"] - $top / 2; /** Draw background rectangle based on textheight */ $image = rectangle($image, 15, (250 - $textheight) / 2 - 5, $settings["width"] + 25, (250 - $textheight) / 2 + 5 + $textheight, 5, $rectangle); imagecopy($image, $content, 20, (250 - $textheight) / 2, 0, 0, $settings["width"], $textheight); // Copy text image to background image $font = "tweet/fonts/GD/cocon.ttf"; $name = arabic("" . $data["name"]); $current = textbox($name, $font, $settings["size"] + 4); $y = (250 - $textheight) / 2 - $current["height"] - $current["top"] + 20; $x = $current["left"] + $current["width"] + 30; $x = $settings["width"] - $x + 10; imagettftext($image, $settings["size"] + 4, 0, $x + 1, $y + 1, $clear, $font, $name); // write Quote name shadow imagettftext($image, $settings["size"] + 4, 0, $x, $y, $color, $font, $name); // write Quote name $current = textbox("ˮ", "tweet/fonts/GD/arial.ttf", 70); // write Quote icon imagettftext($image, 70, 0, $settings["width"] + 20 - $current["width"] + 1, $y + $current["top"] - 15, $color + 1, "tweet/fonts/GD/arial.ttf", "ˮ");