function create_secimage() { global $image; $ret = array(); $width = 250; $height = 100; $image = imagecreatetruecolor($width, $height); imageAlphaBlending($image, true); imageSaveAlpha($image, true); $color_1 = imagecolorallocate($image, 150, 150, 250); $color_2 = imagecolorallocate($image, 80, 80, 80); imageblend(0, 0, FIXED_GFX_PATH . "sec-gfx/bg.png", $image); /* 25/06/10 - AC: Disabled races logos for readability $thumbs=array(FIXED_GFX_PATH."sec-gfx/cardassian.png", FIXED_GFX_PATH."sec-gfx/dominion.png", FIXED_GFX_PATH."sec-gfx/federation.png", FIXED_GFX_PATH."sec-gfx/ferengi.png", FIXED_GFX_PATH."sec-gfx/klingon.png", FIXED_GFX_PATH."sec-gfx/romlulan.png"); shuffle($thumbs); $t=0; foreach ($thumbs as $value) { imageblend($t*50,rand(0,$height-60),$value,$image); $t++; }*/ for ($t = 0; $t < 6; $t++) { $color = imagecolorallocate($image, rand(40, 255), rand(40, 255), rand(40, 255)); circle(rand(25, $width - 25), rand(25, $height - 25), 50, $color); } $color = imagecolorallocate($image, rand(40, 255), rand(40, 255), rand(40, 255)); $pos[0] = rand(25, $width - 25); $pos[1] = rand(25, $height - 25); circle_sectioned($pos[0], $pos[1], 50, $color); $ret['center'] = implode(":", $pos); $md5 = md5(rand(0, 1000000)); $ret['filename'] = 'tmpsec/sec' . $md5 . '.jpg'; imagejpeg($image, $ret['filename'], 20); return $ret; }
// '#FF8000'; $green = '#7CFC00'; //#008000'; $width = 60; $widthMinus = $width - 1; $centre = 30; //$height = 60; $radius = $centre - 1; function circle($fill, $c, $r) { return "<circle cx=\"{$c}\" cy=\"{$c}\" r=\"{$r}\" \n style=\"fill:{$fill};stroke:#000000;stroke-width:2\" />"; } $header = "<?xml version=\"1.0\"?>\n<svg viewBox=\"0 0 {$width} {$width}\" version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\">"; $path = "<path\n d=\"M {$centre}, 1 A {$radius}, {$radius} 0 0 0 {$centre}, {$widthMinus} L {$centre} {$centre} Z\"\n style=\"fill:{$white}\" />"; $footer = "</svg>"; echo $header; if ($model->total == 0) { $colour = $red; } else { if ($model->total == $model->done) { $colour = $green; } else { $colour = $orange; } } echo circle($colour, $centre, $radius); //error_log("SVG total {$model->total} done {$model->done}"); if ($model->total != $model->done && $model->done > 0) { echo $path; } echo $footer;
<h4>Решение:</h4> </div> <div class="col-xs-12 col-md-10"> <?php // Code Here! function circle($r) { //vars $pi = pi(); $radius = $r * 2; //code $S = $radius * $pi; return $S; } $circleRadius = 10; echo '<p>Площадь круга будет равна: ' . circle($circleRadius) . ' при радиусе ' . $circleRadius . '.</p>'; ?> </div> </div> </section> <section class="container"> <h2>Exercise 2</h2> <div class="row"> <div class="col-xs-12 col-md-2"> <h4>Задание:</h4> </div> <div class="col-xs-12 col-md-10"> <p>Напишите функцию рассчета скорости движения машины. На основании полученных данных: пройденный путь и время.</p> </div> </div>
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: "); echo "The area of your shape is: " . regularpolygon($sidelength, $sideamount) . "\n"; echo "\n"; } } } }
$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"; } else { echo "Invalid Shape\n"; } } } }
function cutoutButton($x,$y,$r) { $z1 = 0.25; $z2 = $z1 + 0.125; $z3 = $z2 + 0.125; $a1 = 40; $a2 = 180 - $a1; circlePocket($x,$y,$r+R,depth(0.75,$z3,DM)); cap($x,$y,$r+R,$z3,$z2,10); circle($x,$y,$r+R,depth($z2,$z1,DM)); arc($x,$y, polarX($x,$r+R,$a2), polarY($y,$r+R,$a2), polarX($x,$r+R,$a1), polarY($y,$r+R,$a1), depth($z1,0,DM)); arc($x,$y, polarX($x,$r+R,-$a1), polarY($y,$r+R,-$a1), polarX($x,$r+R,-$a2), polarY($y,$r+R,-$a2), depth($z1,0,DM)); $y1 = $y-R-0.0625; $y2 = $y+R+0.0625; $x1 = $x+$r+R-0.0425; $x2 = $x+$r+R+0.125; line($x1,$y1, $x2,$y1, depth($z1,0,DM)); line($x2,$y2, $x1,$y2, depth($z1,0,DM)); $x1 = $x-$r-R+0.0425; $x2 = $x-$r-R-0.125; line($x1,$y1, $x2,$y1, depth($z1,0,DM)); line($x2,$y2, $x1,$y2, depth($z1,0,DM)); $x2 = $x+$r+R+0.125; line($x2,$y1, $x2,$y2, depth($z1,0,DM)); $x2 = $x-$r-R-0.125; line($x2,$y1, $x2,$y2, depth($z1,0,DM)); }