Skip to content
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

Relative positioning inspired by TikZ #36

Open
asteppke opened this issue Jan 14, 2022 · 0 comments
Open

Relative positioning inspired by TikZ #36

asteppke opened this issue Jan 14, 2022 · 0 comments

Comments

@asteppke
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant