mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-22 11:56:14 +02:00
tools/ant-txt/: new utility to compose texts for Antorcha
This commit is contained in:
parent
60e9a1e919
commit
fbe0767eb4
37
tools/ant-txt/Makefile
Normal file
37
tools/ant-txt/Makefile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#
|
||||||
|
# tools/ant-txt/Makefile - Build the Antorcha text composer
|
||||||
|
#
|
||||||
|
# Written 2012 by Werner Almesberger
|
||||||
|
# Copyright 2012 Werner Almesberger
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
MAIN = ant-txt
|
||||||
|
|
||||||
|
CFLAGS = -g -Wall -I.. \
|
||||||
|
$(if $(BEN), -static)
|
||||||
|
|
||||||
|
LDLIBS = -L../libtxt -ltxt
|
||||||
|
|
||||||
|
OBJS = ant-txt.o
|
||||||
|
|
||||||
|
.PHONY: all ben clean spotless
|
||||||
|
|
||||||
|
all: $(MAIN)
|
||||||
|
|
||||||
|
ben:
|
||||||
|
$(MAKE) BEN=y CC=mipsel-openwrt-linux-gcc
|
||||||
|
|
||||||
|
$(MAIN): $(OBJS)
|
||||||
|
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDLIBS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(OBJS)
|
||||||
|
|
||||||
|
spotless: clean
|
||||||
|
rm -f $(MAIN)
|
65
tools/ant-txt/ant-txt.c
Normal file
65
tools/ant-txt/ant-txt.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* tools/ant-txt/ant-txt.c - Antorcha text composer
|
||||||
|
*
|
||||||
|
* Written 2012 by Werner Almesberger
|
||||||
|
* Copyright 2012 Werner Almesberger
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <libtxt/libtxt.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define W 80
|
||||||
|
#define H 16
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
struct edit *edits = NULL, **last = &edits;
|
||||||
|
uint8_t *canvas;
|
||||||
|
const char *err;
|
||||||
|
int i, x, y;
|
||||||
|
|
||||||
|
for (i = 1; i != argc; i++) {
|
||||||
|
while (*last)
|
||||||
|
last = &(*last)->next;
|
||||||
|
if (edits) {
|
||||||
|
*last = malloc(sizeof(struct edit));
|
||||||
|
if (!*last)
|
||||||
|
abort();
|
||||||
|
(*last)->type = edit_nl;
|
||||||
|
last = &(*last)->next;
|
||||||
|
}
|
||||||
|
*last = text2edit(argv[i]);
|
||||||
|
if (!*last) {
|
||||||
|
fprintf(stderr, "\"%s\": compilation failed\n",
|
||||||
|
argv[i]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas = apply_edits(W, H, edits, &err);
|
||||||
|
if (!canvas) {
|
||||||
|
fprintf(stderr, "%s\n", err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for (y = 0; y != H; y++) {
|
||||||
|
for (x = 0; x != W; x++)
|
||||||
|
if (canvas[(y*W+x) >> 3] & (1 << (x & 7)))
|
||||||
|
putchar('#');
|
||||||
|
else
|
||||||
|
putchar('.');
|
||||||
|
putchar('\n');
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user