loading...

Rainbow effect: ternary color spaces and SBTCVM

thomasthespacefox profile image Thomas Leathers ・2 min read

SBTCVM's pygame frontend and its many colors.

The pygame frontend. It was the oldest interface SBTCVM had aside from a barren terminal, without even a period of curses to be seen. Now, after much work on the common components of SBTCVM gen2-9, pygame makes a return to SBTCVM, with a new frontend. A few new features have made it into SBTCVM via the pygame frontend as well.

SBTCVM, traditionally, had only plain, black & white text coloring. However, it has had graphics of one sort or another for a while, so color is no new addition to it.

With the many changes in SBTCVM's newest revision, comes colored text functionality. While the feature itself is new, it, in-part, uses some research that began before SBTCVM even did.

colortext demo. Shows off 27-color foreground and background colors.
Screenshot showing colored text.

Years ago, before SBTCVM was even a thing, I was working with balanced ternary color palettes, and possible graphics resolutions, and so forth. namely:

  • 1-trit Greyscale (3 shades)
  • 2-trit Greyscale (9 shades)
  • 3-trit Greyscale (27 shades)
  • 3-trit RGB (27 colors)
  • 6-trit RGB (729 colors) [later on]
  • 9-trit RGB (19683 colors) [later on]

These 3 Balanced Ternary color spaces were interesting to work with ascetically, and are the reason even SBTCVM's predecessor, TDA-Mark1, had color support, in the form of a crude 729-color, 27x27 pixel vector plotter, and a smaller monochromatic, 9x9 vector plotter.

While those plotters no longer exist in SBTCVM Gen 2-9, a new 243x243, 19683 color (9-trit RGB), vector plotter has appeared, in the form of SBTGA mode 30.

colorpack demo. Shows off a 3-trit RGB color-block encoding scheme.
screenshot showing 27-color packed art encoding

The new pygame frontend's TTY has both a 3-color indexed and a 27-color RGB color-block encoding scheme. (mainly to save memory, and ease coding.)

Some observations on ternary colors

While SBTCVM may have had colors for a while, as far as I've seen, its the only balanced ternary computer, virtual or not, to really tackle the problem. One odd thing is 0 is never black in linear RGB and monochrome palettes. the lowest negative value is. while the highest positive value is always white.

Compared to binary, balanced ternary color palettes balloon in size quite quickly:

No. of Units ternary colors binary colors
1 3 2
2 9 4
3 27 8
4 81 16
6 729 64
8 6561 256
9 19683 512

Units, refers to the equivalent bits/trits measurements of binary & balanced ternary respectively.

Overall, I've learned quite a few things about balanced ternary since starting SBTCVM, and even learned some things before that. As well, all this new color text and graphics should make SBTCVM a bit more interesting at least.

To use the new pygame frontend, just run:

./pyg_sbtcvm.py

Posted on by:

thomasthespacefox profile

Thomas Leathers

@thomasthespacefox

Hi, I'm Thomas, chief developer of the SBTCVM project, and all around artist and programmer. I do have more of an understanding of balanced ternary than most i would say.

Discussion

markdown guide