Skip to content

Relative positioning inspired by TikZ #36

@asteppke

Description

@asteppke

First of all thank you for this fresh take on graphics in python. This is one of the few approaches that are directed at the user creating actual drawings with a succinct syntax!

What comes to mind is that often a relative placement of objects would be handy. In the spirit of TikZ (Overleaf tutorial, TikZ on Wikipedia) to draw a diagram such as this one:

image

\begin{tikzpicture}[
roundnode/.style={circle, draw=green!60, fill=green!5, very thick, minimum size=7mm},
squarednode/.style={rectangle, draw=red!60, fill=red!5, very thick, minimum size=5mm},
]
%Nodes
\node[squarednode]      (maintopic)                              {2};
\node[roundnode]        (uppercircle)       [above=of maintopic] {1};
\node[squarednode]      (rightsquare)       [right=of maintopic] {3};
\node[roundnode]        (lowercircle)       [below=of maintopic] {4};

%Lines
\draw[->] (uppercircle.south) -- (maintopic.north);
\draw[->] (maintopic.east) -- (rightsquare.west);
\draw[->] (rightsquare.south) .. controls +(down:7mm) and +(right:7mm) .. (lowercircle.east);
\end{tikzpicture}

So for something comparable in joy maybe something along these lines would allow this:

maintopic = text(2)
uppercircle = text(1) | above_of(maintopic)
rightsquare = text(3) | right_of(maintopic)
lowercircle = text(4) | below_of(maintopic)

And corresponding lines:

line(arrow='->') | from(uppercircle.south) | to(maintopic.north)
# or alternative syntax ideas:
line(from=uppercircle.south, to=maintopic.north)

Would that be in the spirit of joy?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions