A character avatar that generates particle effects based on HTML5 canvas

Source: Internet
Author: User

Before we shared a HTML5 canvas implementation of the image mosaic blur effect, HTML5 processing the picture is really very simple. Today we are going to use HTML5 canvas to achieve a particle effect of the avatar, you can choose an avatar image, then the image will be broken into many particles, and then slowly reorganized into a picture, the mouse over the picture when the particles will also appear floating animation effects, looks very cool.

Online preview Source Download

The HTML code is as follows

<Pclass= "Center">Change pixel resolution<inputtype= "Range"min= "4"Max= "+"value= "+"ID= "Range" /> <spanID= "Output">32</span></P><Divclass= "thumb">         <imgsrc= "Img/1.jpg"ID= "Dolly1" />        <imgsrc= "Img/2.jpg"ID= "Dolly2" />        <imgsrc= "Img/3.jpg"ID= "Dolly3" /></Div>

Defines a slider and 3 images to blur. The JavaScript code is as follows

varDolly1 = document.getElementById (' dolly1 '))      varDolly2 = document.getElementById (' dolly2 '))      varDolly3 = document.getElementById (' Dolly3 '))      varPixelopts = [{Resolution:8 } ]      varPixelDolly1 =dolly1.closepixelate (pixelopts)varPixelDolly2 =dolly2.closepixelate (pixelopts)varPixelDolly3 =dolly3.closepixelate (pixelopts)varRange = document.getElementById (' Range ')      varOutput = document.getElementById (' Output ') Range.addeventlistener (' Change ',function(event) {varres = parseint (Event.target.value, 10) Res= Math.floor (RES/2) * 2Res= Math.max (4, Math.min (100, RES)) Output.textcontent=Res//Console.log (res);Pixelopts =[{resolution:res}] Pixeldolly1.render (pixelopts) pixeldolly2.render (pixelopts) Pixeldol Ly3.render (pixelopts)},false)

The above JS file is the concrete implementation of mosaic blur effect. Here is the JS code called on the page:

varDolly1 = document.getElementById (' dolly1 '))      varDolly2 = document.getElementById (' dolly2 '))      varDolly3 = document.getElementById (' Dolly3 '))      varPixelopts = [{Resolution:8 } ]      varPixelDolly1 =dolly1.closepixelate (pixelopts)varPixelDolly2 =dolly2.closepixelate (pixelopts)varPixelDolly3 =dolly3.closepixelate (pixelopts)varRange = document.getElementById (' Range ')      varOutput = document.getElementById (' Output ') Range.addeventlistener (' Change ',function(event) {varres = parseint (Event.target.value, 10) Res= Math.floor (RES/2) * 2Res= Math.max (4, Math.min (100, RES)) Output.textcontent=Res//Console.log (res);Pixelopts =[{resolution:res}] Pixeldolly1.render (pixelopts) pixeldolly2.render (pixelopts) Pixeldol Ly3.render (pixelopts)},false)

The above is the whole process of realizing this HTML5 canvas mosaic blur animation.

via:http://www.w2bc.com/article/21456

A character avatar that generates particle effects based on HTML5 canvas

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.