SVG 影像元素

SVG 的 <image> 元素允許在 SVG 物件中渲染點陣圖影像。

在這個基本示例中,一個由 href 屬性引用的 .jpg 影像將在 SVG 物件內渲染

xml
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="5cm" height="4cm" version="1.1"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <image href="firefox.jpg" x="0" y="0" height="50px" width="50px"/>
</svg>

有幾點重要提示需要注意

  • 如果您不設定 xy 屬性,它們將預設設定為 0
  • 如果您不設定 heightwidth 屬性,它們將預設設定為 0
  • heightwidth 屬性設定為 0 將停用影像的渲染。