Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw a hollow circle in SVG

Tags:

svg

I'm not sure how to approach drawing a hollow circle in SVG.

I would like a ring shape filled with a colour and then have a black outline.

The way I thought about doing it was have 2 circles, one with a smaller radius than the other. The problem is when I fill them, how do I make the smaller circle take the same fill colour as what it sits on?

like image 531
luketorjussen Avatar asked Nov 19 '11 11:11

luketorjussen


People also ask

Which tag of SVG is used to draw a circle?

The <circle> SVG element is an SVG basic shape, used to draw circles based on a center point and a radius.


1 Answers

Just use fill="none" and then only the stroke (outline) will be drawn.

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">     <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="none" />  </svg> 

Or this if you want two colours:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">     <circle cx="100" cy="50" r="40" stroke="black" stroke-width="3" fill="none" />     <circle cx="100" cy="50" r="39" stroke="red" stroke-width="2" fill="none" />  </svg>
like image 148
Robert Longson Avatar answered Sep 21 '22 12:09

Robert Longson