#[repr(transparent)]
pub struct NcChannels(pub NcChannels_u64);
Expand description

64 bits containing a foreground and background NcChannel

At render time, both 24-bit NcRgb values are quantized down to terminal capabilities, if necessary. There’s a clear path to 10-bit support should we one day need it.

Default Color

The “default color” is best explained by color(3NCURSES) and default_colors(3NCURSES). Ours is the same concept.

Until the “not default color” bit is set, any color you load will be ignored.

Diagram

~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB║~~AA~~~~|RRRRRRRR|GGGGGGGG|BBBBBBBB
↑↑↑↑↑↑↑↑↑↑↑↑ foreground ↑↑↑↑↑↑↑↑↑↑↑║↑↑↑↑↑↑↑↑↑↑↑↑ background ↑↑↑↑↑↑↑↑↑↑↑

Detailed info (specially on the context-dependent bits on each NcChannel’s 4th byte):

                            ~foreground channel~
reserved, must be 0                                  ↓bits view↓               ↓hex mask↓
0·······|········|········|········║········|········|········|········  =  8·······|········

NcChannels::FG_DEFAULT_MASK: foreground is NOT "default color"
·1······|········|········|········║········|········|········|········  =  4·······|········

NcChannels::FG_ALPHA_MASK: foreground alpha (2bits)
··11····|········|········|········║········|········|········|········  =  3·······|········

NcChannels::FG_PALETTE: foreground uses palette index
····1···|········|········|········║········|········|········|········  =  ·8······|········

NcChannels::NOBACKGROUND_MASK: glyph is entirely foreground
·····1··|········|········|········║········|········|········|········  =  ·4······|········

reserved, must be 0
······00|········|········|········║········|········|········|········  =  ·3······|········

NcChannels::FG_RGB_MASK: foreground in 3x8 RGB (rrggbb)
········|11111111|11111111|11111111║········|········|········|········  =  ··FFFFFF|········
                            ~background channel~
reserved, must be 0                                  ↓bits view↓               ↓hex mask↓
········|········|········|········║0·······|········|········|········  =  ········|8·······

NcChannels::BGDEFAULT_MASK: background is NOT "default color"
········|········|········|········║·1······|········|········|········  =  ········|4·······

NcChannels::BG_ALPHA_MASK: background alpha (2 bits)
········|········|········|········║··11····|········|········|········  =  ········|3·······

NcChannels::BG_PALETTE: background uses palette index
········|········|········|········║····1···|········|········|········  =  ········|·8······

reserved, must be 0
········|········|········|········║·····000|········|········|········  =  ········|·7······

NcChannels::BG_RGB_MASK: background in 3x8 RGB (rrggbb)
········|········|········|········║········|11111111|11111111|11111111  =  ········|··FFFFFF

type in C: channels (uint64_t)

NcChannels Mask Flags

Tuple Fields

0: NcChannels_u64

Implementations

If this bit is set, we are not using the default background color.

See the detailed diagram at NcChannels

Extract these bits to get the background NcAlpha mask.

See the detailed diagram at NcChannels

If this bit and BG_DEFAULT_MASK are set, we’re using a palette-indexed background color.

See the detailed diagram at NcChannels

Extract these bits to get the background NcRgb value.

Does this glyph completely obscure the background? If so, there’s no need to emit a background when rasterizing, a small optimization. These are also used to track regions into which we must not cellblit.

New NcChannels, set to black and NOT using the “default color”.

New NcChannels, set to black and using the “default color”.

New NcChannels, expects two separate NcRgbs for the foreground and background channels.

New NcChannels, expects a single NcRgb for both foreground and background channels.

New NcChannels, expects two separate NcRgb & NcAlpha for the foreground and background channels.

New NcChannels, expects NcRgb & NcAlpha for both channels.

Combines two NcChannels into an NcChannels.

C style function: channels_combine().

Returns the NcChannels with the fore- and background’s color information swapped, but without touching housekeeping bits.

