Notcurses: Difference between revisions

From dankwiki
No edit summary
(explain transparency and contrasting)
Line 9: Line 9:
* All APIs use 24-bit 8bpc RGB color natively
* All APIs use 24-bit 8bpc RGB color natively
** Color is quantized down for indexed palette terminals
** Color is quantized down for indexed palette terminals
* Transparency/semi-transparency
* Transparency/semi-transparency plus dynamic high-contrast text
** Lower planes can affect color of higher translucent ones
** Lower planes can affect color of higher translucent ones
* Full support for Unicode, including wide glyphs and bidirectional text
* Full support for Unicode, including wide glyphs and bidirectional text
Line 16: Line 16:
* Subregion fade in/out
* Subregion fade in/out
* Linear interpolation for line color
* Linear interpolation for line color
==Transparency/Contrasting==
It is not obvious what "transparency" or "alpha blending" means in a character context. I have assigned my own meanings. Each of the foreground and background channel of an ncplane's cell have two bits dedicated to alpha. Channels are always initialized to 0, and thus the default alpha setting is <tt>CELL_ALPHA_OPAQUE</tt>. It is important to note that <i>glyph selection</i> is independent of alpha. The first glyph found while descending the planes intersecting a cell will be the glyph used. Only presentation of the glyph is modified by alpha.
{| class="wikitable"
! Value !! Foreground !! Background
|-
| 00 || Opaque. Use the fg color unchanged. || Opaque. Use the bg color unchanged.
|-
| 01 || Translucent. Blend the fg color down. || Translucent. Blend the bg color down.
|-
| 10 || Transparent. Select the next fg color. || Transparent. Select the next bg color.
|-
| 11 || High-contrast. Complement bg color computed through this plane. || Forbidden.
|-
|}
The value 11 is currently forbidden for a bg alpha setting, but might be used in the future. To "blend the color down" means to average the colors encountered until hitting an opaque channel, or running out of planes. To "select the next color" means to ignore this color, and instead take the color as computed by lower planes.
High-contrast text is not strictly defined. notcurses will attempt to make the glyph as readable as possible, given the background color <i>computed at the plane</i>.
Note that a cell with the zero glyph will not have its channels considered. The containing plane's default channels will instead be factored into any color/transparency calculations (if a default glyph has been defined for the plane). A cell containing a zero glyph on a plane with a default zero glyph cannot impact the rendered scene; any associated channels will be ignored.


==Releases==
==Releases==

Revision as of 22:07, 20 December 2019

My library for building complex, vibrant textual user interfaces (TUIs) on modern terminal emulators. It does not use Ncurses (though it does make use of libtinfo from that package), nor is it an X/Open Curses source-compatible replacement. It is written in C, with C++-safe headers.

Source and issue-tracking live at Github.

Contact sheet from Notcurses 0.4.0 demo

Features

  • Optional use of "alternate screen" where available (smcup/rmcup terminfo capabilities)
  • All APIs use 24-bit 8bpc RGB color natively
    • Color is quantized down for indexed palette terminals
  • Transparency/semi-transparency plus dynamic high-contrast text
    • Lower planes can affect color of higher translucent ones
  • Full support for Unicode, including wide glyphs and bidirectional text
    • Composed keys (number pad, etc.) are mapped into Private Supplementary Area B
  • Image/video support via ffmpeg
  • Subregion fade in/out
  • Linear interpolation for line color

Transparency/Contrasting

It is not obvious what "transparency" or "alpha blending" means in a character context. I have assigned my own meanings. Each of the foreground and background channel of an ncplane's cell have two bits dedicated to alpha. Channels are always initialized to 0, and thus the default alpha setting is CELL_ALPHA_OPAQUE. It is important to note that glyph selection is independent of alpha. The first glyph found while descending the planes intersecting a cell will be the glyph used. Only presentation of the glyph is modified by alpha.

Value Foreground Background
00 Opaque. Use the fg color unchanged. Opaque. Use the bg color unchanged.
01 Translucent. Blend the fg color down. Translucent. Blend the bg color down.
10 Transparent. Select the next fg color. Transparent. Select the next bg color.
11 High-contrast. Complement bg color computed through this plane. Forbidden.

The value 11 is currently forbidden for a bg alpha setting, but might be used in the future. To "blend the color down" means to average the colors encountered until hitting an opaque channel, or running out of planes. To "select the next color" means to ignore this color, and instead take the color as computed by lower planes.

High-contrast text is not strictly defined. notcurses will attempt to make the glyph as readable as possible, given the background color computed at the plane.

Note that a cell with the zero glyph will not have its channels considered. The containing plane's default channels will instead be factored into any color/transparency calculations (if a default glyph has been defined for the plane). A cell containing a zero glyph on a plane with a default zero glyph cannot impact the rendered scene; any associated channels will be ignored.

Releases

Release Date Key features
0.9.0 2019-12-18 Recognize COLORTERM, damage map, quantized colors, _yx API extensions, alignment
0.4.0 2019-12-05 Cell API, input, resize handling
0.3.0 2019-12-02 Video support, transparent planes, fades
0.2.0 2019-12-02 Panelreels, image support
0.1.0 2019-11-30 Ncplanes, basic output


See Also