Html5 canvas draws a circular seal and interacts with the page. html5canvas

Source: Internet
Author: User
Tags drawtext

Html5 canvas draws a circular seal and interacts with the page. html5canvas

1 <! DOCTYPE html> 2 // Rotate 69 if (I = 0) {70 context around the center of the canvas. rotate (5 * Math. PI/6); 71} else {72 context. rotate (angle); 73} 74 context. save (); 75 context. translate (66, 0); // translate to this position. The word is perpendicular to the X axis, and the company name is 76 context away from the outermost circle. rotate (Math. PI/2); // Rotate 90 degrees to make the word parallel to 77 context on the X axis. scale (1, 2); // scale the canvas to extend the text by 78 context. fillText (c, 0, 0); // This point is the center of the word 79 context. restore (); 80} 81 // set the canvas to the original position as the origin, and rotate back to the original position of the balance to clear the 82 context of the canvas. rotate (-Math. PI/6); 83 context. translate (0-canvas.width/2,0-canvas. height/2); 84 85 86 87 // draw a star 88/** 89 * to create a star shape. the center coordinate of the star is (sx, sy), and the distance from the center to the vertex is radius. When rotate = 0, a vertex is 90 * rotate on the axis of symmetry: rotate radians 91 */92 function create5star (context, sx, sy, radius, color, rotato) {93 context. save (); 94 context. fillStyle = color; 95 context. translate (sx, sy); // move the coordinate origin 96 context. rotate (Math. PI + rotato); // rotate 97 context. beginPath (); // create path 98 var x = Math. sin (0); 99 var y = Math. cos (0); 100 var dig = Math. PI/5*4; 101 for (var I = 0; I <5; I ++) {// draw the five sides of a pentagram 102 var x = Math. sin (I * dig); 103 var y = Math. cos (I * dig); 104 context. lineTo (x * radius, y * radius); 105} 106 context. closePath (); 107 context. stroke (); 108 context. fill (); 109 context. restore (); 110} 111} 112 113 </script> 114 </body> 115 

Canvas has just started learning, but it is not very understandable. I searched many examples from the Internet and combined them with my own understanding. If there are any shortcomings, I would like to ask some experts to correct them.

It is not enough to understand rotation and peaceful movement, and the canvas clearance is not very good at rotation. I hope the great god who passed by can give me some advice. Thank you very much.

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.