Graphviz 15.1.1~dev.20260628.0906
Loading...
Searching...
No Matches
gvplugin_vt.c File Reference

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

#include "config.h"
#include <assert.h>
#include <gvc/gvplugin.h>
#include <gvc/gvplugin_device.h>
#include <limits.h>
#include <stddef.h>
#include <util/gv_math.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
 

Enumerations

enum  {
  PPC2_3 , PPC2_24 , PPC4 , PPC6 ,
  PPC8_BRAILLE , PPC8_OCTANTS
}
 

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, const char **tiles)
 draw a 8-pixels-per-character monochrome image
 
static void process8up1 (GVJ_t *job)
 draw a 8-pixels-per-character monochrome image with Braille characters
 
static void process8up2 (GVJ_t *job)
 draw a 8-pixels-per-character monochrome image with octant characters
 

Variables

static const color_t COLORS []
 ANSI 3-bit colors.
 
static gvdevice_engine_t engine3
 
static gvdevice_engine_t engine24
 
static gvdevice_engine_t engine4up
 
static gvdevice_engine_t engine6up
 
static gvdevice_engine_t engine8up1
 
static gvdevice_engine_t engine8up2
 
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 342 of file gvplugin_vt.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PPC2_3 
PPC2_24 
PPC4 
PPC6 
PPC8_BRAILLE 
PPC8_OCTANTS 

Definition at line 315 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 37 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 47 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 BYTES_PER_PIXEL, get_color(), gvprintf(), GVJ_s::height, GVJ_s::imagedata, 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 120 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 118 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 192 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 203 of file gvplugin_vt.c.

References processNup().

Here is the call graph for this function:

◆ process8up()

static void process8up ( GVJ_t job,
const char **  tiles 
)
static

Definition at line 218 of file gvplugin_vt.c.

References processNup().

Referenced by process8up1(), and process8up2().

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

◆ process8up1()

static void process8up1 ( GVJ_t job)
static

Definition at line 226 of file gvplugin_vt.c.

References process8up().

Here is the call graph for this function:

◆ process8up2()

static void process8up2 ( GVJ_t job)
static

Definition at line 251 of file gvplugin_vt.c.

References process8up().

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 143 of file gvplugin_vt.c.

References BYTES_PER_PIXEL, gvputc(), gvputs(), GVJ_s::height, GVJ_s::imagedata, NULL, 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 123 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 334 of file gvplugin_vt.c.

◆ 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 25 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 311 of file gvplugin_vt.c.

◆ device_types

gvplugin_installed_t device_types[]
static
Initial value:
= {
{PPC2_3, "vt:cairo", 0, &engine3, &device_features},
{PPC2_24, "vt-24bit:cairo", 0, &engine24, &device_features},
{PPC4, "vt-4up:cairo", 0, &engine4up, &device_features},
{PPC6, "vt-6up:cairo", 0, &engine6up, &device_features},
{PPC8_BRAILLE, "vt-8up:cairo", 0, &engine8up1, &device_features},
{PPC8_OCTANTS, "vt-8up2:cairo", 0, &engine8up2, &device_features},
{0},
}
static gvdevice_engine_t engine8up2
static gvdevice_features_t device_features
static gvdevice_engine_t engine24
static gvdevice_engine_t engine8up1
static gvdevice_engine_t engine3
static gvdevice_engine_t engine4up
static gvdevice_engine_t engine6up
@ PPC8_BRAILLE
@ PPC8_OCTANTS
@ PPC4
@ PPC6
@ PPC2_3
@ PPC2_24

Definition at line 324 of file gvplugin_vt.c.

◆ engine24

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

Definition at line 291 of file gvplugin_vt.c.

◆ engine3

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

Definition at line 287 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 295 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 299 of file gvplugin_vt.c.

◆ engine8up1

gvdevice_engine_t engine8up1
static
Initial value:
= {
.format = process8up1,
}
static void process8up1(GVJ_t *job)
draw a 8-pixels-per-character monochrome image with Braille characters

Definition at line 303 of file gvplugin_vt.c.

◆ engine8up2

gvdevice_engine_t engine8up2
static
Initial value:
= {
.format = process8up2,
}
static void process8up2(GVJ_t *job)
draw a 8-pixels-per-character monochrome image with octant characters

Definition at line 307 of file gvplugin_vt.c.

◆ gvplugin_vt_LTX_library

GVPLUGIN_VT_API gvplugin_library_t gvplugin_vt_LTX_library = {"vt", apis}

Definition at line 345 of file gvplugin_vt.c.