{"id":150,"date":"2009-01-10T00:00:05","date_gmt":"2009-01-10T07:00:05","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=496"},"modified":"2009-01-10T00:00:05","modified_gmt":"2009-01-10T07:00:05","slug":"bresenham-circle-filled","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=150","title":{"rendered":"Bresenham Circle Filled"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar canvas:BitmapData = new BitmapData(400, 400, false, 0xCCCCCC);\r\naddChild(new Bitmap(canvas));\r\n\r\nfillCircle(100,100,50,0xFF0000);\r\n\r\nfunction fillCircle(xp:Number,yp:Number, radius:Number, col:uint = 0x000000):void {\r\n    var xoff:int =0;\r\n\tvar yoff:int = radius;\r\n\tvar balance:int = -radius;\r\n\r\n\twhile (xoff &lt;= yoff) {\r\n\t\t var p0:int = xp - xoff;\r\n\t\t var p1:int = xp - yoff;\r\n\t\t \r\n\t\t var w0:int = xoff + xoff;\r\n\t\t var w1:int = yoff + yoff;\r\n\t\t \r\n\t\t hLine(p0, yp + yoff, w0, col);\r\n\t\t hLine(p0, yp - yoff, w0, col);\r\n\t\t \r\n\t\t hLine(p1, yp + xoff, w1, col);\r\n\t\t hLine(p1, yp - xoff, w1, col);\r\n\t\t\r\n\t\tif ((balance += xoff++ + xoff) &gt;= 0) {\r\n\t\t\tbalance-=--yoff+yoff;\r\n\t\t}\r\n\t}\r\n}\r\n \r\nfunction hLine(xp:Number, yp:Number, w:Number, col:uint):void {\r\n\tfor (var i:int = 0; i &lt; w; i++){\r\n\t\tcanvas.setPixel(xp + i, yp, col);\r\n\t}\r\n}\r\n<\/pre>\n<p>An implementation of yesterdays post that draws a filled circle instead of an outlined circle.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>var canvas:BitmapData = new BitmapData(400, 400, false, 0xCCCCCC); addChild(new Bitmap(canvas)); fillCircle(100,100,50,0xFF0000); function fillCircle(xp:Number,yp:Number, radius:Number, col:uint = 0x000000):void { var xoff:int =0; var yoff:int = radius; var balance:int = -radius; while (xoff &lt;= yoff) { var p0:int = xp &#8211; xoff; var p1:int = xp &#8211; yoff; var w0:int = xoff + xoff; var w1:int = [&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,114,25,26],"tags":[3,4],"class_list":["post-150","post","type-post","status-publish","format-standard","hentry","category-bitmapdata","category-graphics-algorithms","category-pixel-manipulation","category-setpixel","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/150","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=150"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}