It seems as if calling "clear" on a CanvasKit's canvas has no effect. The JavaScript-Code in question is ('hello-skia.js'):
const ckLoaded = CanvasKitInit({
locateFile: (file) => '/node_modules/canvaskit-wasm/bin/'+file});
ckLoaded.then((CanvasKit) => {
const paint = new CanvasKit.Paint();
function drawFrame(canvas) {
// Clear background
canvas.clear(CanvasKit.LTGREY);
paint.setColor(CanvasKit.RED);
// Draw a rectangle with red paint
rect = CanvasKit.LTRBRect(10, 10, 128, 128);
canvas.drawRect(rect, paint);
...
surface.requestAnimationFrame(drawFrame); }
surface.requestAnimationFrame(drawFrame);
});
------------
HTML file is as simple as this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World, Skia</title>
</head>
<body>
<script type = "text/javascript" src="/node_modules/canvaskit-wasm/bin/canvaskit.js"></script>
<script type = "text/javascript" src="src/hello-skia.js"></script>
<canvas id=skia-canvas width=500 height=500></canvas>
</body>
</html>
------------------
The red rectangle is drawn as expected, but the canvas it not cleared to light grey background. Did anybody encounter this? Does the canvas need special setup in order to be able to be cleared? Thanks for help, Michael.