@@ -1055,16 +1055,22 @@ Webapp.createCanvas = function (opts) {
1055
1055
var divWebapp = document . getElementById ( 'divWebapp' ) ;
1056
1056
1057
1057
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 ;
1068
1074
} ;
1069
1075
1070
1076
Webapp . canvasDrawLine = function ( opts ) {
@@ -1091,8 +1097,8 @@ Webapp.canvasDrawCircle = function (opts) {
1091
1097
opts . radius * Webapp . canvasScale ,
1092
1098
0 ,
1093
1099
2 * Math . PI ) ;
1100
+ ctx . fill ( ) ;
1094
1101
ctx . stroke ( ) ;
1095
- ctx . closePath ( ) ;
1096
1102
}
1097
1103
return false ;
1098
1104
} ;
0 commit comments