mirror of
https://github.com/storytold/craft-libs.git
synced 2026-12-01 02:36:54 +01:00
Merge #644 (fix/linesweeper-really-correct-last-y) into integration/linesweeper
This commit is contained in:
commit
d71d53ed35
3 files changed
+60
-2
No files matched your search
Vendored
+4
@@ -51,6 +51,9 @@ names, which is archived; its README says development moved off GitHub.
|
||||
`824b0791a750f7b27b8edcbb6c6244d0e629875e`. That commit is not in the GitHub repository the manifest
|
||||
names, which is archived; its README says development moved off GitHub.
|
||||
|
||||
`824b0791a750f7b27b8edcbb6c6244d0e629875e`. That commit is not in the GitHub repository the manifest
|
||||
names, which is archived; its README says development moved off GitHub.
|
||||
|
||||
Every file here except this one, `SOURCE.json` and the files under Local changes is byte for byte the
|
||||
file in the `.crate` archive. `SOURCE.json` records the hash of the `.crate` download
|
||||
(`source_archive_sha256`) and, for every file kept, the hash in the package (`source_sha256`) and the
|
||||
@@ -70,6 +73,7 @@ and, for every file kept, the hash in the package (`source_sha256`) and the hash
|
||||
`upstream_repository` is null because no public repository this copy can name holds
|
||||
`upstream_revision`. `local_patches` describes each change.
|
||||
| `ComparisonCache::compare_segments` panics with a message when either segment is horizontal, in every build profile, and its doc comment states it | `Craft patch (horizontal comparison)` | `src/order.rs` | `horizontal_and_cubic`, `horizontal_and_line` |
|
||||
| `compute_positions` starts each output segment's `last_y` at the segment's start height instead of 0, so a segment that starts at `y < 0` is not skipped at its first queue entry and close segments there are put in order | `Craft patch (start height)` | `src/position.rs` | `position::tests::correct_positions_at_negative_y` |
|
||||
|
||||
Every change here updates this table and `SOURCE.json` in the same commit.
|
||||
|
||||
|
||||
Vendored
+2
@@ -18,6 +18,7 @@
|
||||
"In `examples/boolean_op.rs`, `examples/visualize_op.rs` and `examples/winding-numbers.rs`, the SVG stroke width is the larger of the bounding box's width and height divided by 512. The package computed `(max_y - min_y).max(max_x - max_y) / 512.0`, which uses `max_x - max_y` for the width: a box from (0, 1000) to (512, 1001) got a stroke width of 1/512 instead of 1. `examples/visualize_op.rs` computes it in a `stroke_width` function with the test `stroke_width_follows_the_larger_side`; the other two examples do not compile in this copy."
|
||||
"Remove the `boolean_op` and `winding-numbers` examples, the `fonts` and `snapshots` tests and the `linebender_logo` bench from `Cargo.toml`, since they need dev-dependencies or files the package leaves out. Their source files stay unchanged."
|
||||
"`ComparisonCache::compare_segments` in `src/order.rs` panics with the message \"compare_segments does not take horizontal segments\" when either segment is horizontal, in every build profile, and its doc comment states it. Before, a horizontal line and a cubic stopped at a `debug_assert` in `Segments::horiz_decomp` in a debug build, and a release build skipped that check."
|
||||
"In `src/position.rs`, `compute_positions` sets each output segment's `last_y` to the segment's start height before queuing it. It started at 0, so a segment starting at `y < 0` was skipped at its first queue entry and close segments there were not put in order: with `Correctness::ReallyCorrect`, two lenses 0.001 apart at `dy = 100` gave 48 corrected quadratics, and the same lenses at `dy = -100` gave 20 uncorrected cubics. `position::tests::correct_positions_at_negative_y` checks both heights."
|
||||
],
|
||||
"files": [
|
||||
{ "path": ".cargo_vcs_info.json", "source_sha256": "47fba6a9dbdf445a5c97f783c9be62093035f9d5e5cdc2cf3216ad8259bcd8fc", "source_git_blob": null, "sha256": "47fba6a9dbdf445a5c97f783c9be62093035f9d5e5cdc2cf3216ad8259bcd8fc" },
|
||||
@@ -60,6 +61,7 @@
|
||||
{ "path": "src/order.rs", "source_sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596", "source_git_blob": null, "sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596" },
|
||||
{ "path": "src/perturbation.rs", "source_sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5", "source_git_blob": null, "sha256": "a0108503efbcfa15a05b8a228d7891737e51f13fdd6c7d67dc4b4282847b14fb" },
|
||||
{ "path": "src/position.rs", "source_sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0", "source_git_blob": null, "sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0" },
|
||||
{ "path": "src/position.rs", "source_sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0", "source_git_blob": null, "sha256": "37686f512c4f4ded9fcbd19e8a736f1462ad2e883a65d88d32a7c441d512dc30" },
|
||||
{ "path": "src/segments.rs", "source_sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc", "source_git_blob": null, "sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc" },
|
||||
{ "path": "src/snapshots/linesweeper__tests__empty_horizontals.snap", "source_sha256": "e319881853e889badf6524f19af4cd6f112e8dd71bdc516826f4463134a82244", "source_git_blob": null, "sha256": "e319881853e889badf6524f19af4cd6f112e8dd71bdc516826f4463134a82244" },
|
||||
{ "path": "src/snapshots/linesweeper__tests__two_squares.snap", "source_sha256": "01961e0311a5af3b8f13eb52a2a7112560c47cf86771c04e40475dc6f15a0846", "source_git_blob": null, "sha256": "01961e0311a5af3b8f13eb52a2a7112560c47cf86771c04e40475dc6f15a0846" },
|
||||
|
||||
Vendored
+54
-2
@@ -384,6 +384,8 @@ pub(crate) fn compute_positions(
|
||||
continue;
|
||||
}
|
||||
out[idx].path.move_to(p);
|
||||
// Craft patch (start height): a segment that starts at y < 0 is not skipped.
|
||||
last_y[idx] = p.y;
|
||||
queue.push(HeapEntry { y: p.y.into(), idx });
|
||||
}
|
||||
|
||||
@@ -504,9 +506,9 @@ pub(crate) fn compute_positions(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use kurbo::{BezPath, CubicBez, Line, PathSeg};
|
||||
use kurbo::{BezPath, CubicBez, Line, PathEl, PathSeg};
|
||||
|
||||
use crate::Segments;
|
||||
use crate::{Segments, sweep::Correctness, topology::Topology};
|
||||
|
||||
use super::horizontal_error_weight;
|
||||
|
||||
@@ -558,4 +560,54 @@ mod tests {
|
||||
let next_y0 = super::approximate(90.03645987646233, y1, &[s0, s1], &segs, 2.5e-7, &mut out);
|
||||
assert_eq!(next_y0, y1);
|
||||
}
|
||||
|
||||
// Counts the path elements of each kind in the correct positions of two
|
||||
// lenses that run close together, moved down by `dy`.
|
||||
fn close_lens_elements(dy: f64) -> [usize; 4] {
|
||||
fn lens(dx: f64, dy: f64) -> BezPath {
|
||||
let mut p = BezPath::new();
|
||||
p.move_to((dx, dy));
|
||||
p.curve_to(
|
||||
(10.0 + dx, 3.0 + dy),
|
||||
(10.0 + dx, 7.0 + dy),
|
||||
(dx, 10.0 + dy),
|
||||
);
|
||||
p.curve_to((-10.0 + dx, 7.0 + dy), (-10.0 + dx, 3.0 + dy), (dx, dy));
|
||||
p.close_path();
|
||||
p
|
||||
}
|
||||
let a = lens(0.0, dy);
|
||||
let b = lens(0.001, dy);
|
||||
let top = Topology::<i32>::from_paths_with_correctness(
|
||||
[(&a, ()), (&b, ())],
|
||||
0.01,
|
||||
Correctness::ReallyCorrect,
|
||||
)
|
||||
.unwrap();
|
||||
let positions = top.compute_positions();
|
||||
let mut counts = [0; 4];
|
||||
for idx in positions.indices() {
|
||||
for el in positions[idx].path.elements() {
|
||||
match el {
|
||||
PathEl::MoveTo(_) => counts[0] += 1,
|
||||
PathEl::LineTo(_) => counts[1] += 1,
|
||||
PathEl::QuadTo(..) => counts[2] += 1,
|
||||
PathEl::CurveTo(..) => counts[3] += 1,
|
||||
PathEl::ClosePath => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
counts
|
||||
}
|
||||
|
||||
// Craft patch (start height): moving the input up or down must not change
|
||||
// how the close segments are positioned, including when the segments start
|
||||
// at y < 0.
|
||||
#[test]
|
||||
fn correct_positions_at_negative_y() {
|
||||
let below = close_lens_elements(100.0);
|
||||
let above = close_lens_elements(-100.0);
|
||||
assert!(below[2] > 0, "{below:?}");
|
||||
assert_eq!(below, above);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user