On April 4th, I posted software that drew circles on a GLCD. In the software, I used the equation for a circle- x^2 + y^2 = Radius^2. In the first version I solved this equation for Y which produced a top and bottom half of a circle but left open areas along the left and right sides of the circle.

To fill in these areas I modified the software to solve for X. This produced a left half and a right half of a circle with openings at the top and bottom.

By combining these two solutions I filled in the circle openings. The new portion is the second FOR.... NEXT loop.

My GLCD is very noisy and prone to generating spurious pixels but I think this fix solves the problem. If anybody tries this please let me know what you find.

Here is the software.

;Variables Dim Radius, Radius_2 As integer Dim x_1, x_2, x_3, y_1, y_2, y_3, z_1, G_1 As integer ' InitGLCD GLCDCLS ' 'RADIUS is the radius of the circle - Must be <= 31 for 128x64 display 'OffsetX is the left most edge of the circle 'OffsetY is the top most edge of the circle ' 'Some examples using the CIRCLE command ' Circle 16, 48, 15; Small circle with center in MIDDLE of display Circle 10, 10, 10; Circle in TOP LEFT of display Circle 10, 100, 10; Circle in TOP Right of display Circle 10, 10, 40; Circle in BOTTOM LEFT of display Circle 10, 100, 40; Circle in BOTTOM Right of display Circle 32, 32, 0; Large circle with center in MIDDLE of display ' 'SUB ROUTINES ******************************************** ' Sub Circle (In Radius, In OffsetX, In OffsetY) 'For a 128x64 GLCD - ' Radius cannot exceed 63/2 = 31 ' If 2xRadius plus OffsetX > 127, circle will move off right edge of screen ' If 2xRadius plus OffsetY > 63, circle will move off bottom edge of screen ' The below two IF statements address this situation by reducing OffsetX and/or OffsetY If (2 * Radius + OffsetX) > 127 then OffsetX = 127 - (2 * Radius) end If ' If (2 * Radius + OffsetY) > 63 then OffsetY = 63 - (2 * Radius) end If ' Radius_2= Radius * (-1); Negative Radius numbers for plotting other side of circle '*********************************************************************** 'Solve for y - this portions leaves openings on the SIDES the of the circle ' Combining with second FOR..NEXT section fills in the openings ' For x_1 = Radius_2 to Radius y_1 = (Radius * Radius) - (x_1 * x_1); x-axis squared ' Sq_Root y_1, G_1 ' x_2 = x_1 + Radius + OffSetX; x-axis y_2 = G_1 + Radius + OffSetY; y-axis for bottom half of circle y_3 = abs(G_1 - Radius) + OffSetY; y-axis for top half of circle ' pset x_2,y_2,on; Bottom half of circle pset x_2,y_3,on; Top half of circle ' next '******************************************************************** 'Solve for x - this portions leaves openings on the TOP and BOTTOM of the circle ' Combining with first FOR..NEXT section fills in the openings ' For z_1 = Radius_2 to Radius x_1 = (Radius * Radius) - (z_1 * z_1); y-axis squared ' Sq_Root x_1, G_1 ' y_2 = z_1 + Radius + OffSetY; y-axis x_2 = abs(G_1 - Radius) + OffSetX; x-axis for left half of circle x_3 = G_1 + Radius + OffSetX; x-axis for right half of circle ' pset x_2,y_2,on; Left half of circle pset x_3,y_2,on; Right half of circle ' next '******************************************************************** ' End Sub Sub Sq_root (In y_1, G_1) 'SQUARE ROOT Approximation &&&&&&&&&&&&& ' G_1 = 200;First Guess for 5 Digit y_1 If y_1 < 10000 then G_1 = 60;First Guess for 4 Digit y_1 End If If y_1 < 1000 then G_1 = 20;First Guess for 3 Digit y_1 End If If y_1 < 100 then G_1 = 6;First Guess for 2 Digit y_1 End If If y_1 < 10 then G_1 = 2;First Guess for 1 Digit y_1 End If ' G_1 = (G_1 + (y_1 / G_1))/2 G_1 = (G_1 + (y_1 / G_1))/2 G_1 = (G_1 + (y_1 / G_1))/2 G_1 = (G_1 + (y_1 / G_1))/2;Square Root of y_1 End Sub