Code: Select all
Circle(x, y, Radius [, Color]) ;current implementation
Circle(x, y, x2, y2 [, Color]) ;requested variation.
Ellipse(x, y, RadiusX, RadiusY [, Color])
Ellipse(x, y, x2, y2 [, Color]) ;requested variation
Unlike Line(), Circle() is limited in this respect because it cannot draw a fractional radius. This means that if the radius is an integer, only circles of even diameters can be drawn. This leaves out half of all circles. If the bounding coordinates were able to be specified instead this would be handled by the function easier.
Here's a demonstration for the visually minded that shows this graphically using API to draw the circles in the manner I'm desiring. The top drawing is done with PB's Circle() and draws circles of integer radii from 0 to 100. The bottom drawing is done with API and draws circles in boxes to generate circles of diameters from 0 to 200 (the same as the other method). The API method shows the overlapping circles cover the in-between radii that PB's method doesn't.
Code: Select all
OpenWindow(0,0,0,221,421,"Circle method",#PB_Window_SystemMenu)
hdc.l = StartDrawing(WindowOutput(0))
FillArea(50,50,-1,$0000A0)
;draw grid
For i.l = 0 To 420 Step 10
LineXY(0,i,220,i,$0000FF)
LineXY(i,0,i,420,$0000FF)
Next i
DrawingMode(#PB_2DDrawing_Outlined)
;using radius and PB Circle
For i = 0 To 100
Circle(110,110,i,RGB(i << 1,i << 1,i << 1))
Next i
;using diameter and API Ellipse
hNewPen.l = CreatePen_(#PS_SOLID,0,0)
hOldPen.l = SelectObject_(hdc, hNewPen)
hOldBrush = SelectObject_(hdc, #Null)
For i = 0 To 200
hPrevPen.l = hNewPen
hNewPen.l = CreatePen_(#PS_SOLID,0,RGB(i,i,i))
SelectObject_(hdc,hNewPen)
DeleteObject_(hPrevPen)
tl.l = 110 - Round(i / 2,#pb_round_down)
br.l = 110 + Round(i / 2,#pb_round_up)
Ellipse_(hdc,tl,tl + 200,br,br + 200)
Next i
SelectObject_(hdc, hOldPen)
DeleteObject_(hNewPen)
SelectObject_(hdc, hOldBrush)
StopDrawing()
Repeat
event.l = WindowEvent()
Until event = #PB_Event_CloseWindow