Canvas implementation to draw a bean fish effect

If you say, please see the code:

    Canvas eats bean fish    Body {text-align: center;} canvas {background: #efefef;}    curved = 2 * pi * angle / 360 = angle * Pi / 180   


VAR CTX = A1.GetContext ('2D'); // Get the brush on the canvas and set the drawing function OpenMOMSE () {// Draw circle (3/4) ctx.beginpath (); // Start a path CTX.arc (250, 200, 100, 45 * math.pi / 180, 315 * math.pi / 180); // Center is (250,200 ), Radius is 100 ctx.Lineto (250, 200); ctx.closepath (); ctx.stroke (); // 轮 / = c c te ;s = = '# 00ffff'; ctx.fill (); Eye (); } // OpenMouse (); function closemouse () {ctx.beginpath (); // Start a path CTX.ARC (250, 200, 100, 0 * math.pi / 180, 360 * math.pi / 180); // Center is (250,200 ), Radius is 100 ctx.Lineto (250, 200); ctx.closepath (); ctx.stroke (); // 轮 / / stroke CTX.FillStyle = '# 00ffffff'; ctx.fill (); Eye ();} // closemouse (); // Draw public partial eye function eye () {// Draw eye CTX.BeginPath (); CTX.ARC (250, 200-100 / 2, 25, 0, 2 * math.pi); // Eye radius is 25 ctx.Stroke (); ctx.fillstyle = '# 001900'; ctx.fill (); // Draw eyelight CTX.BeginPath (); CTX .arc (265, 140, 5, 0, 2 * math.pi); // eye light radius is 5 ctx.stroke (); ctx.fillstyle = '# fffff'; ctx.fill ();} var isopen = true; / / Define Variables ISOpen: Whether to open VAR Timer = setInterval (Function () {var CTX = A1.GetContext ('2D'); CTX.ClearRect (0,0,500,400); // Empty Canada size if (isopen) {Closemouse (); @ @}} else {OpenMouse (); isopen = true;}}, 500);

The above is all the contents of this article, hope The content of this article has a certain help to everyone's learning or work, and I hope to support Tumi cloud!
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment