【发布时间】:2013-12-02 19:24:18
【问题描述】:
我想在我的画布的矩形块中添加文本。请告诉我该怎么做,我的代码在下面
<html>
<title>Canvas app</title>
<head>
<style>
#canvas_ract{
border:1px solid black;
}
</style>
<script>
window.onload =function(){
var myCanvas = document.getElementById('canvas_ract');
var ctx = myCanvas.getContext("2d");
ctx.beginPath();
ctx.fillStyle="#FF0000";
//ctx.strokeStyle = "#0000bb";
ctx.arc(200,100,100,0,Math.PI*2,true);
ctx.closePath();
ctx.fill();
ctx.font="30px Arial";
ctx.fillText("Hello World",10,50);
ctx.fillStyle="pink";
ctx.fillRect(30,40,200,100);
}
</script>
</head>
<body>
<canvas id="canvas_ract" width="500"height="500"><canvas>
</body>
</html>
并告诉我是否有任何好的方法可以获取有关此画布 api 的更多知识
【问题讨论】: