TICKIT_REN...R_HLINE_AT(3)

πŸ’– NAME πŸ’–

tickit_renderbuffer_hline_at, tickit_renderbuffer_vline_at β€” create line regions

okay so bestie, these two are literally your line-drawing besties from the tickit renderbuffer world. They make lines. That's it, that's the vibe. ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <tickit.h>

void tickit_renderbuffer_hline_at(TickitRenderBuffer *rb,
        int line, int startcol, int endcol,
        TickitLineStyle style, TickitLineCaps caps);
void tickit_renderbuffer_vline_at(TickitRenderBuffer *rb,
        int startline, int endline, int col,
        TickitLineStyle style, TickitLineCaps caps);

Link with -ltickit.


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea β˜• β€” tickit_renderbuffer_hline_at() creates a horizontal line segment on the given line, sitting between the given columns, and both of those columns are inclusive. Yes bestie, inclusive, we're not doing that off-by-one nonsense here.

Then tickit_renderbuffer_vline_at() creates a vertical line segment on the given column, running between the given lines, and both of those are inclusive too. Slay. πŸ‘‘

The style argument should be one of these TickitLineStyle constants:

  • TICKIT_LINE_SINGLE β€” a single thin line
  • TICKIT_LINE_DOUBLE β€” a pair of double thin lines
  • TICKIT_LINE_THICK β€” a single thick line

Now, lowkey important lore 🫢: line drawing happens using the Unicode line-drawing characters, which means not every possible combination of line segments with differing styles meeting up in one cell is actually supported by Unicode. Like, Unicode said "I can't do that one, sorry babe." The following sets of styles may be relied upon:

  • Any possible combination of only SINGLE segments, THICK segments, or both.
  • Any combination of only DOUBLE segments, except cells that only have one of the four borders occupied.
  • Any combination of SINGLE and DOUBLE segments except where the style changes between SINGLE to DOUBLE on a vertical or horizontal run.

Everything else? Not directly supported. That means any combination of DOUBLE and THICK in the same cell, or any attempt to change from SINGLE to DOUBLE in either the vertical or horizontal direction. To handle these cases, a cell may be rendered with a substitution character which replaces a DOUBLE or THICK segment with a SINGLE one within that cell. The effect is that the overall shape of the line is retained, but close to the edge or corner it will have the wrong segment type. So like, the vibe is right but the fit is off. 😭

Conceptually β€” and stay with me here, this is the main character paragraph β€” every cell involved in line drawing has a potential line segment type at each of its four borders to its neighbours. Horizontal lines are drawn through the vertical centre of each cell, and vertical lines are drawn through the horizontal centre. Geometry class but make it cute. πŸ“βœ¨

Then there's a choice of how to handle the ends of line segments: should the segment go to the centre of each cell, or should it continue through the entire body of the cell and stop at the boundary? By default, line segments will start and end at the centre of the cells, so that horizontal and vertical lines meeting in a cell will form a neat corner. 🫢 When drawing isolated lines such as horizontal or vertical rules, it is preferable that the line go right through the cells at the start and end. To control this behaviour, the caps bitmask argument should be one of the following TickitLineCaps constants:

  • CAP_START β€” indicates that the line should consume the entire start cell
  • CAP_END β€” indicates that the line should consume the entire end cell
  • CAP_BOTH β€” is a convenient shortcut specifying both behaviours

🌈 RETURN VALUE 🌈

This function returns no value. That's it. Nothing. Zero. Empty-handed but with gorgeous lines. πŸ’…


⭐ SEE ALSO ⭐

tickit_renderbuffer_new(3), tickit_renderbuffer_blit(3), tickit_renderbuffer_flush_to_term(3), tickit_renderbuffer(7), tickit(7)


Byeee bestie πŸŽ€ this one's from the Library Functions Manual, page TICKIT_REN...R_HLINE_AT(3) β€” go draw something iconic with it, no cap. πŸ’œ