This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
joshmanisdabomb's profile picture

Weird Extra Pixel Created When Drawing A Circle.

Started by joshmanisdabomb, 28 September 2013 - 06:04 AM
joshmanisdabomb #1
Posted 28 September 2013 - 08:04 AM
How would I go about removing this?



Code:

function circle(cx,cy,radius,precision)
  precision = precision or 1
  for i=0,359,precision do
    local x = cx + radius*math.cos(i)
    local y = cy + radius*math.sin(i) / 1.5
    pixel(x,y)
  end
end

Thank you in advance. :)/>
theoriginalbit #2
Posted 28 September 2013 - 09:58 AM
I'm not overly positive if you can doing it that way, it may just be an anomaly due to the pixels. Someone will correct me if I'm wrong though.

There is one major improvement that you could make to it, and that's draw 4 points at once.
Spoiler

function circle(cx,cy,radius,precision)
  precision = precision or 1
  for i = 0, 89, precision do
    local x = cx + radius*math.cos(i)
    local y = cy + radius*math.sin(i) / 1.5
    pixel(x,y)
    pixel(-x,y)
    pixel(-x,-y)
    pixel(x,-y)
  end
end

I do know that drawing a circle without anomalies is possible though, a while back I made a function to do it with radians.