From a047593eb36bb5b4d19a9b325e53cba2f7a5ad95 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Sat, 8 Jul 2023 22:29:34 +0800 Subject: [PATCH] use cairo to draw the board --- Makefile | 1 + ses_layout.c | 26 ++++++++++++++++++++++++++ ses_layout.h | 1 + 3 files changed, 28 insertions(+) diff --git a/Makefile b/Makefile index adc38c4..9cd579c 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ CFLAGS += -g CFLAGS += -I./ LDFLAGS += -lprotobuf-c +LDFLAGS += -lcairo all: gcc $(CFLAGS) $(CFILES) $(LDFLAGS) diff --git a/ses_layout.c b/ses_layout.c index b4e9ffb..1170d20 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -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; } diff --git a/ses_layout.h b/ses_layout.h index e5a0d48..a7cd846 100644 --- a/ses_layout.h +++ b/ses_layout.h @@ -1,6 +1,7 @@ #ifndef SES_LAYOUT_H #define SES_LAYOUT_H +#include #include"scf_eda_pb.h" #include"scf_vector.h" -- 2.25.1