在HTML5 Canvas中的圆圈内创建文本
要在画布上的圆圈内创建文本,请使用:
context.beginPath();
以下是画布:
$("#demo").on("click", "#canvas1", function(event) {
var canvas = document.getElementById('canvas1');
if (canvas.getContext) {
var context = canvas.getContext("2d");
var w = 25;
var x = event.pageX;
var y = Math.floor(event.pageY-$(this).offset().top);
context.beginPath();
context.fillStyle = "blue";
context.arc(x, y, w/2, 0, 2 * Math.PI, false);
context.fill();
context = canvas.getContext("2d");
context.font = '9pt';
context.fillStyle = 'white';
context.textAlign = 'center';
context.fillText('amit', x, y+4);
}
});的HTML
<div id = demo> <canvas id = canvas1></canvas> </div>
热门推荐
4 家长会简短祝福语
10 换工作简短特别祝福语
11 春节最好的祝福语简短
12 恭喜生孩子祝福语简短
13 侄儿高考试祝福语简短
14 简短他人的生日祝福语
15 感谢再见的祝福语简短
16 祖国祝福语简短走心
17 回复生日祝福语 简短
18 同学贺卡励志祝福语简短