### drop unused code

parent 4870dc60
 ... ... @@ -47,55 +47,11 @@ def _findSingleSection(data, i, j, section, background): # HELPERS def normalizeLine(sec): """tries to convert a section to a list of pixels following a line""" # simple line if len(sec) < 2: return None if len([p for p in sec if len(getAdjacent(sec,p)) <= 2]) is len(sec): starts = [p for p in sec if len(getAdjacent(sec,p)) == 1] if len(starts): #line has 2 ends start = starts else: #line is circular start = iter(sec).next() line = [start] while len(line) < len(sec): line.append([p for p in getAdjacent(sec,line[-1]) if p not in line]) return line #TODO not so simple lines return None def chunks(l, n): """splits an iterable into *n*-sized chunks""" for i in xrange(0, len(l), n): yield l[i:i+n] def getAdjacent(section, target): """returns the adjacent pixels within the section for a target""" if type(section) is set: return [(target+i,target+j) for i in [-1,0,1] for j in [-1,0,1] if (target+i,target+j) in section and (i,j) != (0,0)] elif type(section) is list: index = section.index(target) return [section[i] for i in range(len(section)) if abs(i-index) == 1] def pixelByStiches(a,b): """returns a pixel identified by two stiches""" diff = (a-b).abs() if diff in [0,1] and diff in [0,1]: return Tp(min(c,d) for c,d in zip(a,b)) return None def crossPixel(pixel, corner): """takes a pixel and an adjacent stitch and returns the stitch to cross the pixel""" if corner in [pixel+(i,j) for i in [0,1] for j in [0,1]]: diff = corner-pixel if diff == diff: return pixel+(diff-(1,1)).abs() else: return pixel+diff.swap() else: return None def T(a,b): return Tp((a,b)) ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!