#circle
import numpy
			

def sun(w,h):
	def besenham_circle(lst,x0,y0,rad,wr):
		f = 1 - rad
		ddF_x = 1
		ddF_y = -2 * rad
		x = 0
		y = rad
		lst[x0,y0+rad]=wr
		lst[x0,y0-rad]=wr
		lst[x0+rad,y0]=wr
		lst[x0-rad,y0]=wr
		
		while(x < y):
			if (f >= 0):
				y-=1
				ddF_y += 2
				f += ddF_y
			x+=1
			ddF_x +=2
			f += ddF_x
			lst[x0+x,y0+y]=wr
			lst[x0-x,y0+y]=wr
			lst[x0+x,y0-y]=wr
			lst[x0-x,y0-y]=wr
			lst[x0+y,y0+x]=wr
			lst[x0-y,y0+x]=wr
			lst[x0+y,y0-x]=wr
			lst[x0-y,y0-x]=wr
		return lst
	diam = h
	a = numpy.zeros((w,h))
	x0 = (w/2)-1
	y0 = (h/2)-1
	rad = diam/2
	for i,l in enumerate([rad]):
		a = besenham_circle(a,x0,y0,l,i+3)
		for x in range(l):
			
			
			if x0+x != w:
				y=0
				while a[x0+x,y0+y] != i+3:
					a[x0+x,y0+y]+=3
					y+=1
			y=0
			while a[x0-x,y0+y] != i+3:
				a[x0-x,y0+y]+=3
				y+=1
			y=-1
			if x0+x != w:
				while a[x0+x,y0+y] != i+3:
					a[x0+x,y0+y]+=3
					y-=1
			y=-1
			while a[x0-x,y0+y] != i+3:
				a[x0-x,y0+y]+=3
				y-=1
		for k in range(2):
			t = 3-k
			for x in range(w):
				for y in range(h):
					if x==0 and a[x,y] != 0: a[x,y]-=1
					elif x==1 and t==3 and a[x,y] != 0: a[x,y]-=1
					elif x==w-1 and a[x,y] != 0: a[x,y]-=1
					elif x==w-2 and t==3 and a[x,y] != 0: a[x,y]-=1
					if y+1 < h:
						if a[x,y+1] == t and a[x,y] < t:
							a[x,y] = t-1
					if y-1 > 0:
						if a[x,y-1] == t and a[x,y] < t:
							a[x,y] = t-1
					if x-1 > 0:
						if a[x-1,y] == t and a[x,y] < t:
							a[x,y] = t-1
					if x+1 < w:
						if a[x+1,y] == t and a[x,y] < t:
							a[x,y] = t-1
		
	return a
sun(14,14)
