def drawStringCentered(self, boxLL, boxUR, text): ll, ur = self.getStringBBox(text) stringSize = vec2.sub(ur, ll) boxSize = vec2.sub(boxUR, boxLL) deltaSize = vec2.sub(boxSize, stringSize) halfDeltaSize = vec2.mulN(deltaSize, .5) self.drawString(vec2.add(boxLL, halfDeltaSize), text)
def drawStringCentered(self, boxLL, boxUR, text): ll,ur = self.getStringBBox(text) stringSize = vec2.sub(ur,ll) boxSize = vec2.sub(boxUR,boxLL) deltaSize = vec2.sub(boxSize, stringSize) halfDeltaSize = vec2.mulN(deltaSize, .5) self.drawString(vec2.add(boxLL,halfDeltaSize), text)
#ppts.append(p1) ppts.append(path[-1]) if 1: up = [] down = [] ref = path[0] for i,pt in enumerate(ppts): ref = ppts[min(len(ppts)-1,i+1)] vec = vec2.sub(pt,ref) l = vec2.length(vec) if l<.000001: vec = (1.,0.) else: vec = vec2.rotate90(vec2.divN(vec,l)) width = .001 * (1. - (depth + i/20.)/N) up.append(vec2.add(pt, vec2.mulN(vec, width))) down.append(vec2.add(pt, vec2.mulN(vec, -width))) ref = pt # c.drawLineStrip(up) # c.drawLineStrip(down) c.drawFilledPolygon(down + up[::-1]) else: c.drawLineStrip(ppts) # print len(paths),sum(map(len,paths)) # print len(nPaths),sum(map(len,nPaths)) else: for P in segments: c.drawLineStrip([catmullRom2(P,x/10.) for x in range(10+1)]) if 0: c.setPointSize(10) c.drawPoints(allPoints)
# ppts.append(p1) ppts.append(path[-1]) if 1: up = [] down = [] ref = path[0] for i, pt in enumerate(ppts): ref = ppts[min(len(ppts) - 1, i + 1)] vec = vec2.sub(pt, ref) l = vec2.length(vec) if l < .000001: vec = (1., 0.) else: vec = vec2.rotate90(vec2.divN(vec, l)) width = .001 * (1. - (depth + i / 20.) / N) up.append(vec2.add(pt, vec2.mulN(vec, width))) down.append(vec2.add(pt, vec2.mulN(vec, -width))) ref = pt # c.drawLineStrip(up) # c.drawLineStrip(down) c.drawFilledPolygon(down + up[::-1]) else: c.drawLineStrip(ppts) # print len(paths),sum(map(len,paths)) # print len(nPaths),sum(map(len,nPaths)) else: for P in segments: c.drawLineStrip([catmullRom2(P, x / 10.) for x in range(10 + 1)]) if 0: c.setPointSize(10) c.drawPoints(allPoints)