我正在尝试给下面的线条上色,但是我的画布要么给所有的线条上色,要么根本不上色。任何帮助都将不胜感激
canvas.save();
canvas.scale(1, 0.75);
canvas.beginPath();
canvas.arc(100, 95, 8, 0, Math.PI * 2, false);
canvas.stroke();
canvas.strokeStyle= "red";
canvas.closePath();
canvas.restore();
发布于 2013-04-04 06:37:53
您使用的是canvas,我想您指的是上下文。
Canvas=getElementById(“我的画布”);
context.getContext("2d");
几个要点: 1.使用context.beginPath()开始1个或多个绘图;2.当您将上下文告诉context.stroke()时,它将使用您设置的最后一个 strokeStyle (上一个strokeStyles被忽略) 3. always to context.stroke()以将绘制的直线、圆弧等物理应用到画布上。
// draw a red circle
context.beginPath();
context.arc(100, 95, 8, 0, Math.PI * 2, false);
context.strokeStyle="red";
context.stroke();
//then begin a new path and draw a blue circle
context.beginPath();
context.arc(150, 95, 8, 0, Math.PI * 2, false);
context.strokeStyle="blue";
context.stroke();
https://stackoverflow.com/questions/15797340
复制相似问题