mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-12-23 14:39:53 +02:00
sch2fig/cairo.c: support dashed lines (for *_line); line width 2 also for PNG
This commit is contained in:
parent
dc761d2dc2
commit
15bab1c163
@ -13,7 +13,6 @@
|
||||
- find libraries (e.g., from .pro)
|
||||
- PDF TOC
|
||||
- let user set PNG size or zoom level
|
||||
- implement dashed lines in cairo.c
|
||||
- directly pick versions out of git, without requiring checkout to file
|
||||
- handle differences
|
||||
- parse .kicad_wks
|
||||
|
@ -116,6 +116,21 @@ static void paint(cairo_t *cr, int color, int fill_color)
|
||||
/* ----- General items ----------------------------------------------------- */
|
||||
|
||||
|
||||
static void cr_line(void *ctx, int sx, int sy, int ex, int ey,
|
||||
int color, unsigned layer)
|
||||
{
|
||||
struct cairo_ctx *cc = ctx;
|
||||
static const double dashes[] = { 4, 2 };
|
||||
|
||||
cairo_new_path(cc->cr);
|
||||
cairo_move_to(cc->cr, cx(cc, sx), cy(cc, sy));
|
||||
cairo_line_to(cc->cr, cx(cc, ex), cy(cc, ey));
|
||||
cairo_set_dash(cc->cr, dashes, ARRAY_ELEMENTS(dashes), 0);
|
||||
paint(cc->cr, color, COLOR_NONE);
|
||||
cairo_set_dash(cc->cr, NULL, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void cr_poly(void *ctx,
|
||||
int points, const int x[points], const int y[points],
|
||||
int color, int fill_color, unsigned layer)
|
||||
@ -217,7 +232,7 @@ static unsigned cr_text_width(void *ctx, const char *s, unsigned size)
|
||||
|
||||
static const struct gfx_ops real_cairo_ops = {
|
||||
.name = "cairo",
|
||||
// .line = cr_line, @@@ later
|
||||
.line = cr_line,
|
||||
.poly = cr_poly,
|
||||
.circ = cr_circ,
|
||||
.arc = cr_arc,
|
||||
@ -320,7 +335,7 @@ static void cr_png_end(void *ctx)
|
||||
|
||||
cairo_select_font_face(cc->cr, "Helvetica", CAIRO_FONT_SLANT_NORMAL,
|
||||
CAIRO_FONT_WEIGHT_BOLD);
|
||||
cairo_set_line_width(cc->cr, 3);
|
||||
cairo_set_line_width(cc->cr, 2);
|
||||
|
||||
layer_replay(&cc->layer);
|
||||
layer_destroy(&cc->layer);
|
||||
@ -385,7 +400,7 @@ static void cr_pdf_end(void *ctx)
|
||||
|
||||
const struct gfx_ops cairo_png_ops = {
|
||||
.name = "png",
|
||||
// .line = cr_line, @@@ later
|
||||
.line = layer_line,
|
||||
.poly = layer_poly,
|
||||
.circ = layer_circ,
|
||||
.arc = layer_arc,
|
||||
@ -397,7 +412,7 @@ const struct gfx_ops cairo_png_ops = {
|
||||
|
||||
const struct gfx_ops cairo_pdf_ops = {
|
||||
.name = "pdf",
|
||||
// .line = cr_line, @@@ later
|
||||
.line = layer_line,
|
||||
.poly = layer_poly,
|
||||
.circ = layer_circ,
|
||||
.arc = layer_arc,
|
||||
|
Loading…
Reference in New Issue
Block a user