Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
gvplugin_vt.c File Reference

Device that renders using ANSI terminal colors. More...

#include <assert.h>
#include <gvc/gvplugin.h>
#include <gvc/gvplugin_device.h>
#include <limits.h>
#include <stddef.h>
#include <gvc/gvio.h>
Include dependency graph for gvplugin_vt.c:

Go to the source code of this file.

Data Structures

struct  color_t
 an ANSI color More...
 

Macros

#define GVPLUGIN_VT_API
 

Functions

static unsigned distance (const color_t base, unsigned red, unsigned green, unsigned blue)
 a metric of “closeness” to a given color
 
static unsigned get_color (unsigned red, unsigned green, unsigned blue)
 find closest ANSI color
 
static void process (GVJ_t *job, int color_depth)
 
static void process3 (GVJ_t *job)
 
static void process24 (GVJ_t *job)
 
static unsigned rgb_to_grayscale (unsigned red, unsigned green, unsigned blue)
 convert an RGB color to grayscale
 
static void processNup (GVJ_t *job, unsigned y_stride, unsigned x_stride, const char **tiles)
 
static void process4up (GVJ_t *job)
 draw a 4-pixels-per-character monochrome image
 
static void process6up (GVJ_t *job)
 draw a 6-pixels-per-character monochrome image
 
static void process8up (GVJ_t *job)
 draw a 8-pixels-per-character monochrome image
 

Variables

static const color_t COLORS []
 ANSI 3-bit colors.
 
static const unsigned BPP = 4
 
static gvdevice_engine_t engine3
 
static gvdevice_engine_t engine24
 
static gvdevice_engine_t engine4up
 
static gvdevice_engine_t engine6up
 
static gvdevice_engine_t engine8up
 
static gvdevice_features_t device_features
 
static gvplugin_installed_t device_types []
 
static gvplugin_api_t apis []
 
GVPLUGIN_VT_API gvplugin_library_t gvplugin_vt_LTX_library = {"vt", apis}
 

Macro Definition Documentation

◆ GVPLUGIN_VT_API

#define GVPLUGIN_VT_API

Definition at line 283 of file gvplugin_vt.c.

Function Documentation

◆ distance()

static unsigned distance ( const color_t  base,
unsigned  red,
unsigned  green,
unsigned  blue 
)
static

Definition at line 34 of file gvplugin_vt.c.

References color_t::blue, color_t::green, and color_t::red.

Referenced by get_color().

Here is the caller graph for this function:

◆ get_color()

static unsigned get_color ( unsigned  red,
unsigned  green,
unsigned  blue 
)
static

Definition at line 44 of file gvplugin_vt.c.

References COLORS, distance(), and color_t::value.

Referenced by process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process()

static void process ( GVJ_t job,
int  color_depth 
)
static

Definition at line 60 of file gvplugin_vt.c.

References BPP, get_color(), gvprintf(), GVJ_s::height, GVJ_s::imagedata, offset, and GVJ_s::width.

Referenced by process24(), and process3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process24()

static void process24 ( GVJ_t job)
static

Definition at line 118 of file gvplugin_vt.c.

References process().

Here is the call graph for this function:

◆ process3()

static void process3 ( GVJ_t job)
static

Definition at line 116 of file gvplugin_vt.c.

References process().

Here is the call graph for this function:

◆ process4up()

static void process4up ( GVJ_t job)
static

Definition at line 189 of file gvplugin_vt.c.

References processNup().

Here is the call graph for this function:

◆ process6up()

static void process6up ( GVJ_t job)
static

Definition at line 200 of file gvplugin_vt.c.

References processNup().

Here is the call graph for this function:

◆ process8up()

static void process8up ( GVJ_t job)
static

Definition at line 215 of file gvplugin_vt.c.

References processNup().

Here is the call graph for this function:

◆ processNup()

static void processNup ( GVJ_t job,
unsigned  y_stride,
unsigned  x_stride,
const char **  tiles 
)
static

draw a y_stride×x_stride-pixels-per-character monochrome image

