在计算机课上,我不得不画一些我喜欢的东西,所以我决定绘制m& ms。然而,它写了" m"在糖果上与糖果颜色相同而不是白色。这是我的一个m& m的代码:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
function drawCircle(x, y, rad, cut, pi, color) {
ctx.beginPath();
ctx.arc(x, y, rad, cut, Math.PI * pi);
ctx.closePath();
ctx.fillStyle = color;
ctx.fill();
}
function drawMnM(x, y, color) {
drawCircle(x, y, 15, 0, 2, color);
ctx.font = "30px Arial";
ctx.fillText("m", x - 15, y);
ctx.fillStyle = "white";
}
drawMnM(75, 75, "red");

<canvas id="myCanvas" style="border:1px solid #d3d3d3;">
</canvas>
&#13;
m&amp; m&#34; m&#34;出现红色,那么我怎么能解决这个问题呢?
答案 0 :(得分:2)
您需要在 $(function() {
$("#password2").keyup(function() {
var password = $("#password1").val();
var password2 = $("#password2").val();
if(password!== null && password2!== null){
if(password == password2) {
$('#divCheckPasswordMatch').show();
$("#divCheckPasswordMatch").html("Passwords match.")
}
else {
$('#divCheckPasswordMatch').hide();
$("#divCheckPasswordMatch").html("Passwords do not match!")
}
}
});
});
之前设置fillStyle
(,因为它将用于绘制文本)
fillText
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
function drawCircle(x, y, rad, cut, pi, color) {
ctx.beginPath();
ctx.arc(x, y, rad, cut, Math.PI * pi);
ctx.closePath();
ctx.fillStyle = color;
ctx.fill();
}
function drawMnM(x, y, color) {
drawCircle(x, y, 15, 0, 2, color);
ctx.font = "30px Arial";
ctx.fillStyle = "white";
ctx.fillText("m", x - 15, y);
}
drawMnM(75, 75, "red");