Add ColorBw for printer
This commit is contained in:
parent
59a1235b1d
commit
097f4ee548
6 changed files with 38 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -148,6 +148,7 @@ dependencies = [
|
||||||
name = "showbits-thermal-printer"
|
name = "showbits-thermal-printer"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"palette",
|
||||||
"showbits-common",
|
"showbits-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ version = "0.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
palette = "0.7.5"
|
||||||
showbits-common.path = "./showbits-common"
|
showbits-common.path = "./showbits-common"
|
||||||
|
|
||||||
[workspace.lints]
|
[workspace.lints]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ edition.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.80"
|
anyhow = "1.0.80"
|
||||||
palette = "0.7.5"
|
palette.workspace = true
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
palette.workspace = true
|
||||||
showbits-common.workspace = true
|
showbits-common.workspace = true
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
|
|
|
||||||
32
showbits-thermal-printer/src/color.rs
Normal file
32
showbits-thermal-printer/src/color.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
use palette::Srgb;
|
||||||
|
use showbits_common::Color;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub enum PixelBw {
|
||||||
|
Black,
|
||||||
|
White,
|
||||||
|
Transparent,
|
||||||
|
Invert,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Color for PixelBw {
|
||||||
|
fn to_srgb(self) -> Srgb {
|
||||||
|
match self {
|
||||||
|
Self::Black => Srgb::new(0.0, 0.0, 0.0),
|
||||||
|
Self::White => Srgb::new(1.0, 1.0, 1.0),
|
||||||
|
_ => Srgb::new(1.0, 0.0, 1.0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn over(self, other: Self) -> Self {
|
||||||
|
match (self, other) {
|
||||||
|
(Self::Black, _) => Self::Black,
|
||||||
|
(Self::White, _) => Self::White,
|
||||||
|
(Self::Transparent, p) => p,
|
||||||
|
(Self::Invert, Self::Black) => Self::White,
|
||||||
|
(Self::Invert, Self::White) => Self::Black,
|
||||||
|
(Self::Invert, Self::Invert) => Self::Transparent,
|
||||||
|
(Self::Invert, Self::Transparent) => Self::Invert,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
mod color;
|
||||||
|
|
||||||
use showbits_common::Vec2;
|
use showbits_common::Vec2;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue