canvas里面加不了颜色,代码这样的
<!DOCTYPEhtml><htmllang="zh-cn"><head><metacharset="UTF-8"><title>实例演示</title><!--<me...
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>实例演示</title>
<!-- <meta name="vicewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="1.css"> -->
</head>
<body>
<canvas id="mycanvas" width="600px" height="300px" style="border: 1px solid #DCDCDC"></canvas>
<script type="text/javascript">
function draw(){
var c=document.getElementById(`mycanvas`)
var cxt=c.getContext(`2d`)
for(var i=0;i<12;i++){
for(var j=0;j<24;j++){
cxt.fillstyle="rgb(255,222,173)";
cxt.beginPath();
cxt.arc(12.5+j*50,12.5+i*50,10,0,Math.PI*2,true);
cxt.closePath();
cxt.fill();
}
}
}
draw()
</script>
</body>
</html> 展开
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>实例演示</title>
<!-- <meta name="vicewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="1.css"> -->
</head>
<body>
<canvas id="mycanvas" width="600px" height="300px" style="border: 1px solid #DCDCDC"></canvas>
<script type="text/javascript">
function draw(){
var c=document.getElementById(`mycanvas`)
var cxt=c.getContext(`2d`)
for(var i=0;i<12;i++){
for(var j=0;j<24;j++){
cxt.fillstyle="rgb(255,222,173)";
cxt.beginPath();
cxt.arc(12.5+j*50,12.5+i*50,10,0,Math.PI*2,true);
cxt.closePath();
cxt.fill();
}
}
}
draw()
</script>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询