From 87d70ad9b6df3a16f993d96ed9a8dc1b7f578208 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Tue, 11 Jul 2023 18:59:57 +0800 Subject: [PATCH] draw Diode --- main.c | 2 +- ses_layout.c | 28 +++++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/main.c b/main.c index 17d4ce1..451ef17 100644 --- a/main.c +++ b/main.c @@ -46,7 +46,7 @@ int main(int argc, char* argv[]) ScfEboard* b = scf_eboard__unpack(NULL, len, pb); - ses_layout_board(b, 0, 0, 400, 400); + ses_layout_board(b, 0, 0, 500, 500); #if 0 size_t i; size_t j; diff --git a/ses_layout.c b/ses_layout.c index 49ab0f5..5b10968 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -646,23 +646,21 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ case SCF_EDA_Diode: p = c->pins[SCF_EDA_Diode_POS]; - if (p->y < c->y) { - cairo_move_to(cr, c->x - 5, c->y - 5); - cairo_line_to(cr, c->x + 5, c->y - 5); - cairo_line_to(cr, c->x, c->y + 3); - cairo_line_to(cr, c->x - 5, c->y - 5); - } else { - cairo_move_to(cr, c->x - 5, c->y + 5); - cairo_line_to(cr, c->x + 5, c->y + 5); - cairo_line_to(cr, c->x, c->y - 3); - cairo_line_to(cr, c->x - 5, c->y + 5); - } + vertical(&dx0, &dy0, c->x - p->x, c->y - p->y, 6); + vertical(&dx1, &dy1, c->x - p->x, c->y - p->y, -6); + vertical(&dx2, &dy2, c->x - p->x, c->y - p->y, -12); + forward (&dx3, &dy3, c->x - p->x, c->y - p->y, 12); - cairo_move_to(cr, c->x, c->y); - cairo_line_to(cr, p->x, p->y); + cairo_move_to(cr, p->x, p->y); + cairo_line_to(cr, c->x, c->y); + + cairo_rel_move_to(cr, dx0, dy0); + cairo_rel_line_to(cr, dx2, dy2); + cairo_line_to (cr, c->x + dx3, c->y + dy3); + cairo_line_to (cr, c->x + dx0, c->y + dy0); p = c->pins[SCF_EDA_Diode_NEG]; - cairo_move_to(cr, c->x, c->y); + cairo_move_to(cr, c->x + dx3, c->y + dy3); cairo_line_to(cr, p->x, p->y); break; @@ -714,7 +712,7 @@ int ses_layout_board(ScfEboard* b, uint32_t x, uint32_t y, uint32_t w, uint32_t ses_lines_same_components(f); - int ret = ses_layout_function(f, 25, x + 30, y + 30, w - 40, h - 40); + int ret = ses_layout_function(f, 30, x + 30, y + 30, w - 40, h - 40); if (ret < 0) { scf_loge("\n"); return ret; -- 2.25.1