How to draw a smooth circle?

When I draw circles with display.newCircle() the result appears jagged/pixelated. Is there a way to draw a smoother circle for retina screens? I hoped to be able to draw my app’s buttons instead of importing graphics for them, but they don’t look nearly as clean.

try setting antialias=true in your config.lua (take note it may slow down your app if antialias is on).

This was disabled in Graphics 2 because of a bug I think. Would love to know if/when it is returning.

You can draw a circle using image, or you can draw a circle with a large radius and then to reduce it, the circle will be more smooth.

A little routine to play with…

May not solve as is but you might be able to figure a better solution from this.

–==========

_W = display.contentWidth

_H = display.contentHeight

local i

local Pi=3.14159265358979323846264338327950288----355/113 --(22/7)

local segments=5000

local stepAngle=(2*Pi)/segments

local delta=stepAngle

local circlePointsx ={}

local circlePointsy ={}

local centre={}

–local deltaline

centre.x =display.contentWidth*0.5

centre.y =display.contentHeight*0.5

radius=display.contentWidth*0.4

for i =1, segments-1 do

    local xNew

    local yNew

        xNew = centre.x + radius * math.cos(stepAngle)

        yNew = centre.y + radius * math.sin(stepAngle)

        circlePointsx[#circlePointsx+1]=math.round(xNew)

        circlePointsy[#circlePointsy+1]=math.round(yNew)

        stepAngle=stepAngle+delta;

  if  i > 1 and  i < (segments+1) then

  _deltaline=display.newLine(circlePointsx[i-1], circlePointsy[i-1],circlePointsx[i], circlePointsy[i])

  end

end

try setting antialias=true in your config.lua (take note it may slow down your app if antialias is on).

This was disabled in Graphics 2 because of a bug I think. Would love to know if/when it is returning.

You can draw a circle using image, or you can draw a circle with a large radius and then to reduce it, the circle will be more smooth.

A little routine to play with…

May not solve as is but you might be able to figure a better solution from this.

–==========

_W = display.contentWidth

_H = display.contentHeight

local i

local Pi=3.14159265358979323846264338327950288----355/113 --(22/7)

local segments=5000

local stepAngle=(2*Pi)/segments

local delta=stepAngle

local circlePointsx ={}

local circlePointsy ={}

local centre={}

–local deltaline

centre.x =display.contentWidth*0.5

centre.y =display.contentHeight*0.5

radius=display.contentWidth*0.4

for i =1, segments-1 do

    local xNew

    local yNew

        xNew = centre.x + radius * math.cos(stepAngle)

        yNew = centre.y + radius * math.sin(stepAngle)

        circlePointsx[#circlePointsx+1]=math.round(xNew)

        circlePointsy[#circlePointsy+1]=math.round(yNew)

        stepAngle=stepAngle+delta;

  if  i > 1 and  i < (segments+1) then

  _deltaline=display.newLine(circlePointsx[i-1], circlePointsy[i-1],circlePointsx[i], circlePointsy[i])

  end

end