1<! DOCTYPE html>234<title>insert you title</title>5<meta name= ' description ' content= ' This is my page ' >6<meta name= ' keywords ' content= ' keyword1,keyword2,keyword3 ' >7<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">8<link rel= ' stylesheet ' type= ' text/css ' href= './css/index.css '/>9<script type= ' text/javascript ' src= './js/jquery-1.12.1.min.js ' ></script>Ten<style type= ' text/css ' > One Html,body,canvas { Amargin:0; padding:0; - } - the HTML { -height:100%; - } - + Body { -Background: #000; + } A at #can { -Background: #FFF/*url ('./images/index.jpg ') no-repeat Center; Backgrond-size:cover*/; -Display:block; MARGIN:25PX Auto; border-radius:2px; cursor:pointer; - } -</style> -<script type= ' Text/javascript ' > in$(function(){ - varcan = $ (' #can '). Get (0 ); to varOcan = Can.getcontext (' 2d ' ); + varOimg =NewImage (); -OIMG.SRC = './images/index.jpg '; the varGimg = Ocan.getimagedata (50, 30, 100, 150);/*The reason for this is that the number of reads in the Loop*/ *Oimg.onload =function(){ $ varnum = 0;Panax Notoginseng varLength =gImg.data.length; - varimg = ocan.createimagedata (100, 100 ); the for(vari = 0; i < length; i++ ){ +num = i% 4;/*0 1 2 3*/ A Switch(num) { the Case0 : +num = 0; -img.data[I] =getrandomnum (); $ Break; $ Case1 : -num = 255; -img.data[I] =getrandomnum (); the Break; - Case2 :Wuyinum = 0; theimg.data[I] =getrandomnum (); - Break; Wu Case3 : -num =getrandomnum (); Aboutimg.data[I] =num; $ Break; - } - } -Ocan.putimagedata (IMG, 10, 20 ); A }; + functionGetrandomnum () { the returnMath.ceil (Math.random () * 255);/*0--255*/ - } $ //alert (Getrandomnum ()); the } ); the</script> the the<body> -<canvas id= ' can ' width= ' height= ' 168 ' > detects that your browser version is too low please upgrade your browser version for a better user experience ...</canvas> in</body> the
[HTML canvas createimagedata create kaleidoscope effects] Canvas drawing properties Createimagedata Properties Explain and create kaleidoscope effects