无法在画布上绘制超过八个矩形
我试图在画布上绘制简单的矩形。这是我的代码。
代码完全执行。但它只完全绘制了7个矩形,并且仅绘制了8个矩形。
最后两个矩形未绘制。我究竟做错了什么?我尝试过IE9 beta,FF3和Chrome 9.请帮忙。
<html>
<head>
<script src="javascript/jquery-1.4.4.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
drawsegment($('#divTree'));
});
function drawsegment(widget) {
var $ctx = $('<canvas />', {
width: '300',
height: '200'
});
widget.html($ctx);
var ctx = $ctx[0].getContext('2d');
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 255, 20);
ctx.fillStyle = "yellow";
ctx.fillRect(0, 20, 255, 20);
ctx.fillStyle = "blue";
ctx.fillRect(0, 40, 255, 20);
ctx.fillStyle = "green";
ctx.fillRect(0, 60, 255, 20);
ctx.fillStyle = "violet";
ctx.fillRect(0, 80, 255, 20);
ctx.fillStyle = "white";
ctx.fillRect(0, 100, 255, 20);
ctx.fillStyle = "black";
ctx.fillRect(0, 120, 255, 20);
ctx.fillStyle = "gray";
ctx.fillRect(0, 140, 255, 20);
ctx.fillStyle = "yellow";
ctx.fillRect(0, 160, 255, 20);
ctx.fillStyle = "blue";
ctx.fillRect(0, 180, 255, 20);
}
</script>
</head>
<body>
<div id="divTree"></div>
</body>
</html>
没有找到相关结果
已邀请:
1 个回复
缮淳彼誊