{"action":"created","issue":{"url":"https://api.github.com/repos/openfl/openfl/issues/616","labels_url":"https://api.github.com/repos/openfl/openfl/issues/616/labels{/name}","comments_url":"https://api.github.com/repos/openfl/openfl/issues/616/comments","events_url":"https://api.github.com/repos/openfl/openfl/issues/616/events","html_url":"https://github.com/openfl/openfl/issues/616","id":70460428,"number":616,"title":"BitmapData.draw() before BitmapData.fillRect() causes inconsistent visuals","user":{"login":"larsiusprime","id":739064,"avatar_url":"https://avatars.githubusercontent.com/u/739064?v=3","gravatar_id":"","url":"https://api.github.com/users/larsiusprime","html_url":"https://github.com/larsiusprime","followers_url":"https://api.github.com/users/larsiusprime/followers","following_url":"https://api.github.com/users/larsiusprime/following{/other_user}","gists_url":"https://api.github.com/users/larsiusprime/gists{/gist_id}","starred_url":"https://api.github.com/users/larsiusprime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsiusprime/subscriptions","organizations_url":"https://api.github.com/users/larsiusprime/orgs","repos_url":"https://api.github.com/users/larsiusprime/repos","events_url":"https://api.github.com/users/larsiusprime/events{/privacy}","received_events_url":"https://api.github.com/users/larsiusprime/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-04-23T16:55:06Z","updated_at":"2015-04-23T18:04:51Z","closed_at":null,"body":"BitmapData.draw() still has lingering issues with drawSelf.\r\n\r\nSome quick screengrab crops-\r\n\r\nCorrect (flash):\r\n![flash](https://cloud.githubusercontent.com/assets/739064/7303198/7351aae8-e9b4-11e4-9a80-bf2124098f46.png)\r\n\r\nNext (drawSelf = false)\r\n![next_drawself_false](https://cloud.githubusercontent.com/assets/739064/7303199/73532d96-e9b4-11e4-8633-fa1888bb396f.png)\r\n\r\nNext (drawSelf = true)\r\n![next_drawself_true](https://cloud.githubusercontent.com/assets/739064/7303200/7353f618-e9b4-11e4-83f6-6f39932913ca.png)\r\n\r\n\r\n\r\nCode to reproduce:\r\n\r\n```\r\n\tprivate var _matrix:Matrix;\r\n\t\r\n\tpublic function new () {\r\n\t\t\r\n\t\t_matrix = new Matrix();\r\n\t\t\r\n\t\tsuper ();\r\n\t\ttextTest();\r\n\t}\r\n\t\r\n\tprivate function textTest():Void\r\n\t{\r\n\t\tvar text:TextField = new TextField();\r\n\t\taddChild(text);\r\n\t\t\r\n\t\ttext.textColor = 0xFFFF0000;\r\n\t\ttext.text = \"Hello, World!\";\r\n\t\t\r\n\t\ttext.x = 5;\r\n\t\ttext.y = 5;\r\n\t\t\r\n\t\tvar data = new BitmapData(Std.int(text.textWidth+4), Std.int(text.textHeight+4), true);\r\n\t\tvar r = new Rectangle(0, 0, data.width, data.height);\r\n\t\t\r\n\t\t// WORKS if drawSelf = true  (text on yellow bkg)\r\n\t\t//!WORKS if drawSelf = false (text on !exist bkg)\r\n\t\tdata.draw(text);\r\n\t\tdata.fillRect(r, 0xFFFFFF00);\r\n\t\tdata.draw(text);\r\n\t\t\r\n\t\tvar b = new Bitmap(data);\r\n\t\tb.x = text.x + text.textWidth + 10;\r\n\t\tb.y = text.y;\r\n\t\taddChild(b);\r\n\t\t\r\n\t\tvar data2 = new BitmapData(data.width, data.height, true);\r\n\t\tvar r2 = new Rectangle(0, 0, data2.width, data2.height);\r\n\t\t\r\n\t\t// WORKS if drawSelf = false (text on yellow bkg)\r\n\t\t// WORKS if drawSelf = true  (text on yellow bkg)\r\n\t\tdata2.fillRect(r, 0xFFFFFF00);\r\n\t\tdata2.draw(text);\r\n\t\t\r\n\t\tvar b2 = new Bitmap(data2);\r\n\t\tb2.x = b.x + b.width + 10;\r\n\t\tb2.y = b.y;\r\n\t\taddChild(b2);\r\n\t\t\r\n\t\tvar data3 = new BitmapData(data.width, data.height, true);\r\n\t\tvar r3 = new Rectangle(0, 0, data3.width, data3.height);\r\n\t\t\r\n\t\t// WORKS if drawSelf = false (yellow text outlined blue)\r\n\t\t//!WORKS if drawSelf = true  (yellow text)\r\n\t\tdrawTextWithBorder(text, data3, 0xFFFFFF00, 0xFF0000FF, 1);\r\n\t\t\r\n\t\tvar b3 = new Bitmap(data3);\r\n\t\tb3.x = b2.x + b2.width + 10;\r\n\t\tb3.y = b2.y;\r\n\t\taddChild(b3);\r\n\t}\r\n\t\r\n\tprivate function drawTextWithBorder(txt:TextField, bmp:BitmapData, color:Int, outlineColor:Int, border:Int)\r\n\t{\r\n\t\tdrawOutline(txt, bmp, border, outlineColor);\r\n\t\tvar oldcolor = txt.textColor;\r\n\t\ttxt.textColor = color;\r\n\t\tbmp.draw(txt);\r\n\t\ttxt.textColor = oldcolor;\r\n\t}\r\n\t\r\n\tprivate function drawOutline(txt:TextField, bmp:BitmapData, offset:Int, color:Int)\r\n\t{\r\n\t\t_matrix.identity();\r\n\t\t\r\n\t\tvar oldcolor = txt.defaultTextFormat.color;\r\n\t\t\r\n\t\ttxt.textColor = color;\r\n\t\t\r\n\t\tcopyTextWithOffset( -offset, -offset, txt, bmp);\r\n\t\tcopyTextWithOffset( offset, 0, txt, bmp);\r\n\t\tcopyTextWithOffset( offset, 0, txt, bmp);\r\n\t\tcopyTextWithOffset( 0, offset, txt, bmp);\r\n\t\tcopyTextWithOffset( 0, offset, txt, bmp);\r\n\t\tcopyTextWithOffset( -offset, 0, txt, bmp);\r\n\t\tcopyTextWithOffset( -offset, 0, txt, bmp);\r\n\t\tcopyTextWithOffset( 0, -offset, txt, bmp);\r\n\t\t\r\n\t\t_matrix.translate(offset, 0);\r\n\t\t\r\n\t\ttxt.textColor = oldcolor;\r\n\t}\r\n\t\r\n\tprivate function copyTextWithOffset(x:Float, y:Float, txt:TextField, bmp:BitmapData)\r\n\t{\r\n\t\t_matrix.translate(x, y);\r\n\t\tbmp.draw(txt, _matrix);\r\n\t}\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/openfl/openfl/issues/comments/95673057","html_url":"https://github.com/openfl/openfl/issues/616#issuecomment-95673057","issue_url":"https://api.github.com/repos/openfl/openfl/issues/616","id":95673057,"user":{"login":"larsiusprime","id":739064,"avatar_url":"https://avatars.githubusercontent.com/u/739064?v=3","gravatar_id":"","url":"https://api.github.com/users/larsiusprime","html_url":"https://github.com/larsiusprime","followers_url":"https://api.github.com/users/larsiusprime/followers","following_url":"https://api.github.com/users/larsiusprime/following{/other_user}","gists_url":"https://api.github.com/users/larsiusprime/gists{/gist_id}","starred_url":"https://api.github.com/users/larsiusprime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsiusprime/subscriptions","organizations_url":"https://api.github.com/users/larsiusprime/orgs","repos_url":"https://api.github.com/users/larsiusprime/repos","events_url":"https://api.github.com/users/larsiusprime/events{/privacy}","received_events_url":"https://api.github.com/users/larsiusprime/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T18:04:51Z","updated_at":"2015-04-23T18:04:51Z","body":"I'm leaning towards the case that drawSelf should = false by default now, and we correct the outlier there.\r\n\r\nAnyways, look at this:\r\n\r\nCorrect (flash):\r\n![flash](https://cloud.githubusercontent.com/assets/739064/7303198/7351aae8-e9b4-11e4-9a80-bf2124098f46.png)\r\n\r\nNext (drawSelf = false)\r\n![next_drawself_false](https://cloud.githubusercontent.com/assets/739064/7303199/73532d96-e9b4-11e4-8633-fa1888bb396f.png)\r\n\r\nNotice here how the erroneous text is not only missing a background, but appears **bold**? That's not a text formatting issue. It's the result of the text being drawn twice on top of itself with nothing in between.\r\n\r\nI just tested, and if you remove the fillRect() call, you get the same results. \r\n\r\nSo draw(text)+fillRect()+draw(text) is the same as just draw(text)+draw(text).\r\n\r\nSo this suggests to me maybe fillRect isn't operating on the same set of pixels, or some buffer doesn't get updated. Or something."}}