diamond shape: keep aspect when checking against minimum ht/wd - #1042
diamond shape: keep aspect when checking against minimum ht/wd#1042muzimuzhi wants to merge 2 commits into
Conversation
Signed-off-by: muzimuzhi <muzimuzhi@gmail.com>
|
Hmm, pgfmanual reads "the aspect (set by pgf/doc/generic/pgf/text-en/pgfmanual-en-library-shapes.tex Lines 112 to 115 in 85d2c38 Though the relation between Therefore this PR may end in one of two ways:
|
|
Unfortunately, we can't do that. What we can do, however, is change the default value for |
TODO: adjust for shapes cylinder and cloud Signed-off-by: muzimuzhi <muzimuzhi@gmail.com>
|
Please review if the current implementation is "what we can do". If so, I will do the same for shapes Also can the aspect staff common in libs Feels like we can only add features if there's a crack in the manual wall. :) Examples, new \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\tikzset{nodes={diamond, draw}, baseline=0pt}
\def\demo#1{%
\def\tmp{#1}%
\ifx\tmp\empty default\else \texttt{#1}\fi:
\begin{tikzpicture}[style/.expanded={#1}]
\node[minimum width=50pt] {x};
\node[minimum height=50pt] at (2,0) {x};
\end{tikzpicture}
}
\demo{}\par
\demo{shape aspect=none}
\foreach \v in {1, 2, .5} {
\foreach \k in {shape aspect, aspect} {
\demo{\k=\v}\qquad
}\par
}
\end{document} |
| option sets the ratio between width and height of the shape. Unlike | ||
| |/pgf/aspect| which only recommends the ratio, this key ensures it. | ||
|
|
||
| If the special value |none| is given, the ratio assurance is canceled. |
There was a problem hiding this comment.
Why the special none value? I would have just left it empty.
| \ifx\pgf@lib@temp\pgf@nonetext | ||
| \pgfkeys{/pgf/aspect=1}% | ||
| \else | ||
| \pgfkeys{/pgf/aspect=#1}% | ||
| \fi | ||
| \pgfkeyssetvalue{/pgf/shape aspect}{#1}% |
There was a problem hiding this comment.
If the default was empty the code could be simplified (untested).
| \ifx\pgf@lib@temp\pgf@nonetext | |
| \pgfkeys{/pgf/aspect=1}% | |
| \else | |
| \pgfkeys{/pgf/aspect=#1}% | |
| \fi | |
| \pgfkeyssetvalue{/pgf/shape aspect}{#1}% | |
| \pgfqkeys{/pgf}{aspect/.expanded=\pgfutil@ifxempty\pgf@lib@temp{1}{#1}}% | |
| \pgfkeyssetvalue{/pgf/shape aspect}{#1}% |
Same for the other conditionals.
|
On 2026-06-15 a more comprehensive testsuite was introduced for PGF/TikZ. This tests all new contributions against the examples extracted from the manual and checks whether anything has changed to avoid regressions. Since this pull request was opened before that, these tests were not run automatically. I have run Tip Your pull request might have failed some tests. This does not mean that your contribution will be rejected. In fact, depending on the changes you propose, it might even be expected that some tests fail, however, this needs to be evaluated carefully. Failed tests
|

Motivation for this change
Currently, when a
diamondshape is enlarged when checking againstminimum height/width, theshape aspectis not kept. This PR fixes the problem.Example
Checklist
Please check the boxes below and signoff your commits to explicitly
state your agreement to the Developer Certificate of Origin: