Crate ternlog

Source
Expand description

§Ternary logic

Compute “ternary logic” using an 8-entry lookup table.

For each bit, the expression will be computed as:

abclut
000lut & (1 << 0) != 0
001lut & (1 << 1) != 0
010lut & (1 << 2) != 0
011lut & (1 << 3) != 0
100lut & (1 << 4) != 0
101lut & (1 << 5) != 0
110lut & (1 << 6) != 0
111lut & (1 << 7) != 0

§Example

// if sprite_mask { background } else { sprite }
background.ternlog(sprite, sprite_mask, 0xe4)

Traits§

TernLog
Extension trait to compute ternary logic on integer types.