代码
提交代码
<!DOCTYPE html> <html> <head> <title>A Simple Canvas Example</title> <style> body{ background: #dddddd; } #canvas{ margin: 10px; padding: 10px; background: #ffffff; border: thin inset #aaaaaa; } </style> </head> <body> <canvas id="canvas" width="600" height="600"> Canvas not supported </canvas> <script> var canvas=document.getElementById('canvas'), context=canvas.getContext('2d'); context.font='38pt Arial'; context.fillStyle='cornflowerblue'; context.strokeStyle='blue'; context.fillText('Hello imooc',canvas.width/2-150,canvas.height/2+15); context.strokeText('Hello imooc',canvas.width/2-150,canvas.height/2+15); </script> </body> </html>
运行结果