Skip to content

Commit f3e5fe0

Browse files
committed
Fix marker drawing
1 parent 1399c96 commit f3e5fe0

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

plotters/src/element/basic_shapes.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,18 @@ where
326326
backend: &mut DB,
327327
ps: (u32, u32),
328328
) -> Result<(), DrawingErrorKind<DB::ErrorType>> {
329+
let mut shift = self.shift.in_pixels(&ps).max(0) as f32;
329330
let mut start = match points.next() {
330-
Some(c) => to_f(c),
331+
Some(start_i) => {
332+
// Draw the first marker if no shift
333+
if shift == 0. {
334+
let mk = (self.func)(start_i).into_dyn();
335+
mk.draw(mk.point_iter().iter().copied(), backend, ps)?;
336+
}
337+
to_f(start_i)
338+
}
331339
None => return Ok(()),
332340
};
333-
let mut shift = self.shift.in_pixels(&ps).max(0) as f32;
334341
let spacing = self.spacing.in_pixels(&ps).max(0) as f32;
335342
let mut dist = 0.;
336343
for curr in points {
@@ -352,12 +359,10 @@ where
352359
}
353360
// Draw if needed
354361
if spacing <= dist {
355-
let start_i = to_i(start);
356-
(self.func)(start_i)
357-
.into_dyn()
358-
.draw(std::iter::once(start_i), backend, ps)?;
359-
dist = 0.;
362+
let mk = (self.func)(to_i(start)).into_dyn();
363+
mk.draw(mk.point_iter().iter().copied(), backend, ps)?;
360364
shift = 0.;
365+
dist = 0.;
361366
}
362367
}
363368
}

0 commit comments

Comments
 (0)