<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文字排版</title>
<script type="text/javascript">
function clearmap(){
context.clearRect(0,0,300,200);
}
</script>
</head>
<body>
<canvas id="canvas" width="700" height="300" style="border:1px solid"></canvas>
</body>
<script type="text/javascript">
function draw(){
var c=document.getElementById("canvas");
var context = c.getContext("2d");
var lingrad = context.createLinearGradient(0,0,0,200);
lingrad.addColorStop(0,'#ff0000');
lingrad.addColorStop(1/7,'#ff9900');
lingrad.addColorStop(2/7,'#ffff00');
lingrad.addColorStop(3/7,'#00ff00');
context.fillStyle=lingrad;
context.strokeStyle=lingrad;
context.fillRect(10,10,200,200);
}
window.οnlοad=function(){
draw();
}
</script>
<input name="" type="button" value="清空画布" οnclick="clearmap();">
</html>
<html>
<head>
<meta charset="utf-8">
<title>文字排版</title>
<script type="text/javascript">
function clearmap(){
context.clearRect(0,0,300,200);
}
</script>
</head>
<body>
<canvas id="canvas" width="700" height="300" style="border:1px solid"></canvas>
</body>
<script type="text/javascript">
function draw(){
var c=document.getElementById("canvas");
var context = c.getContext("2d");
var lingrad = context.createLinearGradient(0,0,0,200);
lingrad.addColorStop(0,'#ff0000');
lingrad.addColorStop(1/7,'#ff9900');
lingrad.addColorStop(2/7,'#ffff00');
lingrad.addColorStop(3/7,'#00ff00');
context.fillStyle=lingrad;
context.strokeStyle=lingrad;
context.fillRect(10,10,200,200);
}
window.οnlοad=function(){
draw();
}
</script>
<input name="" type="button" value="清空画布" οnclick="clearmap();">
</html>