SVG Circle
In SVG, the element is used to draw circles; it is one of the commonly used basic shapes in SVG.
Use The element can create circular shapes, and the circle's position, size, and style can be controlled by setting attributes.
Basic Syntax
cy="y-coordinate"
r="radius"
fill="fill-color"
stroke="stroke-color"
stroke-width="width"
/>
Attribute Analysis:
-
cxandcyThe attribute defines the coordinates of the circle's center, i.e. the position of the center point. -
rThe attribute defines the radius of the circle, determining its size. -
fillThe attribute defines the fill color of the circle. -
strokeThe attribute defines the stroke color of the circle. -
stroke-widthThe attribute defines the stroke width of the circle.
The following code draws a circle with blue fill, black stroke, and a radius of 50 pixels, with center coordinates at (100, 100).
Example
Below is the SVG code:
Example
Try it »
Click to view:View SVG File.
Code analysis:
- The cx and cy attributes define the x and y coordinates of the circle's center. If cx and cy are omitted, the circle's center is set to (0, 0)
- The r attribute defines the radius of the circle