From 4e8870d1931cff9ecaf0f589b3d987628df98739 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 30 Jul 2016 23:43:49 -0300 Subject: [PATCH] sch2fig/: make gfx_ops->line optional; add COLOR_WHITE; add color map --- sch2fig/Makefile | 2 +- sch2fig/gfx.c | 11 ++++++++++- sch2fig/style.h | 11 ++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/sch2fig/Makefile b/sch2fig/Makefile index aff6edd..2bff7a7 100644 --- a/sch2fig/Makefile +++ b/sch2fig/Makefile @@ -11,7 +11,7 @@ # NAME = sch2fig -OBJS = main.o sch.o lib.o fig.o gfx.o dwg.o text.o misc.o +OBJS = main.o sch.o lib.o style.o fig.o gfx.o dwg.o text.o misc.o CFLAGS = -g -O -Wall -Wextra -Wno-unused-parameter -Wshadow LIBS = -lm diff --git a/sch2fig/gfx.c b/sch2fig/gfx.c index f0b4c23..a01c949 100644 --- a/sch2fig/gfx.c +++ b/sch2fig/gfx.c @@ -11,6 +11,7 @@ */ +#include "style.h" #include "text.h" #include "gfx.h" @@ -21,7 +22,15 @@ static void *gfx_ctx; void gfx_line(int sx, int sy, int ex, int ey, int color, unsigned layer) { - gfx_ops->line(gfx_ctx, sx, sy, ex, ey, color, layer); + if (gfx_ops->line) { + gfx_ops->line(gfx_ctx, sx, sy, ex, ey, color, layer); + return; + } + + int vx[] = { sx, ex }; + int vy[] = { sy, sy }; + + gfx_poly(2, vx, vy, color, COLOR_NONE, layer); } diff --git a/sch2fig/style.h b/sch2fig/style.h index 89a97df..fc07a05 100644 --- a/sch2fig/style.h +++ b/sch2fig/style.h @@ -1,5 +1,5 @@ /* - * style.h - FIG drawing style + * style.h - Drawing style * * Written 2016 by Werner Almesberger * Copyright 2016 by Werner Almesberger @@ -13,10 +13,16 @@ #ifndef STYLE_H #define STYLE_H +#include + + +/* FIG colors */ + #define COLOR_NONE -1 #define COLOR_BLACK 0 #define COLOR_BLUE 1 #define COLOR_YELLOW 6 +#define COLOR_WHITE 7 #define COLOR_GREEN4 12 #define COLOR_CYAN4 15 #define COLOR_CYAN3 16 @@ -77,4 +83,7 @@ #define NEWLINE_SKIP 1.4 // * text size + +extern uint32_t color_rgb[]; + #endif /* !STYLE_H */