ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
ascii.h File Reference

🖼️ ASCII Art Conversion and Output Interface More...

Go to the source code of this file.

Data Structures

struct  ascii_frame_source_t
 Frame source structure for grid layout. More...
 

Macros

#define ASCII_LUMINANCE_LEVELS   256
 Number of luminance levels supported (256)
 
#define ASCII_SLEEP_NS   50000L
 Sleep duration in nanoseconds between frames (50000 ns = 50 μs)
 
#define ANSI_FG_PREFIX   "\033[38;2;"
 ANSI foreground color prefix (truecolor mode)
 
#define ANSI_BG_PREFIX   "\033[48;2;"
 ANSI background color prefix (truecolor mode)
 
#define ANSI_COLOR_SUFFIX   "m"
 ANSI color suffix.
 
#define print(s)   fwrite(s, 1, sizeof(s) / sizeof((s)[0]), stdout)
 Print string to stdout.
 
#define console_clear(fd)   (terminal_clear_screen(), terminal_cursor_home(fd))
 Clear console and move cursor to home position.
 
#define cursor_reset(fd)   terminal_cursor_home(fd)
 Reset cursor to home position.
 
#define ascii_clear_screen(fd)   terminal_clear_screen()
 Clear terminal screen.
 
#define cursor_hide(fd)   terminal_hide_cursor(fd, true)
 Hide terminal cursor.
 
#define cursor_show(fd)   terminal_hide_cursor(fd, false)
 Show terminal cursor.
 
#define ascii_zzz()   nanosleep((struct timespec *)&ASCII_SLEEP_START, (struct timespec *)&ASCII_SLEEP_STOP)
 Sleep for frame rate limiting.
 

Functions

asciichat_error_t ascii_read_init (unsigned short int webcam_index)
 Initialize ASCII read subsystem (e.g., webcam)
 
asciichat_error_t ascii_write_init (int fd, bool reset_terminal)
 Initialize ASCII write subsystem.
 
char * ascii_convert (image_t *original, const ssize_t width, const ssize_t height, const bool color, const bool aspect_ratio, const bool stretch, const char *palette_chars, const char luminance_palette[256])
 Convert image to ASCII art.
 
char * ascii_convert_with_capabilities (image_t *original, const ssize_t width, const ssize_t height, const terminal_capabilities_t *caps, const bool use_aspect_ratio, const bool stretch, const char *palette_chars, const char luminance_palette[256])
 Convert image to ASCII art with terminal capability awareness.
 
asciichat_error_t ascii_write (const char *frame)
 Write ASCII frame to terminal.
 
void ascii_read_destroy (void)
 Destroy ASCII read subsystem.
 
void ascii_write_destroy (int fd, bool reset_terminal)
 Destroy ASCII write subsystem.
 
char * ascii_pad_frame_width (const char *frame, size_t pad)
 Add leading spaces (left-padding) to each line of a frame.
 
char * ascii_pad_frame_height (const char *frame, size_t pad_top)
 Add blank lines (vertical padding) to center a frame vertically.
 
char * ascii_create_grid (ascii_frame_source_t *sources, int source_count, int width, int height, size_t *out_size)
 Create a grid layout from multiple ASCII frames.
 
char * get_lum_palette (void)
 Get luminance palette for character mapping.
 

Variables

char ascii_palette []
 Default ASCII palette characters.
 

Detailed Description

🖼️ ASCII Art Conversion and Output Interface

Definition in file ascii.h.