add pixel_perfect feature, document stuff

This commit is contained in:
griffi-gh 2024-02-19 21:32:13 +01:00
parent 99e1bc5549
commit 91e8b44dd5
3 changed files with 16 additions and 3 deletions

View file

@ -23,9 +23,15 @@ fontdue = "0.8"
rect_packer = "0.2"
log = "0.4"
nz = "0.3"
document-features = "0.2"
[features]
default = ["builtin_elements", "builtin_font"]
default = ["builtin_elements", "builtin_font", "pixel_perfect"]
## Enable the built-in font (ProggyTiny, adds 35kb to the executable)
builtin_font = []
## Enable the built-in elements (`Container`, `ProgressBar`, etc.)
builtin_elements = []
## Round vertex positions to nearest integer coordinates (fixes blurry text)
pixel_perfect = []
#parallel = ["dep:rayon", "fontdue/parallel"]

View file

@ -317,6 +317,10 @@ impl UiDrawPlan {
}
}
}
#[cfg(feature = "pixel_perfect")]
swapper.current_mut().vertices.iter_mut().for_each(|v| {
v.position = v.position.floor()
});
prev_command = Some(command);
}
Self {

View file

@ -1,9 +1,12 @@
#![forbid(unsafe_code)]
#![forbid(unsafe_op_in_unsafe_fn)]
#![doc(html_logo_url = "https://raw.githubusercontent.com/griffi-gh/hui/master/.assets/hui.svg")]
//!
//! Simple UI library for games and other interactive applications
//!
//! # Features
#![doc = document_features::document_features!()]
#![forbid(unsafe_code)]
#![forbid(unsafe_op_in_unsafe_fn)]
use std::collections::VecDeque;