To reduce the size of the "d" attribute for Line and Lines I propose:
- implement the H and V commands
- add the possibility of creating these objects in relative coordinates
Current:
import drawsvg as dw
line = dw.Line(30, 30, 30, 90)
print(line.args["d"])
# M30,30 L30,90
line = dw.Line(30, 30, 90, 30)
print(line.args["d"])
# M30,30 L90,30
line = dw.Line(30, 30, 90, 90)
print(line.args["d"])
# M30,30 L90,90
lines = dw.Lines(10, 10, 20, 10, 20, 20, 5, 25)
print(lines.args["d"])
# M10,10 L20,10 L20,20 L5,25
polygon = dw.Lines(10, 10, 20, 10, 20, 20, 5, 25, close=True)
print(polygon.args["d"])
# M10,10 L20,10 L20,20 L5,25 Z
After the change:
import drawsvg as dw
line = dw.Line(30, 30, 30, 90)
print(line.args["d"])
# M30,30 V90
line = dw.Line(30, 30, 90, 30)
print(line.args["d"])
# M30,30 H90
line = dw.Line(30, 30, 90, 90)
print(line.args["d"])
# M30,30 L90,90
lines = dw.Lines(10, 10, 20, 10, 20, 20, 5, 25)
print(lines.args["d"])
# M10,10 H20 V20 L5,25
polygon = dw.Lines(10, 10, 20, 10, 20, 20, 5, 25, close=True)
print(polygon.args["d"])
# M10,10 H20 V20 L5,25 Z
# Relative coordinates
line = dw.Line(30, 30, 30, 90, relative=True)
print(line.args["d"])
# M30,30 v60
line = dw.Line(30, 30, 90, 30, relative=True)
print(line.args["d"])
# M30,30 h60
line = dw.Line(30, 30, 90, 90, relative=True)
print(line.args["d"])
# M30,30 l60,60
lines = dw.Lines(10, 10, 20, 10, 20, 20, 5, 25, relative=True)
print(lines.args["d"])
# M10,10 h10 v10 l-15,5
polygon = dw.Lines(10, 10, 20, 10, 20, 20, 5, 25, close=True, relative=True)
print(polygon.args["d"])
# M10,10 h10 v10 l-15,5 Z
To reduce the size of the "d" attribute for Line and Lines I propose:
Current:
After the change: