idraw strings - ploot - simple plotting tools Err bitreich.org 70 hgit clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ploot URL:git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ploot bitreich.org 70 1Log /scm/ploot/log.gph bitreich.org 70 1Files /scm/ploot/files.gph bitreich.org 70 1Refs /scm/ploot/refs.gph bitreich.org 70 1Tags /scm/ploot/tag bitreich.org 70 1README /scm/ploot/file/README.md.gph bitreich.org 70 1LICENSE /scm/ploot/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 1commit d962017f48ac3c15c670c154b9a7f951fe1dd82d /scm/ploot/commit/d962017f48ac3c15c670c154b9a7f951fe1dd82d.gph bitreich.org 70 1parent b46882e628eb24be3bd67c724a50edceb6687030 /scm/ploot/commit/b46882e628eb24be3bd67c724a50edceb6687030.gph bitreich.org 70 hAuthor: Josuah Demangeon URL:mailto:mail@josuah.net bitreich.org 70 iDate: Mon, 30 Apr 2018 16:01:27 +0200 Err bitreich.org 70 i Err bitreich.org 70 idraw strings Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M ffdraw.c | 16 +++++++++++++--- Err bitreich.org 70 i M ffdraw.h | 1 + Err bitreich.org 70 i M main.c | 4 +--- Err bitreich.org 70 i Err bitreich.org 70 i3 files changed, 15 insertions(+), 6 deletions(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/ffdraw.c b/ffdraw.c /scm/ploot/file/ffdraw.c.gph bitreich.org 70 i@@ -22,10 +22,8 @@ void Err bitreich.org 70 i ffdraw_pixel(Canvas *can, Color col, Err bitreich.org 70 i int x, int y) Err bitreich.org 70 i { Err bitreich.org 70 i-/* Make it segfault early. * / Err bitreich.org 70 i x = MIN(can->w - 1, x); Err bitreich.org 70 i y = MIN(can->h - 1, y); Err bitreich.org 70 i-/ **/ Err bitreich.org 70 i memcpy(can->b + x + (can->h - 1 - y) * can->w, col, sizeof(*can->b)); Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i@@ -45,7 +43,7 @@ ffdraw_rectangle(Canvas *can, Color col, Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i /* Err bitreich.org 70 i- * Adapted from Bresenham's line algorithm and dcat's tplot. Err bitreich.org 70 i+ * From Bresenham's line algorithm and dcat's tplot. Err bitreich.org 70 i */ Err bitreich.org 70 i void Err bitreich.org 70 i ffdraw_line(Canvas *can, Color col, Err bitreich.org 70 i@@ -96,6 +94,18 @@ ffdraw_char(Canvas *can, Color col, char c, Font *f, Err bitreich.org 70 i ffdraw_pixel(can, col, x + xf, y + yf); Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i+/* Err bitreich.org 70 i+ * Draw a left aligned string without wrapping it. Err bitreich.org 70 i+ */ Err bitreich.org 70 i+void Err bitreich.org 70 i+ffdraw_str(Canvas *can, Color col, char *s, Font *f, Err bitreich.org 70 i+ int x, int y) Err bitreich.org 70 i+{ Err bitreich.org 70 i+ for (; *s; x += f->w, s++) Err bitreich.org 70 i+ ffdraw_char(can, col, *s, f, x, y); Err bitreich.org 70 i+ Err bitreich.org 70 i+} Err bitreich.org 70 i+ Err bitreich.org 70 i void Err bitreich.org 70 i ffdraw_fill(Canvas *can, Color col) Err bitreich.org 70 i { Err bitreich.org 70 1diff --git a/ffdraw.h b/ffdraw.h /scm/ploot/file/ffdraw.h.gph bitreich.org 70 i@@ -20,4 +20,5 @@ void ffdraw_pixel (Canvas *, Color, int, int); Err bitreich.org 70 i void ffdraw_rectangle(Canvas *, Color, int, int, int, int); Err bitreich.org 70 i void ffdraw_line (Canvas *, Color, int, int, int, int); Err bitreich.org 70 i void ffdraw_char (Canvas *, Color, char, Font *, int, int); Err bitreich.org 70 i+void ffdraw_str (Canvas *, Color, char *, Font *, int, int); Err bitreich.org 70 i void ffdraw_fill (Canvas *, Color); Err bitreich.org 70 1diff --git a/main.c b/main.c /scm/ploot/file/main.c.gph bitreich.org 70 i@@ -19,9 +19,7 @@ ffdraw(Canvas *can) Err bitreich.org 70 i Err bitreich.org 70 i ffdraw_fill(can, col1); Err bitreich.org 70 i ffdraw_line(can, col2, 49,1,9,79); Err bitreich.org 70 i- ffdraw_char(can, col2, '0' - 1, &font_14x6, 44, 50); Err bitreich.org 70 i- ffdraw_char(can, col2, '0' + 0, &font_14x6, 50, 50); Err bitreich.org 70 i- ffdraw_char(can, col2, '0' + 1, &font_14x6, 56, 50); Err bitreich.org 70 i+ ffdraw_str(can, col2, "01234", &font_14x6, 44, 50); Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i int Err bitreich.org 70 .