Esempio n. 1
0
def make_grid(svgs, num_cols=3, grid_width=24):
    """
        svgs: List[svg_lib.SVG]
    """
    nb_rows = math.ceil(len(svgs) / num_cols)
    grid = svg_lib.SVG([],
                       viewbox=Bbox(grid_width * num_cols,
                                    grid_width * nb_rows))

    for i, svg in enumerate(svgs):
        row, col = i // num_cols, i % num_cols
        svg = svg.copy().translate(Point(grid_width * col, grid_width * row))

        grid.add_path_groups(svg.svg_path_groups)

    return grid
Esempio n. 2
0
def make_grid_grid(svg_grid, grid_width=24):
    """
        svg_grid: List[List[svg_lib.SVG]]
    """
    nb_rows = len(svg_grid)
    num_cols = len(svg_grid[0])
    grid = svg_lib.SVG([],
                       viewbox=Bbox(grid_width * num_cols,
                                    grid_width * nb_rows))

    for i, row in enumerate(svg_grid):
        for j, svg in enumerate(row):
            svg = svg.copy().translate(Point(grid_width * j, grid_width * i))

            grid.add_path_groups(svg.svg_path_groups)

    return grid
Esempio n. 3
0
def make_grid_lines(svg_grid, grid_width=24):
    """
        svg_grid: List[List[svg_lib.SVG]]
    """
    nb_rows = len(svg_grid)
    num_cols = max(len(r) for r in svg_grid)
    grid = svg_lib.SVG([],
                       viewbox=Bbox(grid_width * num_cols,
                                    grid_width * nb_rows))

    for i, row in enumerate(svg_grid):
        for j, svg in enumerate(row):
            j_shift = (num_cols - len(row)) // 2
            svg = svg.copy().translate(
                Point(grid_width * (j + j_shift), grid_width * i))

            grid.add_path_groups(svg.svg_path_groups)

    return grid