I would like to add a filled background to the H
timing character, which otherwise does not have one (it is just a line). I don't want to use the D
or U
characters which do have a background fill, because they also add lines at both top and bottom - I would like a line only on top. This is how far I got with the MWE below:
In the metachar Y
, I'm trying to add a H
, then a background node (but \timing
doesn't define a background
layer), then use B
(back) character to re-draw a H
on "top" again, but that doesn't work - as it can be seen, the fills are still in front, and are not quite aligned with the transition lines.
How could I get an equivalent to a properly "filled" H
character?
An additional question is - how could I get the \timing
diagram as a "fitting node" (with width and height), so I could align it center in the master node? anchor=center
doesn't make any difference (probably because either the named node tgraph1
doesn't have a size, or it just refers to the start of the diagram)
The MWE:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{fit}
\usepackage{tikz-timing}
% "The modifiers ‘@’ and ‘$’ allow the user to include macros."
\tikztimingmetachar{Y}{H@{\begin{pgfonlayer}{background}}N[rectangle,fill=gray,anchor=north east,minimum width=\xunit,minimum height=\yunit,draw=none,on background layer]{}@{\end{pgfonlayer}}BH}
% \tikzset{timing/u/.style={draw=none}} \tikztimingmetachar{Y}{U{}BH} % doesn't look good
% \tikzset{timing/h/.style={draw=red}} % nope
% %http://tex.stackexchange.com/questions/47704/how-to-establish-node-anchor-like-points-on-a-tikz-rectangle-path
\makeatletter
\tikzset{ %
fitting node/.style={
inner sep=0pt,
fill=none,
draw=none,
reset transform,
fit={(\pgf@pathminx,\pgf@pathminy) (\pgf@pathmaxx,\pgf@pathmaxy)}
},
reset transform/.code={\pgftransformreset},
}
\makeatother
\begin{document}
\begin{tikzpicture}
\node[draw,minimum width=5cm,minimum height=2.5cm] (master) at (0,0) {};
\timing[very thick,
name=tgraph1,
fill=black,
%timing/h/.style={fill=black},%{,cycle},
%fitting node, % crashes w/ "! Dimension too large."
anchor=center,
timing/yunit=1cm,
]
at (master.center)
{ LLL YYL HHH HHL };
\end{tikzpicture}
\end{document}