pub struct Pixfmt<T> { /* private fields */ }
Expand description
Pixel Format Wrapper around raw pixel component data
Implementations
sourceimpl<T> Pixfmt<T>where
Pixfmt<T>: PixelDraw,
impl<T> Pixfmt<T>where
Pixfmt<T>: PixelDraw,
sourcepub fn new(width: usize, height: usize) -> Self
pub fn new(width: usize, height: usize) -> Self
Create new Pixel Format of width * height * bpp
Allocates memory of width * height * bpp
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the Image
All color components are set to 255, including alpha
if present
use agg::{Source,Pixfmt,Rgb8,Rgba8};
// Pixfmt with Rgb8, not Alpha Component
let mut pix = Pixfmt::<Rgb8>::new(2,2);
pix.clear();
let empty = Rgba8 { r:255, g:255, b:255, a:255};
assert_eq!(pix.get((0,0)), empty);
assert_eq!(pix.get((0,1)), empty);
assert_eq!(pix.get((1,0)), empty);
assert_eq!(pix.get((1,1)), empty);
// Pixfmt with Rgba8, including Alpha Component
let mut pix = Pixfmt::<Rgb8>::new(2,2);
pix.clear();
let empty = Rgba8 { r:255, g:255, b:255, a:255};
assert_eq!(pix.get((0,0)), empty);
assert_eq!(pix.get((0,1)), empty);
assert_eq!(pix.get((1,0)), empty);
assert_eq!(pix.get((1,1)), empty);
sourcepub fn copy_pixel<C: Color>(&mut self, x: usize, y: usize, c: C)
pub fn copy_pixel<C: Color>(&mut self, x: usize, y: usize, c: C)
Copies the Color c
to pixel at (x
,y
)
Locations outside of the region are igorned
use agg::{Source,Pixfmt,Rgba8};
let mut pix = Pixfmt::<Rgba8>::new(1,2);
let black = Rgba8::black();
pix.copy_pixel(0,1, black);
assert_eq!(pix.get((0,0)), Rgba8{r:0, g:0, b:0, a:0});
assert_eq!(pix.get((0,1)), black);
pix.copy_pixel(10,10, black); // Ignored, outside of range
sourcepub fn copy_hline<C: Color>(&mut self, x: usize, y: usize, n: usize, c: C)
pub fn copy_hline<C: Color>(&mut self, x: usize, y: usize, n: usize, c: C)
Copies the Color c
to pixels from (x
,y
) to (x+n-1
,y)
Locations outside of the region are ignored
use agg::{Source,Pixfmt,Rgb8,Rgba8};
let mut pix = Pixfmt::<Rgb8>::new(10,1);
let black = Rgba8::black();
pix.copy_hline(0,0,10, black);
assert_eq!(pix.get((0,0)), black);
assert_eq!(pix.get((1,0)), black);
assert_eq!(pix.get((9,0)), black);
pix.copy_hline(1,1,10, black); // Ignored, outside of range
sourcepub fn copy_vline<C: Color>(&mut self, x: usize, y: usize, n: usize, c: C)
pub fn copy_vline<C: Color>(&mut self, x: usize, y: usize, n: usize, c: C)
Copies the Color c
to pixels from (x
,y
) to (x
,y+n-1
)
Locations outside of the region are ignored
use agg::{Source,Pixfmt,Rgba8,Rgba32};
let mut pix = Pixfmt::<Rgba32>::new(1,10);
let black = Rgba32::new(0.,0.,0.,1.);
pix.copy_vline(0,0,10, black);
let black8 = Rgba8::from_trait(black); // pix.get() returns Rgba8
assert_eq!(pix.get((0,0)), black8);
assert_eq!(pix.get((0,1)), black8);
assert_eq!(pix.get((0,9)), black8);
pix.copy_vline(1,1,10, black); // Ignored, outside of range
sourcepub fn line_sp_aa(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, c: Rgb8)
👎Deprecated since 0.1.0: please use path_storage
and friends instead
pub fn line_sp_aa(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, c: Rgb8)
path_storage
and friends insteadDraw a line from (x1,y1)
to (x2,y2)
of color c
Uses Xiaolin Wu’s line drawing algorithm which include Anti-Aliasing
Trait Implementations
sourceimpl Pixel for Pixfmt<Gray8>
impl Pixel for Pixfmt<Gray8>
sourceimpl Pixel for Pixfmt<Rgb8>
impl Pixel for Pixfmt<Rgb8>
sourceimpl Pixel for Pixfmt<Rgba32>
impl Pixel for Pixfmt<Rgba32>
sourceimpl Pixel for Pixfmt<Rgba8>
impl Pixel for Pixfmt<Rgba8>
sourceimpl Pixel for Pixfmt<Rgba8pre>
impl Pixel for Pixfmt<Rgba8pre>
sourceimpl<T> PixelDraw for Pixfmt<T>where
Pixfmt<T>: Pixel,
impl<T> PixelDraw for Pixfmt<T>where
Pixfmt<T>: Pixel,
sourcefn copy_or_blend_pix<C: Color>(&mut self, id: (usize, usize), color: C)
fn copy_or_blend_pix<C: Color>(&mut self, id: (usize, usize), color: C)
sourcefn copy_or_blend_pix_with_cover<C: Color>(
&mut self,
id: (usize, usize),
color: C,
cover: u64
)
fn copy_or_blend_pix_with_cover<C: Color>(
&mut self,
id: (usize, usize),
color: C,
cover: u64
)
sourcefn blend_solid_hspan<C: Color>(
&mut self,
x: i64,
y: i64,
len: i64,
color: C,
covers: &[u64]
)
fn blend_solid_hspan<C: Color>(
&mut self,
x: i64,
y: i64,
len: i64,
color: C,
covers: &[u64]
)
Auto Trait Implementations
impl<T> RefUnwindSafe for Pixfmt<T>where
T: RefUnwindSafe,
impl<T> Send for Pixfmt<T>where
T: Send,
impl<T> Sync for Pixfmt<T>where
T: Sync,
impl<T> Unpin for Pixfmt<T>where
T: Unpin,
impl<T> UnwindSafe for Pixfmt<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more