\NeedsTeXFormat{LaTeX2e}
\ProvidesExplPackage{PrimeTeX/packages/Graphics}{2025-09-03}{1.0}{
	Custom non-floating Graphics commands.
}

\RequirePackage{PrimeTeX/packages/Layout}

\RequirePackage{calc}

\RequirePackage{wrapfig2}

\dim_const:Nn \c_Graphics_icon_dim {0.25in}

\NewDocumentCommand{\IconSize}{}{\c_Graphics_icon_dim}

\keys_define:nn{InlineGraphic}{
	height	.dim_set:N	= \l_InlineGraphic_height_dim,
	height	.initial:n	= {12pt},
%	height	.default:n	= {12pt},

	offset	.dim_set:N	= \l_InlineGraphic_offset_dim,
	offset	.initial:n	= {-2pt},
%	offset	.default:n	= {-2pt},
}

\NewDocumentCommand{\InlineGraphic}{
	% Key=value options.
	O{}
	% Graphic file.
	m
}{%
	\keys_set:nn{InlineGraphic}{#1}
	\raisebox{\l_InlineGraphic_offset_dim}{
		\includegraphics[keepaspectratio,height=\l_InlineGraphic_height_dim]{#2}
	}%
}

\dim_const:Nn \c_ig_width_dim {0.5in}

% Shorthand command for \includegraphics.
\NewDocumentCommand{\ig}{O{width=\c_ig_width_dim} m}{%
	\includegraphics[keepaspectratio,#1]{#2}%
}

\NewDocumentCommand{\wrapfig}{
	% alignment [l,r,i,o]
	O{O}
	% horizontal_offset
	O{\marparwidth}
	% graphic_file
	m
	% (width|height)=lengthvalue
	O{}
	% label
	>{\TrimSpaces}m
	% caption
	m%
}{%
	\begin{wrapfigure}{#1}[#2]%
		\captionsetup{type=figure}%
		\capstart%
		\includegraphics[%
			keepaspectratio,%
			#4%
		]{#3}%
		\Centering\captionof{figure}{#6}%
		\label{fig:#5}%
	\end{wrapfigure}%
}