As the title states, I'd like to know if it's possible to issue a LaTeX warning if something was clipped in a tikzpicture. And, if so, how would I achieve this?
My use case is that I'm working on a small set of macros for producing drawings and I'd like a warning if I've drawn anything outside of a certain defined drawing area. I use clipping in the drawing to prevent anything outside the area from being drawn. This prevents the page layout from getting messed up, but the user has no idea that something was not actually put on the page (apart from manually inspecting the output). It'd be nice to give the user a heads up in my particular use case.
Ideally this warning would be enabled by putting a style, say clip warn, on a scope environment or the clip \path itself.
Here's a MWE for a starting point and for testing purposes:
\documentclass{article}
\usepackage{tikz}
\tikzset{x=1em,y=1em}
\tikzset{
clip warn/.style = {
% insert magic code here
},
}
\begin{document}
This diagram should not produce a warning:
\tikz{\path[clip] (0,0) rectangle (1,1); \draw (0.25,0.25) -- (0.75,0.75)}
This diagram should produce a warning:
\tikz{\path[clip] (0,0) rectangle (1,1); \draw (-0.25,0.25) -- (0.25,0.75)}
\end{document}

fitor other libs to determine the bounding box of a scope's contents and compare to clip path? (In my case the clip path is always a simple rectangle which makes things simpler if the general case can't be done.) – Paul Gessler Feb 19 '18 at 17:05\typeout). But I don't know how to do that automatically. – Feb 19 '18 at 18:22