4

I'm trying to replicate sucking effect in ios using css3 -webkit-transform:matrix3d() property.

However, I can't manage the curved edges like in the picture. The closest solution by myself is the following:

-webkit-transform: matrix3d(0.85, 0.0678, 0, 0, 2.37, 0.85, -1.36, -0.0019, 0, 0, -1.53, -3.73, 0, 0, 0.34, 1);

Here is the jsfiddle result.

How can I do the transformation like in the picture. Note that how right and left edges are curved.

enter image description here

4

1 回答 1

9

我已经对 css3 转换进行了一些搜索。如果您使用的是matrix3d属性,则只能进行线性变换,这不会让您弯曲任何东西。它包括剪切、比例和平移。

但是,当前的实验技术可以让您进行非线性变换。因此,您可以扭曲、卷曲等任何对象。这需要编写着色器,因此您需要为 GPU 编写代码。

Adobe 有 CSS 过滤器实验室来证明这一点。多亏了他们,我设法应用了我想要的转换。这是屏幕截图: 吸吮效应

这是管理它的代码

-webkit-filter:
custom(url(shaders/vertex/warp.vs) mix(url(shaders/fragment/warp.fs) normal source-atop), 20 20 border-box, k array(-0.429, -0.471, 467, -0.286, -0.507, 0, -0.086, -0.507, 0, 0.15, -0.514, 0, -0.407, -0.086, 0, -0.021, -0.171, 0, 0.193, -0.171, 0, 0.364, -0.171, 0, 0.036, 0.179, 0, 0.179, 0.171, 0, 0.35, 0.179, 0, 0.464, 0.171, 0, 0.2, 0.5, 0, 0.279, 0.5, 0, 0.414, 0.493, 0, 0.5, 0.5, 0), matrix perspective(1000) scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg), useColoredBack 1, backColor 1 1 1 1);

您可以在使用此链接启用实验功能后自行测试:http: //html.adobe.com/webplatform/graphics/customfilters/cssfilterlab/#suckeffect

于 2013-07-26T08:19:39.290 回答