Skip to content

Commit 99b0ab5

Browse files
committed
make fillColor work
1 parent 1e86fe1 commit 99b0ab5

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

blockly/src/webapp/webapp.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,16 +1055,22 @@ Webapp.createCanvas = function (opts) {
10551055
var divWebapp = document.getElementById('divWebapp');
10561056

10571057
var newElement = document.createElement("canvas");
1058-
newElement.id = opts.elementId;
1059-
// default width/height if params are missing
1060-
var width = opts.width || 400;
1061-
var height = opts.height || 400;
1062-
newElement.width = width * Webapp.canvasScale;
1063-
newElement.height = height * Webapp.canvasScale;
1064-
newElement.style.width = width + 'px';
1065-
newElement.style.height = height + 'px';
1066-
1067-
return Boolean(divWebapp.appendChild(newElement));
1058+
var ctx = newElement.getContext("2d");
1059+
if (newElement && ctx) {
1060+
newElement.id = opts.elementId;
1061+
// default width/height if params are missing
1062+
var width = opts.width || 400;
1063+
var height = opts.height || 400;
1064+
newElement.width = width * Webapp.canvasScale;
1065+
newElement.height = height * Webapp.canvasScale;
1066+
newElement.style.width = width + 'px';
1067+
newElement.style.height = height + 'px';
1068+
// set transparent fill by default:
1069+
ctx.fillStyle = "rgba(255, 255, 255, 0)";
1070+
1071+
return Boolean(divWebapp.appendChild(newElement));
1072+
}
1073+
return false;
10681074
};
10691075

10701076
Webapp.canvasDrawLine = function (opts) {
@@ -1091,8 +1097,8 @@ Webapp.canvasDrawCircle = function (opts) {
10911097
opts.radius * Webapp.canvasScale,
10921098
0,
10931099
2 * Math.PI);
1100+
ctx.fill();
10941101
ctx.stroke();
1095-
ctx.closePath();
10961102
}
10971103
return false;
10981104
};

0 commit comments

Comments
 (0)