23 {0, 0x00, 0x00, 0x00},
24 {1, 0xff, 0x00, 0x00},
25 {2, 0x00, 0xff, 0x00},
26 {3, 0xff, 0xff, 0x00},
27 {4, 0x00, 0x00, 0xff},
28 {5, 0xff, 0x00, 0xff},
29 {6, 0x00, 0xff, 0xff},
30 {7, 0xff, 0xff, 0xff},
37 diff += red > base.
red ? red - base.
red : base.
red - red;
39 diff += blue > base.
blue ? blue - base.
blue : base.
blue - blue;
44static unsigned get_color(
unsigned red,
unsigned green,
unsigned blue) {
46 unsigned diff = UINT_MAX;
47 for (
size_t i = 0; i <
sizeof(
COLORS) /
sizeof(
COLORS[0]); ++i) {
61 assert(color_depth == 3 || color_depth == 24);
63 for (
unsigned y = 0; y < job->
height; y += 2) {
64 for (
unsigned x = 0; x < job->
width; ++x) {
67 const unsigned BPP = 4;
77 if (color_depth == 3) {
78 unsigned fg =
get_color(red, green, blue);
81 assert(color_depth == 24);
82 gvprintf(job,
"\033[38;2;%u;%u;%um", red, green, blue);
92 unsigned offset = (y + 1) * job->
width * BPP + x * BPP;
99 if (color_depth == 3) {
100 unsigned bg =
get_color(red, green, blue);
103 assert(color_depth == 24);
104 gvprintf(job,
"\033[48;2;%u;%u;%um", red, green, blue);
144#define GVPLUGIN_VT_API __declspec(dllexport)
146#define GVPLUGIN_VT_API
swig_ptr_object_handlers offset
void gvprintf(GVJ_t *job, const char *format,...)
static void process(GVJ_t *job, int color_depth)
static gvplugin_installed_t device_types[]
static gvdevice_features_t device_features
static gvdevice_engine_t engine24
static const color_t COLORS[]
ANSI 3-bit colors.
static gvdevice_engine_t engine3
static void process24(GVJ_t *job)
static void process3(GVJ_t *job)
static unsigned distance(const color_t base, unsigned red, unsigned green, unsigned blue)
a metric of “closeness” to a given color
GVPLUGIN_VT_API gvplugin_library_t gvplugin_vt_LTX_library
static gvplugin_api_t apis[]
static unsigned get_color(unsigned red, unsigned green, unsigned blue)
find closest ANSI color
void(* format)(GVJ_t *firstjob)