Contacto | #php_para_torpes | Enlázanos | ¿Quiénes somos?
18 usuarios Online (0)
Darse de alta en la web | Recuperar password   
Inicio / Desafios / Poligonator / Solucion de AaMP3rio

Desafío Poligonator

#3 Solución de AaMP3rio

Código de la Solución Ver código | Comentarios Ver comentarios (8) | Descargar Descargar código

Fecha: 03 septiembre 2005

Tamaño: 6616 caracteres

Comentarios: 8

Solución online:
Lo siento, pero no está disponible

Valoración PuntuaciónPuntuaciónPuntuaciónPuntuaciónPuntuaciónPuntuaciónPuntuaciónPuntuaciónPuntuaciónPuntuación 9.25 (8 votos)

"Bueno, yo también me estreno aquí... jeje.
Un reto muy sencillo, pura matemática.

Había olvidado poner el formulario."

Valora esta solución

<?php
if (@isset($_GET['n'], $_GET['r'], $_GET['m'])) {
  
$n = $_GET['n'];
  
$r = $_GET['r'];
  
$m = $_GET['m'];
  
$w = $r * 2 + $m;

  
$img = imagecreate($w, $w);
  
imagecolorallocate($img, 255, 255, 255);
  
$b = imagecolorallocate($img, 0, 0, 0);

  
$w /= 2;

  for (
$i = 1; $i <= $n + 1; $i++) {
  if (isset(
$x, $y)) {
   
$a = $w + ($r * sin(deg2rad($i * 360 / $n)));
   
$b = $w - ($r * cos(deg2rad($i * 360 / $n)));
   
imageline($img, $x, $y, $a, $b, $b);
  }
  
$x = $w + ($r * sin(deg2rad($i * 360 / $n)));
  
$y = $w - ($r * cos(deg2rad($i * 360 / $n)));
}
header('Content-type: image/png');
imagepng($img);
exit;
}
?>
<html>
<head><title>Poligonator</title></head>
<body>
<form>
<pre>
<input type="text" size="5" name="n" value="5"> - Lados
<input type="text" size="5" name="r" value="50"> - Radio
<input type="text" size="5" name="m" value="100"> - Margin
</pre><input type="submit" value="poligonize">
</form>
</body></html>

Web alojada en Zilos

php-hispano.net 2002 - 2008 | XHTML 1.0
Datos Legales | Webmaster