I am trying to create a radial gradient that fades to the clear background. My goal is to create this gradient and paste it as the background to another image.
So far, i have been able to create a circular gradient, but it i not transparent. i found the code below in stackoverflow :
imgsize=(650,650)
image = Image.new('RGBA', imgsize)
innerColor = [153,0,0]
for y in range(imgsize[1]):
for x in range(imgsize[0]):
distanceToCenter = math.sqrt((x - imgsize[0]/2) ** 2 + (y - imgsize[1]/2) ** 2)
distanceToCenter = float(distanceToCenter) / (math.sqrt(2) * imgsize[0]/2)
r = distanceToCenter + innerColor[0] * (1 - distanceToCenter)
g = distanceToCenter + innerColor[1] * (1 - distanceToCenter)
b = distanceToCenter + innerColor[2] * (1 - distanceToCenter)
image.putpixel((x, y), (int(r), int(g), int(b)))
this is the image that is produced i would like to not have it fade to black, but to clear instead.
thank you for your help :)