如何使用jQuery SVG插件设置SVG rect元素的背景图像? [英] How to set a SVG rect element's background image with jQuery SVG plugin?
本文介绍了如何使用jQuery SVG插件设置SVG rect元素的背景图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用keith-wood的jQuery SVG插件创建了SVG矩形.这是代码:
I created a SVG rect using keith-wood's jQuery SVG plugin. Here is the code:
svg.graph._wrapper.rect(group, 0, 100, 40, 20,
{fill: 'ivory',
stroke: 'black',
strokeWidth : 2});
所以我认为我可以轻松地更改填充而不是使用象牙",而是将其更改为"theImageIwantToUse".但这似乎不起作用.
So I thought I could easily change the fill instead of using 'ivory', I changed it to 'theImageIwantToUse'. But it does not seem to work.
推荐答案
您可以使用<image>
元素您提到的插件中提供了适当的功能.
An appropriate function is available in the plugin you mentioned.
svg.image(parent, x, y, width, height, ref, settings)
( http://keith-wood.name/svg.html )
我怀疑是否可以在图像中使用笔触,因此在绘制图像后必须绘制一个没有填充的矩形才能获得所需的精确结果.
I doubt it's possible to use stroke in an image so you'll have to draw a rectangle with no fill after drawing the image to get the exact result you want.
这篇关于如何使用jQuery SVG插件设置SVG rect元素的背景图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文