(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 = '<svg width="{}" height="{}" style="stroke:rgb(0,0,0);stroke-width:1" >\n'.format( |
| 59 | int(max_x + 50), int(max_y + 50) |
| 60 | ) |
| 61 | footer = "\n</svg>" |
| 62 | |
| 63 | if shape[0] >= 100: |
| 64 | rotate = -90 |
| 65 | else: |
| 66 | rotate = 0 |
| 67 | |
| 68 | text = [ |
| 69 | "", |
| 70 | " <!-- Text -->", |
| 71 | ' <text x="{}" y="{}" {} >{}</text>'.format( |
| 72 | max_x / 2, max_y + 20, text_style, shape[1] |
| 73 | ), |
| 74 | ' <text x="{}" y="{}" {} transform="rotate({},{},{})">{}</text>'.format( |
| 75 | max_x + 20, |
| 76 | max_y / 2, |
| 77 | text_style, |
| 78 | rotate, |
| 79 | max_x + 20, |
| 80 | max_y / 2, |
| 81 | shape[0], |
| 82 | ), |
| 83 | ] |
| 84 | |
| 85 | return header + "\n".join(lines + text) + footer |
| 86 | |
| 87 | |
| 88 | def svg_3d(chunks, size=200, sizes=None, offset=(0, 0)): |
no test coverage detected
searching dependent graphs…