Update sixdraw.
This commit is contained in:
parent
1a9cbf9302
commit
53f467a336
|
@ -172,26 +172,32 @@ static void
|
||||||
print_sixel_dot(struct sixdraw_ctx *ctx, unsigned x, unsigned y)
|
print_sixel_dot(struct sixdraw_ctx *ctx, unsigned x, unsigned y)
|
||||||
{
|
{
|
||||||
char *sixel_seq = get_sixel_buffer();
|
char *sixel_seq = get_sixel_buffer();
|
||||||
size_t offset = sizeof(SIXEL_SEQ_HEAD) - 1;
|
size_t seq_len = sizeof(SIXEL_SEQ_HEAD) - 1;
|
||||||
offset += sprintf(sixel_seq + offset, "%d;%d", ctx->ch_width, ctx->ch_height);
|
seq_len += sprintf(sixel_seq + seq_len, "%d;%d", ctx->ch_width, ctx->ch_height);
|
||||||
|
|
||||||
// Select color
|
// Select color.
|
||||||
unsigned red, green, blue;
|
unsigned red, green, blue;
|
||||||
get_sixel_color(ctx->line_color, &red, &green, &blue);
|
get_sixel_color(ctx->line_color, &red, &green, &blue);
|
||||||
offset += sprintf(sixel_seq + offset, "#0;2;%d;%d;%d#0", red, green, blue);
|
seq_len += sprintf(sixel_seq + seq_len, "#0;2;%d;%d;%d#0", red, green, blue);
|
||||||
|
|
||||||
// Move cursor
|
// Move cursor.
|
||||||
unsigned row = y / ctx->ch_height + 1;
|
unsigned row = y / ctx->ch_height + 1;
|
||||||
unsigned col = x / ctx->ch_width + 1;
|
unsigned col = x / ctx->ch_width + 1;
|
||||||
dprintf(ctx->out_fd, CTLSEQS_CUP("%d", "%d"), row, col);
|
dprintf(ctx->out_fd, CTLSEQS_CUP("%d", "%d"), row, col);
|
||||||
|
|
||||||
// Print dot
|
// Draw dot.
|
||||||
row = y % ctx->ch_height;
|
row = y % ctx->ch_height;
|
||||||
col = x % ctx->ch_width;
|
col = x % ctx->ch_width;
|
||||||
offset += sprintf(sixel_seq + offset, "%.*s", row / 6, "----------------");
|
seq_len += sprintf(sixel_seq + seq_len, "%.*s", row / 6, "------------------------");
|
||||||
offset += sprintf(sixel_seq + offset, "!%u?%c" CTLSEQS_ST, col, (1 << row % 6) + 0x3F);
|
seq_len += sprintf(sixel_seq + seq_len, "!%u?%c" CTLSEQS_ST, col, (1 << row % 6) + 0x3F);
|
||||||
|
|
||||||
write(ctx->out_fd, sixel_seq, offset);
|
// Output sixel sequence.
|
||||||
|
do {
|
||||||
|
ssize_t nbytes = write(ctx->out_fd, sixel_seq, seq_len);
|
||||||
|
if (nbytes > 0) {
|
||||||
|
seq_len -= nbytes;
|
||||||
|
}
|
||||||
|
} while (seq_len > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
Loading…
Reference in New Issue
Block a user