-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples drawing arrows using trails #122
Comments
Hello Jerin! Thanks for the report! I'll try to have a look at the issue these days. |
Hi, I have worked around this for the time being by just manually finding locations and adding an elbow connector myself. snippeteout = diagram.get_subdiagram("encoder_out").get_location()
d0in = diagram.get_subdiagram("decoder_0_in").get_location()
print(eout)
print(d0in)
# Create an elbow connector.
dx = -1 * (eout.x - d0in.x)
dy = -1 * (eout.y - d0in.y)
up = 4
p0 = V2(0, 0)
p1 = V2(0, -1 * up)
p2 = V2(dx / 2, 0)
p3 = V2(0, (dy + up))
p4 = V2(dx / 2, 0)
# print(eout + p1 + p2 + p3 + p4, d0in)
# assert p4 == d0in
elbow_connector = trail.stroke().line_color(grey).translate(eout.x, eout.y)
diagram = elbow_connector + diagram |
Cool! I think your solution provides a good compromise for the current situation. I thought about this issue as well, but I have failed to come up with a better answer. As you've noticed, the reason of the observed behavior is that the arrow's trail is relative to its orientation (the start-point to end-point vector). I've also tried getting some inspiration from the Haskell example that you've mentioned, but I had trouble understanding it. Maybe flowcharts should use a different API, for example, something similar to the one in TikZ? Let me know if you have any suggestions on this matter. |
While trying out a few more diagrams - I get a feeling a While I'm familiar with Tikz, I have not used it enough to form an opinion. My preferred choices for diagrams at the moment are inkscape > excalidraw > ppt-software. I'm currently trying chalk to replace this with a chalk + finishing touch-ups by inkscape workflow. |
Thanks for the feedback @jerinphilip! I'm currently on vacation, but I'll try to implement your suggestion when I get back. |
I've added a An example would be: from colour import Color
from chalk import *
from chalk.arrow import connect_outside_elbow
color = Color("pink")
def make_dia():
c1 = circle(0.75).fill_color(color).named("src") + text("src", 0.7)
c2 = circle(0.75).fill_color(color).named("tgt") + text("tgt", 0.7)
return c1 + c2.translate(3, 3)
dia1 = make_dia()
dia1 = connect_outside_elbow(dia1, "src", "tgt", "hv")
dia2 = make_dia()
dia2 = connect_outside_elbow(dia2, "src", "tgt", "vh")
dia = hcat([dia1, dia2], sep=2)
path = "examples/output/connect_elbow.svg"
dia.render_svg(path, height=256) yielding Is this similar to what you envisioned? |
I get the following directly using your code: Adding I think this is an entirely different bug? I'm happy with the results I can achieve with this convenience.
|
Hmm... the first rendering looks unexpected. In this Colab it looks fine. What tool do you use to open and view the SVG? Can it be related to this? |
I'm running ArchLinux, I suspect this could be due to a font difference (hence I'm using Eye of Gnome ( |
There are currently no examples of using arrows with trails in ./examples/arrows.py, so I'm working off bits and pieces here and in haskell diagrams. I'm not very strong with haskell, arrow.html#lengths-and-gaps looks similar to my problem but I'm not sure how to proceed.
I'm trying to get
A
to connect toB
, using arrows and trails.code (click to expand)
As visible from the picture, I'm not having much luck with this. I tried some rotation of the arrow (outside) but that ends up weird. I'm assuming the trail is placed on the line between the nodes
a
andb
. Placing the arrow (inside, but atop) through A and B centers get me the desired result (grey), but in this case I find it difficult to place heads (dart) and tails without configuring pad.The larger diagram I'm trying to solve the above for is below (trying to connect an encoder and decoder), and the endpoints are not parallel to horizontal:
translation (click to expand)
The text was updated successfully, but these errors were encountered: