All pastes #2045179 Raw Edit

Something

public text v1 · immutable
#2045179 ·published 2011-04-11 18:11 UTC
rendered paste body
def boundary(ls,inpoint,color1,img,w,h,win):
    outline="green"
    inside=color1
    for i in ls:
        bresenhamthick.draw_line(img,i.getP1(),i.getP2(),outline,win)
    stackx=[]
    stacky=[]
    dx=[1,-1,0,0,1,-1,1,-1]
    dy=[0,0,-1,1,1,-1,-1,1]
    stackx.append(int(inpoint.getX()))
    stacky.append(int(h-inpoint.getY()))
    tmp=[]
    visited=[]
    for i in range(w+1):
        tmp.append(False)
    for i in range(h+1):
        visited.append(tmp)
    while(len(stackx)>0):
        x=stackx.pop()
        y=stacky.pop()
        if(x>=w or y>=h or x<0 or y<0):
            continue
        if(visited[y][x]==True):
            continue
        col=img.getPixel(x,y)
        if(col[1]!=255):
            visited[y][x]=True
            img.setPixel(x,y,inside)
            for i in range(len(dx)):
                stackx.append(dx[i]+x)
                stacky.append(dy[i]+y)