o1-mini-2024-09-12· OpenAI
WildChat-4.8M (AI2)
Draw a sword in SVG
- User
Draw a sword in SVG
- Assistant
Draw a sword in SVG
Sure! Below is an SVG representation of a simple sword. You can copy the SVG code and use it in your HTML files or SVG-compatible applications.
<svg
width="200"
height="500"
viewBox="0 0 200 500"
xmlns="http://www.w3.org/2000/svg"
>
<!-- Blade -->
<polygon
points="90,50 110,50 120,450 80,450"
fill="silver"
stroke="black"
stroke-width="2"
/>
<!-- Guard -->
<rect
x="70"
y="50"
width="60"
height="10"
fill="gold"
stroke="black"
stroke-width="2"
/>
<!-- Handle -->
<rect
x="90"
y="60"
width="20"
height="200"
fill="brown"
stroke="black"
stroke-width="2"
/>
<!-- Pommel -->
<circle
cx="100"
cy="260"
r="10"
fill="gold"
stroke="black"
stroke-width="2"
/>
</svg>
SVG Container:
width="200" and height="500" set the size of the SVG canvas.viewBox="0 0 200 500" defines the coordinate system. This ensures the SVG scales properly.Blade:
<polygon> creates the blade using four points:
(90,50) and (110,50) are the top corners of the blade.(120,450) and (80,450) are the bottom corners.fill="silver" gives the blade a metallic look.stroke="black" and stroke-width="2" add a border to the blade.Guard:
<rect> creates the horizontal guard.(70,50) with a width of 60 and height of 10.fill="gold" gives it a metallic appearance.stroke="black" and stroke-width="2" add a border.Handle:
<rect> creates the handle of the sword.(90,60) with a width of 20 and height of 200.fill="brown" gives it a wooden appearance.stroke="black" and stroke-width="2" add a border.Pommel:
<circle> adds a pommel at the end of the handle.(100,260) with a radius of 10.fill="gold" matches the guard.stroke="black" and stroke-width="2" add a border.Embed in HTML: You can directly embed this SVG code within your HTML file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SVG Sword</title>
</head>
<body>
<!-- Paste the SVG code here -->
<svg ...>...</svg>
</body>
</html>
Use as an Image Source:
Save the SVG code in a file, say sword.svg, and reference it in an <img> tag.
<img src="sword.svg" alt="Sword Illustration">
Styling with CSS: You can style the SVG using CSS by adding classes or IDs to the SVG elements.
fill attributes to customize the colors of different parts of the sword.width, height, and viewBox to resize the sword or change its proportions.To see the sword, you can use an online SVG editor like SVG Edit or embed the SVG code in an HTML file and open it in your browser.
Feel free to modify the SVG code to better suit your design needs!