pub struct ScreenParams {
pub kind: ScreenType,
pub size: i32,
pub dot_radius: i32,
}Expand description
Parameters for constructing a halftone screen.
§Valid values
kind: anyScreenTypevariant.size: must be a power of two and ≥ 2 (e.g. 2, 4, 8, 16 …). The screen matrix issize × sizecells. Values that are not powers of two, or values less than 2, produce an undefined screen pattern. Callvalidateafter construction to enforce these constraints.dot_radius: meaningful only forScreenType::StochasticClustered; must be ≥ 1. Ignored for other screen types but must still be positive.
§Default
{ Dispersed, size: 2, dot_radius: 2 }.
Fields§
§kind: ScreenTypeThe halftone algorithm to use.
size: i32Screen matrix dimension in cells.
Must be a power of two and ≥ 2. Typical values: 2, 4, 8, 16, 32, 64.
dot_radius: i32Dot radius for ScreenType::StochasticClustered screens.
Must be ≥ 1. Ignored (but still validated) for other screen types.
Implementations§
Source§impl ScreenParams
impl ScreenParams
Sourcepub const fn validate(&self) -> Result<(), Cow<'static, str>>
pub const fn validate(&self) -> Result<(), Cow<'static, str>>
Validates that the parameter values are within their documented ranges.
§Constraints checked
sizemust be ≥ 2.sizemust be a power of two.dot_radiusmust be ≥ 1.
§Errors
Returns Err with a human-readable Cow<'static, str> message
describing the first constraint violated. All current error messages
are static string literals (Cow::Borrowed), so no allocation occurs.
Future callers that need dynamic messages (e.g. including the offending
field value) can return Cow::Owned(format!(...)) without a breaking
API change.
§Examples
assert!(ScreenParams::default().validate().is_ok());
let bad = ScreenParams { size: 3, ..ScreenParams::default() };
assert!(bad.validate().is_err());Trait Implementations§
Source§impl Clone for ScreenParams
impl Clone for ScreenParams
Source§fn clone(&self) -> ScreenParams
fn clone(&self) -> ScreenParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more