jquery变形图像效果
我很确定这是不可能的,但是。 。 。
我正在尝试获得变形效果(就像在 Flash 图像旋转器中的此页面上一样 -> http://www.sikids. com) 在 jquery.或者至少是非常相似的效果。我看到jquery UI有一些变形效果,但我一直没能找到它。这对我们的客户很重要,因此任何尽可能接近的效果都会很棒。
I'm pretty sure this is impossible, but. . .
I am trying to get a morphing effect (like on this page in the flash image rotator -> http://www.sikids.com) in jquery. Or at least an effect that is very similar. I saw that jquery UI had some morphing effects, but I haven't been able to find it. This is important to our client, so any effect that is as close as possible would be awesome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
另一种可能同样慢但不需要任何画布的选择是使用 1x1 像素图像编写像素化算法。
第一步是将图像缩减为 32 种颜色的调色板。
然后,您可以将图像映射到起始像素级别的调色板。例如,如果图像为 100 像素 x 200 像素,第一级像素化为 50 x 100 的网格,则将图像替换为 50x100 = 5000,
,每个图像都带有来自颜色的背景图像调色板。
这需要在服务器端完成并作为 JavaScript 数组传递,然后将其转换为
:
将变为:
然后在 javascript 中放大一些
< /code>,并通过删除一些
来缩小网格,直到达到某个停止放大倍数。
然后用高倍率的新图像替换它,并反转新图像的算法。
Another option that might be equally as slow, but would not require any canvases would be to write the pixelation algorithm using 1x1 pixel images.
The first step would be to reduce the image to a palette of 32 colors.
Then you would map the image to the palette at the start pixelation level. For example, if the image was 100px by 200px and the first level pixelation is a grid 50 by 100, replace the image with, 50x100 = 5000,
<IMG>
each with a background image from the color palette.This would need to be done server side and passed as a javascript array that would then be converted to
<IMG>
:Would become:
Then in javascript enlarge some of the
<IMG>
, and reduce the grid by removing some of the<IMG>
, until some stopping magnification is reached.Then replace that with the new image on high magnification and reverse the algorithm for the new image.
这并非不可能……但可能会很慢。
您必须使用画布来获取图像数据并对其进行转换。看看这个所以答案< /a> 和这个插件,这可能会让事情变得更容易。我没有在 IE 中使用过该插件,因此您可能需要添加一个额外的 canvas 插件。
It's not impossible... but it might be slow.
You'll have to use canvas to grab the image data and transform it. Check out this SO answer and this plugin, which might help make things easier. I haven't used that plugin so in IE, you might have to include an additional canvas plugin.
为此目的开发了一个名为 MorpherJS 的 JavaScript 库 - 它完全是客户端 JavaScript。可以在此处找到 MorpherJS 的一些演示。它使用 HTML canvas 元素来显示变形图像动画。
A JavaScript library called MorpherJS has been developed for this purpose - it's entirely client-side JavaScript. Some demos of MorpherJS can be found here. It uses the HTML canvas element to display morphing image animations.