pub enum Coverage {
Exact,
Thresholded,
Full,
}Expand description
How an integrated coverage becomes an alpha byte — AGG’s three modes.
See AntiAlias, whose three variants these
mirror one for one; this is the integrator’s own spelling of the same
choice, so scanline does not depend on the device vocabulary.
use pdfrum_render::scanline::{Coverage, FillRule, Rasterizer};
// A half-covered pixel: `Exact` keeps the partial alpha, `Full`
// pushes any touched pixel to 255.
let alpha = |coverage| {
let mut rasterizer = Rasterizer::new();
rasterizer.move_to(0.0, 0.0);
rasterizer.line_to(0.5, 0.0);
rasterizer.line_to(0.5, 1.0);
rasterizer.line_to(0.0, 1.0);
rasterizer.close_polygon();
let mut out = 0u8;
rasterizer.sweep(FillRule::Winding, coverage, |_, _, _, a| out = a);
out
};
assert!(alpha(Coverage::Exact) < 255);
assert_eq!(alpha(Coverage::Full), 255);Variants§
Exact
Coverage becomes alpha: min(255, floor(cov * 256)).
Thresholded
aliased_path: the same coverage thresholded at its midpoint.
Full
full_cover: any touched pixel at 255, whatever its coverage.
Trait Implementations§
impl Copy for Coverage
impl Eq for Coverage
impl StructuralPartialEq for Coverage
Auto Trait Implementations§
impl Freeze for Coverage
impl RefUnwindSafe for Coverage
impl Send for Coverage
impl Sync for Coverage
impl Unpin for Coverage
impl UnsafeUnpin for Coverage
impl UnwindSafe for Coverage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more