En Scalable Vector Graphics (SVG), el elemento <circle>
se utiliza para crear un círculo. Aquí hay algunas formas en que puede usar el elemento <circle>
en SVG:
XML <svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>
Este ejemplo crea un círculo con un centro en (50, 50), un radio de 40, un borde negro con un grosor de 3 y un relleno rojo.
Puedes usar JavaScript para cambiar dinámicamente los atributos del círculo:
XML <svg width="100" height="100">
<circle id="myCircle" cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
<script>
// Example of changing the circle's color on click
document.getElementById('myCircle').addEventListener('click', function() {
this.setAttribute('fill', 'blue');
});
</script>
</svg>
Anima el círculo usando animaciones SVG:
XML <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red">
<animate attributeName="r" from="40" to="20" dur="2s" repeatCount="indefinite" />
</circle>
</svg>
En este ejemplo, el radio del círculo se anima para cambiar de 40 a 20 en un período de 2 segundos y la animación se repite indefinidamente.
Puedes usar degradados para el relleno del círculo:
XML <svg width="100" height="100">
<defs>
<radialGradient id="grad1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" style="stop-color:rgb(255,255,255); stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(0,0,255); stop-opacity:1" />
</radialGradient>
</defs>
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="url(#grad1)" />
</svg>
Este ejemplo utiliza un degradado radial para el relleno del círculo, pasando de blanco a azul.
Estos son solo algunos ejemplos y hay muchos más atributos y propiedades que puede usar para personalizar círculos en SVG.