mirror of
https://github.com/RTimothyEdwards/magic.git
synced 2026-08-29 01:24:51 +02:00
Added a "plot svg" command that, when used in conjuction with the
Cairo graphics package (magic -d XR), will map the display onto an SVG surface and save it to a file using the Cairo SVG backend. Due to the simplicity of the mapping, there are no options to this plot command; it just creates a file that is a (scalable!) replica of the layout window.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#include <cairo/cairo-xlib.h>
|
||||
#include <cairo/cairo-svg.h>
|
||||
|
||||
#include "tcltk/tclmagic.h"
|
||||
#include "utils/main.h"
|
||||
@@ -342,9 +343,47 @@ GrTCairoFlush ()
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------
|
||||
* Generate SVG graphics output
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
GrTCairoPlotSVG (char *filename, MagWindow *mw)
|
||||
{
|
||||
int screenw, screenh;
|
||||
cairo_surface_t *wind_surface;
|
||||
cairo_t *wind_context;
|
||||
|
||||
TCairoData *tcairodata = (TCairoData *)mw->w_grdata2;
|
||||
|
||||
if (tcairodata == NULL)
|
||||
{
|
||||
TxError("Must be running in mode \"-d XR\" (CAIRO) to get SVG output.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
screenw = mw->w_screenArea.r_xtop - mw->w_screenArea.r_xbot;
|
||||
screenh = mw->w_screenArea.r_ytop - mw->w_screenArea.r_ybot;
|
||||
|
||||
wind_surface = tcairodata->surface;
|
||||
wind_context = tcairodata->context;
|
||||
tcairodata->surface = (cairo_surface_t *)cairo_svg_surface_create(filename,
|
||||
(double)screenw, (double)screenh);
|
||||
tcairodata->context = cairo_create(tcairodata->surface);
|
||||
WindRedisplay(mw);
|
||||
WindUpdate();
|
||||
|
||||
cairo_surface_destroy(tcairodata->surface);
|
||||
cairo_destroy(tcairodata->context);
|
||||
tcairodata->surface = wind_surface;
|
||||
tcairodata->context = wind_context;
|
||||
WindRedisplay(mw);
|
||||
WindUpdate();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------
|
||||
* Set the Cairo projection matrix for a window
|
||||
|
||||
Reference in New Issue
Block a user