[ html canvas quadraticCurveTo ] canvas绘图quadraticCurveTo()属性研究实例演示之二
1 <!DOCTYPE html>
2 <html lang='zh-cn'>
3 <head>
4 <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>
10 <style type='text/css'>
11 html,body {
12 margin: 0; padding: 0;
13 }
14
15 html {
16 height: 100%;
17 }
18
19 body {
20 background: #000;
21 }
22
23 #can {
24 display: block; border-radius: 2px; margin: 25px auto; background: #FFF;
25 }
26 </style>
27 <script type='text/javascript'>
28 $( function(){
29 var oCan = $( '#can' ).get( 0 ).getContext( '2d' );
30 oCan.strokeStyle = '#000';
31 oCan.lineWidth = 2;
32 oCan.save();
33 oCan.moveTo(100,300);
34 oCan.quadraticCurveTo(30,70,400,150,50);
35 oCan.stroke();
36 oCan.restore();
37 /* 控制点位置 */
38 oCan.save();
39 oCan.beginPath();
40 oCan.strokeStyle = '#F00';
41 oCan.arc(100,300,2,0,2*Math.PI,false);
42 oCan.moveTo(100,300);
43 oCan.lineTo(30,70);
44 oCan.stroke();
45 oCan.closePath();
46 oCan.save();
47 oCan.beginPath();
48 oCan.strokeStyle = '#F90';
49 oCan.arc(30,70,2,0,2*Math.PI,false);
50 oCan.stroke();
51 oCan.closePath();
52 oCan.save();
53 oCan.beginPath();
54 oCan.strokeStyle = '#F9B';
55 oCan.arc(400,150,2,0,2*Math.PI,false);
56 oCan.stroke();
57 oCan.closePath();
58 oCan.moveTo(30,70);
59 oCan.lineTo(400,150);
60 oCan.stroke();
61
62
63
64 } );
65 </script>
66 </head>
67 <body>
68 <canvas id='can' width='500' height='450'>您的浏览器版本过低,请升级您的浏览器以获取更好的使用体验...</canvas>
69 </body>
70 </html>