Skip to content

Commit 0aeb925

Browse files
committed
implement field to specify if anti-aliasing is used
1 parent 903e23e commit 0aeb925

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

plotters-bitmap/src/bitmap.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub struct BitMapBackend<'a, P: PixelFormat = RGBPixel> {
4040
buffer: Buffer<'a>,
4141
/// Flag indicates if the bitmap has been saved
4242
saved: bool,
43+
use_anti_aliasing: bool,
4344
_phantomdata: PhantomData<P>,
4445
}
4546

@@ -57,6 +58,7 @@ impl<'a> BitMapBackend<'a, RGBPixel> {
5758
size: (w, h),
5859
buffer: Buffer::Owned(vec![0; Self::PIXEL_SIZE * (w * h) as usize]),
5960
saved: false,
61+
use_anti_aliasing: true,
6062
_phantomdata: PhantomData,
6163
}
6264
}
@@ -85,6 +87,7 @@ impl<'a> BitMapBackend<'a, RGBPixel> {
8587
size: (w, h),
8688
buffer: Buffer::Owned(vec![0; Self::PIXEL_SIZE * (w * h) as usize]),
8789
saved: false,
90+
use_anti_aliasing: true,
8891
_phantomdata: PhantomData,
8992
})
9093
}
@@ -128,6 +131,7 @@ impl<'a, P: PixelFormat> BitMapBackend<'a, P> {
128131
size: (w, h),
129132
buffer: Buffer::Borrowed(buf),
130133
saved: false,
134+
use_anti_aliasing: true,
131135
_phantomdata: PhantomData,
132136
})
133137
}
@@ -137,6 +141,13 @@ impl<'a, P: PixelFormat> BitMapBackend<'a, P> {
137141
self.buffer.borrow_buffer()
138142
}
139143

144+
#[inline(always)]
145+
pub fn anti_aliasing(self, use_anti_aliasing: bool) -> Self {
146+
let mut s = self;
147+
s.use_anti_aliasing = use_anti_aliasing;
148+
s
149+
}
150+
140151
/// Split a bitmap backend vertically into several sub drawing area which allows
141152
/// multi-threading rendering.
142153
///
@@ -334,6 +345,10 @@ impl<'a, P: PixelFormat> DrawingBackend for BitMapBackend<'a, P> {
334345

335346
Ok(())
336347
}
348+
349+
fn use_anti_aliasing(&self) -> bool {
350+
self.use_anti_aliasing
351+
}
337352
}
338353

339354
impl<P: PixelFormat> Drop for BitMapBackend<'_, P> {

plotters-svg/src/svg.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,10 @@ impl<'a> DrawingBackend for SVGBackend<'a> {
662662

663663
Ok(())
664664
}
665+
666+
fn use_anti_aliasing(&self) -> bool {
667+
true
668+
}
665669
}
666670

667671
impl Drop for SVGBackend<'_> {

0 commit comments

Comments
 (0)