1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-23 18:39:32 +02:00

sch2fig/cairo.c: support dashed lines (for *_line); line width 2 also for PNG

This commit is contained in:
Werner Almesberger 2016-08-01 10:52:08 -03:00
parent dc761d2dc2
commit 15bab1c163
2 changed files with 19 additions and 5 deletions

View File

@ -13,7 +13,6 @@
- find libraries (e.g., from .pro) - find libraries (e.g., from .pro)
- PDF TOC - PDF TOC
- let user set PNG size or zoom level - 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 - directly pick versions out of git, without requiring checkout to file
- handle differences - handle differences
- parse .kicad_wks - parse .kicad_wks

View File

@ -116,6 +116,21 @@ static void paint(cairo_t *cr, int color, int fill_color)
/* ----- General items ----------------------------------------------------- */ /* ----- 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, static void cr_poly(void *ctx,
int points, const int x[points], const int y[points], int points, const int x[points], const int y[points],
int color, int fill_color, unsigned layer) 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 = { static const struct gfx_ops real_cairo_ops = {
.name = "cairo", .name = "cairo",
// .line = cr_line, @@@ later .line = cr_line,
.poly = cr_poly, .poly = cr_poly,
.circ = cr_circ, .circ = cr_circ,
.arc = cr_arc, .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_select_font_face(cc->cr, "Helvetica", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD); CAIRO_FONT_WEIGHT_BOLD);
cairo_set_line_width(cc->cr, 3); cairo_set_line_width(cc->cr, 2);
layer_replay(&cc->layer); layer_replay(&cc->layer);
layer_destroy(&cc->layer); layer_destroy(&cc->layer);
@ -385,7 +400,7 @@ static void cr_pdf_end(void *ctx)
const struct gfx_ops cairo_png_ops = { const struct gfx_ops cairo_png_ops = {
.name = "png", .name = "png",
// .line = cr_line, @@@ later .line = layer_line,
.poly = layer_poly, .poly = layer_poly,
.circ = layer_circ, .circ = layer_circ,
.arc = layer_arc, .arc = layer_arc,
@ -397,7 +412,7 @@ const struct gfx_ops cairo_png_ops = {
const struct gfx_ops cairo_pdf_ops = { const struct gfx_ops cairo_pdf_ops = {
.name = "pdf", .name = "pdf",
// .line = cr_line, @@@ later .line = layer_line,
.poly = layer_poly, .poly = layer_poly,
.circ = layer_circ, .circ = layer_circ,
.arc = layer_arc, .arc = layer_arc,