Closed FlandiaYingman closed 4 months ago
After reading the manual again, seems that the edge only respect pos
but not enclose
? Now I am not sure if it is a feature or bug.
You can fix this by setting the snap-to
argument of edge()
.
Usually, edges automatically snap to the nearest node, as long as it is within one unit. However, nodes which enclose many points are hard, because what if there are smaller nodes inside? Should the edge snap to the inner node or larger node? I couldn't decide, so instead added the snap-to
argument as a manual override.
You can specify nodes in snap-to
by giving the target node a name. In the example below, I gave the "Reg. File" a node name and set snap-to
for all the edges that didn't snap automatically.
Instead of names, you can also give enclosing nodes a "position", which doesn't control the node's position, but still affects how edges snap to it. Notice for the "Data Mem." node I added (12, 0)
as its center, so the two edges snap to it automatically.
That's great and it works!
IMO, the default snap-to for edges could be the outermost node, because, if there is a node that encloses many points, then:
and,
Yeah, that's a good point. Maybe snapping to the wrong node is better than not snapping at all.
Please refer to the following image:
At
(7, 0)
,(7, 3)
and(12, 0)
, the edges do not respect theenclose
property and directly go through the node.This happens if the node spans over 3 or more distance units, only the - 2 units in the center will be regarded as node.
Source Code:
I am using the latest version of fletcher on the main branch.