I have some strange behaviour with the BitmapData.draw() function
Consider the following code:
var canvas:BitmapData = new BitmapData(400, 400, true, 0xFF000000);
var rwidth:Int = 250;
var rheight:Int = 50;
var redcolor:Int = 0xFFFF0000;
var ribbon:BitmapData = new BitmapData(rwidth, rheight, true, 0x00000000);
var hs:Shape = new Shape();
var g:Graphics = hs.graphics;
g.lineStyle(1, redcolor);
g.beginFill(redcolor);
g.drawRect(0, 0, rwidth, rheight);
g.endFill();
ribbon.draw(hs);
var cliprect:Rectangle = new Rectangle(0, 0, 50, 50);
if I do
canvas.copyPixels(ribbon, cliprect, new Point(50, 50), null, null, true);
That’s OK, I have a red square that appear over my black canvas (at position (50,50))
But now, if instead of using the copyPixel() function, I use the draw function, with the following code:
var mat:Matrix = new Matrix();
mat.translate(50, 50);
canvas.draw(ribbon, mat, null, null, cliprect);
I have nothing but my black canvas (no red square at all). Whereas I would be expecting the same result as with the copyPixel() function (a red square at position 50,50 ).
So is there something I misunderstood or is it a bug in the bitmapdata.draw() function?
Tested with openfl 3.3.3 and lime 2.6.2 on flash target