<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>初学html5</title>
<meta name="keywords" content="">
<meta name="description" content="">
<script src="canvas2.js"></script>
<style>
*{margin:0;padding:0;}
</style>
</head>
<body onload="draw('canvas');">
<canvas id="canvas" width="400" height="300"></canvas>
</body>
</html>
function draw(id)
{
var canvas=document.getElementById(id);
var context=canvas.getContext('2d');
context.fillStyle='green';
context.fillRect(0,0,800,300);
context.fillStyle="#fff";
context.strokeStyle="#fff";
context.font="bold 40px 宋体";
context.textBaseline="top";
// context.textAlign="center";
context.fillText("麦子学院",0,0);
context.strokeText("麦子学院",0,40);
}