mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 21:42:59 -05:00
Canvas: tessellate the anchor marks again when a built square is thin enough to draw as a line
The move of the kept anchor marks mesh compared each requested square side with twice the feathering, but the tessellator tests the built rectangle's f32 width and height. A side just over 2 pixels gives a square exactly 2 pixels wide at x = 252.5, which the tessellator draws as a line. The check now tests both built squares, before and after the move.
This commit is contained in:
1 parent
31e7720114
commit
63e06cd7cf
2 files changed
+6
No files matched your search
@@ -742,7 +742,9 @@ impl KeptMesh {
|
||||
}
|
||||
for side in sides {
|
||||
let (a, b) = (Rect::from_center_size(from, egui::Vec2::splat(side)), Rect::from_center_size(to, egui::Vec2::splat(side)));
|
||||
// The tessellator tests the built square's `f32` width and height, which can come out below `side`.
|
||||
if a.size() != b.size()
|
||||
|| [a, b].iter().any(|r| r.width() <= 2.0 * feathering || r.height() <= 2.0 * feathering)
|
||||
|| !(lands(a.min.x, b.min.x, pixels[0])
|
||||
&& lands(a.max.x, b.max.x, pixels[0])
|
||||
&& lands(a.min.y, b.min.y, pixels[1])
|
||||
|
||||
@@ -1438,6 +1438,10 @@ fn a_move_tessellates_the_marks_again_when_a_square_is_drawn_as_a_line() {
|
||||
let mut options = PathOptionsSettings::default();
|
||||
options.anchor_size = Some(2.0);
|
||||
assert!(!kept_at_one_pixel_per_point().translate(by, [Point::new(252.5, 10.0)], &options), "a 2 pt anchor at 1 pixel per point");
|
||||
// The `f32` just over 2 passes the check on the side, but the square built at x = 252.5 spans 251.5 to 253.5 in
|
||||
// `f32`, 2 pixels wide, so the tessellator draws it as a line.
|
||||
options.anchor_size = Some(f32::from_bits(2.0_f32.to_bits() + 1));
|
||||
assert!(!kept_at_one_pixel_per_point().translate(by, [Point::new(252.5, 10.0)], &options), "a square built 2 pixels wide");
|
||||
options.anchor_size = Some(3.0);
|
||||
assert!(kept_at_one_pixel_per_point().translate(by, [Point::new(252.5, 10.0)], &options), "a 3 pt anchor");
|
||||
}
|
||||
Reference in new issue
Block a user