Struct ab_glyph_rasterizer::Rasterizer [−][src]
pub struct Rasterizer { /* fields omitted */ }
Expand description
Coverage rasterizer for lines, quadratic & cubic beziers.
Implementations
Allocates a new rasterizer that can draw onto a width
x height
alpha grid.
use ab_glyph_rasterizer::Rasterizer; let mut rasterizer = Rasterizer::new(14, 38);
Resets the rasterizer to an empty width
x height
alpha grid. This method behaves as if
the Rasterizer were re-created, with the advantage of not allocating if the total number of
pixels of the grid does not increase.
rasterizer.reset(12, 24); assert_eq!(rasterizer.dimensions(), (12, 24));
Clears the rasterizer. This method behaves as if the Rasterizer were re-created with the same dimensions, but does not perform an allocation.
rasterizer.clear();
Returns the dimensions the rasterizer was built to draw to.
let rasterizer = Rasterizer::new(9, 8); assert_eq!((9, 8), rasterizer.dimensions());
Adds a straight line from p0
to p1
to the outline.
rasterizer.draw_line(point(0.0, 0.48), point(1.22, 0.48));
Adds a quadratic Bézier curve from p0
to p2
to the outline using p1
as the control.
rasterizer.draw_quad(point(6.2, 34.5), point(7.2, 34.5), point(9.2, 34.0));
Adds a cubic Bézier curve from p0
to p3
to the outline using p1
as the control
at the beginning of the curve and p2
at the end of the curve.
rasterizer.draw_cubic( point(10.3, 16.4), point(8.6, 16.9), point(7.7, 16.5), point(8.2, 15.2), );
Run a callback for each pixel index & alpha, with indices in 0..width * height
.
let mut pixels = vec![0u8; width * height]; rasterizer.for_each_pixel(|index, alpha| { pixels[index] = (alpha * 255.0).round() as u8; });