39,083
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE HTML>
<html>
<head>
<title>我要分享</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<body>
<!-- 绘制用户二维码图片 -->
<canvas id="myCanvas" ></canvas>
<script type="text/javascript">
function draw () {
var canvas = document.getElementById('myCanvas');
canvas.width = 640;
canvas.height = 600;
var context = canvas.getContext("2d");
context.fillStyle = "red";
context.fillRect(0, 0, 640, 300);
};
draw();
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<style type="text/css">
canvas{border:dashed 2px #CCC}
</style>
<script type="text/javascript">
function $$(id){
return document.getElementById(id);
}
function pageLoad(){
var can = $$('can');
var cans = can.getContext('2d');
var gnt1 = cans.createLinearGradient(10,0,390,0);
gnt1.addColorStop(0,'red');
gnt1.addColorStop(0.5,'green');
gnt1.addColorStop(1,'blue');
cans.fillStyle = gnt1;
cans.fillRect(10,10,380,280);
}
</script>
<body onload="pageLoad();">
<canvas id="can" width="400px" height="300px">4</canvas>
</body>
</html>