Introduction
Introduction Statistics Contact Development Disclaimer Help
drawing bitmapped font - ploot - simple plotting tools
git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65…
Log
Files
Refs
Tags
README
LICENSE
---
commit b46882e628eb24be3bd67c724a50edceb6687030
parent bb9f77683b2a4c23a519b71baaea8bec6eb5be90
Author: Josuah Demangeon <[email protected]>
Date: Mon, 30 Apr 2018 15:38:45 +0200
drawing bitmapped font
Diffstat:
M Makefile | 3 +--
D config.h | 2 --
A ffdraw.c | 103 +++++++++++++++++++++++++++++…
A ffdraw.h | 23 +++++++++++++++++++++++
A font-14x6.c | 551 +++++++++++++++++++++++++++++…
A font-14x6.h | 1 +
D font-14x7.h | 548 -----------------------------…
D font.c | 137 -----------------------------…
M font.h | 32 ++++++++++++++++-------------…
A main.c | 44 +++++++++++++++++++++++++++++…
10 files changed, 739 insertions(+), 705 deletions(-)
---
diff --git a/Makefile b/Makefile
@@ -1,12 +1,11 @@
CFLAGS = -Wall -Wextra -Werror -std=c89 -pedantic -D_POSIX_C_SOURCE=200…
-SRC = font.c
+SRC = main.c ffdraw.c font-14x6.c
OBJ = $(SRC:.c=.o)
all:x ploot
-ploot.o: config.h arg.h
ploot: $(OBJ)
${CC} -static -o $@ $(OBJ)
diff --git a/config.h b/config.h
@@ -1,2 +0,0 @@
-#define MAX_WIDTH 80
-#define MAX_HEIGHT 20
diff --git a/ffdraw.c b/ffdraw.c
@@ -0,0 +1,103 @@
+/*
+ * Render bitmapped font as a farbfeld image
+ *
+ * The convention used: y
+ * - (0,0) is at the lower left corner of the canvas. |
+ * - (0,1) is above it. +--x
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "ffdraw.h"
+#include "font-14x6.h"
+
+#define WIDTH 100
+#define HEIGHT 100
+
+Color buffer[WIDTH * HEIGHT];
+
+void
+ffdraw_pixel(Canvas *can, Color col,
+ int x, int y)
+{
+/* Make it segfault early. * /
+ x = MIN(can->w - 1, x);
+ y = MIN(can->h - 1, y);
+/ **/
+ memcpy(can->b + x + (can->h - 1 - y) * can->w, col, sizeof(*can->b));
+}
+
+void
+ffdraw_rectangle(Canvas *can, Color col,
+ int x1, int y1,
+ int x2, int y2)
+{
+ int x, y, xmin, ymin, xmax, ymax;
+
+ xmin = MIN(x1, x2); xmax = MAX(x1, x2);
+ ymin = MIN(y1, y2); ymax = MAX(y1, y2);
+
+ for (x = xmin; x <= xmax; x++)
+ for (y = ymin; y <= ymax; y++)
+ ffdraw_pixel(can, col, x, y);
+}
+
+/*
+ * Adapted from Bresenham's line algorithm and dcat's tplot.
+ */
+void
+ffdraw_line(Canvas *can, Color col,
+ int x0, int y0,
+ int x1, int y1)
+{
+ int dx, dy, sx, sy, err, e;
+
+ sx = x0 < x1 ? 1 : -1;
+ sy = y0 < y1 ? 1 : -1;
+ dx = abs(x1 - x0);
+ dy = abs(y1 - y0);
+ err = (dx > dy ? dx : -dy) / 2;
+
+ for (;;) {
+ ffdraw_pixel(can, col, x0, y0);
+
+ if (x0 == x1 && y0 == y1)
+ break;
+
+ e = err;
+ if (e > -dx) {
+ x0 += sx;
+ err -= dy;
+ }
+ if (e < dy) {
+ y0 += sy;
+ err += dx;
+ }
+ }
+}
+
+/*
+ * Draw a coloured glyph from font f centerd on x, y
+ */
+void
+ffdraw_char(Canvas *can, Color col, char c, Font *f,
+ int x, int y)
+{
+ int xf, yf;
+
+ x -= f->w / 2;
+ y -= f->h / 2;
+
+ for (xf = 0; xf < f->w; xf++)
+ for (yf = 0; yf < f->h; yf++)
+ if (f->b[(int)c][(f->h - yf - 1) * f->w + xf] > 0)
+ ffdraw_pixel(can, col, x + xf, y + yf);
+}
+
+void
+ffdraw_fill(Canvas *can, Color col)
+{
+ ffdraw_rectangle(can, col, 0, 0, can->w - 1, can->h - 1);
+}
diff --git a/ffdraw.h b/ffdraw.h
@@ -0,0 +1,23 @@
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+
+typedef uint16_t Color[4];
+
+typedef struct {
+ int w; /* width */
+ int h; /* height */
+ Color *b; /* buffer */
+} Canvas;
+
+typedef struct {
+ int w; /* width */
+ int h; /* height */
+ char *b[255]; /* buffer */
+} Font;
+
+/* ffdraw.c */
+void ffdraw_pixel (Canvas *, Color, int, int);
+void ffdraw_rectangle(Canvas *, Color, int, int, int, int);
+void ffdraw_line (Canvas *, Color, int, int, int, int);
+void ffdraw_char (Canvas *, Color, char, Font *, int, i…
+void ffdraw_fill (Canvas *, Color);
diff --git a/font-14x6.c b/font-14x6.c
@@ -0,0 +1,551 @@
+#include "font.h"
+#include "font-14x6.h"
+
+#define FONT_HEIGHT 14
+#define FONT_WIDTH 6
+
+C(space) = {
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_
+};
+
+C(bang) = {
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,X,_,_,
+_ ,_,_,X,_,_,
+_ ,_,_,X,_,_,
+_ ,_,_,X,_,_,
+_ ,_,_,X,_,_,
+_ ,_,_,X,_,_,
+_ ,_,_,X,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,X,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_
+};
+
+C(double) = {
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,X,_,X,_,
+_ ,_,X,_,X,_,
+_ ,_,X,_,X,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_,_,_,_,_,
+_ ,_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 ,_,_,X,_,_,
-_ ,_,X,_,_,_,
-_ ,X,_,_,_,_,
-_ ,_,_,_,_,_,
-_ ,_,_,_,_,_
-};
-
-B(question) = {
-_ ,_,_,_,_,_,
-_ ,_,_,_,_,_,
-_ ,_,X,X,X,_,
-_ ,X,_,_,_,X,
-_ ,X,_,_,_,X,
-_ ,_,_,_,_,X,
-_ ,_,_,_,X,_,
-_ ,_,_,X,_,_,
-_ ,_,_,_,_,_,
-_ ,_,_,X,_,_,
-_ ,_,_,X,_,_,
-_ ,_,_,_,_,_,
-_ ,_,_,_,_,_,
-_ ,_,_,_,_,_
-};
-
-FONT(14x7);
diff --git a/font.c b/font.c
@@ -1,137 +0,0 @@
-/*
- * Render bitmapped font as a farbfeld image
- *
- * The convention used: y
- * - (0,0) is at the lower left corner of the canvas. |
- * - (0,1) is above it. +--x
- */
-
-#include <arpa/inet.h>
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "font.h"
-#include "font-14x7.h"
-
-#define WIDTH 100
-#define HEIGHT 100
-
-#define MIN(x, y) ((x) < (y) ? (x) : (y))
-#define MAX(x, y) ((x) > (y) ? (x) : (y))
-
-typedef uint16_t Color[4];
-
-typedef struct {
- Color *b; /* buffer */
- int w; /* width */
- int h; /* height */
-} Canvas;
-
-Color buffer[WIDTH * HEIGHT];
-
-void
-ffdraw_pixel(Canvas *can, Color c,
- int x, int y)
-{
-/* Make it segfault early.
- x = MIN(can->w - 1, x);
- y = MIN(can->h - 1, y);
-*/
- memcpy(can->b + x + (can->h - 1 - y) * can->w, c, sizeof(*can->b));
-}
-
-void
-ffdraw_rectangle(Canvas *can, Color c,
- int x1, int y1,
- int x2, int y2)
-{
- int x, y, xmin, ymin, xmax, ymax;
-
- xmin = MIN(x1, x2); xmax = MAX(x1, x2);
- ymin = MIN(y1, y2); ymax = MAX(y1, y2);
-
- for (x = xmin; x <= xmax; x++)
- for (y = ymin; y <= ymax; y++)
- ffdraw_pixel(can, c, x, y);
-}
-
-/*
- * Adapted from Bresenham's line algorithm and dcat's tplot.
- */
-static void
-ffdraw_line(Canvas *can, Color c,
- int x0, int y0,
- int x1, int y1)
-{
- int dx, dy, sx, sy, err, e;
-
- sx = x0 < x1 ? 1 : -1;
- sy = y0 < y1 ? 1 : -1;
- dx = abs(x1 - x0);
- dy = abs(y1 - y0);
- err = (dx > dy ? dx : -dy) / 2;
-
- for (;;) {
- ffdraw_pixel(can, c, x0, y0);
-
- if (x0 == x1 && y0 == y1)
- break;
-
- e = err;
- if (e > -dx) {
- x0 += sx;
- err -= dy;
- }
- if (e < dy) {
- y0 += sy;
- err += dx;
- }
- }
-}
-
-void
-ffdraw_fill(Canvas *can, Color c)
-{
- ffdraw_rectangle(can, c, 0, 0, can->w - 1, can->h - 1);
-}
-
-void
-ffdraw(Canvas *can)
-{
- Color c1 = { 0x2222, 0x2222, 0x2222, 0xffff };
- Color c2 = { 0x3333, 0xffff, 0x8888, 0xffff };
-
- ffdraw_fill(can, c1);
- ffdraw_line(can, c2,
- 0, 0,
- 50 - 1, 80 - 1);
-}
-
-void
-usage(void)
-{
- fprintf(stderr, "ploot <data.csv >image.ff\n");
- exit(1);
-}
-
-int
-main(void)
-{
- uint32_t w, h;
- Canvas can;
-
- can.b = buffer;
- can.w = WIDTH;
- can.h = HEIGHT;
- w = htonl(WIDTH);
- h = htonl(HEIGHT);
- fputs("farbfeld", stdout);
- fwrite(&w, sizeof(w), 1, stdout);
- fwrite(&h, sizeof(h), 1, stdout);
- ffdraw(&can);
- fwrite(can.b, WIDTH * HEIGHT, sizeof(*can.b), stdout);
- return 0;
-}
diff --git a/font.h b/font.h
@@ -1,29 +1,29 @@
#include <stddef.h>
+#include <stdint.h>
+#include "ffdraw.h"
/*
* Macros to make the fonts header file more readable.
*/
#define _ 0
#define X 1
-#define B(x) char glyph_ ## x[FONT_WIDTH * FONT_HEIGHT]
-#define b(x) glyph_ ## x
-#define NOPR NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
-#define NOPRINT NOPR, NOPR, NOPR, NOPR
-#define FONT(x) char *font_ ## x[] = { \
+#define C(x) char glyph_ ## x[FONT_WIDTH * FONT_HEIGHT]
+
+#define FONT(x) Font x = { FONT_WIDTH, FONT_HEIGHT, { \
NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, \
- b(space), b(bang), b(double), b(hash), \
- b(dollar), b(percent), b(ampersand), b(single), \
- b(l_round), b(r_round), b(asterisk), b(plus), \
- b(coma), b(minus), b(dot), b(slash), \
- b(0), b(1), b(2), b(3), \
- b(4), b(5), b(6), b(7), \
- b(8), b(9), b(column), b(semicolumn), \
- b(l_angle), b(equal), b(r_angle), b(question), \
- b(column), b(semicolumn), b(l_angle), b(equal), \
- b(r_angle), b(question) \
-}
+ glyph_space, glyph_bang, glyph_double, glyph_hash, \
+ glyph_dollar, glyph_percent, glyph_ampersand, glyph_single, \
+ glyph_l_round, glyph_r_round, glyph_asterisk, glyph_plus, \
+ glyph_coma, glyph_minus, glyph_dot, glyph_slash, \
+ glyph_0, glyph_1, glyph_2, glyph_3, \
+ glyph_4, glyph_5, glyph_6, glyph_7, \
+ glyph_8, glyph_9, glyph_column, glyph_semicolumn, \
+ glyph_l_angle, glyph_equal, glyph_r_angle, glyph_question, \
+ glyph_column, glyph_semicolumn, glyph_l_angle, glyph_equal, \
+ glyph_r_angle, glyph_question \
+} }
diff --git a/main.c b/main.c
@@ -0,0 +1,44 @@
+#include <arpa/inet.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "ffdraw.h"
+#include "font-14x6.h"
+
+#define WIDTH 100
+#define HEIGHT 100
+
+Color buffer[WIDTH * HEIGHT];
+
+static void
+ffdraw(Canvas *can)
+{
+ Color col1 = { 0x2222, 0x2222, 0x2222, 0xffff };
+ Color col2 = { 0x3333, 0xffff, 0x8888, 0xffff };
+
+ ffdraw_fill(can, col1);
+ ffdraw_line(can, col2, 49,1,9,79);
+ ffdraw_char(can, col2, '0' - 1, &font_14x6, 44, 50);
+ ffdraw_char(can, col2, '0' + 0, &font_14x6, 50, 50);
+ ffdraw_char(can, col2, '0' + 1, &font_14x6, 56, 50);
+}
+
+int
+main(void)
+{
+ uint32_t w, h;
+ Canvas can;
+
+ can.b = buffer;
+ can.w = WIDTH;
+ can.h = HEIGHT;
+ w = htonl(WIDTH);
+ h = htonl(HEIGHT);
+ fputs("farbfeld", stdout);
+ fwrite(&w, sizeof(w), 1, stdout);
+ fwrite(&h, sizeof(h), 1, stdout);
+ ffdraw(&can);
+ fwrite(can.b, WIDTH * HEIGHT, sizeof(*can.b), stdout);
+ return 0;
+}
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.