Files
vectorcraft/crates/ui-egui/src/panels/tests_stroke.rs
T
bflatasticandClaude Opus 5.5 42ad4540b7 M3.38: dashes fitted to corners and path ends, a flag of their own that keeps the offset
With alignDashes every run between corners and path ends holds a whole number of
periods, scaled to fit, with a dash (or dot) centred on each corner and on both
ends of an open path. It lives in the shared dash generator, so the canvas, SVG
and PDF export (as outlines) and Outline Stroke all draw it.

stroke.set: alignDashes and dashOffset edit the current pattern on their own, and
a new dash array keeps the offset and alignment it replaces. The Stroke panel
turns dashes on fitted to corners (or as last turned off), and its Exact/Fit
buttons send only the flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 23:37:58 +07:00

26 lines
1.2 KiB
Rust

//! Headless frames of the Stroke panel's Dashed Line section.
use serde_json::json;
use super::tests_appearance::{app_with_rect, click, frame_events, run, text_rect};
use super::*;
/// Click the Dashed Line check box and return the stroke's dash afterwards.
fn toggle_dashes(ctx: &egui::Context, app: &mut VectorcraftApp) -> Option<vectorcraft_doc::Dash> {
let at = text_rect(&frame_events(ctx, app, vec![], stroke::show), "Dashed Line").center();
click(ctx, app, at, stroke::show);
current_stroke(app).unwrap().dash
}
#[test]
fn turning_dashes_on_fits_them_to_corners_and_turning_back_on_restores_the_last_ones() {
let (ctx, mut app) = (egui::Context::default(), app_with_rect());
let d = toggle_dashes(&ctx, &mut app).expect("dashes on");
assert_eq!((d.pattern, d.align_corners), (vec![12.0, 12.0], true));
// Exact 4/2 dashes turned off and on again come back as they were.
run(&mut app, "stroke.set", json!({"dash": [4, 2], "alignDashes": false}));
assert!(toggle_dashes(&ctx, &mut app).is_none());
let d = toggle_dashes(&ctx, &mut app).expect("dashes on");
assert_eq!((d.pattern, d.align_corners), (vec![4.0, 2.0], false));
}