I am writing the method to draw a full circle in a numpy array of pixels, and I just don't understand why I am getting a TypeError. I apologize in advanced - I am a new Python programmer who recently switched from Java and I am still having trouble with all of this "lack-of-defining-variable-data-type-ing".
class Image:
def drawCircle(self, centerX, centerY, radius):
sin45 = 0.70710678118
distance = radius/(2*sin45)
for i in range(radius,distance,-1.0): ####This is the error line####
j = math.sqrt(r*r - i*i)
for k in range(-j, j, 1):
self.writePixel(self.centerX - k, self.enterY + i)
self.writePixel(self.centerX - k, self.enterY - i)
self.writePixel(self.centerX + i, self.enterY + i)
self.writePixel(self.centerX - i, self.enterY - i)
'''Testing the code'''
obj = Image()
obj.drawCircle(35.0, 35.0, 35.0)
This code may be filled with other errors, but as of right now I am stumped on "TypeError: 'float' object cannot be interpreted as an integer". Also, for the sake of saving space I have left the definition for writePixel() out, but just assume that it works. Thanks!
rangecannot accept float,radiusanddistancemight be floats