W3C home > Mailing lists > Public > www-svg@w3.org > May 2008

Source-image offset/dimensions control for the image element

From: Erik Dahlström <ed@opera.com>
Date: Wed, 07 May 2008 10:19:21 +0200
To: "www-svg@w3.org" <www-svg@w3.org>
Message-ID: <op.uaryqj12gqiacl@gnorps.palace.opera.no>

Hello www-svg,

I'm wondering if there's interest in being able to control the offset,  
width and height of a raster image to draw in the <image> element, to be  
able to select exactly what part of the raster image to draw.

Something similar to CSS background-position [1], which allows you to pick  
an arbitrary (x,y) offset of an image. This is often used to collect many  
sprites in one image, to be able to load multiple resources as one.

In SVG it's only possible to use the 'preserveAspectRatio' attribute to  
control the position for raster images. The 1.1 spec says that when an  
<image> element references a raster image the implicit 'viewBox' has a  
value of "0 0 raster-image-width raster-image-height". If there was a way  
of controlling the implicit viewBox it would be possible to draw raster  
sprites more efficiently.

It is possible to control all of this in SVG, using for example the clip,  
mask or pattern features. However, each of these comes at the price of  
additional processing, since they are meant to cover more advanced  
use-cases as well.



[1] http://www.w3.org/TR/CSS21/colors.html#background-properties
[2] http://www.w3.org/TR/SVG11/struct.html#ImageElement

Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed
Received on Wednesday, 7 May 2008 08:22:00 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:47:13 UTC