将渐变服务器作为SVG中的外部文件 [英] Gradient servers as external files in SVG

查看:83
本文介绍了将渐变服务器作为SVG中的外部文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
在SVG中包含SVG文件

Possible Duplicate:
Include SVG file in SVG

SVG中的fill属性接受一个指向渐变/图案元素(即所谓的绘画服务器"的实例)的网址.

the fill property in SVG accepts an url to point to a gradient/pattern element, an instance of a so-called 'paint server'.

问题:在任何浏览器(当然不是IE)中,是否可以使用在外部SVG文件中定义的渐变?就像在rect.svg

The Question: Is it possible in any browser (that is, not IE, of course), to use a gradient defined in an external SVG file? Like, in rect.svg,

<rect fill="url(grad.svg#my_grad)" />

grad.svg中相应的<linearGradient />元素?

那真的很不错,因为这样一来,他就可以将所有渐变/图案存储在一个文件中,并进行缓存...

It would be really nice, because then one could store all his gradients/patterns in one file and get that cached...

干杯

更新:从本质上讲,这个问题是在SVG中包含SVG文件(至少在Firefox中回答了该问题).我保持开放状态,因为我认为标题和标签很可能会被您发现.

Update: This question is, by its meaning, a duplicate of Include SVG file in SVG (where the question was answered for at least Firefox). I keep mine open, because I think the title and tags are more likely to get found by, well, you.

推荐答案

SVG规范仅声明您可以使用URI,因此应该可以.浏览器支持当然是另一回事.

The SVG Specification just states that you can use an URI - so it should be possible. Browser Support is of course a different matter.

我只是编写并测试了一个小样本文件.

I just wrote and tested a little sample file.

它在Inkscape中不起作用-但它与Apache Batik Toolkit一起起作用.

It doesn't work in Inkscape - but it does work with the Apache Batik Toolkit.

为了获得浏览器支持,我将文件上传到了 browsershots.org 并进行了总结:某些浏览器确实支持外部渐变-有些则没有. 例如:

For Browser Support, i uploaded the file to browsershots.org and to summarize it: some browsers do support external gradients - some don't. e.g.:

  • Firefox 3.0否
  • Firefox 3.5是
  • Opera 9.64,10.0是
  • Safari 4否
  • Chrome 2.0否

这篇关于将渐变服务器作为SVG中的外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