Alpha is retained unless it would lead to an illegal state: HIGHCONTRAST, TRANSPARENT and BLEND are taken to OPAQUE unless the new value is RGB.

HIGHCONTRAST TRANSPARENT BLEND OPAQUE

C style function: ncchannels_reverse().

Gets the foreground alpha and coloring bits as an NcChannel.

C style function: ncchannels_fchannel().

Gets the background alpha and coloring bits as an NcChannel.

C style function: ncchannels_bchannel().

Sets the foreground alpha and coloring bits from an NcChannel.

C style function: ncchannels_set_fchannel().

Sets the background alpha and coloring bits from an NcChannel.

C style function: ncchannels_set_bchannel().

Gets the alpha and coloring bits as an NcChannels.

C style function: ncchannels_bchannel().

Sets the foreground alpha and coloring bits as an NcChannels, from another NcChannels.

C style function: ncchannels_set_fchannel().

Gets the foreground NcAlpha.

C style function: ncchannels_fg_alpha().

Gets the background NcAlpha.

C style function: ncchannels_bg_alpha().

Sets the foreground NcAlpha.

C style function: ncchannels_set_fg_alpha().

Sets the background NcAlpha.

C style function: ncchannels_set_bg_alpha().

Returns true if the foreground channel is set to RGB color.

C style function: ncchannels_fg_rgb_p().

Returns true if the background channel is set to RGB color.

C style function: ncchannels_bg_rgb_p().

Gets the foreground NcRgb.

C style function: ncchannels_fg_rgb().

Gets the background NcRgb.

C style function: ncchannels_bg_rgb().

Sets the foreground NcRgb.

C style function: channels_set_fg_rgb().

Sets the background NcRgb.

C style function: channels_set_bg_rgb().

Gets the foreground red component.

(No equivalent C style function)

Gets the foreground green component.

(No equivalent C style function)

Gets the foreground blue component.

(No equivalent C style function)

Gets the background red component.

(No equivalent C style function)

Gets the background green component.

(No equivalent C style function)

Gets the background blue component.

(No equivalent C style function)

Sets the foreground red component, and returns the new NcChannels.

(No equivalent C style function)

Sets the foreground green component, and returns the new NcChannels.

(No equivalent C style function)

Sets the foreground blue component, and returns the new NcChannels.

(No equivalent C style function)

Sets the background red component, and returns the new NcChannels.

(No equivalent C style function)

Sets the background green component, and returns the new NcChannels.

(No equivalent C style function)

Sets the background blue component, and returns the new NcChannels.

(No equivalent C style function)

Is the background using the “default background color”?

C style function: channels_fg_default_p().

Is the background using the “default background color”?

The “default background color” must generally be used to take advantage of terminal-effected transparency.

C style function: channels_bg_default_p().

Marks the foreground as using its “default color”, and returns the new NcChannels.

C style function: channels_set_fg_default().

Marks the background as using its “default color”, and returns the new NcChannels.

C style function: channels_set_bg_default().

Marks the foreground as NOT using its “default color”, and returns the new NcChannels.

C style function: channels_set_fg_default().

Marks the background as NOT using its “default color”, and returns the new NcChannels.

C style function: channels_set_bg_not_default().

Marks both the foreground and background as using its “default color”, and returns the new NcChannels.

Marks both the foreground and background as NOT using its “default color”, and returns the new NcChannels.

Gets the NcPaletteIndex from the foreground NcChannel.

C style function: channels_fg_palindex().

Gets the NcPaletteIndex from the background NcChannel.

C style function: channels_bg_palindex().

Is the foreground of using an indexed NcPalette color?

C style function: channels_fg_palindex_p().

Is the background of using an indexed NcPalette color?

C style function: channels_bg_palindex_p().

Sets the foreground of an NcChannels as using an indexed NcPalette color.

C style function: channels_set_fg_palindex().

Sets the background of an NcChannels as using an indexed NcPalette color.

C style function: channels_set_bg_palindex().

Trait Implementations

Formats the value using the given formatter.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Formats the value using the given formatter.

Formats the value using the given formatter.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.