beginBitmapFill problem

Hello,
I am trying to draw and fill a rectangle with bitmap(for html5 target), like this:

var sh:Shape = new Shape()
var bData:BitmapData = new BitmapData(20, 20, true, 0xFF00FF00);

sh.graphics.lineStyle(1);
sh.graphics.beginBitmapFill(bData, null, false);
sh.graphics.drawRect(0, 0, 200, 200);
sh.graphics.endFill();

However, for some reason the fill doesn’t work in chrome browser (but works in firefox). How can i fix this?

Sorry for not directly answering your question, but do you actually need a “beginBitmapFill” here? You could use “beginFill” and just use a solid colour if you don’t require the features of a bitmap.

It’s just an example. In a real project, I need to fill the bitmap with the preloaded texture. Unfortunately, beginBitmapFill only draws the original texture and does not fill the area completely.

1 Like

Thanks for clarifying. Do you have any special settings in your project.xml which may affect rendering, such as a haxeflag for -Dcanvas ?

Probably not. I tested this in the default haxedevelop openfl project.