{"id":264,"date":"2024-05-21T10:13:51","date_gmt":"2024-05-21T08:13:51","guid":{"rendered":"https:\/\/blog.sutilweb.eu\/?page_id=264"},"modified":"2024-05-21T10:13:51","modified_gmt":"2024-05-21T08:13:51","slug":"59-svg-html","status":"publish","type":"page","link":"https:\/\/sutilweb.eu\/index.php\/lenguajes\/html5\/html5-manual\/59-svg-html\/","title":{"rendered":"59. SVG HTML"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>SVG<\/strong> define gr\u00e1ficos basados en vectores en formato <strong>XML<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Qu\u00e9 es SVG?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SVG<\/strong> significa <strong>Scalable Vector Graphics<\/strong><\/li>\n\n\n\n<li><strong>SVG<\/strong> se utiliza para definir gr\u00e1ficos para la Web<\/li>\n\n\n\n<li><strong>SVG<\/strong> es una recomendaci\u00f3n del <strong>W3C<\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">El elemento &lt;svg&gt;<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">El elemento HTML <strong><em>&lt;svg&gt;<\/em><\/strong> es un contenedor para gr\u00e1ficos <strong>SVG<\/strong>. <strong>SVG<\/strong> tiene varios m\u00e9todos para dibujar rutas, cuadros, c\u00edrculos, texto e im\u00e1genes gr\u00e1ficas.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SVG c\u00edrculo<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;!DOCTYPE&nbsp;html&gt;\n&lt;html&gt;\n&lt;body&gt;\n\n&lt;svg&nbsp;width=\"100\"&nbsp;height=\"100\"&gt;\n&nbsp;&nbsp;&lt;circle&nbsp;cx=\"50\"&nbsp;cy=\"50\"&nbsp;r=\"40\"&nbsp;stroke=\"green\"&nbsp;stroke-width=\"4\"&nbsp;fill=\"yellow\"&nbsp;\/&gt;\n&lt;\/svg&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Rect\u00e1ngulo SVG<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;svg&nbsp;width=\"400\"&nbsp;height=\"100\"&gt;\n&nbsp;&nbsp;&lt;rect&nbsp;width=\"400\"&nbsp;height=\"100\"&nbsp;\n  style=\"fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)\"&nbsp;\/&gt;\n&lt;\/svg&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Rect\u00e1ngulo redondeado con SVG<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;svg&nbsp;width=\"400\"&nbsp;height=\"180\"&gt;\n&nbsp;&nbsp;&lt;rect&nbsp;x=\"50\"&nbsp;y=\"20\"&nbsp;rx=\"20\"&nbsp;ry=\"20\"&nbsp;width=\"150\"&nbsp;height=\"150\"\n&nbsp; style=\"fill:red;stroke:black;stroke-width:5;opacity:0.5\"&nbsp;\/&gt;\n&lt;\/svg&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Estrella SVG<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;svg&nbsp;width=\"300\"&nbsp;height=\"200\"&gt;\n&lt;polygon&nbsp;points=\"100,10 40,198 190,78 10,78 160,198\"\nstyle=\"fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;\"&nbsp;\/&gt;\n&lt;\/svg&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">SVG logo<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;svg&nbsp;height=\"130\"&nbsp;width=\"500\"&gt;\n&nbsp;&nbsp;&lt;defs&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;linearGradient&nbsp;id=\"grad1\"&nbsp;x1=\"0%\"&nbsp;y1=\"0%\"&nbsp;x2=\"100%\"&nbsp;y2=\"0%\"&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;stop&nbsp;offset=\"0%\"&nbsp;style=\"stop-color:rgb(255,255,0);stop-opacity:1\"&nbsp;\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;stop&nbsp;offset=\"100%\"&nbsp;style=\"stop-color:rgb(255,0,0);stop-opacity:1\"&nbsp;\/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/linearGradient&gt;\n&nbsp;&nbsp;&lt;\/defs&gt;\n&nbsp;&nbsp;&lt;ellipse&nbsp;cx=\"100\"&nbsp;cy=\"70\"&nbsp;rx=\"85\"&nbsp;ry=\"55\"&nbsp;fill=\"url(#grad1)\"&nbsp;\/&gt;\n&nbsp;&nbsp;&lt;text&nbsp;fill=\"#ffffff\"&nbsp;font-size=\"45\"&nbsp;font-family=\"Verdana\"&nbsp;x=\"50\"&nbsp;y=\"86\"&gt;SVG&lt;\/text&gt;\n&nbsp; Sorry, your browser does not support inline SVG.\n&lt;\/svg&gt;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Diferencias entre SVG y Canvas<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>SVG<\/strong> es un lenguaje para describir gr\u00e1ficos 2D en <strong>XML<\/strong>. <strong>Canvas<\/strong> dibuja gr\u00e1ficos 2D, sobre la marcha (con <strong>JavaScript<\/strong>). <strong>SVG<\/strong> est\u00e1 basado en <strong>XML<\/strong>, lo que significa que todos los elementos est\u00e1n disponibles dentro del <strong>SVG DOM<\/strong>. Puede adjuntar controladores de eventos de <strong>JavaScript<\/strong> para un elemento.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">En <strong>SVG<\/strong>, cada forma dibujada se recuerda como un objeto. Si se cambian los atributos de un objeto <strong>SVG<\/strong>, el navegador puede volver a representar autom\u00e1ticamente la forma.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">El lienzo se representa p\u00edxel por p\u00edxel. En el lienzo, una vez que se dibuja el gr\u00e1fico, el navegador lo olvida. Si se debe cambiar su posici\u00f3n, se debe volver a dibujar toda la escena, incluidos los objetos que podr\u00edan haber estado cubiertos por el gr\u00e1fico.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SVG define gr\u00e1ficos basados en vectores en formato XML. Qu\u00e9 es SVG? El elemento &lt;svg&gt; El elemento HTML &lt;svg&gt; es un contenedor&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":41,"menu_order":58,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","footnotes":""},"class_list":["post-264","page","type-page","status-publish","hentry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Sutil Web","author_link":"https:\/\/sutilweb.eu\/index.php\/author\/sutilweb\/"},"uagb_comment_info":0,"uagb_excerpt":"SVG define gr\u00e1ficos basados en vectores en formato XML. Qu\u00e9 es SVG? El elemento &lt;svg&gt; El elemento HTML &lt;svg&gt; es un contenedor...","_links":{"self":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/comments?post=264"}],"version-history":[{"count":2,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/264\/revisions"}],"predecessor-version":[{"id":266,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/264\/revisions\/266"}],"up":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/41"}],"wp:attachment":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/media?parent=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}