rv::presentation:: latex packages changeable

This commit is contained in:
Zeno Rogue 2022-07-23 15:37:56 +02:00
parent 42abdd223e
commit ded7bde82c
2 changed files with 18 additions and 8 deletions

View File

@ -2849,7 +2849,7 @@ EX namespace linepatterns {
}
)
);
linepattern patTriRings("triangle grid: rings", 0xFFFFFF00, always_available,
EX linepattern patTriRings = linepattern("triangle grid: rings", 0xFFFFFF00, always_available,
ALLCELLS(
forCellIdEx(c2, i, c) {
if(S3 == 4) c2 = (cellwalker(c, i) + wstep + 1).cpeek();
@ -2858,14 +2858,14 @@ EX namespace linepatterns {
}
)
);
linepattern patTriTree("triangle grid: tree edges", 0xFFFFFF00, always_available,
EX linepattern patTriTree = linepattern("triangle grid: tree edges", 0xFFFFFF00, always_available,
ALLCELLS(
cell *parent = ts::right_parent(c, curr_dist);
if(gmatrix.count(parent))
gridlinef(V, C0, V * currentmap->adj(c, neighborId(c, parent)), C0, col, 2 + vid.linequality);
)
);
linepattern patTriOther("triangle grid: other edges", 0xFFFFFF00, always_available,
EX linepattern patTriOther = linepattern("triangle grid: other edges", 0xFFFFFF00, always_available,
ALLCELLS(
cell *parent = ts::right_parent(c, curr_dist);
forCellIdEx(c2, i, c) if(curr_dist(c2) < curr_dist(c) && c2 != parent)

View File

@ -154,9 +154,21 @@ void show_picture(presmode mode, string s) {
});
}
string latex_packages =
"\\usepackage{amsmath}\n"
"\\usepackage{amssymb}\n"
"\\usepackage{amsfonts}\n"
"\\usepackage{varwidth}\n"
"\\usepackage{amsfonts}\n"
"\\usepackage{enumitem}\n"
"\\usepackage{color}\n"
"\\usepackage{graphicx}\n"
"\\definecolor{remph}{rgb}{0,0.5,0}\n"
"\\renewcommand{\\labelitemi}{{\\color{remph}$\\blacktriangleright$}}\n";
string gen_latex(presmode mode, string s, int res, flagtype flags) {
unsigned hash = 0;
for(char c: s) hash = (hash << 3) ^ hash ^ c ^ flags;
for(char c: latex_packages + s) hash = (hash << 3) ^ hash ^ c ^ flags;
string filename = format("latex-cache/%08X.png", hash);
if(mode == pmStartAll) {
if(!file_exists(filename)) {
@ -164,14 +176,12 @@ string gen_latex(presmode mode, string s, int res, flagtype flags) {
FILE *f = fopen("latex-cache/rogueviz-latex.tex", "w");
fprintf(f,
"\\documentclass[border=2pt]{standalone}\n"
"\\usepackage{amsmath}\n"
"\\usepackage{varwidth}\n"
"\\usepackage{color}\n"
"%s"
"\\begin{document}\n"
"\\begin{varwidth}{\\linewidth}\n"
"%s"
"\\end{varwidth}\n"
"\\end{document}\n", s.c_str());
"\\end{document}\n", latex_packages.c_str(), s.c_str());
fclose(f);
hr::ignore(system("cd latex-cache; pdflatex rogueviz-latex.tex"));
string pngline =