Image Mosaic blur effects based on HTML5 Canvas,

Source: Internet
Author: User

Image Mosaic blur effects based on HTML5 Canvas,

Mosaic blur is often applied to images or videos. Today we will use the HTML5 Canvas technology to achieve mosaic blur. In the demonstration, we can drag the slider to set the degree of mosaic blur. You can observe the effect of the image after Mosaic under different values. HTML5 is indeed very powerful. As follows:

Download Online Preview source code

Implementation code.

Html code:

<div class="thumb">                                                            </div>

Js Code:

window.onload = function () {            var dolly1 = document.getElementById('dolly1')            var dolly2 = document.getElementById('dolly2')            var dolly3 = document.getElementById('dolly3')            var pixelOpts = [{ resolution: 8}]            var pixelDolly1 = dolly1.closePixelate(pixelOpts)            var pixelDolly2 = dolly2.closePixelate(pixelOpts)            var pixelDolly3 = dolly3.closePixelate(pixelOpts)            var range = document.getElementById('range')            var output = document.getElementById('output')            range.addEventListener('change', function (event) {                var res = parseInt(event.target.value, 10)                res = Math.floor(res / 2) * 2                res = Math.max(4, Math.min(100, res))                output.textContent = res                // console.log( res );                pixelOpts = [{ resolution: res}]                pixelDolly1.render(pixelOpts)                pixelDolly2.render(pixelOpts)                pixelDolly3.render(pixelOpts)            }, false)        }

Via: http://www.w2bc.com/Article/20795

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.