\documentclass[crop,multi=tikzpicture,varwidth=false,border=0cm]{standalone}
\usepackage{colortbl}
\usepackage{tikz}
\usepackage{fontspec}
\usepackage{parskip}
\usepackage{textcomp}
\usepackage{tcolorbox}
\usepackage{multirow}
\usepackage{xspace}
\usepackage{xstring}
\usepackage{xparse}
\usepackage{enumitem}
\usepackage{setspace}
\usepackage{relsize}
\usepackage{graphbox}
\usepackage{tabularx}
\usepackage{changepage}
\usepackage{etoolbox}
\usetikzlibrary{arrows.meta,math,calc,scopes,fadings,backgrounds}
%\usepgflibrary{fpu}
\graphicspath{{}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TIKZ

\pgfdeclarelayer{print}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{print,background,main,foreground}

\newenvironment{background}{\begin{pgfonlayer}{background}}{\end{pgfonlayer}}
\newenvironment{foreground}{\begin{pgfonlayer}{foreground}}{\end{pgfonlayer}}

\tikzset{inner sep=0cm,outer sep=0cm,text badly ragged}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CARDLATEX

\def\bleed{<$bleed$>}
\def\setcoords{
	\coordinate (TL) at (0,0);
	\coordinate (TR) at (\cardx,0);
	\coordinate (BR) at (\cardx,-\cardy);
	\coordinate (BL) at (0,-\cardy);
	\coordinate (T) at (\cardx/2,0);
	\coordinate (R) at (\cardx,-\cardy/2);
	\coordinate (B) at (\cardx/2,-\cardy);
	\coordinate (L) at (0,-\cardy/2);
	\coordinate (C) at (\cardx/2,-\cardy/2);
}

\newenvironment{tikzcard}[3][0]{
\tikzmath{
	coordinate \card;
	\card = (#2-\bleed,#3-\bleed);
}

\begin{tikzpicture}
	\setcoords
	\pgfmathparse{#1}
	\ifdimequal{\pgfmathresult pt}{0pt}{}{
		\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}
		\tikzmath{
			\resolutionx=(10/((#1)/2.54))*(\cardx/(\cardx+\bleed));
			\resolutiony=(10/((#1)/2.54))*(\cardy/(\cardy+\bleed));
		}
		\pgfsetxvec{\pgfpoint{\resolutionx mm}{0cm}}
		\pgfsetyvec{\pgfpoint{0mm}{-\resolutiony mm}}
		\pgfkeys{/pgf/fpu=false}
	}
}{
	\setcoords
	\begin{pgfonlayer}{print}
		\draw[fill=black] ([xshift=-\bleed,yshift=\bleed]TL) rectangle ([xshift=\bleed,yshift=-\bleed]BR);
	\end{pgfonlayer}
	\pgfsetxvec{\pgfpoint{1cm}{0cm}}
	\pgfsetyvec{\pgfpoint{0cm}{1cm}}
\end{tikzpicture}
}

\newcommand{\cardlatex}[2][]{}
\newcommand{\ifvar}[3]{\iftoggle{#1}{#2}{#3}}
