Skip to content

Commit

Permalink
feat: Make HELP text dependand on alpha support is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed Jun 12, 2023
1 parent 9d08574 commit c368259
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
35 changes: 31 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ version = "0.1.0"
edition = "2021"

[dependencies]
chrono = "0.4"
const_format = "0.2"
clap = { version = "4.3", features = ["derive"] }
rusttype = "0.9"
number_prefix = "0.4"
Expand All @@ -17,7 +19,6 @@ simple_moving_average = "0.1"
thread-priority = "0.13"
tokio = { version = "1.28", features = ["fs", "rt-multi-thread", "net", "io-util", "macros", "process", "signal", "sync", "time"] }
vncserver = { version ="0.2", optional = true}
chrono = "0.4.26"

[dev-dependencies]
criterion = {version = "0.5", features = ["async_tokio"]}
Expand Down
17 changes: 11 additions & 6 deletions src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
use crate::framebuffer::FrameBuffer;
use const_format::formatcp;
use std::sync::Arc;

use tokio::io::AsyncWriteExt;

use crate::framebuffer::FrameBuffer;

pub const PARSER_LOOKAHEAD: usize = "PX 1234 1234 rrggbbaa\n".len(); // Longest possible command
pub const HELP_TEXT: &[u8] = "\
pub const HELP_TEXT: &[u8] = formatcp!("\
Pixelflut server powered by breakwater https://github.com/sbernauer/breakwater
Available commands:
HELP: Show this help
PX x y rrggbb: Color the pixel (x,y) with the given hexadecimal color rrggbb
PX x y rrggbbaa: Color the pixel (x,y) with the given hexadecimal color rrggbb (alpha channel is ignored by default, unless breakwater is compiled with \"--feature alpha\". This is for performance reasons)
{}
PX x y gg: Color the pixel (x,y) with the hexadecimal color gggggg. Basically this is the same as the other commands, but is a more efficient way of filling white, black or gray areas
PX x y: Get the color value of the pixel (x,y)
SIZE: Get the size of the drawing surface, e.g. `SIZE 1920 1080`
OFFSET x y: Apply offset (x,y) to all further pixel draws on this connection. This can e.g. be used to pre-calculate an image/animation and simply use the OFFSET command to move it around the screen without the need to re-calculate it
".as_bytes();
",
if cfg!(feature = "alpha") {
"PX x y rrggbbaa: Color the pixel (x,y) with the given hexadecimal color rrggbb and a transparency of aa, where ff means draw normally on top of the existing pixel and 00 means fully transparent (no change at all)"
} else {
"PX x y rrggbbaa: Color the pixel (x,y) with the given hexadecimal color rrggbb. The alpha part is discarded for performance reasons, as breakwater was compiled without the alpha feature"
}
).as_bytes();

#[derive(Clone, Default, Debug)]
pub struct ParserState {
Expand Down

0 comments on commit c368259

Please sign in to comment.