logoExtra: postal_svg

Descripción: Comodín que sirve para mostrar las postales de forma individual según su identificador (id) en formato svg.


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

Postales en SVG
Tenemos nuestras postales digitales también en formato svg
// Descripción para sindicación:
/*
    [rss]Comodín que sirve para mostrar las postales de forma individual según su identificador (id) en formato svg.[/rss]
*/

$hoy = getdate();
$año = $hoy["year"];

$_escala = (isset($_GET["porcentaje"])) ? (int) ($_GET["porcentaje"]) / 100 : 1;
$ancho = 480 * $_escala;
$alto = 360 * $_escala;
$anchopx = $ancho."px";
$altopx = $alto."px";
$__url = ($_GET["url"] == "si"); //$sale = ($__url) ? "con" : "sin"; echo $sale;

if (isset($_GET["id"]))    {
    $sql = "select * from $tabla_postales where id='{$_GET[id]}'";
//    $error = "Postal con id: ";
}
else    {
    header("Location: ?extra=postales_svg");
}

$res = mysql_query($sql);
if ($res)    {
    $existe = (mysql_num_rows($res) > 0);
    if (!$existe)    {
        $sql = "select * from $tabla_postales order by rand() limit 1";
        $res = mysql_query($sql);
        //$id = mysql_result($res, 0, "id");
        //$error = "Postal con id: {$_GET[id]} inexistente. Nuevo id: ";

    }
    $id = mysql_result($res, 0, "id");
    //$error .= $id;
    $titulo = mysql_result($res, 0, "titulo");
    $autor = mysql_result($res, 0, "autor");
    $fondo = mysql_result($res, 0, "fondo");
    $datos = mysql_result($res, 0, "elementos");
    $_eles = explode("\n", $datos);
    $postalita = Array();
    array_push($postalita, "<rect style=\"fill: $fondo\" width=\"480\" height=\"360\" x=\"0\" y=\"0\" />");
    for($i = 0, $total = count($_eles); $i < $total; $i++)    {
        $desglose = (explode("|", $_eles[$i]));
        $tipoPostal = array_shift($desglose);
        $_y_ = substr(array_shift($desglose), 4);
        $_y_ = (int) $_y_."px";
        //$_y_ *= $_escala;
        //array$postalita.="\n\t<div class=\"$tipoPostal\" style=\"top: ". ($_tope_ * $_escala);
        $_x_ = (float) substr(array_shift($desglose), 5)."px";
        //$_x_ *= $_escala;
        $_width_ = ((float) substr(array_shift($desglose), 6))."px";// * $_escala;
        $_height_ = ((float) substr(array_shift($desglose), 7))."px";// * $_escala;
        if ($tipoPostal == "imagen")    {
            $_url_ = substr(array_shift($desglose), 4);
            if (!$__url) {
                $_datos_ = getImageSize($_url_);
                $_mime_ = $_datos_["mime"];
                $_contenido_ = base64_encode(file_get_contents($_url_));
                $_poner_ = "data:$_mime_;base64,$_contenido_";
            }
            else    {
                if (strpos($_url_, "pepemolina.com/")){list (, $_u_) = explode("pepemolina.com/", $_url_); $_poner_ = $_u_;}
                else
                    $_poner_ = $_url_;
            }

            array_push($postalita, "<image xlink:href=\"$_poner_\" x=\"$_x_\" y=\"$_y_\" width=\"$_width_\" height=\"$_height_\" />");
        }
        else    {
            $familia = substr(array_shift($desglose), 4);
            $texto = substr(array_shift($desglose), 6);
 $_x_ += ($_width_ / 2);
$_y_ += ($_height_ / 2);
            $estilos = "font-family: $familia; fill: ".substr(array_shift($desglose), 6);
            $estilos .="; font-style: ".substr(array_shift($desglose), 11);
            $estilos .="; font-weight: ".substr(array_shift($desglose), 12);
$alineado = substr(array_shift($desglose), 11);
if ($alineado == "center" || $alineado == "justify")
$anchor = "middle";
else
$anchor = $alineado;
            $estilos .="; text-anchor: $anchor";
            $estilos .="; font-size: ".((int) substr(array_shift($desglose), 10));
            $estilos .="px";;
array_push($postalita, "<text x=\"$_x_\" y=\"$_y_\" width=\"$_width_\" height=\"$_height_\" style=\"$estilos\">$texto</text>");
        }
        //$postalita.="\n\t</div>\n";
    }

// Removemos: preserveAspectRatio="meetOrSlice" => none


//<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">standalone="no" 

$postal =<<< cabeza
<?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" width="$anchopx" height="$altopx" viewBox="0 0 480 360" preserveAspectRatio="xMidYMid slice" style="overflow: hidden; margin: 0">

cabeza;
$postal .= implode("\n", $postalita)."\n</svg>";
}
else    {// if ($res)
    $error = mysql_error();
}

unset($body);
unset($css);
header("Content-type=image/svg+xml");
echo $postal;

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

Zona de comentarios

Esta extra aún no tiene comentarios.

Evaluación

Valoración de esta página: (extra.postal_svg) 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