Any subDrawing instances ?
Thibaud-Ardoin opened this issue · 5 comments
Thibaud-Ardoin commented
Hello,
I like your library, although I can't find any complete doc about it.
I don't manage to create multiple drawing elements and then combine them. Would there be a way to do that properly ?
For example :
# A map element
d = draw.subDrawing(2, 2, origin='center', id='map')
d.append(draw.Circle(position_relative_to_map[0],position_relative_to_map[1], 0.03,
fill=pick_fill_col, stroke_width=0.008, stroke=pick_strok_col))
# An information element
panel = draw.subDrawing(2, 2, origin='center', id='data_panel')
panel.append(draw.Text(data_text, position_in_data[0], position_in_data[1], fill=target_text_color, text_anchor='start'))
# Final combination of booth
final = draw.Drawing(4,2, origin='center')
final.append(d, (3, 1)) #Inserting subDrawing at determinated position
final.append(panel, (1, 1))
A hacky way would be to append everything directly to the final drawing with a offset that depends on the 'subDrawing'. It is unpleasant tho.
Thank you in advance for your help
Best,
T.
cduck commented
You would use Group
for this. It looks like there is no example in the README for Group
yet.
d = draw.Drawing(...)
map = draw.Group(id='map_panel', x=3, y=1)
map.append(...)
d.append(map)
panel = draw.Group(id='data_panel', x=1, y=1)
panel.append(...)
d.append(panel)
Thibaud-Ardoin commented
Oh I see,
Thank you very much !
Best,
T.
cduck commented
Re-opening this until I add an example to the documentation.
Thibaud-Ardoin commented
Actually, I what is working is the following
d = draw.Drawing(...)
map = draw.Group(id='map_panel', transform='translate(3, -1)')
map.append(...)
d.append(map)
panel = draw.Group(id='data_panel', transform='translate(1, -1)')
panel.append(...)
d.append(panel)
cduck commented
Right, x and y work with Use
with may also be helpful for you.
d.append(draw.Use(map, 3, -1))