SVG and Canvas

Standards-Based Open Graphics

SVG and Canvas

Raster vs. Vector


Resizing to Fit

Easy to change size of images by either attributes or CSS.

          <object type="image/svg+xml" data="svgLogo.svg" 
                     style="width: 150px; height: 150px;"> </object>
        
          <object type="image/svg+xml" data="svgLogo.svg" 
                     width="150px" height="150px"> </object> 
       
          <svg xmlns="http://www.w3.org/2000/svg"
             width="100%" height="100%" viewBox="0 0 50 50">
             <circle cx="25" cy="25" r="25" fill="orange">
          </svg>
       

SVG

Canvas

Simple example: rounded corners

Markup:

   <svg xmlns="http://www.w3.org/2000/svg">
     <rect x="20" y="20" width="400" height="300" 
           rx="35" ry="35" 
           fill="none" stroke="black" />
   </svg>
 

Script:

Common Features

How do you create SVG and Canvas?

Authoring Tools

Libraries

Browser Support

Both mostly supported by Firefox, Opera, and WebKit (Safari, Google Chrome)

Both supported by iPhone, SVG supported on many keitai

SVG vs. Canvas: Fight!

Passing Values to Embedded SVG

To pass parameters to an SVG, use the <object> element with child <param> elements. Each <param> element should have name/value pairs with the 'name' and 'value' attributes; these will be exposed to the embedded SVG document.

    <object type="image/svg+xml" data="light.svg">
       <param name="color" value="red" />
       <param name="label" value="stop" />
    </object>

SVG in CSS

SVG in text/html and XHTML

Common Open Graphics



Contact

schepers@w3.org