\startluacode pgfutil = pgfutil or { } local texsprint, format = tex.sprint, string.format local prtcatcodes = tex.prtcatcodes function pgfutil.unsupported_color(name) texsprint(prtcatcodes,format("\\PackageError{pgf}{color %s has unsupported model}{}", name)) texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{gray}{0}", name)) end function pgfutil.registercolor(name, attributes) print(name, attributes) local cv = colors.value(attributes) if cv then local model = cv[1] if model == 1 then print("model=1") texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{gray}{%1.3f}", name, cv[2])) elseif model == 3 then print("model=2") texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{rgb}{%1.3f,%1.3f,%1.3f}", name, cv[3], cv[4], cv[5])) else print("no model") pgfutil.unsupported_color(name) end else print("no color") pgfutil.unsupported_color(name) end end \stopluacode \unprotect \def\pgfutil@registercolor#1% {\ctxlua{pgfutil.registercolor("#1",\thecolorattribute {#1})}} \protect