我使用下面的代码来设置样式myCanvas,但我无法设置fillStyle.然而,strokeStyle并且lineWidth工作正常.有人可以帮忙吗?
Init()
{
var can = byId('myCanvas');
// get it's context
hdc = can.getContext('2d');
hdc.strokeStyle = 'red';
hdc.lineWidth = 2;
// Fill the path
hdc.fillStyle = "#9ea7b8";
hdc.opacity = 0.2;
hdc.fill();
}
// And call the drawPoly function with coordinates.
function drawPoly(coOrdStr) {
var canvas = byId('myCanvas');
hdc.clearRect(0, 0, canvas.width, canvas.height);
var mCoords = coOrdStr.split(',');
var i, n;
n = mCoords.length;
hdc.beginPath();
hdc.moveTo(mCoords[0], mCoords[1]);
for (i = 2; i < n; i …Run Code Online (Sandbox Code Playgroud) 我刚开始用 Konva,不知道有没有办法设置舞台颜色?默认情况下它是某种亮灰色,如果可能,我想更改它,而不必添加矩形并填充它。