使用 Raphael 在图像周围绘制圆形边框
我正在使用 Raphael JavaScript 库。我想在图像(这是一个拉斐尔对象)周围绘制一个带有圆角边缘的边框,但我似乎不知道如何做到这一点。我试图设置笔划,但它没有出现。
我有这样的想法:
var paper = Raphael(10, 50, 500, 500);
var google_img = paper.image("http://www.google.com/images/logos/ps_logo2.png", 10, 10, 200, 200);
感谢我能得到的任何帮助!
I'm using the Raphael JavaScript library. I'd like to draw a border with rounded edges around an image (which is a Raphael object) but I can't seem to figure out how to do that. I tried to set a stroke but it doesn't appear.
I have this:
var paper = Raphael(10, 50, 500, 500);
var google_img = paper.image("http://www.google.com/images/logos/ps_logo2.png", 10, 10, 200, 200);
Appreciate any help I can get!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用图像作为填充怎么样:
How about using image as a fill:
我认为你在谈论剪切路径。查看维基百科上的剪切路径。距离 Google 不远,我从 Raphaël 的 Google 群组中发现了一些不幸的消息:
(摘自RaphaelJS 支持剪切遮罩合成吗? ,塞巴斯蒂安·古林 (Sebastian Gurin) 发表)。
如果您有兴趣使用插件在支持它的浏览器中启用剪辑,请查看该线程。
或者,您可以尝试在与图像相同的位置绘制一个未填充的描边矩形,其尺寸相同,但具有图像集的
r
属性和描边宽度
code> 足够大以补偿半径(请注意,这可能会导致隐藏图像的四肢)。I think you are talking about a clipping path. Check out Clipping path on Wikipedia. A short Google away, I found some unfortunate news from Raphaël's Google Group:
(From Does RaphaelJS support clipping masking compositing?, post by Sebastian Gurin).
Check out the thread if you are interested in using a plugin to enable clipping in browsers that support it.
Alternatively, you could try drawing an unfilled, stroked rectangle with the same dimensions at the same location as the image, but with the
r
attribute of the image set, and thestroke-width
large enough to compensate for the radius (note that this may result in hiding the extremities of the image).