{"id":140,"date":"2008-12-31T00:00:59","date_gmt":"2008-12-31T07:00:59","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=442"},"modified":"2008-12-31T00:00:59","modified_gmt":"2008-12-31T07:00:59","slug":"bitmapdatafloodfill","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=140","title":{"rendered":"BitmapData.floodFill()"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar canvas:BitmapData = new BitmapData(400,400,false, 0xCC0000);\r\naddChild(new Bitmap(canvas));\r\n\r\nvar s:Shape = new Shape();\r\ns.graphics.beginFill(0x00CCCC);\r\ns.graphics.moveTo(Math.random()*400,Math.random()*400);\r\nfor(var i:int = 0; i&lt;10; i++){\r\n\ts.graphics.lineTo(Math.random()*400,Math.random()*400);\r\n}\r\ncanvas.draw(s);\r\n\r\nstage.addEventListener(MouseEvent.CLICK, onDown);\r\nfunction onDown(evt:MouseEvent):void {\r\n\tcanvas.floodFill(mouseX, mouseY, 0x000000);\r\n}\r\n<\/pre>\n<p>floodFill() is basically the paint bucket (fill) tool in any bitmap drawing program. The above example draws an arbitrary blue polygon to a red background. Click anywhere on the resulting image to see floodFill() in action.<\/p>\n<p>floodFill() takes 3 arguments&#8230; x, y and color.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>var canvas:BitmapData = new BitmapData(400,400,false, 0xCC0000); addChild(new Bitmap(canvas)); var s:Shape = new Shape(); s.graphics.beginFill(0x00CCCC); s.graphics.moveTo(Math.random()*400,Math.random()*400); for(var i:int = 0; i&lt;10; i++){ s.graphics.lineTo(Math.random()*400,Math.random()*400); } canvas.draw(s); stage.addEventListener(MouseEvent.CLICK, onDown); function onDown(evt:MouseEvent):void { canvas.floodFill(mouseX, mouseY, 0x000000); } floodFill() is basically the paint bucket (fill) tool in any bitmap drawing program. The above example draws an arbitrary blue polygon to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,25],"tags":[3,4],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-bitmapdata","category-pixel-manipulation","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=140"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}