mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-08 07:11:31 +00:00
The overlap sweep moves a horizontal line down the page, and its time per event grows with the number of segments on that line. A long, low path, such as rows of a zigzag, puts a whole row on the line at once. stroke_region, unite_all_with and try_unite_all_with now estimate how many segments the sweep holds at once in each direction, from up to 4,096 segment boxes (one from each run of segments, at a position that changes from run to run). When the estimate for the input turned a quarter turn is under two thirds of the upright one (2,048 segments or more), the operation runs on the turned input and the result is turned back. A quarter turn swaps and negates coordinates, so no point moves by rounding. Offset Path is not turned. Callers of unite_all, try_unite_all and outline_stroke take the turned sweep through these functions. Tidy's lookups of the input curves around a piece and of the kept anchors can search along y: once lookups with more than 64 candidates along x have scanned 16 per item, a lookup sorts the list along y once and uses that window when it holds fewer candidates (under a quarter as many for curves). Where the y window rarely helps, only one lookup in 32 measures it. is_kept counts the few points within its tolerance directly instead of searching for the window's end. In the sweep_axis tests, a turned result has as many subpaths as the result without the turn, and the area where the two differ is no larger than the refit precision times the outline's length. On one open path of 200,000 anchors in rows of 1,000, Outline Stroke takes 17.3 s of processor time instead of 31.3 s and Unite 2.9 s instead of 6.5 s in a release build. Unite of 2,000 circles takes the same time as before.