draw Diode
authoryu.dongliang <18588496441@163.com>
Tue, 11 Jul 2023 10:59:57 +0000 (18:59 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 11 Jul 2023 10:59:57 +0000 (18:59 +0800)
main.c
ses_layout.c

diff --git a/main.c b/main.c
index 17d4ce1794f0016dc8ea5bbfb258fef8e39161a7..451ef178fc6814b39decb60c59fcc341547ee2ed 100644 (file)
--- 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;
index 49ab0f58f31ef759d9333aac0f5bb95aa71a57cc..5b109683f8548605358d6304570cc8043a021eb0 100644 (file)
@@ -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;