What cx,cy do? I couldn't really understand | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What cx,cy do? I couldn't really understand

What x,y do in rect tag?

26th Sep 2020, 8:50 AM
Shahina Ismoilova
Shahina Ismoilova - avatar
2 Answers
+ 2
x and y are left and top coordinates of a rectangle in a rect element. For a circle, cx and cy are coordinates of the centre of the circle. I suggest you create a simple svg file that shows a circle and a rect and load it in a web browser. Change the x, y, cx, and cy values, save, and reload in browser until you see what affect they have on what you see. Here is a starting point for you: <?xml version="1.0" encoding="UTF-8" ?> <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 846 557" width="846" height="557" > <circle cx="185" cy="35" r="26.5" stroke="#000" stroke-width="17"/> <rect x="262" y="53" width="40" height="17" style="fill:#f00"/> </svg>
26th Sep 2020, 9:33 AM
Josh Greig
Josh Greig - avatar
+ 1
Thanks. I understood
26th Sep 2020, 12:50 PM
Shahina Ismoilova
Shahina Ismoilova - avatar