1
0
Fork 0
forked from AbleOS/ableos

Merge branch 'master' of ssh://git.ablecorp.us:20/able/ableos

This commit is contained in:
Able 2022-02-04 00:16:10 -06:00
commit b3b9cc3c76

View file

@ -1,15 +1,17 @@
use core::ops::{BitAnd, BitOr, Shr};
use vga::colors::Color16; use vga::colors::Color16;
pub type Rgba64 = u64; pub type Rgba64 = u64;
pub fn get_r(rgba: Rgba64) -> u8 { pub fn get_r(rgba: Rgba64) -> u8 {
((rgba & 0xff_00_00_00) >> 0o30) as u8 rgba.bitand(0xff_00_00_00).shr(0o30) as u8
} }
pub fn get_g(rgba: Rgba64) -> u8 { pub fn get_g(rgba: Rgba64) -> u8 {
((rgba & 0xff_00_00) >> 0o20) as u8 rgba.bitand(0xff_00_00).shr(0o20) as u8
} }
pub fn get_b(rgba: Rgba64) -> u8 { pub fn get_b(rgba: Rgba64) -> u8 {
((rgba & 0xff_00) >> 0o10) as u8 rgba.bitand(0xff_00).shr(0o10) as u8
} }
pub fn get_a(rgba: Rgba64) -> u8 { pub fn get_a(rgba: Rgba64) -> u8 {
@ -17,19 +19,25 @@ pub fn get_a(rgba: Rgba64) -> u8 {
} }
pub fn set_r(rgba: Rgba64, r: u8) -> Rgba64 { pub fn set_r(rgba: Rgba64, r: u8) -> Rgba64 {
rgba & 0xffffffff_00_ff_ff_ff | (r as Rgba64) << 0o30 rgba
.bitand(0xffffffff_00_ff_ff_ff)
.bitor((r as Rgba64).shr(0o30))
} }
pub fn set_g(rgba: Rgba64, g: u8) -> Rgba64 { pub fn set_g(rgba: Rgba64, g: u8) -> Rgba64 {
rgba & 0xffffffff_ff_00_ff_ff | (g as Rgba64) << 0o20 rgba
.bitand(0xffffffff_ff_00_ff_ff)
.bitor((g as Rgba64).shr(0o20))
} }
pub fn set_b(rgba: Rgba64, b: u8) -> Rgba64 { pub fn set_b(rgba: Rgba64, b: u8) -> Rgba64 {
rgba & 0xffffffff_ff_ff_00_ff | (b as Rgba64) << 0o10 rgba
.bitand(0xffffffff_ff_ff_00_ff)
.bitor((b as Rgba64).shr(0o10))
} }
pub fn set_a(rgba: Rgba64, a: u8) -> Rgba64 { pub fn set_a(rgba: Rgba64, a: u8) -> Rgba64 {
rgba & 0xffffffff_ff_ff_ff_00 | (a as Rgba64) rgba.bitand(0xffffffff_ff_ff_ff_00).bitor(a as Rgba64)
} }
pub fn rgba_div(a: Rgba64, b: Rgba64) -> Rgba64 { pub fn rgba_div(a: Rgba64, b: Rgba64) -> Rgba64 {