第24章 canvas绘制矩形
html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="24.js"></script>
<style type="text/css">
body{ margin:0; padding:0;}
</style>
</head>
<body onBlur="draw('canvas');">
<canvas id="canvas" width="400" height="300"></canvas>
</body>
</html>js
// JavaScript Document
function draw(id){
var canvas = document.getElementById(id);
var context = canvas.getContext('2d');
context.fillStyle = "green";
context.strokeStyle = "#fff";
context.lineWidth = 5;
context.fillRect(0,0,400,300);
context.strokeRect(50,50,180,120);
context.strokeRect(110,110,180,120);
}效果图:
相关推荐
jinxiutong 2020-05-10
MIKUScallion 2020-02-22
songfens 2020-01-10
大地飞鸿 2020-11-12
星星有所不知 2020-10-12
jinxiutong 2020-07-26
MIKUScallion 2020-07-05
songfens 2020-07-05
songfens 2020-06-11
songfens 2020-06-08
northwindx 2020-05-31
northwindx 2020-05-31
northwindx 2020-05-27
northwindx 2020-05-25
MIKUScallion 2020-05-25
xdyangxiaoromg 2020-05-10
大地飞鸿 2020-05-06