Parameters
jobGVC job to operate on
y_strideHow many Y pixels fit in a character
x_strideHow many X pixels fit in a character
tilesIn-order list of characters for each representation

Definition at line 141 of file gvplugin_vt.c.

References BPP, gvputc(), gvputs(), GVJ_s::height, GVJ_s::imagedata, NULL, offset, rgb_to_grayscale(), and GVJ_s::width.

Referenced by process4up(), process6up(), and process8up().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rgb_to_grayscale()

static unsigned rgb_to_grayscale ( unsigned  red,
unsigned  green,
unsigned  blue 
)
static

use “perceptual” scaling, https://en.wikipedia.org/wiki/Grayscale#Colorimetric_(perceptual_luminance-preserving)_conversion_to_grayscale

Definition at line 121 of file gvplugin_vt.c.

Referenced by processNup().

Here is the caller graph for this function:

Variable Documentation

◆ apis

gvplugin_api_t apis[]
static
Initial value:
= {
{API_device, device_types},
{(api_t)0, 0},
}
api_t
Definition gvcext.h:32
static gvplugin_installed_t device_types[]

Definition at line 275 of file gvplugin_vt.c.

◆ BPP

const unsigned BPP = 4
static

Definition at line 58 of file gvplugin_vt.c.

Referenced by process(), and processNup().

◆ COLORS

const color_t COLORS[]
static
Initial value:
= {
{0, 0x00, 0x00, 0x00},
{1, 0xff, 0x00, 0x00},
{2, 0x00, 0xff, 0x00},
{3, 0xff, 0xff, 0x00},
{4, 0x00, 0x00, 0xff},
{5, 0xff, 0x00, 0xff},
{6, 0x00, 0xff, 0xff},
{7, 0xff, 0xff, 0xff},
}

Definition at line 22 of file gvplugin_vt.c.

Referenced by get_color().

◆ device_features

gvdevice_features_t device_features
static
Initial value:
= {
.default_dpi = {96, 96},
}

Definition at line 262 of file gvplugin_vt.c.

◆ device_types

gvplugin_installed_t device_types[]
static
Initial value:
= {
{8, "vt:cairo", 0, &engine3, &device_features},
{1 << 24, "vt-24bit:cairo", 0, &engine24, &device_features},
{4, "vt-4up:cairo", 0, &engine4up, &device_features},
{6, "vt-6up:cairo", 0, &engine6up, &device_features},
{7, "vt-8up:cairo", 0, &engine8up, &device_features},
{0},
}
static gvdevice_engine_t engine8up
static gvdevice_features_t device_features
static gvdevice_engine_t engine24
static gvdevice_engine_t engine3
static gvdevice_engine_t engine4up
static gvdevice_engine_t engine6up

Definition at line 266 of file gvplugin_vt.c.

◆ engine24

gvdevice_engine_t engine24
static
Initial value:
= {
.format = process24,
}
static void process24(GVJ_t *job)

Definition at line 246 of file gvplugin_vt.c.

◆ engine3

gvdevice_engine_t engine3
static
Initial value:
= {
.format = process3,
}
static void process3(GVJ_t *job)

Definition at line 242 of file gvplugin_vt.c.

◆ engine4up

gvdevice_engine_t engine4up
static
Initial value:
= {
.format = process4up,
}
static void process4up(GVJ_t *job)
draw a 4-pixels-per-character monochrome image

Definition at line 250 of file gvplugin_vt.c.

◆ engine6up

gvdevice_engine_t engine6up
static
Initial value:
= {
.format = process6up,
}
static void process6up(GVJ_t *job)
draw a 6-pixels-per-character monochrome image

Definition at line 254 of file gvplugin_vt.c.

◆ engine8up

gvdevice_engine_t engine8up
static
Initial value:
= {
.format = process8up,
}
static void process8up(GVJ_t *job)
draw a 8-pixels-per-character monochrome image

Definition at line 258 of file gvplugin_vt.c.

◆ gvplugin_vt_LTX_library

GVPLUGIN_VT_API gvplugin_library_t gvplugin_vt_LTX_library = {"vt", apis}

Definition at line 286 of file gvplugin_vt.c.