if (el2->id == ec->lid && 0 == el2->n_lines) {
- int diff = 5 + rand() % 10;
+ int diff = 10 + rand() % 20;
bx += diff;
bw -= diff;
if (ret < 0)
return ret;
- int diff = 5 + rand() % 10;
+ int diff = 10 + rand() % 20;
bx += diff;
bw -= diff;
uint64_t cid = el->pins[j];
uint64_t pid = el->pins[j + 1];
- scf_logi("j: %ld, cid: %ld, pid: %ld\n", j, cid, pid);
-
ScfEcomponent* c = f->components[cid];
ScfEpin* p = NULL;
}
}
+ ScfEcomponent* c;
+ ScfEpin* p;
+
+ for (i = 0; i < f->n_components; i++) {
+ c = f->components[i];
+
+ uint32_t cx = 0;
+ uint32_t cy = 0;
+
+ for (j = 0; j < c->n_pins; j++) {
+ p = c->pins[j];
+
+ cx += p->x;
+ cy += p->y;
+ }
+
+ c->x = cx / c->n_pins;
+ c->y = cy / c->n_pins;
+ }
+
return 0;
}
}
}
- double ccolors[3][3] =
- {
- {1, 0, 0},
- {0, 1, 0},
- {0, 0, 1},
- };
-
for (i = 0; i < b->n_functions; i++) {
f = b->functions[i];
for (j = 0; j < f->n_components; j++) {
c = f->components[j];
- double red = ccolors[j % 3][0];
- double green = ccolors[j % 3][1];
- double blue = ccolors[j % 3][2];
-
- cairo_set_source_rgb(cr, red, green, blue);
+ cairo_set_source_rgb(cr, 0.5, 0.5, 0.0);
scf_logw("j: %ld, c->id: %ld, n_pins: %ld, ", j, c->id, c->n_pins);
else
cairo_line_to(cr, p->x, p->y);
}
+
+ switch (c->type) {
+
+ case SCF_EDA_Battery:
+ p = c->pins[SCF_EDA_Battery_POS];
+
+ if (p->y < c->y) {
+ cairo_move_to(cr, c->x - 7, c->y - 5);
+ cairo_line_to(cr, c->x + 7, c->y - 5);
+
+ cairo_move_to(cr, c->x - 5, c->y + 5);
+ 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_move_to(cr, c->x - 7, c->y + 5);
+ cairo_line_to(cr, c->x + 7, c->y + 5);
+ }
+ break;
+
+ case SCF_EDA_Resistor:
+ cairo_rectangle(cr, c->x - 5, c->y - 5, 10, 10);
+ break;
+
+ 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);
+ }
+ break;
+ default:
+ break;
+ };
+ cairo_stroke(cr);
+
printf("\n");
}
- cairo_stroke(cr);
}
cairo_surface_write_to_png(surface, "./a.png");