{"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":2,"created_at":"2015-04-23T16:55:06Z","updated_at":"2015-04-23T17:04:49Z","closed_at":null,"body":"Similar to https://github.com/openfl/openfl/issues/608, but in reverse!\r\n\r\nFlash: Correct (text draws correctly in all cases)\r\n![textdraw_flash](https://cloud.githubusercontent.com/assets/739064/7302499/6a8f609e-e9af-11e4-8596-387d9bdcb4a3.png)\r\n\r\nOpenFL Next: (text draws incorrectly if a draw() was called before the first fillRect() command)\r\n![textdraw_next](https://cloud.githubusercontent.com/assets/739064/7302501/6c386f62-e9af-11e4-8373-238b8888dc1a.png)\r\n\r\nCode to reproduce:\r\n```\r\nprivate 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), Std.int(text.textHeight), true);\r\n\t\tvar r = new Rectangle(0, 0, data.width, data.height);\r\n\t\t\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\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}\r\n```\r\n\r\nLegacy seems to correct:\r\n![textdraw_legacy](https://cloud.githubusercontent.com/assets/739064/7302553/b8fcbb00-e9af-11e4-9f7e-7b716c9b6b06.png)\r\n\r\nThis right here seems like the culprit to reproduce:\r\n\r\n```\r\ndata.draw(text);\r\ndata.fillRect(r, 0xFFFFFF00);\r\ndata.draw(text);\r\n```\r\nCalling a draw() before a fillRect() causes the subsequent draw() to ignore the previous fillRect(), or something. But if you just do the fillRect() and then the draw() everything's fine!"},"comment":{"url":"https://api.github.com/repos/openfl/openfl/issues/comments/95655337","html_url":"https://github.com/openfl/openfl/issues/616#issuecomment-95655337","issue_url":"https://api.github.com/repos/openfl/openfl/issues/616","id":95655337,"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-23T17:04:49Z","updated_at":"2015-04-23T17:04:49Z","body":"Yup, I knew it. Text outlines as rendered in flixel don't work if we set \r\n```var drawSelf = true```\r\nin BitmapData.draw().\r\n\r\nNeko-Next (drawSelf = false)\r\n![next_drawself_false](https://cloud.githubusercontent.com/assets/739064/7302703/ccd7b444-e9b0-11e4-9009-93a3db22cece.png)\r\n\r\nNeko-Next (drawSelf = true)\r\n![next_drawself_true](https://cloud.githubusercontent.com/assets/739064/7302714/ed2828be-e9b0-11e4-851d-202225e04374.png)\r\n\r\nCode:\r\n```\r\nprivate 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\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\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\tdrawTextWithBorder(text, data3, 0xFFFFFF00, 0xFF0000FF, 1);\r\n\t\t\r\n\t\tvar b3 = new Bitmap(data3);\r\n\t\tb3.x = b.x + b.width + 10;\r\n\t\tb3.y = b.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"}}