|
|
@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
use crate::{
|
|
|
|
NcAlphaBits, NcChannel, NcChannelPair, NcColor, NcPaletteIndex, NcRgb,
|
|
|
|
NcAlphaBits, NcChannel, NcChannelPair, NcColor, NcPaletteIndex, NcRgb,
|
|
|
|
NCNCALPHA_HIGHCONTRAST, NCNCALPHA_OPAQUE, NCCELL_BGDEFAULT_MASK, NCCELL_BG_PALETTE,
|
|
|
|
NCCELL_HIGHCONTRAST, NCCELL_OPAQUE, NCCELL_BGDEFAULT_MASK, NCCELL_BG_PALETTE,
|
|
|
|
NCCELL_BG_RGB_MASK, NCCELL_FGDEFAULT_MASK, NCCELL_FG_PALETTE, NCCHANNEL_ALPHA_MASK,
|
|
|
|
NCCELL_BG_RGB_MASK, NCCELL_FGDEFAULT_MASK, NCCELL_FG_PALETTE, NCCHANNEL_ALPHA_MASK,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -24,7 +24,7 @@ pub fn ncchannel_set_alpha(channel: &mut NcChannel, alpha: NcAlphaBits) {
|
|
|
|
let alpha_clean = alpha & NCCHANNEL_ALPHA_MASK;
|
|
|
|
let alpha_clean = alpha & NCCHANNEL_ALPHA_MASK;
|
|
|
|
*channel = alpha_clean | (*channel & !NCCHANNEL_ALPHA_MASK);
|
|
|
|
*channel = alpha_clean | (*channel & !NCCHANNEL_ALPHA_MASK);
|
|
|
|
|
|
|
|
|
|
|
|
if alpha != NCNCALPHA_OPAQUE {
|
|
|
|
if alpha != NCCELL_OPAQUE {
|
|
|
|
// indicate that we are *not* using the default background color
|
|
|
|
// indicate that we are *not* using the default background color
|
|
|
|
*channel |= NCCELL_BGDEFAULT_MASK;
|
|
|
|
*channel |= NCCELL_BGDEFAULT_MASK;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -62,9 +62,9 @@ pub fn ncchannels_set_fg_alpha(channels: &mut NcChannelPair, alpha: NcAlphaBits)
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub fn ncchannels_set_bg_alpha(channels: &mut NcChannelPair, alpha: NcAlphaBits) {
|
|
|
|
pub fn ncchannels_set_bg_alpha(channels: &mut NcChannelPair, alpha: NcAlphaBits) {
|
|
|
|
let mut alpha_clean = alpha;
|
|
|
|
let mut alpha_clean = alpha;
|
|
|
|
if alpha == NCNCALPHA_HIGHCONTRAST {
|
|
|
|
if alpha == NCCELL_HIGHCONTRAST {
|
|
|
|
// forbidden for background alpha, so makes it opaque
|
|
|
|
// forbidden for background alpha, so makes it opaque
|
|
|
|
alpha_clean = NCNCALPHA_OPAQUE;
|
|
|
|
alpha_clean = NCCELL_OPAQUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let mut channel = ncchannels_bchannel(*channels);
|
|
|
|
let mut channel = ncchannels_bchannel(*channels);
|
|
|
|
ncchannel_set_alpha(&mut channel, alpha_clean);
|
|
|
|
ncchannel_set_alpha(&mut channel, alpha_clean);
|
|
|
@ -345,7 +345,7 @@ pub const fn ncchannel_default_p(channel: NcChannel) -> bool {
|
|
|
|
/// *Method: NcChannel.[set_default()][NcChannel#method.set_default]*
|
|
|
|
/// *Method: NcChannel.[set_default()][NcChannel#method.set_default]*
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
pub fn ncchannel_set_default(channel: &mut NcChannel) -> NcChannel {
|
|
|
|
pub fn ncchannel_set_default(channel: &mut NcChannel) -> NcChannel {
|
|
|
|
*channel &= !(NCCELL_BGDEFAULT_MASK | NCNCALPHA_HIGHCONTRAST);
|
|
|
|
*channel &= !(NCCELL_BGDEFAULT_MASK | NCCELL_HIGHCONTRAST);
|
|
|
|
*channel
|
|
|
|
*channel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -491,7 +491,7 @@ pub fn ncchannels_bg_palindex_p(channels: NcChannelPair) -> bool {
|
|
|
|
pub fn ncchannels_set_fg_palindex(channels: &mut NcChannelPair, index: NcPaletteIndex) {
|
|
|
|
pub fn ncchannels_set_fg_palindex(channels: &mut NcChannelPair, index: NcPaletteIndex) {
|
|
|
|
*channels |= NCCELL_FGDEFAULT_MASK;
|
|
|
|
*channels |= NCCELL_FGDEFAULT_MASK;
|
|
|
|
*channels |= NCCELL_FG_PALETTE as NcChannelPair;
|
|
|
|
*channels |= NCCELL_FG_PALETTE as NcChannelPair;
|
|
|
|
ncchannels_set_fg_alpha(channels, NCNCALPHA_OPAQUE);
|
|
|
|
ncchannels_set_fg_alpha(channels, NCCELL_OPAQUE);
|
|
|
|
*channels &= 0xff000000ffffffff as NcChannelPair;
|
|
|
|
*channels &= 0xff000000ffffffff as NcChannelPair;
|
|
|
|
*channels |= (index as NcChannelPair) << 32;
|
|
|
|
*channels |= (index as NcChannelPair) << 32;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -504,7 +504,7 @@ pub fn ncchannels_set_fg_palindex(channels: &mut NcChannelPair, index: NcPalette
|
|
|
|
pub fn ncchannels_set_bg_palindex(channels: &mut NcChannelPair, index: NcPaletteIndex) {
|
|
|
|
pub fn ncchannels_set_bg_palindex(channels: &mut NcChannelPair, index: NcPaletteIndex) {
|
|
|
|
*channels |= NCCELL_BGDEFAULT_MASK as NcChannelPair;
|
|
|
|
*channels |= NCCELL_BGDEFAULT_MASK as NcChannelPair;
|
|
|
|
*channels |= NCCELL_BG_PALETTE as NcChannelPair;
|
|
|
|
*channels |= NCCELL_BG_PALETTE as NcChannelPair;
|
|
|
|
ncchannels_set_bg_alpha(channels, NCNCALPHA_OPAQUE);
|
|
|
|
ncchannels_set_bg_alpha(channels, NCCELL_OPAQUE);
|
|
|
|
*channels &= 0xffffffffff000000;
|
|
|
|
*channels &= 0xffffffffff000000;
|
|
|
|
*channels |= index as NcChannelPair;
|
|
|
|
*channels |= index as NcChannelPair;
|
|
|
|
}
|
|
|
|
}
|
|
|
|