draw Resistor
authoryu.dongliang <18588496441@163.com>
Tue, 11 Jul 2023 10:00:41 +0000 (18:00 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 11 Jul 2023 10:00:41 +0000 (18:00 +0800)
ses_layout.c

index 4d6909cff601d4ed93af5fec2874688d15dfe3f7..49ab0f58f31ef759d9333aac0f5bb95aa71a57cc 100644 (file)
@@ -603,12 +603,12 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_
                                case SCF_EDA_Resistor:
                                        p = c->pins[0];
 
-                                       vertical(&dx0, &dy0, c->x - p->x, c->y - p->y,  4);
-                                       vertical(&dx1, &dy1, c->x - p->x, c->y - p->y, -8);
-                                       vertical(&dx2, &dy2, c->x - p->x, c->y - p->y,  8);
+                                       vertical(&dx0, &dy0, c->x - p->x, c->y - p->y,  3);
+                                       vertical(&dx1, &dy1, c->x - p->x, c->y - p->y, -6);
+                                       vertical(&dx2, &dy2, c->x - p->x, c->y - p->y,  6);
 
-                                       forward (&dx3, &dy3, c->x - p->x, c->y - p->y, -16);
-                                       forward (&dx4, &dy4, c->x - p->x, c->y - p->y,  16);
+                                       forward (&dx3, &dy3, c->x - p->x, c->y - p->y, -12);
+                                       forward (&dx4, &dy4, c->x - p->x, c->y - p->y,  12);
 
                                        scf_logw("dx0: %d, dy0: %d\n", dx0, dy0);
                                        scf_logw("dx1: %d, dy1: %d\n", dx1, dy1);
@@ -623,12 +623,24 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_
                                        cairo_rel_line_to(cr, dx2,  dy2);
                                        cairo_rel_line_to(cr, dx3,  dy3);
 
-                                       cairo_move_to(cr, c->x, c->y);
-                                       cairo_line_to(cr, p->x, p->y);
+                                       if (p->y < c->y) {
+                                               cairo_move_to(cr, c->x, c->y);
+                                               cairo_line_to(cr, p->x, p->y);
+
+                                               p = c->pins[1];
+                                               cairo_move_to(cr, c->x, c->y);
+                                               cairo_rel_move_to(cr, dx4,  dy4);
+                                               cairo_line_to(cr, p->x, p->y);
+                                       } else {
+                                               cairo_move_to(cr, c->x, c->y);
+                                               cairo_rel_move_to(cr, dx4,  dy4);
+                                               cairo_line_to(cr, p->x, p->y);
+
+                                               p = c->pins[1];
+                                               cairo_move_to(cr, c->x, c->y);
+                                               cairo_line_to(cr, p->x, p->y);
+                                       }
 
-                                       p = c->pins[1];
-                                       cairo_move_to(cr, c->x, c->y);
-                                       cairo_line_to(cr, p->x, p->y);
                                        break;
 
                                case SCF_EDA_Diode: