title: sqrt-based filled ellipse pixel drawing function
body: <p>I'm trying to make a function in Lua or VB based code to draw / plot a <strong>filled</strong> ellipse.
  I don't have much knowledge about this math and I can use some help.</p>
  
  <p>I Googled everything there is to Google about drawing ellipses with code but I can't find a good simple working example in VB or Lua for a filled one.</p>
  
  <p><em>On a previous post on this site I did get an answer about how to draw a normal ellipse but nothing came up for a filled one, that's why i make a new topic for a filled one.</em></p>
  
  <p>Here are a few websites I visited but I can't find a way to make a filled ellipse without redrawing already drawed pixels...</p>
  
  <p><a href="https://sites.google.com/site/ruslancray/lab/projects/bresenhamscircleellipsedrawingalgorithm/bresenham-s-circle-ellipse-drawing-algorithm" rel="nofollow">https://sites.google.com/site/ruslancray/lab/projects/bresenhamscircleellipsedrawingalgorithm/bresenham-s-circle-ellipse-drawing-algorithm</a></p>
  
  <p><a href="http://groups.csail.mit.edu/graphics/classes/6.837/F98/Lecture6/circle.html" rel="nofollow">http://groups.csail.mit.edu/graphics/classes/6.837/F98/Lecture6/circle.html</a></p>
  
  <p><a href="http://www.blitzbasic.com/codearcs/codearcs.php?code=2817" rel="nofollow">http://www.blitzbasic.com/codearcs/codearcs.php?code=2817</a></p>
  
  <p><a href="http://hackipedia.org/Algorithms/Graphics/pdf/A%20Fast%20Bresenham%20Type%20Algorithm%20For%20Drawing%20Ellipses%20by%20John%20Kennedy.pdf" rel="nofollow">http://hackipedia.org/Algorithms/Graphics/pdf/A%20Fast%20Bresenham%20Type%20Algorithm%20For%20Drawing%20Ellipses%20by%20John%20Kennedy.pdf</a></p>
  
  <p><a href="https://scratch.mit.edu/projects/49873666/" rel="nofollow">https://scratch.mit.edu/projects/49873666/</a></p>
  
  <p><a href="http://www.sourcecodesworld.com/source/show.asp?ScriptID=112" rel="nofollow">http://www.sourcecodesworld.com/source/show.asp?ScriptID=112</a></p>
  
  <p>Here is the code I have for a normal ellipse (thanks to "Johnny Strings" for the VB version):</p>
  
  <pre><code>function DrawEllipse(xc,yc,w,h)
      local w2  = w * w
      local h2  = h * h
      local fw2 = 4 * w2
      local fh2 = 4 * h2
  
      xc = xc + w
      yc = yc + h
  
      local x  = 0
      local y  = h
      local s  = 2 * h2 + w2 * (1 - h)
      while h2 * x &lt;= w2 * y do
          dot(xc + x, yc + y)
          dot(xc - x, yc + y)
          dot(xc + x, yc - y)
          dot(xc - x, yc - y)
          redraw()inkey()
          color(int(rnd()*255),int(rnd()*255),int(rnd()*255))
          if s &gt;= 0 then
              s = s + fw2 * (1 - y)
              y = y - 1
          end
          s = s + h2 * ((4 * x) + 6)
          x = x + 1
      end
      x = w
      y = 0
      s = 2 * w2 + h2 * (1 - w)
      while w2 * y &lt;= h2 * x do
          dot(xc + x, yc + y)
          dot(xc - x, yc + y)
          dot(xc + x, yc - y)
          dot(xc - x, yc - y)
          redraw()inkey()
          color(int(rnd()*255),int(rnd()*255),int(rnd()*255))
          if s &gt;= 0 then
              s = s + fh2 * (1 - x)
              x = x - 1
          end
          s = s + w2 * ((4 * y) + 6)
          y = y + 1
      end
  end
  </code></pre>