-
Notifications
You must be signed in to change notification settings - Fork 108
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
Adding the opposite of open
to arrow tips definitions
#1348
Comments
Notice that the code of the arrow has been fixed; you can see it here: https://github.com/circuitikz/circuitikz/pull/810/files I am not posting it because it really isn't that relevant --- the matter is adding a "not open" flag argument. I am using |
I think |
Ah, yes, probably it does. Hmmm... I still like more of a "flag" type, but yes, that's a good solution. |
Nope generally one needs \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\pgfkeys{/pgf/arrow keys/filled/.code=\pgfarrowsaddtooptions{\pgfarrowopenfalse}}
\begin{tikzpicture}[nodes={anchor=west}, arrows={[scale=2]}]
\draw[draw=red, fill=gray, -{Stealth}]
(0, 0) -- (1, 0) -- (2,.5) node {default};
\draw[draw=red, fill=gray, yshift=-0.5cm, -{Stealth[cyan]}]
(0, 0) -- (1, 0) -- (2,.5) node {+ cyan};
\draw[draw=red, fill=gray, yshift=-1.0cm, -{Stealth[open, cyan]}]
(0, 0) -- (1, 0) -- (2,.5) node {+ open};
\draw[draw=red, fill=gray, yshift=-1.5cm, -{Stealth[open, cyan, fill=.]}]
(0, 0) -- (1, 0) -- (2,.5) node {current color ``.''};
\draw[draw=red, fill=gray, yshift=-2.0cm, -{Stealth[open, cyan, fill=pgffillcolor]}]
(0, 0) -- (1, 0) -- (2,.5) node {pgffillcolor};
\draw[draw=red, fill=gray, yshift=-2.5cm, -{Stealth[open, cyan, fill=pgfstrokecolor]}]
(0, 0) -- (1, 0) -- (2,.5) node {pgfstrokecolor};
\draw[draw=red, fill=gray, yshift=-3.0cm, -{Stealth[open, cyan, filled]}]
(0, 0) -- (1, 0) -- (2,.5) node {filled};
\end{tikzpicture}
\end{document} |
Well, the behavior is not really the same. Look at this (contrived) example: \documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
%% Jack Tap, see
%% https://github.com/circuitikz/circuitikz/issues/806
\pgfdeclarearrow{name=Jack Tap,
parameters = {%
\the\pgfarrowlength,%
\the\pgfarrowwidth,%
\ifpgfarrowswap s\fi%
\ifpgfarrowopen o\fi%
\ifpgfarrowroundjoin j\fi
\ifpgfarrowroundcap c\fi%
},
setup code = {
\pgfarrowssettipend{.5\pgfarrowlength}
\pgfarrowssetlineend{-.6\pgfarrowlength}
\pgfarrowssetvisualbackend{-.6\pgfarrowlength}
\pgfarrowssetbackend{-.6\pgfarrowlength}
% hull
\pgfarrowshullpoint{.5\pgfarrowlength}{0pt}
\pgfarrowshullpoint{0pt}{\pgfarrowwidth}
\pgfarrowshullpoint{-.6\pgfarrowlength}{0pt}
% Saves: Only the length:
\pgfarrowssavethe\pgfarrowlength
\pgfarrowssavethe\pgfarrowwidth
},
drawing code = {
\pgfsetdash{}{+0pt}
\pgfarrowlinewidth=\pgflinewidth
\ifpgfarrowroundjoin\pgfsetroundjoin\else\pgfsetmiterjoin\fi
\ifpgfarrowroundcap\pgfsetroundcap\else\pgfsetbuttcap\fi
\pgfpathmoveto{\pgfqpoint{-.6\pgfarrowlength}{0pt}}
\pgfpathlineto{\pgfqpoint{-.5\pgfarrowlength}{0pt}}
\pgfpathlineto{\pgfqpoint{0pt}{\pgfarrowwidth}}
\pgfpathlineto{\pgfqpoint{.5\pgfarrowlength}{0pt}}
\ifpgfarrowopen
\pgfusepathqstroke
\else
\pgfpathclose
\ifdim\pgfarrowlinewidth>0pt\pgfusepathqfillstroke\else\pgfusepathqfill\fi
\fi
},
defaults = {length = 0.3cm, width=0.15cm,open},
% cache=false, % breaks everything
}
\pgfkeys{/pgf/arrow keys/filled/.code=\pgfarrowsaddtooptions{\pgfarrowopenfalse}}
\tikzset{v/.tip={Jack Tap[swap]}, ^/.tip={Jack Tap},
vf/.tip={Jack Tap[swap,filled]}, ^f/.tip={Jack Tap[filled]}}
\begin{document}
\begin{tikzpicture}[color=blue]
\draw[-{Jack Tap}] (0,2) edge ++(2,0) -- ++(0,1);
\draw[red, -{Jack Tap[filled]}] (0,0) edge ++(2,0) -- ++(0,1);
\draw[red, -{Jack Tap[fill=.]}] (0,-2) edge ++(2,0) -- ++(0,1);
\end{tikzpicture}
\end{document} |
I would like to avoid adding new keys. Currently |
Yes, that would be possible too --- although I think that having on/off for binary switch is also a clean interface. My feeling would be to let |
...thinking about it a bit more, probably the |
Nice @hmenke, thank you. One little thing: I was trying to provide the fill with no argument for |
@Rmano To undo
Example undoing
|
Thanks @muzimuzhi ! I had managed to arrive at |
Also, I think that |
Yes, that's correct. |
From the point of view of Possible final form of workaround for tikz v3.1.10 or older \IfPackageAtLeastTF{tikz}{2023/01/16}{}{% one day after v3.1.10 (2023-01-15)
\pgfkeys{
/pgf/arrow keys/fill/.code={...}, % new code in v3.1.11 pasted here
/pgf/arrow keys/fill/.default={}
}%
} |
@muzimuzhi Thanks - I suppose that the code in your last answer needs LaTeX, am I right? I mean, it would not work in ConTeXt for example... |
@Rmano Yes,
|
Thanks @muzimuzhi. Unfortunately, I found that the format of the date changed between 2021 and 2022 --- it was separated by |
Maybe I could just check if |
@Rmano Here is a parser that parses three numbers separated by a single arbitrary non-digit token (or group). It assumes \newcount\pdYear
\newcount\pdMonth
\newcount\pdDay
\begingroup
\catcode`\@=11
\unexpanded{\endgroup
% pgfutil replacement code >>>
\let\pgfutil@protected\protected
% <<<
\pgfutil@protected\def\parsedate#1%
{%
\afterassignment\parsedate@month
\pdYear=#1\relax
}
\pgfutil@protected\def\parsedate@month#1%
{%
\afterassignment\parsedate@day
\pdMonth=%
}
\pgfutil@protected\def\parsedate@day#1%
{%
\afterassignment\parsedate@cleanup
\pdDay=%
}
\def\parsedate@cleanup#1\relax{}
}
\def\test#1{\parsedate{#1}\the\pdYear-\the\pdMonth-\the\pdDay\par}
\test{2024-02-01}
\test{2024/02/01}
\test{2024.02.01}
\bye Keep in mind that you don't have to alter the category code, so don't need the |
@Skillmon thanks again. I was not sure about the |
@Rmano Your code looks good. The |
Add a new type of arrow to help drawing Jack connectors Fixes #806 See also pgf-tikz/pgf#1352 Thanks to @Skillmon pgf-tikz/pgf#1348 (comment)
Discussed in #1347
Originally posted by Rmano July 9, 2024
Good morning!
If I define a new arrow tip that by default is open, like this (which is still somehow buggy, I can't see exactly why)
then I can't switch to the not-open (closed, filled?) version without knowing the color, i.e., using
Jack Barb[fill=black]
. Wouldn't it be useful to add a "complementary" switch foropen
, like, for example:Or maybe
closed
, to convey the not-open thing?I tried to search for a complementary flag without success, but if it's already there, please tell me ;-)
The text was updated successfully, but these errors were encountered: