在 HTML5 画布中在圆形内部创建文本
要在画布中的圆形内创建文本,请使用
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>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP