Search code examples
pythongraphicsdrawinggeometrypixel

Dealing with pixels, and the troubles with concentric circles. Python


I'm having some trouble dealing with drawing perfect concentric circles, or perfect spacing between a circle. I'm using John Zelle's graphics library but the problem I'm dealing with is more conceptual (and graphics in general) than it is with the limitations of the Library. When I draw a circle w/ a 200 pixel radius, and I try to create 50 perfect circles within the main circle the library doesn't take into account the outline of a circle, which means I don't get perfect partitions. More circles I add, the further away I get from perimeter of the main circle. The 50 circles are evenly spaced apart, the problem is they come short of the main circle.

for x in range(1, numPartition+1): #numPartitions is 50, for 50 circles
    cInsideRadius = mainCirRadius/(numPartition+1)*x
    c = circle(Point(x,y),Point(x,y), cInsideRadius) #where cInsideRadius is the radius of circle c
    c.draw(window)

Figured it out, has to do with partition sizes being casted as ints and not floats.


Solution

  • Figured it out, has to do with partition sizes being casted as ints and not floats.