- def koloanty(x0,y0,r):
- ppp = []
- data=np.ones((200,200, 3))
- x = 0
- y = r
- a = 3 - 2*r
- while y>=x:
- data[x0+x,y0+y,0]=1
- data[x0+x,y0+y,1]=0.0
- data[x0+x,y0+y,2]=0
- data[x0+x,y0-y,0]=1
- data[x0+x,y0-y,1]=0.0
- data[x0+x,y0-y,2]=0
- data[x0-x,y0+y,0]=1
- data[x0-x,y0+y,1]=0.0
- data[x0-x,y0+y,2]=0
- data[x0-x,y0-y,0]=1
- data[x0-x,y0-y,1]=0.0
- data[x0-x,y0-y,2]=0
- data[x0-y,y0-x,0]=1
- data[x0-y,y0-x,1]=0.0
- data[x0-y,y0-x,2]=0
- data[x0-y,y0+x,0]=1
- data[x0-y,y0+x,1]=0.0
- data[x0-y,y0+x,2]=0
- data[x0+y,y0+x,0]=1
- data[x0+y,y0+x,1]=0.0
- data[x0+y,y0+x,2]=0
- data[x0+y,y0-x,0]=1
- data[x0+y,y0-x,1]=0.0
- data[x0+y,y0-x,2]=0
- x+=1
- if a>0:
- y-=1
- a = a+4*(x-y)+10
- else:
- a+=4*x-6
- for x in range(x0-r-1,x0+r+1):
- for y in range(y0-r-1,y0+r+1):
- if (x0-x)**2+(y0-y)**2<=(r)**2:
- data[x,y,0]=1
- data[x,y,1]=0
- data[x,y,2]=0
- else:
- alfa = np.sqrt((x-x0)**2 + (y-y0)**2) - r
- ppp.append(alfa)
- if alfa<=1 and alfa>0:
- data[x,y,0] = 1.0
- data[x,y,1] = alfa
- data[x,y,2] = alfa
- plt.imshow(data, interpolation='none', aspect=1.0)
- plt.show()
- koloanty(100,100,70)