mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 20:46:22 +01:00
Stroke panel: the cap icons mark the end of the path in one place
The end-of-path line sat at x=16 in Butt and Projecting but at x=12 in Round, and the stroke bar was as opaque as the line, so the line vanished where it crossed the bar and the three icons looked alike. The line is now at x=13 in all three over a lighter (0.55) bar, as the stroke-align icons draw it, and the caps are larger, so Round and Projecting reach 5 units past the end instead of 4. Fixes #9229
This commit is contained in:
1 parent
b1a1c0b7a8
commit
1a7cb29bf2
4 files changed
+29
-3
No files matched your search
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt" stroke-linejoin="miter"><rect x="3" y="8" width="13" height="8" fill="currentColor" fill-opacity="1.0" stroke="none"/><path d="M16 4V20" stroke-width="1" /></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt" stroke-linejoin="miter"><rect x="2" y="7" width="11" height="10" fill="currentColor" fill-opacity="0.55" stroke="none"/><path d="M13 3V21" stroke-width="1" /></svg>
|
||||
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 323 B |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt" stroke-linejoin="miter"><path d="M3 8H12A4 4 0 0 1 12 16H3Z" fill="currentColor" fill-opacity="1.0" stroke="none"/><path d="M12 4V20" stroke-width="1" /></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt" stroke-linejoin="miter"><path d="M2 7H13A5 5 0 0 1 13 17H2Z" fill="currentColor" fill-opacity="0.55" stroke="none"/><path d="M13 3V21" stroke-width="1" /></svg>
|
||||
|
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 319 B |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt" stroke-linejoin="miter"><rect x="3" y="8" width="17" height="8" fill="currentColor" fill-opacity="1.0" stroke="none"/><path d="M16 4V20" stroke-width="1" /></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt" stroke-linejoin="miter"><rect x="2" y="7" width="16" height="10" fill="currentColor" fill-opacity="0.55" stroke="none"/><path d="M13 3V21" stroke-width="1" /></svg>
|
||||
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 323 B |
@@ -207,6 +207,32 @@ mod tests {
|
||||
assert!(appearance.contains("<circle") && !pathfinder.contains("<circle"), "appearance should read as a list, not overlapping squares");
|
||||
}
|
||||
|
||||
// Regression test for storytold/vectorcraft#9229: the Stroke panel's three cap icons looked
|
||||
// almost the same. The end-of-path line sat at a different x in Round, and the stroke bar was
|
||||
// as opaque as the line, so the line vanished where it crossed the bar.
|
||||
#[test]
|
||||
fn the_cap_icons_mark_the_path_end_in_one_place_over_a_lighter_stroke() {
|
||||
let svg = |name: &str| {
|
||||
let (_, bytes) = crate::icon_data::ICONS.iter().find(|(n, _)| *n == name).unwrap_or_else(|| panic!("{name} isn't an icon"));
|
||||
String::from_utf8_lossy(bytes).into_owned()
|
||||
};
|
||||
// The end-of-path line is the icon's last shape, a vertical line `M{x} …V…`.
|
||||
let end_line = |icon: &str| -> String {
|
||||
let last = icon.rsplit("<path").next().unwrap_or_default();
|
||||
last.split('"').nth(1).unwrap_or_default().to_string()
|
||||
};
|
||||
let stroke_opacity = |icon: &str| -> f32 {
|
||||
icon.split(r#"fill-opacity=""#).nth(1).and_then(|s| s.split('"').next()).and_then(|v| v.parse().ok()).unwrap_or(1.0)
|
||||
};
|
||||
let icons = [("butt", svg("dc-cap-butt")), ("round", svg("dc-cap-round")), ("square", svg("dc-cap-square"))];
|
||||
let butt_end = end_line(&icons[0].1);
|
||||
assert!(butt_end.starts_with('M') && butt_end.contains('V'), "the butt cap icon ends with a vertical end-of-path line: {butt_end}");
|
||||
for (name, icon) in &icons {
|
||||
assert_eq!(end_line(icon), butt_end, "the {name} cap icon marks the end of the path where the butt cap icon does");
|
||||
assert!(stroke_opacity(icon) < 1.0, "the {name} cap icon's stroke is lighter than its end-of-path line");
|
||||
}
|
||||
}
|
||||
|
||||
// Regression test for #479: the Add and Delete Anchor Point tools' icons were drawn apart from
|
||||
// the Pen tool's, so the three tools didn't read as one family. They are the Pen's pen with a
|
||||
// plus or a minus beside it.
|
||||
|
||||
Reference in new issue
Block a user