~ft/libpt

9fb0238f306b41d7b809a525cdab1e758588e7cf — Sigrid Haflínudóttir a month ago 15dee22 master
draw text using mask; fix invert mode
3 files changed, 5 insertions(+), 8 deletions(-)

M pt.c
M pt.h
M test.c
M pt.c => pt.c +2 -4
@@ 293,10 293,8 @@ pt_textdraw(Sfont *f, char *s, Rectangle rect, Sdopts *opts)
			}
		}
	}
	if(opts != nil && opts->invert){
		for(i = 0; i < n; i++)
			p[i] = 255 - p[i];
	}
	for(i = 0; i < n; i++)
		p[i] = 255 - p[i];
	loadimage(image, rect, p, n);
	free(p);


M pt.h => pt.h +0 -1
@@ 3,7 3,6 @@ typedef struct Sfont Sfont;
#pragma incomplete Sfont

struct Sdopts {
	int invert;
	int prefilter;
	float gamma;
};

M test.c => test.c +3 -3
@@ 14,12 14,12 @@ static Image *image;
static int invert, prefilter;
static Point offset = {8, 8};
static Sdopts opts = {
	.invert = 0,
	.prefilter = 0,
	.gamma = 1.0,
};
static char info[128];
int mainstacksize = 32768;
static Image *fg;

static void
redraw(void)


@@ 32,7 32,7 @@ redraw(void)

	r = rectaddpt(screen->r, offset);
	r.max = screen->r.max;
	draw(screen, r, image, nil, ZP);
	draw(screen, r, invert ? display->white : display->black, image, ZP);

	r = screen->r;
	r.min.y = r.max.y - font->height - 4;


@@ 164,7 164,7 @@ threadmain(int argc, char **argv)
				height += 1;
				goto changed;
			case 'i':
				opts.invert = !opts.invert;
				invert = !invert;
				goto changed;
			case Kleft:
				opts.prefilter--;