ret = __ses_layout_function(f, el2, pn, d, bx, by, bw, bh);
if (ret < 0)
return ret;
+
+ if (j == el->n_conns / 2
+ && el ->n_lines > 0
+ && el2->n_lines > 0) {
+
+ uint32_t tmp = el ->lines[0]->y0;
+ el ->lines[0]->y0 = el2->lines[0]->y0;
+ el2->lines[0]->y0 = tmp;
+
+ el ->lines[0]->y1 = el ->lines[0]->y0;
+ el2->lines[0]->y1 = el2->lines[0]->y0;
+ }
break;
}
}
return 0;
}
-int ses_layout_draw()
+int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_t bh)
{
- cairo_surface_t *surface;
- cairo_t *cr;
+ ScfEfunction* f;
+ ScfEline* el;
+ ScfLine* l;
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1280, 720);
- cr = cairo_create (surface);
+ cairo_surface_t* surface;
+ cairo_t* cr;
- cairo_set_line_width (cr, 4);
- cairo_set_source_rgb (cr, 1, 1, 1);
- cairo_rectangle (cr, 0, 0, 1280, 720);
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, bx + bw, by + bh);
+ cr = cairo_create (surface);
+
+ cairo_set_line_width(cr, 2);
+ cairo_set_source_rgb(cr, 1, 1, 1);
+ cairo_rectangle (cr, 0, 0, bx + bw, by + bh);
cairo_fill(cr);
+ cairo_stroke(cr);
+
+ size_t i;
+ size_t j;
+ size_t k;
+
+ double colors[7][3] =
+ {
+ {1, 0, 0},
+ {0, 1, 0},
+ {0, 0, 1},
+
+ {1, 0, 1},
+ {1, 1, 0},
+ {0, 1, 1},
+
+ {1, 0.5, 0.5},
+ };
+
+ for (i = 0; i < b->n_functions; i++) {
+ f = b->functions[i];
+
+ for (j = 0; j < f->n_elines; j++) {
+ el = f->elines[j];
+
+ double red = colors[j % 7][0];
+ double green = colors[j % 7][1];
+ double blue = colors[j % 7][2];
+
+ cairo_set_source_rgb(cr, red, green, blue);
+
+ for (k = 0; k < el->n_lines; k++) {
+ l = el->lines[k];
- cairo_set_source_rgb (cr, 1, 0, 0);
- cairo_rectangle (cr, 100, 100, 720, 360);
- cairo_stroke (cr);
+ cairo_move_to(cr, l->x0, l->y0);
+ cairo_line_to(cr, l->x1, l->y1);
+ }
+ cairo_stroke(cr);
+ }
+ }
cairo_surface_write_to_png(surface, "./a.png");
int ses_layout_board(ScfEboard* b, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
{
- ScfEcomponent* c;
ScfEfunction* f;
- ScfEline* l;
- ScfEpin* p;
size_t i;
size_t j;
size_t k;
-
for (i = 0; i < b->n_functions; i++) {
f = b->functions[i];
ses_lines_same_components(f);
- ses_layout_function(f, 5, x , y , w , h );
+ ses_layout_function(f, 5, x + 20, y + 20, w - 20, h - 20);
}
-// ses_layout_draw();
+ ses_layout_draw(b, x, y, w, h);
return 0;
}