use cairo to draw the board
authoryu.dongliang <18588496441@163.com>
Sat, 8 Jul 2023 14:29:34 +0000 (22:29 +0800)
committeryu.dongliang <18588496441@163.com>
Sat, 8 Jul 2023 14:29:34 +0000 (22:29 +0800)
Makefile
ses_layout.c
ses_layout.h

index adc38c429e3a5d43b59ab81eaf6871b6ac06fcad..9cd579c1c6c0cd2b631637bf14723abfa49bb959 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ CFLAGS += -g
 CFLAGS += -I./
 
 LDFLAGS += -lprotobuf-c
+LDFLAGS += -lcairo
 
 all:
        gcc $(CFLAGS) $(CFILES) $(LDFLAGS)
index b4e9ffb35cc8bd66c565f56dd3f1167406010b88..1170d20534af7c7a855f3dcaf1d3dce7229396d7 100644 (file)
@@ -216,6 +216,30 @@ int ses_lines_same_components(ScfEfunction* f)
        return 0;
 }
 
+int ses_layout_draw()
+{
+       cairo_surface_t *surface;
+       cairo_t *cr;
+
+       surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1280, 720);
+       cr = cairo_create (surface);
+
+       cairo_set_line_width (cr, 4);
+       cairo_set_source_rgb (cr, 1, 1, 1);
+       cairo_rectangle (cr, 0, 0, 1280, 720);
+       cairo_fill(cr);
+
+       cairo_set_source_rgb (cr, 1, 0, 0);
+       cairo_rectangle (cr, 100, 100, 720, 360);
+       cairo_stroke (cr);
+
+       cairo_surface_write_to_png(surface, "./a.png");
+
+       cairo_destroy(cr);
+       cairo_surface_destroy(surface);
+       return 0;
+}
+
 int ses_layout_board(ScfEboard* b, int x, int y, int w, int h)
 {
        ScfEcomponent* c;
@@ -238,5 +262,7 @@ int ses_layout_board(ScfEboard* b, int x, int y, int w, int h)
                ses_lines_same_components(f);
        }
 
+       ses_layout_draw();
+
        return 0;
 }
index e5a0d4898d57df88c89fe33926f6b959652c1b31..a7cd84659210a5abb6f533438018b6b33e4c3fa9 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef SES_LAYOUT_H
 #define SES_LAYOUT_H
 
+#include<cairo/cairo.h>
 #include"scf_eda_pb.h"
 #include"scf_vector.h"