Building Web Applications with SVG - Cdn.oreilly.com
Building Web Applications with SVG - Cdn.oreilly.com
Building Web Applications with SVG - Cdn.oreilly.com
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
The xmlns attribute (which appears not to have been a part of the language originally, because the<br />
Adobe and Opera viewers are unique in not requiring it) is necessary for most browsers to be able to<br />
display the code as <strong>SVG</strong>.<br />
Essentially, the xmlns attribute merely tells the browser that it will be speaking a new dialect of<br />
XML. This is because most browsers of the 20th century assumed that the only language they would<br />
need to know was HTML. Writing isn’t sufficient to let the browser know this, because the XML<br />
specification requires a namespace. It is rather unfortunate, from the perspective of teachers and<br />
learners, that the <strong>com</strong>puter languages we learn are filled <strong>with</strong> mysteries that have no apparent purpose<br />
until one be<strong>com</strong>es a guru. However, you can think of the code xmlns=”http://www.w3.org/2000/<br />
svg” <strong>with</strong>in the element as just that: a mysterious incantation probably placed in the language<br />
to make sure that casual learners know to be on their guard. It turns out that it is not all that important<br />
to understand.<br />
Screen Coordinates<br />
Before beginning the second exercise, in which you’ll begin experimenting <strong>with</strong> <strong>SVG</strong>, consider the<br />
drawing space itself—the browser window. Each point <strong>with</strong>in the drawing space (also known as the<br />
Cartesian plane) is identified by a pair of coordinates (x and y). The upper-left corner of the screen<br />
is the point (0,0) and—depending on screen resolution and the current size of the window—the<br />
lower-right corner could have coordinates such as (800,640), (951,651), or (1440,900). The number of<br />
pixels determines the resolution of the screen. The resolution on mobile devices varies considerably;<br />
240×320 pixels is a popular size for smaller and older devices.<br />
CHAPTER 1 <strong>SVG</strong> Basics 23