Skip to content

Commit 31b8e5a

Browse files
committed
Merge branch 'master' of github.com:38/plotters
2 parents 4d29053 + 00616fe commit 31b8e5a

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

src/drawing/backend.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ pub trait DrawingBackend: Sized {
267267
break;
268268
}
269269
// FIXME: This assume we have RGB image buffer
270-
let r = src[(dx + dy * w) as usize * 3];
271-
let g = src[(dx + dy * w) as usize * 3 + 1];
272-
let b = src[(dx + dy * w) as usize * 3 + 2];
270+
let r = src[(dx + dy * iw) as usize * 3];
271+
let g = src[(dx + dy * iw) as usize * 3 + 1];
272+
let b = src[(dx + dy * iw) as usize * 3 + 2];
273273
let color = crate::style::RGBColor(r, g, b);
274274
let result =
275275
self.draw_pixel((pos.0 + dx as i32, pos.1 + dy as i32), &color.to_rgba());

src/drawing/backend_impl/bitmap.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,8 @@ impl<'a, P: PixelFormat> DrawingBackend for BitMapBackend<'a, P> {
998998
impl<P: PixelFormat> Drop for BitMapBackend<'_, P> {
999999
fn drop(&mut self) {
10001000
if !self.saved {
1001-
self.present().expect("Unable to save the bitmap");
1001+
// drop should not panic, so we ignore a failed present
1002+
let _ = self.present();
10021003
}
10031004
}
10041005
}

src/drawing/backend_impl/canvas.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ impl DrawingBackend for CanvasBackend {
112112
return Ok(());
113113
}
114114

115-
self.context
116-
.set_stroke_style(&make_canvas_color(style.as_color()));
115+
self.context.set_stroke_style(&make_canvas_color(style.as_color()));
116+
self.context.set_line_width(style.stroke_width() as f64);
117117
self.context.begin_path();
118118
self.context.move_to(f64::from(from.0), f64::from(from.1));
119119
self.context.line_to(f64::from(to.0), f64::from(to.1));

src/drawing/backend_impl/svg.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ impl<'a> SVGBackend<'a> {
124124
&[
125125
("width", &format!("{}", size.0)),
126126
("height", &format!("{}", size.1)),
127+
("viewBox", &format!("0 0 {} {}", size.0, size.1)),
127128
("xmlns", "http://www.w3.org/2000/svg"),
128129
],
129130
false,
@@ -565,7 +566,8 @@ impl<'a> DrawingBackend for SVGBackend<'a> {
565566
impl Drop for SVGBackend<'_> {
566567
fn drop(&mut self) {
567568
if !self.saved {
568-
self.present().expect("Unable to save the SVG image");
569+
// drop should not panic, so we ignore a failed present
570+
let _ = self.present();
569571
}
570572
}
571573
}

0 commit comments

Comments
 (0)