예제 #1
0
def drawGridLines(xstart, ystart, width, height, rows, cols):
    rows_n = map(lambda x: -x, list(vec.scale(tuple(normalize(rows)) , height)))
    cols_n = list(vec.scale(tuple(normalize(cols)) , width))

    ys = scanl(lambda x, y: x + y, [0.0] + rows_n)
    xs = scanl(lambda x, y: x + y, [0.0] + cols_n)

    coords = map(lambda (y1, y2): map(lambda (x1, x2): ((x1, y1), (x2, y2)), zip(xs, xs[1:])), zip(ys, ys[1:]))
    return Fig(FM(lambda (y1, y2): FM(lambda (x1, x2): drawRect(x1, y1, x2, y2), zip(xs, xs[1:])), zip(ys, ys[1:])), trans=lambda x, y: (x + xstart, y + ystart)), coords
예제 #2
0
def distributeX(x1, y1, x2, y2, xs, figs, y_off, x_off):
    scaled = vec.scale(tuple(xs), (x2 - x1) / (xs[-1]))
    return FM(lambda (sx, f): Fig(f, trans = lambda x, y: (x + x1 + sx + x_off, y + y1 + y_off)) , zip(scaled, figs))