首页 > 代码库 > [ html canvas shadowOffsetX shadowOffsetY shadowBlur shadowColor ] canvas绘图属性 shadowOffsetX shadowOffsetY shadowBlur shadowColor 属性演示

[ html canvas shadowOffsetX shadowOffsetY shadowBlur shadowColor ] canvas绘图属性 shadowOffsetX shadowOffsetY shadowBlur shadowColor 属性演示

 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=http://www.mamicode.com/‘./css/index.css‘ />"color: #008080;"> 9 <script type=‘text/javascript‘ src=http://www.mamicode.com/‘./js/jquery-1.12.1.min.js‘></script>"color: #008080;">10 <style type=‘text/css‘>11 html,body,canvas {12     margin: 0; padding: 0;13 }14 15 html {16     height: 100%17 }18 19 body {20     background: #000;21 }22 23 #can {24     background: #FFF; display: block; margin: 25px auto; border-radius: 2px; line-height: 0;25 }26 </style>27 <script type=‘text/javascript‘>28     $( function(){29         var can = $( ‘#can‘ ).get( 0 );30         var oCan = can.getContext( ‘2d‘ );31         var w = can.width;32         var h = can.height;33         oCan.font = ‘900 50px Courier New‘; /* 可以补充加粗方式但字号 字体缺一不可 并且以不同的方式来进行填充是可以更改字体的 */34         oCan.strokeStyle = ‘#F00‘;35         oCan.textAlign = ‘center‘ /* 设置水平居中方式 */36         oCan.textBaseline = ‘middle‘; /* 设置垂直居中方式 */37         oCan.shadowOffsetX = 2;            /* 设置阴影的问题存在兼容问题 火狐不支持  并且只能单独设置*/38         oCan.shadowOffsetY = 2;39         oCan.shadowBlur = 7;40         oCan.shadowColor = ‘rgba(32,96,126,.9)‘;41         oCan.fillText( ‘chuangling‘ , w / 2 , h / 2 ); /* 创建文本的自适应居中方式  */42     } );43 </script>44 </head>45 <body>46     <canvas id=‘can‘ width=‘500‘ height=‘450‘>检测到您的浏览器版本过低请升级您的浏览器版本,以获取更好的使用体验...</canvas>47 </body>48 </html>

 

[ html canvas shadowOffsetX shadowOffsetY shadowBlur shadowColor ] canvas绘图属性 shadowOffsetX shadowOffsetY shadowBlur shadowColor 属性演示