Implement full path support with correct line caps (rounded|flat|squared)
This commit is contained in:
parent
0f4de608a2
commit
690c1cb5ae
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "latex-output.h"
|
||||
#include <math.h>
|
||||
|
||||
#define WRITEOUT_BUFFER(buff) fwrite((buff)->str, sizeof(char), (buff)->len, tex_file)
|
||||
|
||||
@ -87,8 +88,7 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt
|
||||
struct gds_graphics *gfx;
|
||||
struct gds_point *pt;
|
||||
GdkRGBA color;
|
||||
int width;
|
||||
gchar *red, *green, *blue, *opacity;
|
||||
static const char *line_caps[] = {"butt", "round", "rect"};
|
||||
|
||||
for (temp = graphics; temp != NULL; temp = temp->next) {
|
||||
gfx = (struct gds_graphics *)temp->data;
|
||||
@ -108,9 +108,22 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt
|
||||
g_string_printf(buffer, "cycle;\n");
|
||||
WRITEOUT_BUFFER(buffer);
|
||||
} else if(gfx->gfx_type == GRAPHIC_PATH) {
|
||||
g_string_printf(buffer, "\\draw[line width=%lf pt, draw={c%d}, opacity={%lf}] ",
|
||||
gfx->width_absolute/1000.0, gfx->layer, gfx->layer, color.alpha);
|
||||
|
||||
if (g_list_length(gfx->vertices) < 2) {
|
||||
printf("Cannot write path with less than 2 points\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (gfx->path_render_type < 0 || gfx->path_render_type > 2) {
|
||||
printf("Path type unrecognized. Setting to 'flushed'\n");
|
||||
gfx->path_render_type = 0;
|
||||
}
|
||||
|
||||
g_string_printf(buffer, "\\draw[line width=%lf pt, draw={c%d}, opacity={%lf}, cap=%s] ",
|
||||
gfx->width_absolute/1000.0, gfx->layer, color.alpha,
|
||||
line_caps[gfx->path_render_type]);
|
||||
WRITEOUT_BUFFER(buffer);
|
||||
|
||||
/* Append vertices */
|
||||
for (temp_vertex = gfx->vertices; temp_vertex != NULL; temp_vertex = temp_vertex->next) {
|
||||
pt = (struct gds_point *)temp_vertex->data;
|
||||
|
Binary file not shown.
Binary file not shown.
@ -18,7 +18,25 @@
|
||||
\ifcreatepdflayers
|
||||
\begin{scope}[ocg={ref=1, status=visible,name={TOP-Layer}}]
|
||||
\fi]
|
||||
\draw[line width=0.300000 pt, draw={c1}, opacity={1.000000}] (-1.218000 pt, 0.711000 pt) -- (-0.197000 pt, 0.425000 pt) -- (-0.027000 pt, -0.046000 pt) -- (0.919000 pt, -0.304000 pt);
|
||||
\draw[line width=0.300000 pt, draw={c1}, opacity={1.000000}, cap=rect] (-1.108000 pt, 0.589000 pt) -- (-0.498000 pt, 0.589000 pt) -- (-0.255000 pt, 0.343000 pt);
|
||||
\ifcreatepdflayers
|
||||
\end{scope}
|
||||
\fi
|
||||
\end{pgfonlayer}
|
||||
\begin{pgfonlayer}{l1}
|
||||
\ifcreatepdflayers
|
||||
\begin{scope}[ocg={ref=1, status=visible,name={TOP-Layer}}]
|
||||
\fi]
|
||||
\draw[line width=0.300000 pt, draw={c1}, opacity={1.000000}, cap=butt] (-1.031000 pt, 0.326000 pt) -- (-1.028000 pt, 0.093000 pt) -- (-0.282000 pt, -0.019000 pt);
|
||||
\ifcreatepdflayers
|
||||
\end{scope}
|
||||
\fi
|
||||
\end{pgfonlayer}
|
||||
\begin{pgfonlayer}{l1}
|
||||
\ifcreatepdflayers
|
||||
\begin{scope}[ocg={ref=1, status=visible,name={TOP-Layer}}]
|
||||
\fi]
|
||||
\draw[line width=0.300000 pt, draw={c1}, opacity={1.000000}, cap=round] (0.076000 pt, 0.059000 pt) -- (0.660000 pt, 0.027000 pt) -- (0.871000 pt, 0.599000 pt);
|
||||
\ifcreatepdflayers
|
||||
\end{scope}
|
||||
\fi
|
||||
|
Loading…
Reference in New Issue
Block a user