How to realize the effect of canvas sliding Correction by html5
The main content of this article is to explain "html5 how to achieve canvas sliding correction effect", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "html5 how to achieve canvas sliding correction effect"!
Page layout
Style:
* {margin: 0; padding: 0;} # canva {background: indianred;}
JS:
_ window.onload=function () {var canva=document.getElementById ('canva'); var ctx = canva.getContext (' 2d'); var hobby canva.height; var w=canva.width Var rext= {/ / defines the attributes of the verification block x:Math.random () * (wmur50), y:Math.random () * (hmur50),} var hk= {/ / Slider attribute xfreu0' YRV Rect'} () / / draw the verification block Hk (0rext.y); / / draw the slider canva.addEventListener ('click',function () {var ev=ev | | event; var xcaliev.clientX; var ycliev.clientY; if (x > = 0 & & x=rext.y & & yy & x)