使用svg画一个三角形
<svg width="100" height="100">
<polygon points="50,10 10,90 90,90" style="fill:blue; stroke:black; stroke-width:2" />
</svg>
This code creates an SVG image of a blue triangle with a black outline. Here's a breakdown:
<svg>tag: This defines the SVG canvas.widthandheightset the dimensions.<polygon>tag: This draws the triangle.pointsattribute: This specifies the vertices of the triangle. Each pair of numbers represents an x and y coordinate.50,10is the top vertex,10,90is the bottom-left, and90,90is the bottom-right. These coordinates are relative to the top-left corner of the SVG canvas.styleattribute: This sets the visual properties of the triangle:fill:blue;sets the fill color to blue.stroke:black;sets the outline color to black.stroke-width:2;sets the outline thickness to 2 pixels.
You can embed this code directly into an HTML file to display the triangle. You can also adjust the points, fill, stroke, and stroke-width attributes to customize the triangle's appearance. For example, to create a red triangle filled with yellow:
<svg width="100" height="100">
<polygon points="50,10 10,90 90,90" style="fill:yellow; stroke:red; stroke-width:3" />
</svg>
浙公网安备 33010602011771号