logoExtra: alertaEstrella

Descripción: Con este extra se pueden generar estrellas en formato svg de distintas características.


A continuación mostramos los apuntes asociados a este extra:

Uso de estrellas svg: Alertas
Existen muchos posibles usos para dibujos con forma de estrella; tal vez uno de los más comunes son los sistema de evaluación muy usados en blogs o páginas parecidas (como este diario)
// descripción para la sindicación: 
/*
    [rss]Con este extra se pueden generar estrellas en formato svg de distintas características.[/rss]
*/
if (isset($_GET["texto"]))
    $texto = $_GET["texto"];
else
    $texto = "Atención";
if (isset($_GET["img"]))    {
    $img = $_GET["img"];
}
else    {
    $img = "svg";
}
$fondo = "yellow";
$borde = "red";
$tipo = "a";
$radio = "60";
$xy = "40";
$puntas = rand(10, 20);

function coordes($ps, $t, $r) {
    $bucle = $ps * 2;
    $coord = array();
    $_pi = pi();
    $radian = $_pi * 180;
    $arco = 360 / $bucle;
    for ($i = 0; $i < $bucle; $i++)    {
        $alfa = $i * $arco;
        if ($t == "r")
            $punta = ($i % 2 == 0) ? $r : 100;
        else
            $punta = ($i % 2 == 0) ? $r : $r * 1.5 + rand(0, 100 - ($r * 1.5));
        $x = sin(deg2rad($alfa)) * $punta + 100;
        $y = cos(deg2rad($alfa)) * $punta + 100;

        array_push($coord, $x, $y);
    };
    return implode(",", $coord);
};
$_coor = coordes($puntas, $tipo, $radio);
list ($t1, $t2) = explode("|", $texto);
if ($img == "svg")    {
header("Content-type: image/svg+xml");
if ($t2 == "")
    $t = "<text y='100' x='100' font-size='30' fill='red' stroke-width='4'>$t1</text>";
else    {
    $t = "<text x='100' y='90' font-size='30' fill='red' stroke-width='4'>$t1</text>\n<text x='100' y='125' font-size='30' fill='red' stroke-width='4'>$t2</text>";
};
$svg =<<< svg
<?xml version="1.0" encoding="iso-8859-1" ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0" y="0px" width="201px" height="201px" preserveAspectRatio="none" viewBox="0 0 201 201">
<g transform="rotate(-30, 100, 100)" x="0" y="0px" width="201" height="201px" text-anchor='middle'>
<polygon fill="$fondo" stroke="$borde" points="$_coor" >
<animateTransform attributeName="transform" attributeType="XML"
                    type="rotate" from="0 100 100" to="360 100 100" dur="5s"
                    additive="replace" fill="freeze" repeatCount="indefinite"/>
</polygon>
$t
</g>
</svg>
svg;

echo $svg;

}
else    {
header("Content-type: image/gif");
$i = imagecreate(201, 201);
$negro = imagecolorallocate($i, 0, 0, 0);
imagefill($i, 0, 0, $negro);
imagecolortransparent($i, $negro);
$oro = imagecolorallocate($i, 255, 255, 0);
$rojo = imagecolorallocate($i, 255, 0, 0);

imagefilledpolygon($i, explode(",", $_coor), $puntas * 2, $oro);
if ($t2 == "")
    imagestring($i, 8, 60, 100, $t1, $rojo);
else    {
    imagestring($i, 8, 60, 80, $t1, $rojo);
    imagestring($i, 8, 60, 110, $t2, $rojo);
};
$r = imagerotate($i, 35, $negro);
$n = imagecolorallocate($r, 0, 0, 0);
imagefill($r, 0, 0, $n);
imagecolortransparent($r, $n);
$ancho = imagesx($r);
$alto = imagesy($r);
imagedestroy($i);

$i = imagecreate(201, 201);
$negro = imagecolorallocate($i, 0, 0, 0);
imagefill($i, 0, 0, $negro);
imagecolortransparent($i, $negro);
imagecopyresampled($i, $r, 0, 0, ($ancho - 201) / 2, ($alto - 201) / 2, 201, 201, 201, 201);
imagedestroy($r);

imagegif($i);
imagedestroy($i);
};

unset($css);
unset($body);

Este código ha sido leído en 121 ocasiones.

Zona de comentarios

Esta extra aún no tiene comentarios.

Evaluación

Valoración de esta página: (extra.alertaEstrella) valor

Valoración evaluar evaluar evaluar evaluar evaluar evaluar evaluar evaluar evaluar evaluar

Respuesta: Zona de mensajes (proceso de evaluación)

Listados: imágenes, categorías, etiquetas, extras | Anuarios: 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 | Otros enlaces: buscador