Technology News

Scalable Vector Graphics: Drawing Basics

In this article, you’ll discover the basic concepts, document structure, and drawing elements used in SVG images.

If you’re completely new to SVGs, it may help to read the following articles first:

  • Scalable Vector Graphics: an Overview
  • 7 Reasons to Consider SVGs Instead of Canvas

SVG Co-ordinate Grid

An SVG is defined in whatever co-ordinate space you give it. That space does not necessarily correlate with pixels, centimeters, inches, or other absolute units, because an SVG can be scaled to any dimension.

The SVG’s viewBox attribute determines the co-ordinates the image uses. The following SVGs would look identical when scaled to the same size:

  • a viewBox of 0,0 to 200,100 with a line from 0,0 to 100,50
  • a viewBox of 0,0 to 300,150 with a line from 0,0 to 150,75
  • a viewBox of 0,0 to 30,15 with a line from 0,0 to 15,7.5 (fractions of a unit are permitted)

SVG drawing space

Unlike mathematical graphs, the SVG co-ordinate system starts at the top left (usually 0,0) with the x-axis pointing right and y-axis pointing down. Therefore, a point at 100,200 represents 100 units to the right of the left hand edge and 200 units down from the top edge.

When an SVG is rendered, it can be given width and height attributes or assigned dimensions in CSS. The image will be stretched or squashed in both directions to fill the space it’s been allocated. However, an SVG can declare that its aspect ratio can be preserved to ensure dimensions are scaled consistently.

Continue reading Scalable Vector Graphics: Drawing Basics on SitePoint.

Brand Awareness vs Brand Equity: Understand the Differences
How Anthos And Multi-Cloud Are Transforming Enterprise IT

Related Articles

Best Mobile Apps To Manage Trade And Payments For Retail Shops

best-mobile-apps-to-manage-trade-and-payments-for-retail-shops
Mobile-Apps-To-Manage-Trade-And-Payments-For-Retail-Shops Running a business is quite demanding, and that’s where the use of an effective mobile application comes into the picture. Especially for trade and payment scenarios, mobile apps become…

9 UX Tips Every Blog Manager Needs

9-ux-tips-every-blog-manager-needs
A blog is a great way to connect with customers and build loyalty. But the truth is, most company blogs could use some help with their user experience.   Maintaining a…

HYIP: New investment look will be launching soon!

HYIP: New investment look will be launching soon!
Acemero Technologies – we are pleased to announce the introduction of our freshly updated website, which we hope will provide our valued and dependable visitors with a user-friendly browsing experience.…

Best Practices in UI Testing

best-practices-in-ui-testing
When working on software, the user interface matters more than you might think. No matter how incredibly efficient and groundbreaking the backend might be, a shoddy UI can sink a…

12 Ways to Improve Your Site Speed

12-ways-to-improve-your-site-speed
Page load speed is paramount when it comes to website performance. A fast-loading site improves user experience and lowers your bounce rate, improving your online reputation and increasing your ranking…