如何向 Raphael.js 对象添加阴影?

发布于 2024-09-26 06:46:03 字数 65 浏览 0 评论 0原文

我想了解如何向 Raphael.js 对象/路径添加模糊边缘阴影。据我所知,图书馆不可能按原样进行,但有解决办法吗?

I would like to find out how to add blurry edged drop shadows to Raphael.js objects/paths. As far as I know it is not possible with the library as is but is there a work around?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

无语# 2024-10-03 06:46:03

您可以使用Element.glow([glow])来获得阴影效果。 http://raphaeljs.com/reference.html#Element.glow

You can use the Element.glow([glow]) to get a shadow effect. http://raphaeljs.com/reference.html#Element.glow

好多鱼好多余 2024-10-03 06:46:03

根据 OP 的要求,在单独的答案中添加 Raphael.blur 的链接。

http://github.com/DmitryBaranovskiy/raphael/blob/master /plugins/raphael.blur.js

更新的代码示例:

var shadow = canvas.path(p);
shadow.attr({stroke: "none", fill: "#555", translation: "4,4"});
shadow.blur(4);
var shape = canvas.path(p);

请注意,在 Dmitry 的评论中,他提到没有 WebKit 支持。他使用 元素和 feGaussianBlur 滤镜效果。 WebKit 已经实现了 feGaussianBlur 效果,但是滤镜不稳定并且在 Safari 中被禁用(可能会在 Chrome 5 中工作 - 绝对应该在 Chrome 6 中工作)。

Adding a link to Raphael.blur in a separate answer, per the OP's request.

http://github.com/DmitryBaranovskiy/raphael/blob/master/plugins/raphael.blur.js

Updated code sample:

var shadow = canvas.path(p);
shadow.attr({stroke: "none", fill: "#555", translation: "4,4"});
shadow.blur(4);
var shape = canvas.path(p);

Note that in Dmitry's comments he mentions that there is no WebKit support. He uses the <filter> element and the feGaussianBlur filter effect. WebKit has implemented the feGaussianBlur effect, but filters are unstable and are disabled in Safari (it may work in Chrome 5 - should definitely work in Chrome 6).

合约呢 2024-10-03 06:46:03

我编写了一个插件,通过对元素应用 SVG 过滤器来向元素添加阴影。
它基于模糊插件。

您可以在这里找到它:https://github.com/dahoo/raphael.dropshadow.js

I wrote a plugin that adds a drop shadow to an element by applying an SVG filter to it.
It's based on the blur plugin.

You can find it here: https://github.com/dahoo/raphael.dropshadow.js

浅唱々樱花落 2024-10-03 06:46:03

最简单的方法就是用阴影色填充绘制对象,偏移几个像素,然后在顶部绘制实际对象。

var shadow = canvas.path(p);
shadow.attr({stroke: "none", fill: "#555", translation: "4,4"});
var shape = canvas.path(p);

如果需要,您还可以调整不透明度属性。

The easiest way to do it is simply to draw the object with a shadow-colored fill, offset by a few pixels, and then draw the actual object on top.

var shadow = canvas.path(p);
shadow.attr({stroke: "none", fill: "#555", translation: "4,4"});
var shape = canvas.path(p);

You can also adjust the opacity attribute if needed.

不气馁 2024-10-03 06:46:03

您可以使用发光来添加阴影。

.glow({ color: '#900', width:10, offsetx:5 }) // 随机示例...

查看 文档

You can use a glow to add shadows.

.glow({ color: '#900', width:10, offsetx:5 }) // random example...

check out the documentation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文