\input regression-test.tex \documentclass{article} \usepackage{tikz} \usetikzlibrary{tikzphysics.fluids,tikzphysics.elements} \newdimen\fluidtestactual \newdimen\fluidtesterror \newcommand{\fluidassert}[3]{% \fluidtesterror=#1\relax\advance\fluidtesterror by -#2\relax \ifdim\fluidtesterror<0pt \fluidtesterror=-\fluidtesterror\fi \ifdim\fluidtesterror<.03pt\TYPE{PASS: #3}\else\TYPE{FAIL: #3}\fi} \newcommand{\fluidx}[3]{\pgfextractx{\fluidtestactual}{\pgfpointanchor{#1}{center}}\fluidassert{\fluidtestactual}{#2}{#3}} \newcommand{\fluidy}[3]{\pgfextracty{\fluidtestactual}{\pgfpointanchor{#1}{center}}\fluidassert{\fluidtestactual}{#2}{#3}} \begin{document} \START \setbox0=\hbox{\begin{tikzpicture} \pic (T) {fluid tank diagram={fluid={width=4cm,height=2cm,left level=.8,right level=.4},fill=blue!20}}; \fluidx{T-right-surface}{4cm}{scoped width} \fluidy{T-left-surface}{1.6cm}{left surface fraction} \fluidy{T-surface}{1.2cm}{surface midpoint} \pic (A) {physics fluid tank={physics fluid width=40mm,physics fluid height=20mm,physics fluid left level=.8}}; \fluidx{A-right}{4cm}{collision safe pic and key aliases} \pic (D) {physics fluid tank diagram={physics fluid width=40mm,physics fluid height=20mm}}; \fluidx{D-right}{4cm}{explicit collision safe diagram alias} \pic (B) {fluid tank diagram}; \fluidx{B-right}{3cm}{geometry does not leak} \pic[rotate=90,scale=2] (R) {fluid tank diagram={fluid width=2cm,fluid height=1cm}}; \fluidx{R-right}{-1cm}{rotated scaled x coordinate} \fluidy{R-right}{4cm}{rotated scaled y coordinate} \pic (U) {u tube diagram={fluid left level=.4,fluid right level=.7,fluid level=.9}}; \fluidy{U-interface}{1.6cm}{two fluid interface} \fluidy{U-upper-surface}{3.6cm}{upper fluid surface} \pic (V) {rotating fluid diagram={fluid height=4cm,fluid level=.4,fluid bend=.3}}; \fluidy{V-vertex}{1.6cm}{parabola vertex} \fluidy{V-rim-surface}{2.8cm}{parabola rim} \pic (M) {meniscus diagram={fluid height=4cm,fluid level=.6,fluid bend=-.2}}; \fluidy{M-surface}{3cm}{convex meniscus midpoint} \pic (H) {hydraulic press}; \fluidx{H-large-piston}{.64cm}{large piston centre} \fluidx{H-small-piston}{3.85cm}{small piston centre} \node[minimum width=2cm,minimum height=1cm,inner sep=0pt,outer sep=0pt] (N) at (0,0) {}; \pgfextractx{\fluidtestactual}{\pgfpointanchor{N}{east}}\fluidassert{\fluidtestactual}{1cm}{native minimum width unchanged} \end{tikzpicture}} \makeatletter \tikzset{every element label/.append style={execute at begin node={\fluidassert{\f@size pt}{14.4pt}{individual element label font}}}} \setbox0=\hbox{\begin{tikzpicture} \node[rectangular element,font=\Large,show dimensions] {}; \end{tikzpicture}} \tikzset{every fluid label/.append style={execute at begin node={\fluidassert{\f@size pt}{12pt}{native fluid picture font}}}} \setbox0=\hbox{\begin{tikzpicture}[font=\large] \pic {pressure element diagram}; \end{tikzpicture}} \makeatother \setbox0=\hbox{\begin{tikzpicture} \node[fluid tank,outer sep=0pt,fluid width=4cm,fluid height=2cm, fluid left level=.8,fluid right level=.4,pattern=north east lines] (T) {}; \pgfextractx{\fluidtestactual}{\pgfpointanchor{T}{east}}\fluidassert{\fluidtestactual}{2cm}{native node east anchor} \pgfextracty{\fluidtestactual}{\pgfpointanchor{T}{left-surface}}\fluidassert{\fluidtestactual}{.6cm}{native node surface anchor} \node[fluid tank,anchor=west,outer sep=0pt,minimum width=5cm] (W) at (T.east) {}; \pgfextractx{\fluidtestactual}{\pgfpointanchor{W}{east}}\fluidassert{\fluidtestactual}{7cm}{native minimum width and anchor placement} \node[fluid tank,outer sep=0pt,rotate=90] (R) {}; \pgfextractx{\fluidtestactual}{\pgfpointanchor{R}{north}}\fluidassert{\fluidtestactual}{-1.5cm}{native node rotation} \node[rectangle,draw,fill=red,minimum width=1cm] (plain) at (0,-5) {plain}; \makeatletter \node[fluid tank,fill=cyan!20] (solid) {}; \csname pgf@sh@ma@solid\endcsname\tikzphysics@fluid@nodestate \def\expected{none}\ifx\expected\tikzphysics@fluid@nodepattern\TYPE{PASS: native fill overrides default pattern}\else\TYPE{FAIL: solid fill}\fi \node[fluid tank,pattern=horizontal lines,pattern color=blue] (patterned) {}; \csname pgf@sh@ma@patterned\endcsname\tikzphysics@fluid@nodestate \def\expected{horizontal lines}\ifx\expected\tikzphysics@fluid@nodepattern\TYPE{PASS: native pattern override}\else\TYPE{FAIL: pattern override}\fi \def\expected{blue}\ifx\expected\tikz@pattern@color\TYPE{PASS: native pattern color}\else\TYPE{FAIL: pattern color}\fi \makeatother \end{tikzpicture}} \END \end{document}