Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/overlay_editor/src/draw/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl PathWidget {
FloatPoint::new(v.x, v.y)
}).collect();

let sub_triangulation = stroke_builder.build_open_path_mesh::<FloatPoint<f32>, usize>(&screen_path);
let sub_triangulation = stroke_builder.build_open_path_mesh::<usize>(&screen_path);
builder.append(sub_triangulation);

let r2 = 2.0 * width;
Expand All @@ -111,7 +111,7 @@ impl PathWidget {
let v0 = m0 + t0;
let v1 = m0 + t1;

let arrow_triangulation = stroke_builder.build_open_path_mesh::<FloatPoint<f32>, usize>(&[v0, m, v1]);
let arrow_triangulation = stroke_builder.build_open_path_mesh::<usize>(&[v0, m, v1]);
builder.append(arrow_triangulation);

a = b;
Expand Down
4 changes: 2 additions & 2 deletions examples/overlay_editor/src/draw/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl ShapeWidget {
.collect();

let sub_triangulation =
stroke_builder.build_closed_path_mesh::<FloatPoint<f32>, usize>(&world_path);
stroke_builder.build_closed_path_mesh::<usize>(&world_path);
builder.append(sub_triangulation);
}
}
Expand Down Expand Up @@ -192,7 +192,7 @@ impl ShapeWidget {
.collect();

let sub_triangulation =
stroke_builder.build_closed_path_mesh::<FloatPoint<f32>, usize>(&world_path);
stroke_builder.build_closed_path_mesh::<usize>(&world_path);
builder.append(sub_triangulation);
}

Expand Down
12 changes: 12 additions & 0 deletions examples/tests/outline/test_8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"scale": 100.0,
"outline": [
[
[53.0, 42.0],
[35.0, 66.0],
[26.0, 75.0],
[27.0, 74.0],
[53.0, 42.0]
]
]
}
18 changes: 18 additions & 0 deletions examples/tests/outline/test_9.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"scale": 100.0,
"outline": [
[
[0.0, 0.0],
[100.0, 0.0],
[100.0, 100.0],
[0.0, 100.0]
],
[
[53.0, 42.0],
[27.0, 74.0],
[26.0, 75.0],
[35.0, 66.0],
[53.0, 42.0]
]
]
}
2 changes: 1 addition & 1 deletion iOverlay/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "i_overlay"
version = "6.0.0"
version = "6.0.1"
authors = ["Nail Sharipov <nailxsharipov@gmail.com>"]
edition = "2024"
rust-version = "1.88"
Expand Down
8 changes: 6 additions & 2 deletions iOverlay/src/mesh/outline/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,12 @@ impl<J: JoinBuilder<P>, P: FloatPointCompatible> Builder<J, P> {
let vp = s0.b - s0.a;

let cross = vi.cross_product(vp);
debug_assert!(cross != 0, "not possible! UniqueSegmentsIter guarantee it");
let outer_corner = (cross > 0) == self.extend;
let outer_corner = if cross != 0 {
(cross > 0) == self.extend
} else {
vi.dot_product(vp) < 0
};

if outer_corner {
if s0.b_top != s1.a_top {
self.join_builder.add_join(s0, s1, adapter, segments);
Expand Down
18 changes: 18 additions & 0 deletions iOverlay/src/mesh/outline/offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,24 @@ mod tests {
};
}

#[test]
fn test_real_case_1_offset() {
let contour = vec![
[53.0, 42.0],
[35.0, 66.0],
[26.0, 75.0],
[27.0, 74.0],
[53.0f64, 42.0],
];

let style = OutlineStyle::new(1.0f64).line_join(LineJoin::Round(1.0f64));
contour.outline(&style);

if let Some(shape) = contour.outline(&style).first() {
assert!(shape[0].len() < 1_000);
};
}

fn create_star(r0: f64, r1: f64, count: usize, angle: f64) -> Shape<[f64; 2]> {
let da = core::f64::consts::PI / count as f64;
let mut a = angle;
Expand Down
Loading