(chunks, offset=(0, 0), skew=(0, 0), size=200, sizes=None)
| 47 | |
| 48 | |
| 49 | def svg_2d(chunks, offset=(0, 0), skew=(0, 0), size=200, sizes=None): |
| 50 | shape = tuple(map(sum, chunks)) |
| 51 | sizes = sizes or draw_sizes(shape, size=size) |
| 52 | y, x = grid_points(chunks, sizes) |
| 53 | |
| 54 | lines, (min_x, max_x, min_y, max_y) = svg_grid( |
| 55 | x, y, offset=offset, skew=skew, size=size |
| 56 | ) |
| 57 | |
| 58 | header = ( |
| 59 | '<svg width="%d" height="%d" style="stroke:rgb(0,0,0);stroke-width:1" >\n' |
| 60 | % (max_x + 50, max_y + 50) |
| 61 | ) |
| 62 | footer = "\n</svg>" |
| 63 | |
| 64 | if shape[0] >= 100: |
| 65 | rotate = -90 |
| 66 | else: |
| 67 | rotate = 0 |
| 68 | |
| 69 | text = [ |
| 70 | "", |
| 71 | " <!-- Text -->", |
| 72 | ' <text x="%f" y="%f" %s >%d</text>' |
| 73 | % (max_x / 2, max_y + 20, text_style, shape[1]), |
| 74 | ' <text x="%f" y="%f" %s transform="rotate(%d,%f,%f)">%d</text>' |
| 75 | % (max_x + 20, max_y / 2, text_style, rotate, max_x + 20, max_y / 2, shape[0]), |
| 76 | ] |
| 77 | |
| 78 | return header + "\n".join(lines + text) + footer |
| 79 | |
| 80 | |
| 81 | def svg_3d(chunks, size=200, sizes=None, offset=(0, 0)): |
no test coverage detected