Anchors and lines ================= Every shape has named connection points called *anchors*. The eight compass names cover the edges and corners — ``.n``, ``.ne``, ``.e``, ``.se``, ``.s``, ``.sw``, ``.w``, ``.nw`` — and ``.center`` is the middle. Draw a ``line`` between two anchors to join shapes exactly where you want: .. sheeptext:: :alt: Two boxes joined corner to corner by a line from the first box south-east anchor to the second box north-west anchor A: box "A" with .nw at (40, 40) B: box "B" with .nw at (280, 170) line from A.se to B.nw Use ``.center`` to aim at a shape's middle — handy for a leader line pointing straight at a box: .. sheeptext:: :alt: A label with a line leading to the exact centre of a box Label: text "the node" at (70, 40) Node: box "node" with .nw at (240, 20) line from Label to Node.center Nudge an endpoint with a coordinate offset. ``A.n + (20, 0)`` starts the line twenty units to the right of the north anchor: .. sheeptext:: :alt: A line leaving a box just to the right of its top edge and reaching the bottom of another box A: box "source" with .nw at (40, 40) B: box "target" with .nw at (300, 60) line from A.n + (20, 0) to B.s For right-angled connectors, give the line a ``path`` — a sequence of ``right``/``left``/``up``/``down`` steps that routes it between its endpoints: .. sheeptext:: :alt: Two boxes connected by an L-shaped routed line stepping right then down A: box "source" with .nw at (20, 20) B: box "target" with .nw at (300, 180) line from A to B path right 150 then down 80 Position something a fraction of the way between two shapes with ``between``. Here a caption sits at the midpoint (``1/2``) of the gap: .. sheeptext:: :alt: A caption reading syncs with centred between two connected boxes A: box "left" with .nw at (20, 60) B: box "right" with .nw at (320, 60) line from A.e to B.w text "syncs with" align center textsize 12 at between(A, B, 1/2) Putting anchors to work, here is a three-tier chain wired edge to edge: .. sheeptext:: :alt: Three boxes web app and db connected left to right at their east and west anchors Web: box "web" with .nw at (40, 40) App: box "app" with .nw at (240, 40) DB: box "db" with .nw at (440, 40) line from Web.e to App.w line from App.e to DB.w Next: draw containers with :doc:`groups`.