-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the inspec wiki!
To increase the resolution of rendering images in the y-axis, each terminal row is divided into two pixels using the unicode characters █
,
, ▄
, and ▀
, labeled as const.FULL_1
, const.FULL_0
, const.HALF_01
, and const.HALF_10
respectively. A pair of these "pixels" being rendered as a single character I call a "patch".
curses has 255 slots for foreground/background color pairs. We assign each SLOT to a (F, B) color where SLOT is a number between 1 and 255 inclusive representing a curses color slot, and F and B are numbers between 0 and 255 inclusive representing terminal colors for the foreground and background respectively. F and B must come from the set of K colors in a colormap.
To increase the capacity of colors per colormap, we note that we never need to use a slot where F == B since we can always just use █
colored by (F, *), or
colored using (*, B). Similarly, we never need to use a slot for F < B. If we wanted a slot colored as ▄
(F, B) with F < B, we can replace it with ▀
(B, F).
Thus we have the following solution so that every possible patch can be encoded in the colormap using a combination of one of █
,
, ▄
, and ▀
and one of our stored (F, B) pairs.
COLORS are the K color values in the color map indexed from 0 to K-1 inclusive
SLOTS are the 255 slots from 1 to 255 inclusive
PATCH is a (X0, X1) pair where X0 and X1 are the indices into COLORS that we want to render
PATCH = (X0, X1) | (COLORS, CHAR) | (SLOT, CHAR) |
---|---|---|
(0, 0) |
(COLORS[K-1], COLORS[0]), " ") |
(K-1, " ") |
(1, 0) |
(COLORS[1], COLORS[0]), "▀") |
(1, "▀") |
(2, 0) |
(COLORS[2], COLORS[0]), "▀") |
(2, "▀") |
... | ... | ... |
(K-1, 0) |
(COLORS[K-1], COLORS[0]), "▀") |
(K-1, "▀") |
(0, 1) |
(COLORS[1], COLORS[0]), "▄") |
(2, "▄") |
(1, 1) |
(COLORS[1], COLORS[0]), "█") |
(2, "█") |
(2, 1) |
(COLORS[2], COLORS[1]), "▀") |
(K, "▀") |
... | ... | ... |
(K-1, 1) |
(COLORS[K-1], COLORS[1]), "▀") |
(2K-1, "▀") |
(0, 2) |
(COLORS[2], COLORS[0]), "▄") |
(3, "▄") |
(1, 2) |
(COLORS[2], COLORS[1]), "▄") |
(K+1, "▄") |
(2, 2) |
(COLORS[2], COLORS[0]), "█") |
(3, "█") |
(3, 2) |
(COLORS[3], COLORS[2]), "▀") |
(2K, "▀") |
... | ... | ... |
(K-1, 2) |
(COLORS[3], COLORS[2]), "▀") |
(3K-4, "▀") |
... | ... | ... |
(K-1, K-1) |
(COLORS[K-1], COLORS[0]), "█") |
(K-1, "█") |
The formula for this is
SLOT = (X1 * (K - 1)) - (X_1 * (X_1 - 1)) // 2 + X0 - X1