I have a sprite which is a primitive rectangle rotated by 45 degrees. I'd like to create a Bitmap using BitmapData which will copy it exactly. I thought that BitmapData#draw will operate only on my sprite, so I tried naive approach:
var a = new Sprite();
a.graphics.beginFill(0xFF0000);
a.graphics.drawRect(0, 0, 200, 100);
a.graphics.endFill();
a.x = 100;
a.y = 100;
a.rotation = 45;
addChild(a);
var bitmapData = new openfl.display.BitmapData(1500, 1500, false, 0x00000000);
bitmapData.draw(a);
var bitmap = new openfl.display.Bitmap(bitmapData);
bitmap.x = 500;
bitmap.y = 100;
addChild(bitmap);
However the result surprised me:

It seems it preserves transformation matrix (which in fact makes sense, otherwise rotation would be lost). So I tried more robust approach:
var bitmapData = new openfl.display.BitmapData(1500, 1500, false, 0x00000000);
var rect = a.getBounds(a.parent);
var matrix = a.transform.concatenatedMatrix;
matrix.translate(-rect.left, -rect.top);
bitmapData.draw(a, matrix);
Desired result is

And still, same result as in the image provided. I've tried I forgot about clipRect param, but even more weirdly, no matter how big the rectangle is, object is not copied at all (only black space remains).x and y, clip is not an issue
var bitmapData = new openfl.display.BitmapData(1500, 1500, false, 0x00000000);
var clip = new openfl.geom.Rectangle(1500, 1500);
bitmapData.draw(a, clip);
Am I misusing BitmapData#draw? Any help appreciated
(It must be BitmapData, as I have to use it in pixel-perfect collision testing using BitmapData#hitTest)
OpenFL 4.0.0
Tested with Cpp, Neko and HTML5
Thank you.
