使用 CSS 或 JavaScript 在网页中实现 Photoshop 风格的混合模式?
我想知道是否可以使用 Photoshop 中的混合模式(叠加、屏幕、加亮等)在网页上将两个或多个图像混合在一起。
我知道这种事情可以用 flash 和 java 实现,但是没有任何插件(即 CSS 或 JavaScript)是否可以实现?我见过一些这种效果的 javascript 示例,它们适用于相对较小的图像,但我有兴趣在高分辨率图像上执行此操作...这纯粹是出于实验目的。
I am wondering if it is possible to blend two or more images together on a webpage using blend modes like you will find in photoshop (overlay, screen, lighten, etc).
I know that this kind of thing is possible with flash and java, but is it possible without any plugins i.e. with CSS or JavaScript? I have seen a few javascript examples of this effect that work on relatively small images, but I am interested in performing this on high resolution images... this is purely for experimental purposes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用画布元素,您可以轻松获得叠加和增亮效果。这完全取决于您在将每个位图渲染到画布之前指定的设置。
https://developer.mozilla.org/en- US/docs/Web/Guide/HTML/Canvas_tutorial/Compositing
With the canvas element, you can get overlay and lighten pretty easily. It's all about what settings you specify before rendering each bitmap to the canvas.
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Compositing
我创建了一个单独的、轻量级的开源库,用于从一个 HTML Canvas 上下文到另一个上下文执行 Photoshop 风格的混合模式:
请参阅 README 了解更多信息,包括支持的混合模式当前版本。
I have created a separate, lightweight, open-source library for perform Photoshop-style blend modes from one HTML Canvas context to another: context-blender. Here's the sample usage:
See the README for more information, including the blend modes supported in the current version.