SVG - Polygone

L'élément <polygon> est utilisé pour dessiner une forme fermée constituée de lignes droites connectées.

Déclaration

Voici la déclaration de syntaxe de <polygon>élément. Nous n'avons montré que les principaux attributs.

<polygon
   points="list of points"  > 
</polygon>

Les attributs

Sr.No. Nom et description
1 points - Liste des points pour constituer un polygone.

Exemple

testSVG.htm
<html>
   <title>SVG Polygon</title>
   <body>
      
      <h1>Sample SVG Polygon Image</h1>
      
      <svg width="800" height="800">
         <g>
            <text x="0" y="15" fill="black" >Polygon #1: Without opacity.</text>
            
            <polygon points="150,75 258,137.5 258,262.5 150,325 42,262.6 42,137.5"
            stroke="black" stroke-width="3" fill="rgb(121,0,121)"></polygon>
         </g> 
      </svg>
   
   </body>
</html>

Production

Ouvrez textSVG.htm dans le navigateur Web Chrome. Vous pouvez utiliser Chrome / Firefox / Opera pour afficher l'image SVG directement sans aucun plugin. Internet Explorer 9 et supérieur prend également en charge le rendu d'image SVG.

Polygone avec opacité

<html>
   <title>SVG Polygon</title>
   <body>
      <h1>Sample SVG Polygon Image</h1>
      
      <svg width="800" height="800"> 
         <g>
            <text x="0" y="15" fill="black" >Polygon #2: With opacity </text>
         
            <polygon points="150,75 258,137.5 258,262.5 150,325 42,262.6 42,137.5"
            style="fill:rgb(121,0,121);stroke-width:3;
            stroke:rgb(0,0,0);stroke-opacity:0.5;opacity:0.5"></polygon>
         </g>
      </svg>
      
   </body>
</html>

Production

Ouvrez textSVG.htm dans le navigateur Web Chrome. Vous pouvez utiliser Chrome / Firefox / Opera pour afficher l'image SVG directement sans aucun plugin. Internet Explorer 9 et supérieur prend également en charge le rendu d'image SVG.